#include "ircchannel.h"
#include "ircuser.h"
+#include "buffersettings.h"
+
#include "util.h" // get rid of this (needed for isChannelName)
+// #define PHONDEV
+
/*****************************************
* Fancy Buffer Items
*****************************************/
BufferItem::BufferItem(BufferInfo bufferInfo, AbstractTreeItem *parent)
: PropertyMapItem(QStringList() << "bufferName" << "topic" << "nickCount", parent),
_bufferInfo(bufferInfo),
+ _bufferName(bufferInfo.bufferName()),
_activity(Buffer::NoActivity)
{
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
if(bufferType() == BufferInfo::StatusBuffer)
return tr("Status Buffer");
else
- return bufferInfo().bufferName();
+ return _bufferName;
+}
+
+void BufferItem::setBufferName(const QString &name) {
+ _bufferName = name;
+ // as long as we need those bufferInfos, we have to update that one aswell.
+ // pretty ugly though :/
+ _bufferInfo = BufferInfo(_bufferInfo.bufferId(), _bufferInfo.networkId(), _bufferInfo.type(), _bufferInfo.groupId(), _bufferInfo.bufferName());
+ emit dataChanged(0);
}
QString BufferItem::topic() const {
addUserToCategory(ircUser);
}
+QString BufferItem::toolTip(int column) const {
+ Q_UNUSED(column);
+ QStringList toolTip;
+
+ switch(bufferType()) {
+ case BufferInfo::StatusBuffer: {
+ QString netName = Client::network(bufferInfo().networkId())->networkName();
+ toolTip.append(QString("<b>Status buffer from %1</b>").arg(netName));
+ break;
+ }
+ case BufferInfo::ChannelBuffer:
+ toolTip.append(QString("<h4>Channel %1</h4>").arg(bufferName()));
+ if(isActive()) {
+ //TODO: add channel modes
+ toolTip.append(QString("<b>Users:</b> %1").arg(nickCount()));
+
+ BufferSettings s;
+ bool showTopic = s.value("DisplayTopicInTooltip", QVariant(false)).toBool();
+ if(showTopic) {
+ QString _topic = topic();
+ if(_topic != "") {
+ _topic.replace(QString("<"), QString("<"));
+ _topic.replace(QString(">"), QString(">"));
+ toolTip.append(QString("<font size='-2'> </font>"));
+ toolTip.append(QString("<b>Topic:</b> %1").arg(_topic));
+ }
+ }
+ } else {
+ toolTip.append(QString("Not active <br /> Double-click to join"));
+ }
+ break;
+ case BufferInfo::QueryBuffer:
+ toolTip.append(QString("<b>Query with %1</b>").arg(bufferName()));
+ if(topic() != "") toolTip.append(QString("Away Message: %1").arg(topic()));
+ break;
+ default: //this should not happen
+ toolTip.append(QString("%1 - %2").arg(bufferInfo().bufferId().toInt()).arg(bufferName()));
+ break;
+ }
+
+ return QString("<p> %1 </p>").arg(toolTip.join("<br />"));
+}
+
/*
void BufferItem::setLastMsgInsert(QDateTime msgDate) {
if(msgDate.isValid() && msgDate > _lastMsgInsert)
emit dataChanged(1);
}
+
+QString NetworkItem::toolTip(int column) const {
+ Q_UNUSED(column);
+
+ QStringList toolTip(QString("<b>%1</b>").arg(networkName()));
+ toolTip.append(QString("Server: %1").arg(currentServer()));
+ toolTip.append(QString("Users: %1").arg(nickCount()));
+
+ return QString("<p> %1 </p>").arg(toolTip.join("<br />"));
+}
+
+
/*****************************************
* User Category Items (like @vh etc.)
*****************************************/
connect(ircUser, SIGNAL(nickSet(QString)),
this, SLOT(setNick(QString)));
+ connect(ircUser, SIGNAL(awaySet(bool)),
+ this, SLOT(setAway(bool)));
}
QString IrcUserItem::nickName() const {
emit dataChanged(0);
}
+void IrcUserItem::setAway(bool away) {
+ Q_UNUSED(away);
+ emit dataChanged(0);
+}
+
/*****************************************
* NetworkModel
*****************************************/
emit dataChanged(itemindex, itemindex);
}
+void NetworkModel::removeBuffer(BufferId bufferId) {
+ const int numNetworks = rootItem->childCount();
+ if(numNetworks == 0)
+ return;
+
+ for(int i = 0; i < numNetworks; i++) {
+ if(rootItem->child(i)->removeChildById(qHash(bufferId)))
+ break;
+ }
+}
+
/*
void NetworkModel::updateBufferActivity(const Message &msg) {
BufferItem *buff = bufferItem(msg.bufferInfo());