+void BufferItem::setBufferName(const QString &name) {
+ _bufferInfo = BufferInfo(_bufferInfo.bufferId(), _bufferInfo.networkId(), _bufferInfo.type(), _bufferInfo.groupId(), name);
+ emit dataChanged(0);
+}
+
+QString BufferItem::toolTip(int column) const {
+ Q_UNUSED(column);
+ return tr("<p> %1 - %2 </p>").arg(bufferInfo().bufferId().toInt()).arg(bufferName());
+}
+
+/*
+void BufferItem::setLastMsgInsert(QDateTime msgDate) {
+ if(msgDate.isValid() && msgDate > _lastMsgInsert)
+ _lastMsgInsert = msgDate;
+}
+*/
+/*
+// FIXME emit dataChanged()
+bool BufferItem::setLastSeen() {
+ if(_lastSeen > _lastMsgInsert)
+ return false;
+
+ _lastSeen = _lastMsgInsert;
+ BufferSettings(bufferInfo().bufferId()).setLastSeen(_lastSeen);
+ return true;
+}
+
+QDateTime BufferItem::lastSeen() {
+ return _lastSeen;
+}
+*/
+
+/*****************************************
+* StatusBufferItem
+*****************************************/
+StatusBufferItem::StatusBufferItem(const BufferInfo &bufferInfo, NetworkItem *parent)
+ : BufferItem(bufferInfo, parent)
+{
+ Q_ASSERT(parent);
+ connect(parent, SIGNAL(dataChanged()), this, SIGNAL(dataChanged()));
+}
+
+QString StatusBufferItem::toolTip(int column) const {
+ Q_UNUSED(column);
+ QStringList toolTip;
+
+ QString netName = Client::network(bufferInfo().networkId())->networkName();
+ toolTip.append(tr("<b>Status buffer of %1</b>").arg(netName));
+
+ return tr("<p> %1 </p>").arg(toolTip.join("<br />"));
+}
+
+/*****************************************
+* QueryBufferItem
+*****************************************/
+QueryBufferItem::QueryBufferItem(const BufferInfo &bufferInfo, NetworkItem *parent)
+ : BufferItem(bufferInfo, parent),
+ _ircUser(0)
+{
+ setFlags(flags() | Qt::ItemIsDropEnabled);
+
+ const Network *net = Client::network(bufferInfo.networkId());
+ if(!net)
+ return;
+
+ IrcUser *ircUser = net->ircUser(bufferInfo.bufferName());
+ if(ircUser)
+ attachIrcUser(ircUser);
+
+}
+
+bool QueryBufferItem::isActive() const {
+ if(_ircUser)
+ return !_ircUser->isAway();
+ else
+ return false;
+}
+
+QString QueryBufferItem::toolTip(int column) const {
+ // pretty much code duplication of IrcUserItem::toolTip() but inheritance won't solve this...
+ Q_UNUSED(column);
+ QStringList toolTip;
+
+ toolTip.append(tr("<b>Query with %1</b>").arg(bufferName()));
+
+ if(_ircUser) {
+ if(_ircUser->userModes() != "") toolTip[0].append(QString(" (%1)").arg(_ircUser->userModes()));
+ if(_ircUser->isAway()) {
+ toolTip[0].append(QString(" (away%1)").arg(!_ircUser->awayMessage().isEmpty() ? (QString(" ") + _ircUser->awayMessage()) : QString()));
+ }
+ 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));
+
+ 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)));
+ }
+ if(_ircUser->loginTime().isValid()) {
+ toolTip.append(tr("login time: %1").arg(_ircUser->loginTime().toString()));
+ }
+
+ if(!_ircUser->server().isEmpty()) toolTip.append(tr("server: %1").arg(_ircUser->server()));
+ }
+
+ return QString("<p> %1 </p>").arg(toolTip.join("<br />"));
+}
+
+void QueryBufferItem::attachIrcUser(IrcUser *ircUser) {
+ _ircUser = ircUser;
+ connect(_ircUser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed()));
+ connect(_ircUser, SIGNAL(awaySet(bool)), this, SIGNAL(dataChanged()));
+ emit dataChanged();
+}
+
+void QueryBufferItem::ircUserDestroyed() {
+ _ircUser = 0;
+ emit dataChanged();
+}