fixed a bug where a quitting user could leave an empty entry in the nicklist
authorMarcus Eggenberger <egs@quassel-irc.org>
Sun, 27 Jul 2008 12:39:56 +0000 (14:39 +0200)
committerMarcus Eggenberger <egs@quassel-irc.org>
Sun, 27 Jul 2008 12:44:52 +0000 (14:44 +0200)
src/client/networkmodel.cpp
src/client/networkmodel.h

index 238dadb..27bb3e2 100644 (file)
@@ -432,22 +432,8 @@ void ChannelBufferItem::ircChannelDestroyed() {
   removeAllChilds();
 }
 
   removeAllChilds();
 }
 
-void ChannelBufferItem::ircUserDestroyed() {
-  // PRIVATE
-  IrcUser *ircUser = static_cast<IrcUser *>(sender());
-  removeUserFromCategory(ircUser);
-  emit dataChanged(2);
-}
-
 void ChannelBufferItem::join(const QList<IrcUser *> &ircUsers) {
   addUsersToCategory(ircUsers);
 void ChannelBufferItem::join(const QList<IrcUser *> &ircUsers) {
   addUsersToCategory(ircUsers);
-
-  foreach(IrcUser *ircUser, ircUsers) {
-    if(!ircUser)
-      continue;
-    connect(ircUser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed()));
-  }
-  
   emit dataChanged(2);
 }
 
   emit dataChanged(2);
 }
 
@@ -657,26 +643,11 @@ IrcUserItem::IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent)
     _ircUser(ircUser)
 {
   setObjectName(ircUser->nick());  
     _ircUser(ircUser)
 {
   setObjectName(ircUser->nick());  
-  // we don't need to handle the ircUser's destroyed signal since it's automatically removed
-  // by the IrcChannel::ircUserParted();
+  connect(ircUser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed()));
   connect(ircUser, SIGNAL(nickSet(QString)), this, SIGNAL(dataChanged()));
   connect(ircUser, SIGNAL(awaySet(bool)), this, SIGNAL(dataChanged()));
 }
 
   connect(ircUser, SIGNAL(nickSet(QString)), this, SIGNAL(dataChanged()));
   connect(ircUser, SIGNAL(awaySet(bool)), this, SIGNAL(dataChanged()));
 }
 
-QString IrcUserItem::nickName() const {
-  if(_ircUser)
-    return _ircUser->nick();
-  else
-    return QString();
-}
-
-bool IrcUserItem::isActive() const {
-  if(_ircUser)
-    return !_ircUser->isAway();
-  else
-    return false;
-}
-
 QVariant IrcUserItem::data(int column, int role) const {
   switch(role) {
   case NetworkModel::ItemActiveRole:
 QVariant IrcUserItem::data(int column, int role) const {
   switch(role) {
   case NetworkModel::ItemActiveRole:
index 4dcb65c..08ae4af 100644 (file)
@@ -190,7 +190,6 @@ public slots:
 
 private slots:
   void ircChannelDestroyed();
 
 private slots:
   void ircChannelDestroyed();
-  void ircUserDestroyed();
 
 private:
   IrcChannel *_ircChannel;
 
 private:
   IrcChannel *_ircChannel;
@@ -233,13 +232,16 @@ class IrcUserItem : public PropertyMapItem {
 public:
   IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent);
 
 public:
   IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent);
 
-  QString nickName() const;
-  bool isActive() const;
+  inline QString nickName() const { return _ircUser ? _ircUser->nick() : QString(); }
+  inline bool isActive() const { return _ircUser ? !_ircUser->isAway() : false; }
 
   inline IrcUser *ircUser() { return _ircUser; }
   virtual QVariant data(int column, int role) const;
   virtual QString toolTip(int column) const;
 
 
   inline IrcUser *ircUser() { return _ircUser; }
   virtual QVariant data(int column, int role) const;
   virtual QString toolTip(int column) const;
 
+private slots:
+  void ircUserDestroyed() { parent()->removeChild(this); }
+
 private:
   QPointer<IrcUser> _ircUser;
 };
 private:
   QPointer<IrcUser> _ircUser;
 };