X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fnetworkmodel.cpp;h=2c2a03823b635942a6a67eaf2de190ce4ec52cce;hp=713198aa59922f9c5b8173006537b034b954ecbd;hb=d4b7af7050bac6f894a05bff4eab1becaffa27ce;hpb=7a1202a4d6b127521ac1d460aed45ffe9383ebf0 diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 713198aa..2c2a0382 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -27,13 +27,11 @@ #include "signalproxy.h" #include "network.h" #include "ircchannel.h" -#include "ircuser.h" #include "buffersettings.h" #include "util.h" // get rid of this (needed for isChannelName) - /***************************************** * Fancy Buffer Items *****************************************/ @@ -41,7 +39,8 @@ BufferItem::BufferItem(BufferInfo bufferInfo, AbstractTreeItem *parent) : PropertyMapItem(QStringList() << "bufferName" << "topic" << "nickCount", parent), _bufferInfo(bufferInfo), _bufferName(bufferInfo.bufferName()), - _activity(Buffer::NoActivity) + _activity(Buffer::NoActivity), + _ircChannel(0) { Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled; if(bufferType() == BufferInfo::QueryBuffer) @@ -69,10 +68,11 @@ bool BufferItem::isActive() const { return qobject_cast(parent())->isActive(); } -bool BufferItem::setActivityLevel(Buffer::ActivityLevel level) { - _activity = level; - emit dataChanged(); - return true; +void BufferItem::setActivityLevel(Buffer::ActivityLevel level) { + if(_activity != level) { + _activity = level; + emit dataChanged(); + } } void BufferItem::updateActivityLevel(Buffer::ActivityLevel level) { @@ -106,7 +106,8 @@ QVariant BufferItem::data(int column, int role) const { bool BufferItem::setData(int column, const QVariant &value, int role) { switch(role) { case NetworkModel::BufferActivityRole: - return setActivityLevel((Buffer::ActivityLevel)value.toInt()); + setActivityLevel((Buffer::ActivityLevel)value.toInt()); + return true; default: return PropertyMapItem::setData(column, value, role); } @@ -135,15 +136,16 @@ void BufferItem::attachIrcChannel(IrcChannel *ircChannel) { connect(ircChannel, SIGNAL(ircUserModeRemoved(IrcUser *, QString)), this, SLOT(userModeChanged(IrcUser *))); - if(!ircChannel->ircUsers().isEmpty()) { - qWarning() << "Channel" << ircChannel->name() << "has already users which is quite surprising :)"; + if(!ircChannel->ircUsers().isEmpty()) join(ircChannel->ircUsers()); - } emit dataChanged(); } void BufferItem::ircChannelDestroyed() { + Q_CHECK_PTR(_ircChannel); + disconnect(_ircChannel, 0, this, 0); + _ircChannel = 0; emit dataChanged(); removeAllChilds(); } @@ -250,23 +252,23 @@ void BufferItem::removeUserFromCategory(IrcUser *ircUser) { UserCategoryItem *categoryItem = 0; for(int i = 0; i < childCount(); i++) { categoryItem = qobject_cast(child(i)); - if(success = categoryItem->removeUser(ircUser)) { + if((success = categoryItem->removeUser(ircUser))) { if(categoryItem->childCount() == 0) removeChild(i); break; } } - if(!success) { - qDebug() << "didn't find User:" << ircUser << qHash(ircUser); - qDebug() << "==== Childlist for Item:" << this << id() << bufferName() << "===="; - for(int i = 0; i < childCount(); i++) { - categoryItem = qobject_cast(child(i)); - categoryItem->dumpChildList(); - } - qDebug() << "==== End Of Childlist for Item:" << this << id() << bufferName() << "===="; - } - Q_ASSERT(success); +// if(!success) { +// qDebug() << "didn't find User:" << ircUser << qHash(ircUser); +// qDebug() << "==== Childlist for Item:" << this << id() << bufferName() << "===="; +// for(int i = 0; i < childCount(); i++) { +// categoryItem = qobject_cast(child(i)); +// categoryItem->dumpChildList(); +// } +// qDebug() << "==== End Of Childlist for Item:" << this << id() << bufferName() << "===="; +// } +// Q_ASSERT(success); } void BufferItem::userModeChanged(IrcUser *ircUser) { @@ -308,6 +310,11 @@ QString BufferItem::toolTip(int column) const { toolTip.append(tr("Topic: %1").arg(_topic)); } } + if(_ircChannel) { + QString channelMode = _ircChannel->channelModeString(); // channelModeString is compiled on the fly -> thus cache the result + if(!channelMode.isEmpty()) + toolTip.append(tr("Mode: %1").arg(channelMode)); + } } else { toolTip.append(tr("Not active
Double-click to join")); } @@ -414,7 +421,9 @@ void NetworkItem::attachNetwork(Network *network) { this, SLOT(attachIrcChannel(QString))); connect(network, SIGNAL(connectedSet(bool)), this, SIGNAL(dataChanged())); - + connect(network, SIGNAL(destroyed()), + this, SIGNAL(dataChanged())); + emit dataChanged(); } @@ -558,14 +567,6 @@ bool IrcUserItem::isActive() const { return false; } -IrcUser *IrcUserItem::ircUser() { - return _ircUser; -} - -quint64 IrcUserItem::id() const { - return _id; -} - QVariant IrcUserItem::data(int column, int role) const { switch(role) { case NetworkModel::ItemActiveRole: