X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fclient%2Fnetworkmodel.cpp;h=6df98c327a000b27b9376d7b97eb77a0bb9f931c;hb=48dda5f3e963e13e36300ddaef262660bf169672;hp=ddc71dd4f4ab19c5579b07922f93d4e391ee5bfd;hpb=ecf1ab29dd398f0e0beaff327443909096d24f55;p=quassel.git
diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp
index ddc71dd4..6df98c32 100644
--- a/src/client/networkmodel.cpp
+++ b/src/client/networkmodel.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005-2015 by the Quassel Project *
+ * Copyright (C) 2005-2018 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -34,12 +34,13 @@
#include "ircchannel.h"
#include "network.h"
#include "signalproxy.h"
+#include "buffersyncer.h"
/*****************************************
* Network Items
*****************************************/
NetworkItem::NetworkItem(const NetworkId &netid, AbstractTreeItem *parent)
- : PropertyMapItem(QList() << "networkName" << "currentServer" << "nickCount", parent),
+ : PropertyMapItem(parent),
_networkId(netid),
_statusBufferItem(0)
{
@@ -52,6 +53,13 @@ NetworkItem::NetworkItem(const NetworkId &netid, AbstractTreeItem *parent)
}
+QStringList NetworkItem::propertyOrder() const
+{
+ static QStringList order{"networkName", "currentServer", "nickCount"};
+ return order;
+}
+
+
QVariant NetworkItem::data(int column, int role) const
{
switch (role) {
@@ -74,6 +82,18 @@ QVariant NetworkItem::data(int column, int role) const
}
}
+QString NetworkItem::escapeHTML(const QString &string, bool useNonbreakingSpaces)
+{
+ // QString.replace() doesn't guarantee the source string will remain constant.
+ // Use a local variable to avoid compiler errors.
+#if QT_VERSION < 0x050000
+ QString formattedString = Qt::escape(string);
+#else
+ QString formattedString = string.toHtmlEscaped();
+#endif
+ return (useNonbreakingSpaces ? formattedString.replace(" ", " ") : formattedString);
+}
+
// FIXME shouldn't we check the bufferItemCache here?
BufferItem *NetworkItem::findBufferItem(BufferId bufferId)
@@ -133,6 +153,14 @@ BufferItem *NetworkItem::bufferItem(const BufferInfo &bufferInfo)
break;
}
+ BufferSyncer *bufferSyncer = Client::bufferSyncer();
+ if (bufferSyncer) {
+ bufferItem->addActivity(
+ bufferSyncer->activity(bufferItem->bufferId()),
+ bufferSyncer->highlightCount(bufferItem->bufferId()) > 0
+ );
+ }
+
return bufferItem;
}
@@ -210,21 +238,31 @@ void NetworkItem::setCurrentServer(const QString &serverName)
QString NetworkItem::toolTip(int column) const
{
Q_UNUSED(column);
+ QString strTooltip;
+ QTextStream tooltip( &strTooltip, QIODevice::WriteOnly );
+ tooltip << "";
-#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()));
+ // Function to add a row to the tooltip table
+ auto addRow = [&](const QString& key, const QString& value, bool condition) {
+ if (condition) {
+ tooltip << "" << key << " | " << value << " |
";
+ }
+ };
- if (_network) {
- toolTip.append(tr("Lag: %1 msecs").arg(_network->latency()));
- }
+ tooltip << "" << NetworkItem::escapeHTML(networkName(), true) << "
";
+ if (isActive()) {
+ tooltip << "";
+ addRow(tr("Server"), NetworkItem::escapeHTML(currentServer(), true), !currentServer().isEmpty());
+ addRow(tr("Users"), QString::number(nickCount()), true);
+ if (_network)
+ addRow(tr("Lag"), NetworkItem::escapeHTML(tr("%1 msecs").arg(_network->latency()), true), true);
- return QString(" %1
").arg(toolTip.join("
"));
+ tooltip << "
";
+ } else {
+ tooltip << "" << tr("Not connected") << "
";
+ }
+ tooltip << "";
+ return strTooltip;
}
@@ -252,7 +290,7 @@ void NetworkItem::onNetworkDestroyed()
* Fancy Buffer Items
*****************************************/
BufferItem::BufferItem(const BufferInfo &bufferInfo, AbstractTreeItem *parent)
- : PropertyMapItem(QStringList() << "bufferName" << "topic" << "nickCount", parent),
+ : PropertyMapItem(parent),
_bufferInfo(bufferInfo),
_activity(BufferInfo::NoActivity)
{
@@ -260,6 +298,13 @@ BufferItem::BufferItem(const BufferInfo &bufferInfo, AbstractTreeItem *parent)
}
+QStringList BufferItem::propertyOrder() const
+{
+ static QStringList order{"bufferName", "topic", "nickCount"};
+ return order;
+}
+
+
void BufferItem::setActivityLevel(BufferInfo::ActivityLevel level)
{
if (_activity != level) {
@@ -271,11 +316,16 @@ void BufferItem::setActivityLevel(BufferInfo::ActivityLevel level)
void BufferItem::clearActivityLevel()
{
- _activity = BufferInfo::NoActivity;
+ if (Client::isCoreFeatureEnabled(Quassel::Feature::BufferActivitySync)) {
+ // If the core handles activity sync, clear only the highlight flag
+ _activity &= ~BufferInfo::Highlight;
+ } else {
+ _activity = BufferInfo::NoActivity;
+ }
_firstUnreadMsgId = MsgId();
// FIXME remove with core proto v11
- if (!(Client::coreFeatures() & Quassel::SynchronizedMarkerLine)) {
+ if (!Client::isCoreFeatureEnabled(Quassel::Feature::SynchronizedMarkerLine)) {
_markerLineMsgId = _lastSeenMsgId;
}
@@ -285,6 +335,11 @@ void BufferItem::clearActivityLevel()
void BufferItem::updateActivityLevel(const Message &msg)
{
+ // If the core handles activity, and this message is not a highlight, ignore this
+ if (Client::isCoreFeatureEnabled(Quassel::Feature::BufferActivitySync) && !msg.flags().testFlag(Message::Highlight)) {
+ return;
+ }
+
if (isCurrentBuffer()) {
return;
}
@@ -305,19 +360,43 @@ void BufferItem::updateActivityLevel(const Message &msg)
_firstUnreadMsgId = msg.msgId();
}
+ Message::Types type;
+ // If the core handles activities, ignore types
+ if (Client::isCoreFeatureEnabled(Quassel::Feature::BufferActivitySync)) {
+ type = Message::Types();
+ } else {
+ type = msg.type();
+ }
+
+ if (addActivity(type, msg.flags().testFlag(Message::Highlight)) || stateChanged) {
+ emit dataChanged();
+ }
+}
+
+void BufferItem::setActivity(Message::Types type, bool highlight) {
BufferInfo::ActivityLevel oldLevel = activityLevel();
- _activity |= BufferInfo::OtherActivity;
- if (msg.type() & (Message::Plain | Message::Notice | Message::Action))
+ _activity &= BufferInfo::Highlight;
+ addActivity(type, highlight);
+
+ if (_activity != oldLevel) {
+ emit dataChanged();
+ }
+}
+
+bool BufferItem::addActivity(Message::Types type, bool highlight) {
+ auto oldActivity = activityLevel();
+
+ if (type != Message::Types())
+ _activity |= BufferInfo::OtherActivity;
+
+ if (type.testFlag(Message::Plain) || type.testFlag(Message::Notice) || type.testFlag(Message::Action))
_activity |= BufferInfo::NewMessage;
- if (msg.flags() & Message::Highlight)
+ if (highlight)
_activity |= BufferInfo::Highlight;
- stateChanged |= (oldLevel != _activity);
-
- if (stateChanged)
- emit dataChanged();
+ return oldActivity != _activity;
}
@@ -373,7 +452,7 @@ void BufferItem::setLastSeenMsgId(MsgId msgId)
_lastSeenMsgId = msgId;
// FIXME remove with core protocol v11
- if (!(Client::coreFeatures() & Quassel::SynchronizedMarkerLine)) {
+ if (!Client::isCoreFeatureEnabled(Quassel::Feature::SynchronizedMarkerLine)) {
if (!isCurrentBuffer())
_markerLineMsgId = msgId;
}
@@ -498,36 +577,120 @@ QString QueryBufferItem::toolTip(int column) const
{
// pretty much code duplication of IrcUserItem::toolTip() but inheritance won't solve this...
Q_UNUSED(column);
- QStringList toolTip;
+ QString strTooltip;
+ QTextStream tooltip( &strTooltip, QIODevice::WriteOnly );
+ tooltip << "";
+
+ // Keep track of whether or not information has been added
+ bool infoAdded = false;
+
+ // Use bufferName() for QueryBufferItem, nickName() for IrcUserItem
+ tooltip << "";
+ tooltip << tr("Query with %1").arg(NetworkItem::escapeHTML(bufferName(), true));
+ if (!_ircUser) {
+ // User seems to be offline, let the no information message be added below
+ tooltip << "
";
+ } else {
+ // Function to add a row to the tooltip table
+ auto addRow = [&](const QString& key, const QString& value, bool condition) {
+ if (condition) {
+ tooltip << "" << key << " | " << value << " |
";
+ infoAdded = true;
+ }
+ };
- toolTip.append(tr("Query with %1").arg(bufferName()));
+ // User information is available
+ if (_ircUser->userModes() != "") {
+ //TODO Translate user Modes and add them to the table below and in IrcUserItem::toolTip
+ tooltip << " (" << _ircUser->userModes() << ")";
+ }
+ tooltip << "
";
- if (_ircUser) {
- if (_ircUser->userModes() != "") toolTip[0].append(QString(" (+%1)").arg(_ircUser->userModes()));
+ tooltip << "";
if (_ircUser->isAway()) {
- toolTip[0].append(QString(" (away%1)").arg(!_ircUser->awayMessage().isEmpty() ? (QString(" ") + _ircUser->awayMessage()) : QString()));
+ QString awayMessageHTML = QString("%1
").arg(tr("Unknown"));
+
+ // If away message is known, replace with the escaped message.
+ if (!_ircUser->awayMessage().isEmpty()) {
+ awayMessageHTML = NetworkItem::escapeHTML(_ircUser->awayMessage());
+ }
+ addRow(NetworkItem::escapeHTML(tr("Away message"), true), awayMessageHTML, true);
+ }
+ addRow(tr("Realname"),
+ NetworkItem::escapeHTML(_ircUser->realName()),
+ !_ircUser->realName().isEmpty());
+ // suserHost may return " is available for help", which should be translated.
+ // See https://www.alien.net.au/irc/irc2numerics.html
+ if(_ircUser->suserHost().endsWith("available for help")) {
+ addRow(NetworkItem::escapeHTML(tr("Help status"), true),
+ NetworkItem::escapeHTML(tr("Available for help")),
+ true);
+ } else {
+ addRow(NetworkItem::escapeHTML(tr("Service status"), true),
+ NetworkItem::escapeHTML(_ircUser->suserHost()),
+ !_ircUser->suserHost().isEmpty());
}
- if (!_ircUser->realName().isEmpty()) toolTip.append(_ircUser->realName());
- if (!_ircUser->ircOperator().isEmpty()) toolTip.append(QString("%1 %2").arg(_ircUser->nick()).arg(_ircUser->ircOperator()));
- if (!_ircUser->suserHost().isEmpty()) toolTip.append(_ircUser->suserHost());
- if (!_ircUser->whoisServiceReply().isEmpty()) toolTip.append(_ircUser->whoisServiceReply());
- toolTip.append(_ircUser->hostmask().remove(0, _ircUser->hostmask().indexOf("!")+1));
+ // Keep track of whether or not the account information's been added. Don't show it twice.
+ bool accountAdded = false;
+ if(!_ircUser->account().isEmpty()) {
+ // IRCv3 account-notify is supported by the core and IRC server.
+ // Assume logged out (seems to be more common)
+ QString accountHTML = QString("%1
").arg(tr("Not logged in"));
+
+ // If account is logged in, replace with the escaped account name.
+ if (_ircUser->account() != "*") {
+ accountHTML = NetworkItem::escapeHTML(_ircUser->account());
+ }
+ addRow(NetworkItem::escapeHTML(tr("Account"), true),
+ accountHTML,
+ true);
+ // Mark the row as added
+ accountAdded = true;
+ }
+ // whoisServiceReply may return " is identified for this nick", which should be translated.
+ // See https://www.alien.net.au/irc/irc2numerics.html
+ if(_ircUser->whoisServiceReply().endsWith("identified for this nick")) {
+ addRow(NetworkItem::escapeHTML(tr("Account"), true),
+ NetworkItem::escapeHTML(tr("Identified for this nick")),
+ !accountAdded);
+ // Don't add the account row again if information's already added via account-notify
+ // Mark the row as added
+ accountAdded = true;
+ } else {
+ addRow(NetworkItem::escapeHTML(tr("Service Reply"), true),
+ NetworkItem::escapeHTML(_ircUser->whoisServiceReply()),
+ !_ircUser->whoisServiceReply().isEmpty());
+ }
+ addRow(tr("Hostmask"),
+ NetworkItem::escapeHTML(_ircUser->hostmask().remove(0, _ircUser->hostmask().indexOf("!") + 1)),
+ !(_ircUser->hostmask().remove(0, _ircUser->hostmask().indexOf("!") + 1) == "@"));
+ // ircOperator may contain "is an" or "is a", which should be removed.
+ addRow(tr("Operator"),
+ NetworkItem::escapeHTML(_ircUser->ircOperator().replace("is an ", "").replace("is a ", "")),
+ !_ircUser->ircOperator().isEmpty());
if (_ircUser->idleTime().isValid()) {
QDateTime now = QDateTime::currentDateTime();
QDateTime idle = _ircUser->idleTime();
int idleTime = idle.secsTo(now);
- toolTip.append(tr("idling since %1").arg(secondsToString(idleTime)));
+ addRow(NetworkItem::escapeHTML(tr("Idling since"), true), secondsToString(idleTime), true);
}
+
if (_ircUser->loginTime().isValid()) {
- toolTip.append(tr("login time: %1").arg(_ircUser->loginTime().toString()));
+ addRow(NetworkItem::escapeHTML(tr("Login time"), true), _ircUser->loginTime().toString(), true);
}
- if (!_ircUser->server().isEmpty()) toolTip.append(tr("server: %1").arg(_ircUser->server()));
+ addRow(tr("Server"), NetworkItem::escapeHTML(_ircUser->server()), !_ircUser->server().isEmpty());
+ tooltip << "
";
}
- return QString(" %1
").arg(toolTip.join("
"));
+ // If no further information found, offer an explanatory message
+ if (!infoAdded)
+ tooltip << "" << tr("No information available") << "
";
+
+ tooltip << "";
+ return strTooltip;
}
@@ -554,8 +717,22 @@ void QueryBufferItem::setIrcUser(IrcUser *ircUser)
void QueryBufferItem::removeIrcUser()
{
- _ircUser = 0;
- emit dataChanged();
+ if (_ircUser) {
+ // Disconnect the active IrcUser before removing it, otherwise it will fire removeIrcUser()
+ // a second time when the object's destroyed due to QueryBufferItem::setIrcUser() connecting
+ // SIGNAL destroyed(QObject*) to SLOT removeIrcUser().
+ // This fixes removing an active IrcUser if the user had quit then rejoined in a nonstandard
+ // manner (e.g. updateNickFromHost calling newIrcUser, triggered by an away-notify message).
+ disconnect(_ircUser, 0, this, 0);
+
+ // Clear IrcUser (only set to 0 if not already 0)
+ _ircUser = 0;
+
+ // Only emit dataChanged() if data actually changed. This might serve as a small
+ // optimization, but it can be moved outside the if statement if other behavior depends on
+ // it always being called.
+ emit dataChanged();
+ }
}
@@ -566,6 +743,7 @@ ChannelBufferItem::ChannelBufferItem(const BufferInfo &bufferInfo, AbstractTreeI
: BufferItem(bufferInfo, parent),
_ircChannel(0)
{
+ setFlags(flags() | Qt::ItemIsDropEnabled);
}
@@ -583,20 +761,28 @@ QVariant ChannelBufferItem::data(int column, int role) const
QString ChannelBufferItem::toolTip(int column) const
{
Q_UNUSED(column);
- QStringList toolTip;
+ QString strTooltip;
+ QTextStream tooltip( &strTooltip, QIODevice::WriteOnly );
+ tooltip << "";
+
+ // Function to add a row to the tooltip table
+ auto addRow = [&](const QString& key, const QString& value, bool condition) {
+ if (condition) {
+ tooltip << "" << key << " | " << value << " |
";
+ }
+ };
+
+ tooltip << "";
+ tooltip << NetworkItem::escapeHTML(tr("Channel %1").arg(bufferName()), true) << "
";
-#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()));
+ tooltip << "";
+ addRow(tr("Users"), QString::number(nickCount()), true);
+
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));
+ addRow(tr("Mode"), channelMode, true);
}
ItemViewSettings s;
@@ -605,21 +791,18 @@ 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));
+ _topic = NetworkItem::escapeHTML(_topic);
+ addRow(tr("Topic"), _topic, true);
}
}
- }
- else {
- toolTip.append(tr("Not active
Double-click to join"));
+
+ tooltip << "
";
+ } else {
+ tooltip << "" << tr("Not active, double-click to join") << "
";
}
- return tr(" %1
").arg(toolTip.join("
"));
+ tooltip << "";
+ return strTooltip;
}
@@ -657,6 +840,16 @@ void ChannelBufferItem::attachIrcChannel(IrcChannel *ircChannel)
emit dataChanged();
}
+QString ChannelBufferItem::nickChannelModes(const QString &nick) const
+{
+ if (!_ircChannel) {
+ qDebug() << Q_FUNC_INFO << "IrcChannel not set, can't get user modes";
+ return QString();
+ }
+
+ return _ircChannel->userModes(nick);
+}
+
void ChannelBufferItem::ircChannelParted()
{
@@ -813,7 +1006,7 @@ void ChannelBufferItem::userModeChanged(IrcUser *ircUser)
const QList UserCategoryItem::categories = QList() << 'q' << 'a' << 'o' << 'h' << 'v';
UserCategoryItem::UserCategoryItem(int category, AbstractTreeItem *parent)
- : PropertyMapItem(QStringList() << "categoryName", parent),
+ : PropertyMapItem(parent),
_category(category)
{
setFlags(Qt::ItemIsEnabled);
@@ -822,6 +1015,13 @@ UserCategoryItem::UserCategoryItem(int category, AbstractTreeItem *parent)
}
+QStringList UserCategoryItem::propertyOrder() const
+{
+ static QStringList order{"categoryName"};
+ return order;
+}
+
+
// caching this makes no sense, since we display the user number dynamically
QString UserCategoryItem::categoryName() const
{
@@ -915,7 +1115,7 @@ QVariant UserCategoryItem::data(int column, int role) const
* Irc User Items
*****************************************/
IrcUserItem::IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent)
- : PropertyMapItem(QStringList() << "nickName", parent),
+ : PropertyMapItem(parent),
_ircUser(ircUser)
{
setObjectName(ircUser->nick());
@@ -925,6 +1125,13 @@ IrcUserItem::IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent)
}
+QStringList IrcUserItem::propertyOrder() const
+{
+ static QStringList order{"nickName"};
+ return order;
+}
+
+
QVariant IrcUserItem::data(int column, int role) const
{
switch (role) {
@@ -955,11 +1162,15 @@ QString IrcUserItem::toolTip(int column) const
Q_UNUSED(column);
QString strTooltip;
QTextStream tooltip( &strTooltip, QIODevice::WriteOnly );
- tooltip << "";
+ tooltip << "";
+
+ // Keep track of whether or not information has been added
+ bool infoAdded = false;
- tooltip << "" << nickName();
+ // Use bufferName() for QueryBufferItem, nickName() for IrcUserItem
+ tooltip << "
" << NetworkItem::escapeHTML(nickName(), true);
if (_ircUser->userModes() != "") {
- //TODO: Translate user Modes and add them to the table below
+ //TODO: Translate user Modes and add them to the table below and in QueryBufferItem::toolTip
tooltip << " (" << _ircUser->userModes() << ")";
}
tooltip << "
";
@@ -968,41 +1179,115 @@ QString IrcUserItem::toolTip(int column) const
if (condition)
{
tooltip << "" << key << " | " << value << " |
";
+ infoAdded = true;
}
};
tooltip << "";
+ addRow(tr("Modes"),
+ NetworkItem::escapeHTML(channelModes()),
+ !channelModes().isEmpty());
if (_ircUser->isAway()) {
- QString awayMessage(tr("(unknown)"));
- if(!_ircUser->awayMessage().isEmpty()) {
- awayMessage = _ircUser->awayMessage();
+ QString awayMessageHTML = QString("%1
").arg(tr("Unknown"));
+
+ // If away message is known, replace with the escaped message.
+ if (!_ircUser->awayMessage().isEmpty()) {
+ awayMessageHTML = NetworkItem::escapeHTML(_ircUser->awayMessage());
}
- addRow(tr("Away Message"), awayMessage, true);
- }
- addRow(tr("Realname"), _ircUser->realName(), !_ircUser->realName().isEmpty());
- addRow(tr("Operator"), _ircUser->ircOperator(), !_ircUser->ircOperator().isEmpty());
- addRow(tr("Suser Host"), _ircUser->suserHost(),!_ircUser->suserHost().isEmpty());
- addRow(tr("Whois Service Reply"), _ircUser->whoisServiceReply(), !_ircUser->whoisServiceReply().isEmpty());
- addRow(tr("Hostmask"), _ircUser->hostmask().remove(0, _ircUser->hostmask().indexOf("!")+1), true);
- addRow(tr("Operator"), _ircUser->ircOperator(), !_ircUser->ircOperator().isEmpty());
+ addRow(NetworkItem::escapeHTML(tr("Away message"), true), awayMessageHTML, true);
+ }
+ addRow(tr("Realname"),
+ NetworkItem::escapeHTML(_ircUser->realName()),
+ !_ircUser->realName().isEmpty());
+
+ // suserHost may return " is available for help", which should be translated.
+ // See https://www.alien.net.au/irc/irc2numerics.html
+ if(_ircUser->suserHost().endsWith("available for help")) {
+ addRow(NetworkItem::escapeHTML(tr("Help status"), true),
+ NetworkItem::escapeHTML(tr("Available for help")),
+ true);
+ } else {
+ addRow(NetworkItem::escapeHTML(tr("Service status"), true),
+ NetworkItem::escapeHTML(_ircUser->suserHost()),
+ !_ircUser->suserHost().isEmpty());
+ }
+
+ // Keep track of whether or not the account information's been added. Don't show it twice.
+ bool accountAdded = false;
+ if(!_ircUser->account().isEmpty()) {
+ // IRCv3 account-notify is supported by the core and IRC server.
+ // Assume logged out (seems to be more common)
+ QString accountHTML = QString("%1
").arg(tr("Not logged in"));
+
+ // If account is logged in, replace with the escaped account name.
+ if (_ircUser->account() != "*") {
+ accountHTML = NetworkItem::escapeHTML(_ircUser->account());
+ }
+ addRow(NetworkItem::escapeHTML(tr("Account"), true),
+ accountHTML,
+ true);
+ // Mark the row as added
+ accountAdded = true;
+ }
+ // whoisServiceReply may return " is identified for this nick", which should be translated.
+ // See https://www.alien.net.au/irc/irc2numerics.html
+ if(_ircUser->whoisServiceReply().endsWith("identified for this nick")) {
+ addRow(NetworkItem::escapeHTML(tr("Account"), true),
+ NetworkItem::escapeHTML(tr("Identified for this nick")),
+ !accountAdded);
+ // Don't add the account row again if information's already added via account-notify
+ // Mark the row as added
+ accountAdded = true;
+ } else {
+ addRow(NetworkItem::escapeHTML(tr("Service Reply"), true),
+ NetworkItem::escapeHTML(_ircUser->whoisServiceReply()),
+ !_ircUser->whoisServiceReply().isEmpty());
+ }
+ addRow(tr("Hostmask"),
+ NetworkItem::escapeHTML(_ircUser->hostmask().remove(0, _ircUser->hostmask().indexOf("!") + 1)),
+ !(_ircUser->hostmask().remove(0, _ircUser->hostmask().indexOf("!") + 1) == "@"));
+ // ircOperator may contain "is an" or "is a", which should be removed.
+ addRow(tr("Operator"),
+ NetworkItem::escapeHTML(_ircUser->ircOperator().replace("is an ", "").replace("is a ", "")),
+ !_ircUser->ircOperator().isEmpty());
if (_ircUser->idleTime().isValid()) {
QDateTime now = QDateTime::currentDateTime();
QDateTime idle = _ircUser->idleTime();
int idleTime = idle.secsTo(now);
- addRow(tr("Idling since"), secondsToString(idleTime), true);
+ addRow(NetworkItem::escapeHTML(tr("Idling since"), true), secondsToString(idleTime), true);
}
if (_ircUser->loginTime().isValid()) {
- addRow(tr("Login time"), _ircUser->loginTime().toString(), true);
+ addRow(NetworkItem::escapeHTML(tr("Login time"), true), _ircUser->loginTime().toString(), true);
}
- addRow(tr("Server"), _ircUser->server(), !_ircUser->server().isEmpty());
+ addRow(tr("Server"), NetworkItem::escapeHTML(_ircUser->server()), !_ircUser->server().isEmpty());
+ tooltip << "
";
+
+ // If no further information found, offer an explanatory message
+ if (!infoAdded)
+ tooltip << "" << tr("No information available") << "
";
- tooltip << "";
+ tooltip << "";
return strTooltip;
}
+QString IrcUserItem::channelModes() const
+{
+ // IrcUserItems are parented to UserCategoryItem, which are parented to ChannelBufferItem.
+ // We want the channel buffer item in order to get the channel-specific user modes.
+ UserCategoryItem *category = qobject_cast(parent());
+ if (!category)
+ return QString();
+
+ ChannelBufferItem *channel = qobject_cast(category->parent());
+ if (!channel)
+ return QString();
+
+ return channel->nickChannelModes(nickName());
+}
+
/*****************************************
* NetworkModel
@@ -1492,3 +1777,24 @@ void NetworkModel::messageRedirectionSettingsChanged()
_serverNoticesTarget = bufferSettings.serverNoticesTarget();
_errorMsgsTarget = bufferSettings.errorMsgsTarget();
}
+
+void NetworkModel::bufferActivityChanged(BufferId bufferId, const Message::Types activity) {
+ auto _bufferItem = findBufferItem(bufferId);
+ if (!_bufferItem) {
+ qDebug() << "NetworkModel::bufferActivityChanged(): buffer is unknown:" << bufferId;
+ return;
+ }
+ auto hiddenTypes = BufferSettings(bufferId).messageFilter();
+ auto visibleTypes = ~hiddenTypes;
+ auto activityVisibleTypesIntersection = activity & visibleTypes;
+ _bufferItem->setActivity(activityVisibleTypesIntersection, false);
+}
+
+void NetworkModel::highlightCountChanged(BufferId bufferId, int count) {
+ auto _bufferItem = findBufferItem(bufferId);
+ if (!_bufferItem) {
+ qDebug() << "NetworkModel::highlightCountChanged(): buffer is unknown:" << bufferId;
+ return;
+ }
+ _bufferItem->addActivity(Message::Types{}, count > 0);
+}