modernize: Reformat ALL the source... again!
[quassel.git] / src / qtui / settingspages / chatmonitorsettingspage.cpp
index bf546b1..22ee305 100644 (file)
 
 #include "chatmonitorsettingspage.h"
 
-#include "client.h"
-#include "icon.h"
-#include "networkmodel.h"
-#include "bufferviewconfig.h"
+#include <QVariant>
+
 #include "buffermodel.h"
 #include "bufferview.h"
+#include "bufferviewconfig.h"
 #include "bufferviewfilter.h"
 #include "chatviewsettings.h"
+#include "client.h"
+#include "icon.h"
+#include "networkmodel.h"
 
-#include <QVariant>
-
-ChatMonitorSettingsPage::ChatMonitorSettingsPage(QWidget *parent)
+ChatMonitorSettingsPage::ChatMonitorSettingsPage(QWidget* parent)
     : SettingsPage(tr("Interface"), tr("Chat Monitor"), parent)
 {
     ui.setupUi(this);
@@ -68,13 +68,11 @@ ChatMonitorSettingsPage::ChatMonitorSettingsPage(QWidget *parent)
     connect(ui.includeRead, &QAbstractButton::toggled, this, &ChatMonitorSettingsPage::widgetHasChanged);
 }
 
-
 bool ChatMonitorSettingsPage::hasDefaults() const
 {
     return true;
 }
 
-
 void ChatMonitorSettingsPage::defaults()
 {
     // NOTE: Whenever changing defaults here, also update ChatMonitorFilter::ChatMonitorFilter()
@@ -92,7 +90,6 @@ void ChatMonitorSettingsPage::defaults()
     widgetHasChanged();
 }
 
-
 void ChatMonitorSettingsPage::load()
 {
     if (settings.contains("Default"))
@@ -114,7 +111,7 @@ void ChatMonitorSettingsPage::load()
     if (!settings["Buffers"].toList().isEmpty()) {
         QList<BufferId> bufferIdsFromConfig;
         // remove all active buffers from the available config
-        foreach(QVariant v, settings["Buffers"].toList()) {
+        foreach (QVariant v, settings["Buffers"].toList()) {
             bufferIdsFromConfig << v.value<BufferId>();
             allBufferIds.removeAll(v.value<BufferId>());
         }
@@ -130,15 +127,13 @@ void ChatMonitorSettingsPage::load()
     setChangedState(false);
 }
 
-
 void ChatMonitorSettingsPage::loadSettings()
 {
     // NOTE: Whenever changing defaults here, also update ChatMonitorFilter::ChatMonitorFilter()
     // and ChatMonitorSettingsPage::defaults() to match
     ChatViewSettings chatViewSettings("ChatMonitor");
 
-    settings["OperationMode"] = (ChatViewSettings::OperationMode)
-            chatViewSettings.value("OperationMode", ChatViewSettings::OptOut).toInt();
+    settings["OperationMode"] = (ChatViewSettings::OperationMode)chatViewSettings.value("OperationMode", ChatViewSettings::OptOut).toInt();
     settings["ShowHighlights"] = chatViewSettings.value("ShowHighlights", false);
     settings["ShowOwnMsgs"] = chatViewSettings.value("ShowOwnMsgs", true);
     settings["AlwaysOwn"] = chatViewSettings.value("AlwaysOwn", false);
@@ -147,7 +142,6 @@ void ChatMonitorSettingsPage::loadSettings()
     settings["IncludeRead"] = chatViewSettings.value("IncludeRead", false);
 }
 
-
 void ChatMonitorSettingsPage::save()
 {
     ChatViewSettings chatViewSettings("ChatMonitor");
@@ -161,7 +155,7 @@ void ChatMonitorSettingsPage::save()
 
     // save list of active buffers
     QVariantList saveableBufferIdList;
-    foreach(BufferId id, _configActive->bufferList()) {
+    foreach (BufferId id, _configActive->bufferList()) {
         saveableBufferIdList << QVariant::fromValue<BufferId>(id);
     }
 
@@ -170,14 +164,13 @@ void ChatMonitorSettingsPage::save()
     setChangedState(false);
 }
 
-
 void ChatMonitorSettingsPage::widgetHasChanged()
 {
     bool changed = testHasChanged();
-    if (changed != hasChanged()) setChangedState(changed);
+    if (changed != hasChanged())
+        setChangedState(changed);
 }
 
-
 bool ChatMonitorSettingsPage::testHasChanged()
 {
     if (settings["OperationMode"].toInt() != ui.operationMode->currentIndex() + 1)
@@ -198,27 +191,26 @@ bool ChatMonitorSettingsPage::testHasChanged()
 
     QSet<BufferId> uiBufs = _configActive->bufferList().toSet();
     QSet<BufferId> settingsBufs;
-    foreach(QVariant v, settings["Buffers"].toList())
-    settingsBufs << v.value<BufferId>();
+    foreach (QVariant v, settings["Buffers"].toList())
+        settingsBufs << v.value<BufferId>();
     if (uiBufs != settingsBufs)
         return true;
 
     return false;
 }
 
-
-//TODO: - support drag 'n drop
+// TODO: - support drag 'n drop
 //      - adding of complete networks(?)
 
 /*
   toggleBuffers takes each a bufferView and its config for "input" and "output".
   Any selected item will be moved over from the input to the output bufferview.
 */
-void ChatMonitorSettingsPage::toggleBuffers(BufferView *inView, BufferViewConfig *inCfg, BufferView *outView, BufferViewConfig *outCfg)
+void ChatMonitorSettingsPage::toggleBuffers(BufferView* inView, BufferViewConfig* inCfg, BufferView* outView, BufferViewConfig* outCfg)
 {
     // Fill QMap with selected items ordered by selection row
-    QMap<int, QList<BufferId> > selectedBuffers;
-    foreach(QModelIndex index, inView->selectionModel()->selectedIndexes()) {
+    QMap<int, QList<BufferId>> selectedBuffers;
+    foreach (QModelIndex index, inView->selectionModel()->selectedIndexes()) {
         BufferId inBufferId = index.data(NetworkModel::BufferIdRole).value<BufferId>();
         if (index.data(NetworkModel::ItemTypeRole) == NetworkModel::NetworkItemType) {
             // TODO:
@@ -238,12 +230,12 @@ void ChatMonitorSettingsPage::toggleBuffers(BufferView *inView, BufferViewConfig
       This can probably be removed whenever BufferViewConfig::bulkAdd or something
       like that is available.
     */
-    qobject_cast<BufferViewFilter *>(outView->model())->setConfig(nullptr);
-    qobject_cast<BufferViewFilter *>(inView->model())->setConfig(nullptr);
+    qobject_cast<BufferViewFilter*>(outView->model())->setConfig(nullptr);
+    qobject_cast<BufferViewFilter*>(inView->model())->setConfig(nullptr);
 
     // actually move the ids
-    foreach(QList<BufferId> list, selectedBuffers) {
-        foreach(BufferId buffer, list) {
+    foreach (QList<BufferId> list, selectedBuffers) {
+        foreach (BufferId buffer, list) {
             outCfg->addBuffer(buffer, 0);
             inCfg->removeBuffer(buffer);
         }
@@ -255,7 +247,6 @@ void ChatMonitorSettingsPage::toggleBuffers(BufferView *inView, BufferViewConfig
     widgetHasChanged();
 }
 
-
 void ChatMonitorSettingsPage::on_activateBuffer_clicked()
 {
     if (ui.availableBuffers->currentIndex().isValid() && ui.availableBuffers->selectionModel()->hasSelection()) {
@@ -264,7 +255,6 @@ void ChatMonitorSettingsPage::on_activateBuffer_clicked()
     }
 }
 
-
 void ChatMonitorSettingsPage::on_deactivateBuffer_clicked()
 {
     if (ui.activeBuffers->currentIndex().isValid() && ui.activeBuffers->selectionModel()->hasSelection()) {
@@ -273,7 +263,6 @@ void ChatMonitorSettingsPage::on_deactivateBuffer_clicked()
     }
 }
 
-
 /*
   switchOperationMode gets called on combobox signal currentIndexChanged.
   modeIndex is the row id in combobox itemlist