X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fnetworkmodel.cpp;h=51f4123dd3e4858f73d3c41aed3a7ded36eba9ee;hp=238dadbf876a84eef791e9f6e879e7c0cbd956e6;hb=e561e02a8d2f1f009559d17c7b1c66cb6f4e2a5a;hpb=fe9ec46e2b6394b7735a73da5c438b10ba7e5e82 diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 238dadbf..51f4123d 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -123,7 +123,7 @@ void NetworkItem::attachIrcChannel(IrcChannel *ircChannel) { if(channelItem->bufferName().toLower() == ircChannel->name().toLower()) { channelItem->attachIrcChannel(ircChannel); - break; + return; } } } @@ -432,22 +432,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); } @@ -540,13 +526,12 @@ void ChannelBufferItem::userModeChanged(IrcUser *ircUser) { } // find the item that needs reparenting - UserCategoryItem *oldCategoryItem = 0; IrcUserItem *ircUserItem = 0; for(int i = 0; i < childCount(); i++) { - UserCategoryItem *catItem = qobject_cast(child(i)); - IrcUserItem *userItem = catItem->findIrcUser(ircUser); + UserCategoryItem *oldCategoryItem = qobject_cast(child(i)); + Q_ASSERT(oldCategoryItem); + IrcUserItem *userItem = oldCategoryItem->findIrcUser(ircUser); if(userItem) { - oldCategoryItem = catItem; ircUserItem = userItem; break; } @@ -556,11 +541,7 @@ void ChannelBufferItem::userModeChanged(IrcUser *ircUser) { qWarning() << "ChannelBufferItem::userModeChanged(IrcUser *): unable to determine old category of" << ircUser; return; } - - Q_ASSERT(oldCategoryItem); - if(ircUserItem->reParent(categoryItem) && oldCategoryItem->childCount() == 0) { - removeChild(oldCategoryItem); - } + ircUserItem->reParent(categoryItem); } /***************************************** @@ -574,6 +555,7 @@ UserCategoryItem::UserCategoryItem(int category, AbstractTreeItem *parent) : PropertyMapItem(QStringList() << "categoryName", parent), _category(category) { + setTreeItemFlags(AbstractTreeItem::DeleteOnLastChildRemoved); setObjectName(parent->data(0, Qt::DisplayRole).toString() + "/" + QString::number(category)); } @@ -657,26 +639,11 @@ IrcUserItem::IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent) _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())); } -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: @@ -725,6 +692,12 @@ QString IrcUserItem::toolTip(int column) const { return QString("

%1

").arg(toolTip.join("
")); } +// void IrcUserItem::ircUserDestroyed() { +// parent()->removeChild(this); +// if(parent()->childCount() == 0) +// parent()->parent()->removeChild(parent()); +// } + /***************************************** * NetworkModel *****************************************/