/***************************************************************************
- * Copyright (C) 2005-2016 by the Quassel Project *
+ * Copyright (C) 2005-2019 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#include "ircchannel.h"
#include "network.h"
#include "signalproxy.h"
+#include "buffersyncer.h"
/*****************************************
* Network Items
*****************************************/
NetworkItem::NetworkItem(const NetworkId &netid, AbstractTreeItem *parent)
- : PropertyMapItem(QList<QString>() << "networkName" << "currentServer" << "nickCount", parent),
+ : PropertyMapItem(parent),
_networkId(netid),
_statusBufferItem(0)
{
}
+QStringList NetworkItem::propertyOrder() const
+{
+ static auto order = QStringList() << "networkName" << "currentServer" << "nickCount";
+ return order;
+}
+
+
QVariant NetworkItem::data(int column, int role) const
{
switch (role) {
break;
}
+ BufferSyncer *bufferSyncer = Client::bufferSyncer();
+ if (bufferSyncer) {
+ bufferItem->addActivity(
+ bufferSyncer->activity(bufferItem->bufferId()),
+ bufferSyncer->highlightCount(bufferItem->bufferId()) > 0
+ );
+ }
+
return bufferItem;
}
* Fancy Buffer Items
*****************************************/
BufferItem::BufferItem(const BufferInfo &bufferInfo, AbstractTreeItem *parent)
- : PropertyMapItem(QStringList() << "bufferName" << "topic" << "nickCount", parent),
+ : PropertyMapItem(parent),
_bufferInfo(bufferInfo),
_activity(BufferInfo::NoActivity)
{
}
+QStringList BufferItem::propertyOrder() const
+{
+ static auto order = QStringList() << "bufferName" << "topic" << "nickCount";
+ return order;
+}
+
+
void BufferItem::setActivityLevel(BufferInfo::ActivityLevel level)
{
if (_activity != level) {
void BufferItem::clearActivityLevel()
{
- if (Client::coreFeatures().testFlag(Quassel::Feature::BufferActivitySync)) {
+ if (Client::isCoreFeatureEnabled(Quassel::Feature::BufferActivitySync)) {
// If the core handles activity sync, clear only the highlight flag
_activity &= ~BufferInfo::Highlight;
} else {
_firstUnreadMsgId = MsgId();
// FIXME remove with core proto v11
- if (!(Client::coreFeatures() & Quassel::SynchronizedMarkerLine)) {
+ if (!Client::isCoreFeatureEnabled(Quassel::Feature::SynchronizedMarkerLine)) {
_markerLineMsgId = _lastSeenMsgId;
}
void BufferItem::updateActivityLevel(const Message &msg)
{
// If the core handles activity, and this message is not a highlight, ignore this
- if (Client::coreFeatures().testFlag(Quassel::Feature::BufferActivitySync) && !msg.flags().testFlag(Message::Highlight)) {
+ if (Client::isCoreFeatureEnabled(Quassel::Feature::BufferActivitySync) && !msg.flags().testFlag(Message::Highlight)) {
return;
}
Message::Types type;
// If the core handles activities, ignore types
- if (!Client::coreFeatures().testFlag(Quassel::Feature::BufferActivitySync)) {
+ if (Client::isCoreFeatureEnabled(Quassel::Feature::BufferActivitySync)) {
type = Message::Types();
} else {
type = msg.type();
bool BufferItem::addActivity(Message::Types type, bool highlight) {
auto oldActivity = activityLevel();
- if (type != 0)
+ if (type != Message::Types())
_activity |= BufferInfo::OtherActivity;
if (type.testFlag(Message::Plain) || type.testFlag(Message::Notice) || type.testFlag(Message::Action))
default:
return PropertyMapItem::setData(column, value, role);
}
- return true;
}
_lastSeenMsgId = msgId;
// FIXME remove with core protocol v11
- if (!(Client::coreFeatures() & Quassel::SynchronizedMarkerLine)) {
+ if (!Client::isCoreFeatureEnabled(Quassel::Feature::SynchronizedMarkerLine)) {
if (!isCurrentBuffer())
_markerLineMsgId = msgId;
}
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;
+ // Not used further down...
+ // accountAdded = true;
} else {
addRow(NetworkItem::escapeHTML(tr("Service Reply"), true),
NetworkItem::escapeHTML(_ircUser->whoisServiceReply()),
const QList<QChar> UserCategoryItem::categories = QList<QChar>() << 'q' << 'a' << 'o' << 'h' << 'v';
UserCategoryItem::UserCategoryItem(int category, AbstractTreeItem *parent)
- : PropertyMapItem(QStringList() << "categoryName", parent),
+ : PropertyMapItem(parent),
_category(category)
{
setFlags(Qt::ItemIsEnabled);
}
+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
{
* Irc User Items
*****************************************/
IrcUserItem::IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent)
- : PropertyMapItem(QStringList() << "nickName", parent),
+ : PropertyMapItem(parent),
_ircUser(ircUser)
{
setObjectName(ircUser->nick());
}
+QStringList IrcUserItem::propertyOrder() const
+{
+ static QStringList order{"nickName"};
+ return order;
+}
+
+
QVariant IrcUserItem::data(int column, int role) const
{
switch (role) {
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;
+ // Not used further down...
+ // accountAdded = true;
} else {
addRow(NetworkItem::escapeHTML(tr("Service Reply"), true),
NetworkItem::escapeHTML(_ircUser->whoisServiceReply()),
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);
+}