From 2c8f44478dbd11d77d3f8b47aa1b43cd943c21d6 Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Sun, 27 Jul 2008 14:39:56 +0200 Subject: [PATCH] fixed a bug where a quitting user could leave an empty entry in the nicklist --- src/client/networkmodel.cpp | 35 +++-------------------------------- src/client/networkmodel.h | 6 +++--- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 270fbecb..1d54774a 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -355,22 +355,8 @@ void ChannelBufferItem::ircChannelDestroyed() { removeAllChilds(); } -void ChannelBufferItem::ircUserDestroyed() { - // PRIVATE - IrcUser *ircUser = static_cast(sender()); - removeUserFromCategory(ircUser); - emit dataChanged(2); -} - void ChannelBufferItem::join(const QList &ircUsers) { addUsersToCategory(ircUsers); - - foreach(IrcUser *ircUser, ircUsers) { - if(!ircUser) - continue; - connect(ircUser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed())); - } - emit dataChanged(2); } @@ -583,24 +569,9 @@ IrcUserItem::IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent) // we don't need to handle the ircUser's destroyed signal since it's automatically removed // by the IrcChannel::ircUserParted(); - connect(ircUser, SIGNAL(nickSet(QString)), - this, SLOT(setNick(QString))); - connect(ircUser, SIGNAL(awaySet(bool)), - this, SLOT(setAway(bool))); -} - -QString IrcUserItem::nickName() const { - if(_ircUser) - return _ircUser->nick(); - else - return QString(); -} - -bool IrcUserItem::isActive() const { - if(_ircUser) - return !_ircUser->isAway(); - else - return false; + connect(ircUser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed())); + connect(ircUser, SIGNAL(nickSet(QString)), this, SLOT(setNick(QString))); + connect(ircUser, SIGNAL(awaySet(bool)), this, SLOT(setAway(bool))); } QVariant IrcUserItem::data(int column, int role) const { diff --git a/src/client/networkmodel.h b/src/client/networkmodel.h index 22c77b87..43f9552d 100644 --- a/src/client/networkmodel.h +++ b/src/client/networkmodel.h @@ -181,7 +181,6 @@ public slots: private slots: void ircChannelDestroyed(); - void ircUserDestroyed(); private: IrcChannel *_ircChannel; @@ -224,14 +223,15 @@ class IrcUserItem : public PropertyMapItem { 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; private slots: + void ircUserDestroyed() { parent()->removeChild(this); } void setNick(QString newNick); void setAway(bool); -- 2.20.1