#include "networkmodel.h"
#include <QAbstractItemView>
+#include <QTextDocument> // 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
}
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<ChannelBufferItem *>(bufferItem);
+ if(_network) {
+ IrcChannel *ircChannel = _network->ircChannel(bufferInfo.bufferName());
+ if(ircChannel)
+ channelBufferItem->attachIrcChannel(ircChannel);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
return bufferItem;
}
_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();
}
QString NetworkItem::toolTip(int column) const {
Q_UNUSED(column);
- QStringList toolTip(QString("<b>%1</b>").arg(networkName()));
- toolTip.append(tr("Server: %1").arg(currentServer()));
+ QStringList toolTip(QString("<b>%1</b>").arg(Qt::escape(networkName())));
+ toolTip.append(tr("Server: %1").arg(Qt::escape(currentServer())));
toolTip.append(tr("Users: %1").arg(nickCount()));
if(_network) {
stateChanged = true;
_firstUnreadMsgId = msg.msgId();
}
-
+
BufferInfo::ActivityLevel oldLevel = activityLevel();
_activity |= BufferInfo::OtherActivity;
{
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;
: 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 {
Q_UNUSED(column);
QStringList toolTip;
- toolTip.append(tr("<b>Channel %1</b>").arg(bufferName()));
+ toolTip.append(tr("<b>Channel %1</b>").arg(Qt::escape(bufferName())));
if(isActive()) {
//TODO: add channel modes
toolTip.append(tr("<b>Users:</b> %1").arg(nickCount()));
toolTip.append(tr("<b>Mode:</b> %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("<font size='-2'> </font>"));
toolTip.append(tr("<b>Topic:</b> %1").arg(_topic));
}
_ircChannel = ircChannel;
connect(ircChannel, SIGNAL(topicSet(QString)),
- this, SLOT(setTopic(QString)));
+ this, SLOT(setTopic(QString)));
connect(ircChannel, SIGNAL(ircUsersJoined(QList<IrcUser *>)),
- this, SLOT(join(QList<IrcUser *>)));
+ this, SLOT(join(QList<IrcUser *>)));
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());
categoryItem = qobject_cast<UserCategoryItem *>(child(i));
if(categoryItem->removeUser(ircUser)) {
if(categoryItem->childCount() == 0)
- removeChild(i);
+ removeChild(i);
break;
}
}
: 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()));
QList<QVariant >NetworkModel::defaultHeader() {
QList<QVariant> data;
- data << tr("Buffer") << tr("Topic") << tr("Nick Count");
+ data << tr("Chat") << tr("Topic") << tr("Nick Count");
return data;
}
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;
if(redirectionTarget & BufferSettings::StatusBuffer) {
const NetworkItem *netItem = findNetworkItem(msg.bufferInfo().networkId());
if(netItem) {
- updateBufferActivity(netItem->statusBufferItem(), msg);
+ updateBufferActivity(netItem->statusBufferItem(), msg);
}
}
} else {