/***************************************************************************
- * Copyright (C) 2005-2013 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 *
#include <QAbstractItemView>
#include <QMimeData>
+#if QT_VERSION < 0x050000
#include <QTextDocument> // for Qt::escape()
+#endif
#include "buffermodel.h"
#include "buffersettings.h"
connect(network, SIGNAL(connectedSet(bool)),
this, SIGNAL(networkDataChanged()));
connect(network, SIGNAL(destroyed()),
- this, SIGNAL(networkDataChanged()));
+ this, SLOT(onNetworkDestroyed()));
emit networkDataChanged();
}
{
Q_UNUSED(column);
+#if QT_VERSION < 0x050000
QStringList toolTip(QString("<b>%1</b>").arg(Qt::escape(networkName())));
toolTip.append(tr("Server: %1").arg(Qt::escape(currentServer())));
+#else
+ QStringList toolTip(QString("<b>%1</b>").arg(networkName().toHtmlEscaped()));
+ toolTip.append(tr("Server: %1").arg(currentServer().toHtmlEscaped()));
+#endif
toolTip.append(tr("Users: %1").arg(nickCount()));
if (_network) {
}
+void NetworkItem::onNetworkDestroyed()
+{
+ _network = 0;
+ emit networkDataChanged();
+ removeAllChilds();
+}
+
+
/*****************************************
* Fancy Buffer Items
*****************************************/
}
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;
Q_UNUSED(column);
QStringList toolTip;
+#if QT_VERSION < 0x050000
toolTip.append(tr("<b>Channel %1</b>").arg(Qt::escape(bufferName())));
+#else
+ toolTip.append(tr("<b>Channel %1</b>").arg(bufferName().toHtmlEscaped()));
+#endif
if (isActive()) {
//TODO: add channel modes
toolTip.append(tr("<b>Users:</b> %1").arg(nickCount()));
QString _topic = topic();
if (_topic != "") {
_topic = stripFormatCodes(_topic);
+#if QT_VERSION < 0x050000
_topic = Qt::escape(_topic);
+#else
+ _topic = _topic.toHtmlEscaped();
+#endif
toolTip.append(QString("<font size='-2'> </font>"));
toolTip.append(tr("<b>Topic:</b> %1").arg(_topic));
}
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<IrcUser *> )),
this, SLOT(join(QList<IrcUser *> )));
connect(ircChannel, SIGNAL(ircUserParted(IrcUser *)),
}
+void ChannelBufferItem::ircChannelDestroyed()
+{
+ if (_ircChannel) {
+ _ircChannel = 0;
+ emit dataChanged();
+ removeAllChilds();
+ }
+}
+
+
void ChannelBufferItem::join(const QList<IrcUser *> &ircUsers)
{
addUsersToCategory(ircUsers);
QHash<UserCategoryItem *, QList<IrcUser *> >::const_iterator catIter = categories.constBegin();
while (catIter != categories.constEnd()) {
catIter.key()->addUsers(catIter.value());
- catIter++;
+ ++catIter;
}
}
QString IrcUserItem::toolTip(int column) const
{
Q_UNUSED(column);
- QStringList toolTip(QString("<b>%1</b>").arg(nickName()));
- if (_ircUser->userModes() != "") toolTip[0].append(QString(" (%1)").arg(_ircUser->userModes()));
- if (_ircUser->isAway()) {
- toolTip[0].append(tr(" is away"));
- if (!_ircUser->awayMessage().isEmpty())
- toolTip[0].append(QString(" (%1)").arg(_ircUser->awayMessage()));
+ QString strTooltip;
+ QTextStream tooltip( &strTooltip, QIODevice::WriteOnly );
+ tooltip << "<qt><style>.bold { font-weight: bold; }</style>";
+
+ tooltip << "<p class='bold' align='center'>" << nickName();
+ if (_ircUser->userModes() != "") {
+ //TODO: Translate user Modes and add them to the table below
+ tooltip << " (" << _ircUser->userModes() << ")";
}
- if (!_ircUser->realName().isEmpty()) toolTip.append(_ircUser->realName());
- if (!_ircUser->ircOperator().isEmpty()) toolTip.append(QString("%1 %2").arg(nickName()).arg(_ircUser->ircOperator()));
- if (!_ircUser->suserHost().isEmpty()) toolTip.append(_ircUser->suserHost());
- if (!_ircUser->whoisServiceReply().isEmpty()) toolTip.append(_ircUser->whoisServiceReply());
+ tooltip << "</p>";
- toolTip.append(_ircUser->hostmask().remove(0, _ircUser->hostmask().indexOf("!")+1));
+ auto addRow = [&](const QString& key, const QString& value, bool condition = true) {
+ if (condition)
+ {
+ tooltip << "<tr><td class='bold' align='right'>" << key << "</td><td>" << value << "</td></tr>";
+ }
+ };
+
+ tooltip << "<table cellspacing='5' cellpadding='0'>";
+ if (_ircUser->isAway()) {
+ QString awayMessage(tr("(unknown)"));
+ if(!_ircUser->awayMessage().isEmpty()) {
+ awayMessage = _ircUser->awayMessage();
+ }
+ addRow(tr("Away Message"), awayMessage);
+ }
+ 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));
+ addRow(tr("Operator"), _ircUser->ircOperator(), !_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(tr("Idling since"), secondsToString(idleTime));
}
+
if (_ircUser->loginTime().isValid()) {
- toolTip.append(tr("login time: %1").arg(_ircUser->loginTime().toString()));
+ addRow(tr("Login time"), _ircUser->loginTime().toString());
}
- if (!_ircUser->server().isEmpty()) toolTip.append(tr("server: %1").arg(_ircUser->server()));
+ addRow(tr("Server"), _ircUser->server(), !_ircUser->server().isEmpty());
- return QString("<p> %1 </p>").arg(toolTip.join("<br />"));
+ tooltip << "</table></qt>";
+ return strTooltip;
}
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) {
bufferlist << bufferid;
}
- mimeData->setData("application/Quassel/BufferItemList", bufferlist.join(",").toAscii());
+ mimeData->setData("application/Quassel/BufferItemList", bufferlist.join(",").toLatin1());
return mimeData;
}
}
}
else {
- updateBufferActivity(bufferItem(msg.bufferInfo()), msg);
+ if ((BufferSettings(msg.bufferId()).messageFilter() & msg.type()) != msg.type())
+ updateBufferActivity(bufferItem(msg.bufferInfo()), msg);
}
}