modernize: Require member function pointers for Settings::notify()
[quassel.git] / src / qtui / chatmonitorfilter.cpp
index 969d7a3..1229fd4 100644 (file)
@@ -31,15 +31,17 @@ ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent)
 {
     // Global configuration
     ChatViewSettings defaultSettings;
-    _showSenderBrackets = defaultSettings.showSenderBrackets();
-    defaultSettings.notify("ShowSenderBrackets", this, SLOT(showSenderBracketsSettingChanged(const QVariant &)));
+    defaultSettings.initAndNotify("ShowSenderBrackets", this, &ChatMonitorFilter::showSenderBracketsSettingChanged);
+
+    // NOTE: Whenever changing defaults here, also update ChatMonitorSettingsPage::loadSettings()
+    // and ChatMonitorSettingsPage::defaults() to match
 
     // Chat Monitor specific configuration
-    ChatViewSettings viewSettings(idString());
+    ChatViewSettings viewSettings(ChatMonitorFilter::idString());
     _showFields = viewSettings.value("ShowFields", AllFields).toInt();
     _showOwnMessages = viewSettings.value("ShowOwnMsgs", true).toBool();
-    viewSettings.notify("ShowFields", this, SLOT(showFieldsSettingChanged(const QVariant &)));
-    viewSettings.notify("ShowOwnMsgs", this, SLOT(showOwnMessagesSettingChanged(const QVariant &)));
+    viewSettings.notify("ShowFields", this, &ChatMonitorFilter::showFieldsSettingChanged);
+    viewSettings.notify("ShowOwnMsgs", this, &ChatMonitorFilter::showOwnMessagesSettingChanged);
 
     // ChatMonitorSettingsPage
     QString showHighlightsSettingsId = "ShowHighlights";
@@ -47,20 +49,23 @@ ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent)
     QString buffersSettingsId = "Buffers";
     QString showBacklogSettingsId = "ShowBacklog";
     QString includeReadSettingsId = "IncludeRead";
+    QString alwaysOwnSettingsId = "AlwaysOwn";
 
     _showHighlights = viewSettings.value(showHighlightsSettingsId, false).toBool();
-    _operationMode = viewSettings.value(operationModeSettingsId, 0).toInt();
+    _operationMode = viewSettings.value(operationModeSettingsId, ChatViewSettings::InvalidMode).toInt();
     // read configured list of buffers to monitor/ignore
     foreach(QVariant v, viewSettings.value(buffersSettingsId, QVariant()).toList())
-    _bufferIds << v.value<BufferId>();
+        _bufferIds << v.value<BufferId>();
     _showBacklog = viewSettings.value(showBacklogSettingsId, true).toBool();
-    _includeRead = viewSettings.value(includeReadSettingsId, true).toBool();
-
-    viewSettings.notify(showHighlightsSettingsId, this, SLOT(showHighlightsSettingChanged(const QVariant &)));
-    viewSettings.notify(operationModeSettingsId, this, SLOT(operationModeSettingChanged(const QVariant &)));
-    viewSettings.notify(buffersSettingsId, this, SLOT(buffersSettingChanged(const QVariant &)));
-    viewSettings.notify(showBacklogSettingsId, this, SLOT(showBacklogSettingChanged(const QVariant &)));
-    viewSettings.notify(includeReadSettingsId, this, SLOT(includeReadSettingChanged(const QVariant &)));
+    _includeRead = viewSettings.value(includeReadSettingsId, false).toBool();
+    _alwaysOwn = viewSettings.value(alwaysOwnSettingsId, false).toBool();
+
+    viewSettings.notify(showHighlightsSettingsId, this, &ChatMonitorFilter::showHighlightsSettingChanged);
+    viewSettings.notify(operationModeSettingsId, this, &ChatMonitorFilter::operationModeSettingChanged);
+    viewSettings.notify(buffersSettingsId, this, &ChatMonitorFilter::buffersSettingChanged);
+    viewSettings.notify(showBacklogSettingsId, this, &ChatMonitorFilter::showBacklogSettingChanged);
+    viewSettings.notify(includeReadSettingsId, this, &ChatMonitorFilter::includeReadSettingChanged);
+    viewSettings.notify(alwaysOwnSettingsId, this, &ChatMonitorFilter::alwaysOwnSettingChanged);
 }
 
 
@@ -90,6 +95,8 @@ bool ChatMonitorFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourc
     // ChatMonitorSettingsPage
     if (_showHighlights && flags & Message::Highlight)
         ; // pass
+    else if (_alwaysOwn && flags & Message::Self)
+        ; // pass
     else if (_operationMode == ChatViewSettings::OptOut && _bufferIds.contains(bufferId))
         return false;
     else if (_operationMode == ChatViewSettings::OptIn && !_bufferIds.contains(bufferId))
@@ -187,6 +194,9 @@ void ChatMonitorFilter::showOwnMessagesSettingChanged(const QVariant &newValue)
     _showOwnMessages = newValue.toBool();
 }
 
+void ChatMonitorFilter::alwaysOwnSettingChanged(const QVariant &newValue) {
+    _alwaysOwn = newValue.toBool();
+}
 
 void ChatMonitorFilter::showHighlightsSettingChanged(const QVariant &newValue)
 {