void BufferItem::clearActivityLevel()
{
- _activity = BufferInfo::NoActivity;
+ if (Client::coreFeatures().testFlag(Quassel::Feature::BufferActivitySync)) {
+ // If the core handles activity sync, clear only the highlight flag
+ _activity &= ~BufferInfo::Highlight;
+ } else {
+ _activity = BufferInfo::NoActivity;
+ }
_firstUnreadMsgId = MsgId();
// FIXME remove with core proto v11
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)) {
+ return;
+ }
+
if (isCurrentBuffer()) {
return;
}
_firstUnreadMsgId = msg.msgId();
}
+ Message::Types type;
+ // If the core handles activities, ignore types
+ if (Client::coreFeatures().testFlag(Quassel::Feature::BufferActivitySync)) {
+ type = Message::Types();
+ } else {
+ type = msg.type();
+ }
+
+ if (addActivity(type, msg.flags().testFlag(Message::Highlight)) || stateChanged) {
+ emit dataChanged();
+ }
+}
+
+void BufferItem::setActivity(Message::Types type, bool highlight) {
BufferInfo::ActivityLevel oldLevel = activityLevel();
- _activity |= BufferInfo::OtherActivity;
- if (msg.type() & (Message::Plain | Message::Notice | Message::Action))
+ _activity &= BufferInfo::Highlight;
+ addActivity(type, highlight);
+
+ if (_activity != oldLevel) {
+ emit dataChanged();
+ }
+}
+
+bool BufferItem::addActivity(Message::Types type, bool highlight) {
+ auto oldActivity = activityLevel();
+
+ if (type != Message::Types())
+ _activity |= BufferInfo::OtherActivity;
+
+ if (type.testFlag(Message::Plain) || type.testFlag(Message::Notice) || type.testFlag(Message::Action))
_activity |= BufferInfo::NewMessage;
- if (msg.flags() & Message::Highlight)
+ if (highlight)
_activity |= BufferInfo::Highlight;
- stateChanged |= (oldLevel != _activity);
-
- if (stateChanged)
- emit dataChanged();
+ return oldActivity != _activity;
}
void QueryBufferItem::removeIrcUser()
{
- _ircUser = 0;
- emit dataChanged();
+ if (_ircUser) {
+ // Disconnect the active IrcUser before removing it, otherwise it will fire removeIrcUser()
+ // a second time when the object's destroyed due to QueryBufferItem::setIrcUser() connecting
+ // SIGNAL destroyed(QObject*) to SLOT removeIrcUser().
+ // This fixes removing an active IrcUser if the user had quit then rejoined in a nonstandard
+ // manner (e.g. updateNickFromHost calling newIrcUser, triggered by an away-notify message).
+ disconnect(_ircUser, 0, this, 0);
+
+ // Clear IrcUser (only set to 0 if not already 0)
+ _ircUser = 0;
+
+ // Only emit dataChanged() if data actually changed. This might serve as a small
+ // optimization, but it can be moved outside the if statement if other behavior depends on
+ // it always being called.
+ emit dataChanged();
+ }
}
: BufferItem(bufferInfo, parent),
_ircChannel(0)
{
+ setFlags(flags() | Qt::ItemIsDropEnabled);
}
_serverNoticesTarget = bufferSettings.serverNoticesTarget();
_errorMsgsTarget = bufferSettings.errorMsgsTarget();
}
+
+void NetworkModel::bufferActivityChanged(BufferId bufferId, const Message::Types activity) {
+ auto _bufferItem = findBufferItem(bufferId);
+ if (!_bufferItem) {
+ qDebug() << "NetworkModel::bufferActivityChanged(): buffer is unknown:" << bufferId;
+ return;
+ }
+ auto hiddenTypes = BufferSettings(bufferId).messageFilter();
+ auto visibleTypes = ~hiddenTypes;
+ auto activityVisibleTypesIntersection = activity & visibleTypes;
+ _bufferItem->setActivity(activityVisibleTypesIntersection, false);
+}