X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fnetworkmodel.cpp;h=c85f579f296d272a15624dd2690a1e70c1a5dc57;hp=a38ed11d639da12cb2c02c90760626fde9d33dcb;hb=b0fcfdea3deb5e45961745d743c8468e905744b1;hpb=694f9bfbf7f1af19108461c7e00d133e55082bce diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index a38ed11d..c85f579f 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-09 by the Quassel Project * + * Copyright (C) 2005-2015 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,14 +15,16 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "networkmodel.h" #include #include +#if QT_VERSION < 0x050000 #include // for Qt::escape() +#endif #include "buffermodel.h" #include "buffersettings.h" @@ -153,7 +155,7 @@ void NetworkItem::attachNetwork(Network *network) connect(network, SIGNAL(connectedSet(bool)), this, SIGNAL(networkDataChanged())); connect(network, SIGNAL(destroyed()), - this, SIGNAL(networkDataChanged())); + this, SLOT(onNetworkDestroyed())); emit networkDataChanged(); } @@ -209,8 +211,13 @@ QString NetworkItem::toolTip(int column) const { Q_UNUSED(column); +#if QT_VERSION < 0x050000 QStringList toolTip(QString("%1").arg(Qt::escape(networkName()))); toolTip.append(tr("Server: %1").arg(Qt::escape(currentServer()))); +#else + QStringList toolTip(QString("%1").arg(networkName().toHtmlEscaped())); + toolTip.append(tr("Server: %1").arg(currentServer().toHtmlEscaped())); +#endif toolTip.append(tr("Users: %1").arg(nickCount())); if (_network) { @@ -233,6 +240,14 @@ void NetworkItem::onBeginRemoveChilds(int start, int end) } +void NetworkItem::onNetworkDestroyed() +{ + _network = 0; + emit networkDataChanged(); + removeAllChilds(); +} + + /***************************************** * Fancy Buffer Items *****************************************/ @@ -520,8 +535,10 @@ void QueryBufferItem::setIrcUser(IrcUser *ircUser) } if (ircUser) { + connect(ircUser, SIGNAL(destroyed(QObject*)), SLOT(removeIrcUser())); connect(ircUser, SIGNAL(quited()), this, SLOT(removeIrcUser())); connect(ircUser, SIGNAL(awaySet(bool)), this, SIGNAL(dataChanged())); + connect(ircUser, SIGNAL(encryptedSet(bool)), this, SLOT(setEncrypted(bool))); } _ircUser = ircUser; @@ -562,7 +579,11 @@ QString ChannelBufferItem::toolTip(int column) const Q_UNUSED(column); QStringList toolTip; +#if QT_VERSION < 0x050000 toolTip.append(tr("Channel %1").arg(Qt::escape(bufferName()))); +#else + toolTip.append(tr("Channel %1").arg(bufferName().toHtmlEscaped())); +#endif if (isActive()) { //TODO: add channel modes toolTip.append(tr("Users: %1").arg(nickCount())); @@ -578,7 +599,11 @@ QString ChannelBufferItem::toolTip(int column) const QString _topic = topic(); if (_topic != "") { _topic = stripFormatCodes(_topic); +#if QT_VERSION < 0x050000 _topic = Qt::escape(_topic); +#else + _topic = _topic.toHtmlEscaped(); +#endif toolTip.append(QString(" ")); toolTip.append(tr("Topic: %1").arg(_topic)); } @@ -594,12 +619,19 @@ QString ChannelBufferItem::toolTip(int column) const void ChannelBufferItem::attachIrcChannel(IrcChannel *ircChannel) { - Q_ASSERT(!_ircChannel && ircChannel); + if (_ircChannel) { + qWarning() << Q_FUNC_INFO << "IrcChannel already set; cleanup failed!?"; + disconnect(_ircChannel, 0, this, 0); + } _ircChannel = ircChannel; + connect(ircChannel, SIGNAL(destroyed(QObject*)), + this, SLOT(ircChannelDestroyed())); connect(ircChannel, SIGNAL(topicSet(QString)), this, SLOT(setTopic(QString))); + connect(ircChannel, SIGNAL(encryptedSet(bool)), + this, SLOT(setEncrypted(bool))); connect(ircChannel, SIGNAL(ircUsersJoined(QList )), this, SLOT(join(QList ))); connect(ircChannel, SIGNAL(ircUserParted(IrcUser *)), @@ -630,6 +662,16 @@ void ChannelBufferItem::ircChannelParted() } +void ChannelBufferItem::ircChannelDestroyed() +{ + if (_ircChannel) { + _ircChannel = 0; + emit dataChanged(); + removeAllChilds(); + } +} + + void ChannelBufferItem::join(const QList &ircUsers) { addUsersToCategory(ircUsers); @@ -681,7 +723,7 @@ void ChannelBufferItem::addUsersToCategory(const QList &ircUsers) QHash >::const_iterator catIter = categories.constBegin(); while (catIter != categories.constEnd()) { catIter.key()->addUsers(catIter.value()); - catIter++; + ++catIter; } } @@ -1075,7 +1117,7 @@ QList > NetworkModel::mimeDataToBufferList(const QMim if (!mimeContainsBufferList(mimeData)) return bufferList; - QStringList rawBufferList = QString::fromAscii(mimeData->data("application/Quassel/BufferItemList")).split(","); + QStringList rawBufferList = QString::fromLatin1(mimeData->data("application/Quassel/BufferItemList")).split(","); NetworkId networkId; BufferId bufferUid; foreach(QString rawBuffer, rawBufferList) { @@ -1103,7 +1145,7 @@ QMimeData *NetworkModel::mimeData(const QModelIndexList &indexes) const bufferlist << bufferid; } - mimeData->setData("application/Quassel/BufferItemList", bufferlist.join(",").toAscii()); + mimeData->setData("application/Quassel/BufferItemList", bufferlist.join(",").toLatin1()); return mimeData; } @@ -1237,7 +1279,8 @@ void NetworkModel::updateBufferActivity(Message &msg) } } else { - updateBufferActivity(bufferItem(msg.bufferInfo()), msg); + if ((BufferSettings(msg.bufferId()).messageFilter() & msg.type()) != msg.type()) + updateBufferActivity(bufferItem(msg.bufferInfo()), msg); } }