X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fclient%2Fnetworkmodel.cpp;h=1c365a447222943f7f7674e5409143bf483038c7;hb=2baaaea16e777a1fe961d6cc4d34aa9dd323333e;hp=f5442be1d2dcfd6b7e3392d00e7d2df2bf2e45dd;hpb=6b31f4c8abb36ebe658c2e5ce2a8e9ba2a50f443;p=quassel.git diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index f5442be1..1c365a44 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -21,16 +21,15 @@ #include "networkmodel.h" #include +#include // for Qt::escape() #include "buffermodel.h" +#include "buffersettings.h" #include "client.h" -#include "signalproxy.h" -#include "network.h" +#include "clientsettings.h" #include "ircchannel.h" - -#include "buffersettings.h" - -#include "util.h" // get rid of this (needed for isChannelName) +#include "network.h" +#include "signalproxy.h" /***************************************** * Network Items @@ -107,6 +106,23 @@ BufferItem *NetworkItem::bufferItem(const BufferInfo &bufferInfo) { } newChild(bufferItem); + + // postprocess... this is necessary because Qt doesn't seem to like adding childs which already have childs on their own + switch(bufferInfo.type()) { + case BufferInfo::ChannelBuffer: + { + ChannelBufferItem *channelBufferItem = static_cast(bufferItem); + if(_network) { + IrcChannel *ircChannel = _network->ircChannel(bufferInfo.bufferName()); + if(ircChannel) + channelBufferItem->attachIrcChannel(ircChannel); + } + } + break; + default: + break; + } + return bufferItem; } @@ -117,17 +133,17 @@ void NetworkItem::attachNetwork(Network *network) { _network = network; connect(network, SIGNAL(networkNameSet(QString)), - this, SLOT(setNetworkName(QString))); + this, SLOT(setNetworkName(QString))); connect(network, SIGNAL(currentServerSet(QString)), - this, SLOT(setCurrentServer(QString))); + this, SLOT(setCurrentServer(QString))); connect(network, SIGNAL(ircChannelAdded(IrcChannel *)), - this, SLOT(attachIrcChannel(IrcChannel *))); + this, SLOT(attachIrcChannel(IrcChannel *))); connect(network, SIGNAL(ircUserAdded(IrcUser *)), - this, SLOT(attachIrcUser(IrcUser *))); + this, SLOT(attachIrcUser(IrcUser *))); connect(network, SIGNAL(connectedSet(bool)), - this, SIGNAL(networkDataChanged())); + this, SIGNAL(networkDataChanged())); connect(network, SIGNAL(destroyed()), - this, SIGNAL(networkDataChanged())); + this, SIGNAL(networkDataChanged())); emit networkDataChanged(); } @@ -174,8 +190,8 @@ void NetworkItem::setCurrentServer(const QString &serverName) { QString NetworkItem::toolTip(int column) const { Q_UNUSED(column); - QStringList toolTip(QString("%1").arg(networkName())); - toolTip.append(tr("Server: %1").arg(currentServer())); + QStringList toolTip(QString("%1").arg(Qt::escape(networkName()))); + toolTip.append(tr("Server: %1").arg(Qt::escape(currentServer()))); toolTip.append(tr("Users: %1").arg(nickCount())); if(_network) { @@ -236,7 +252,7 @@ void BufferItem::updateActivityLevel(const Message &msg) { stateChanged = true; _firstUnreadMsgId = msg.msgId(); } - + BufferInfo::ActivityLevel oldLevel = activityLevel(); _activity |= BufferInfo::OtherActivity; @@ -363,10 +379,10 @@ bool QueryBufferItem::setData(int column, const QVariant &value, int role) { { QString newName = value.toString(); if(!newName.isEmpty()) { - Client::renameBuffer(bufferId(), newName); - return true; + Client::renameBuffer(bufferId(), newName); + return true; } else { - return false; + return false; } } break; @@ -447,13 +463,6 @@ ChannelBufferItem::ChannelBufferItem(const BufferInfo &bufferInfo, AbstractTreeI : BufferItem(bufferInfo, parent), _ircChannel(0) { - const Network *net = Client::network(bufferInfo.networkId()); - if(!net) - return; - - IrcChannel *ircChannel = net->ircChannel(bufferInfo.bufferName()); - if(ircChannel) - attachIrcChannel(ircChannel); } QVariant ChannelBufferItem::data(int column, int role) const { @@ -469,7 +478,7 @@ QString ChannelBufferItem::toolTip(int column) const { Q_UNUSED(column); QStringList toolTip; - toolTip.append(tr("Channel %1").arg(bufferName())); + toolTip.append(tr("Channel %1").arg(Qt::escape(bufferName()))); if(isActive()) { //TODO: add channel modes toolTip.append(tr("Users: %1").arg(nickCount())); @@ -479,14 +488,13 @@ QString ChannelBufferItem::toolTip(int column) const { toolTip.append(tr("Mode: %1").arg(channelMode)); } - BufferSettings s; - bool showTopic = s.value("DisplayTopicInTooltip", QVariant(false)).toBool(); + ItemViewSettings s; + bool showTopic = s.displayTopicInTooltip(); if(showTopic) { QString _topic = topic(); if(_topic != "") { _topic = stripFormatCodes(_topic); - _topic.replace(QString("<"), QString("<")); - _topic.replace(QString(">"), QString(">")); + _topic = Qt::escape(_topic); toolTip.append(QString(" ")); toolTip.append(tr("Topic: %1").arg(_topic)); } @@ -504,19 +512,19 @@ void ChannelBufferItem::attachIrcChannel(IrcChannel *ircChannel) { _ircChannel = ircChannel; connect(ircChannel, SIGNAL(topicSet(QString)), - this, SLOT(setTopic(QString))); + this, SLOT(setTopic(QString))); connect(ircChannel, SIGNAL(ircUsersJoined(QList)), - this, SLOT(join(QList))); + this, SLOT(join(QList))); connect(ircChannel, SIGNAL(ircUserParted(IrcUser *)), - this, SLOT(part(IrcUser *))); + this, SLOT(part(IrcUser *))); connect(ircChannel, SIGNAL(parted()), - this, SLOT(ircChannelParted())); + this, SLOT(ircChannelParted())); connect(ircChannel, SIGNAL(ircUserModesSet(IrcUser *, QString)), - this, SLOT(userModeChanged(IrcUser *))); + this, SLOT(userModeChanged(IrcUser *))); connect(ircChannel, SIGNAL(ircUserModeAdded(IrcUser *, QString)), - this, SLOT(userModeChanged(IrcUser *))); + this, SLOT(userModeChanged(IrcUser *))); connect(ircChannel, SIGNAL(ircUserModeRemoved(IrcUser *, QString)), - this, SLOT(userModeChanged(IrcUser *))); + this, SLOT(userModeChanged(IrcUser *))); if(!ircChannel->ircUsers().isEmpty()) join(ircChannel->ircUsers()); @@ -604,7 +612,7 @@ void ChannelBufferItem::removeUserFromCategory(IrcUser *ircUser) { categoryItem = qobject_cast(child(i)); if(categoryItem->removeUser(ircUser)) { if(categoryItem->childCount() == 0) - removeChild(i); + removeChild(i); break; } } @@ -806,9 +814,9 @@ NetworkModel::NetworkModel(QObject *parent) : TreeModel(NetworkModel::defaultHeader(), parent) { connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), - this, SLOT(checkForNewBuffers(const QModelIndex &, int, int))); + this, SLOT(checkForNewBuffers(const QModelIndex &, int, int))); connect(this, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)), - this, SLOT(checkForRemovedBuffers(const QModelIndex &, int, int))); + this, SLOT(checkForRemovedBuffers(const QModelIndex &, int, int))); BufferSettings defaultSettings; defaultSettings.notify("UserNoticesTarget", this, SLOT(messageRedirectionSettingsChanged())); @@ -819,7 +827,7 @@ NetworkModel::NetworkModel(QObject *parent) QListNetworkModel::defaultHeader() { QList data; - data << tr("Buffer") << tr("Topic") << tr("Nick Count"); + data << tr("Chat") << tr("Topic") << tr("Nick Count"); return data; } @@ -1005,10 +1013,10 @@ void NetworkModel::updateBufferActivity(Message &msg) { if(bufferType(msg.bufferId()) != BufferInfo::ChannelBuffer) { msg.setFlags(msg.flags() | Message::Redirected); if(msg.flags() & Message::ServerMsg) { - // server notice - redirectionTarget = _serverNoticesTarget; + // server notice + redirectionTarget = _serverNoticesTarget; } else { - redirectionTarget = _userNoticesTarget; + redirectionTarget = _userNoticesTarget; } } break; @@ -1037,7 +1045,7 @@ void NetworkModel::updateBufferActivity(Message &msg) { if(redirectionTarget & BufferSettings::StatusBuffer) { const NetworkItem *netItem = findNetworkItem(msg.bufferInfo().networkId()); if(netItem) { - updateBufferActivity(netItem->statusBufferItem(), msg); + updateBufferActivity(netItem->statusBufferItem(), msg); } } } else {