X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fchatmonitorsettingspage.cpp;h=22ee3056233af5ad2285328de59d923dba0f254f;hp=bf546b1d0963554f8a0055eca707e13276374d95;hb=c1cf157116de7fc3da96203aa6f03c38c7ebb650;hpb=30b159cb876a9495de42e9a3e70ca050516f0805 diff --git a/src/qtui/settingspages/chatmonitorsettingspage.cpp b/src/qtui/settingspages/chatmonitorsettingspage.cpp index bf546b1d..22ee3056 100644 --- a/src/qtui/settingspages/chatmonitorsettingspage.cpp +++ b/src/qtui/settingspages/chatmonitorsettingspage.cpp @@ -20,18 +20,18 @@ #include "chatmonitorsettingspage.h" -#include "client.h" -#include "icon.h" -#include "networkmodel.h" -#include "bufferviewconfig.h" +#include + #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 - -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 bufferIdsFromConfig; // remove all active buffers from the available config - foreach(QVariant v, settings["Buffers"].toList()) { + foreach (QVariant v, settings["Buffers"].toList()) { bufferIdsFromConfig << v.value(); allBufferIds.removeAll(v.value()); } @@ -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(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 uiBufs = _configActive->bufferList().toSet(); QSet settingsBufs; - foreach(QVariant v, settings["Buffers"].toList()) - settingsBufs << v.value(); + foreach (QVariant v, settings["Buffers"].toList()) + settingsBufs << v.value(); 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 > selectedBuffers; - foreach(QModelIndex index, inView->selectionModel()->selectedIndexes()) { + QMap> selectedBuffers; + foreach (QModelIndex index, inView->selectionModel()->selectedIndexes()) { BufferId inBufferId = index.data(NetworkModel::BufferIdRole).value(); 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(outView->model())->setConfig(nullptr); - qobject_cast(inView->model())->setConfig(nullptr); + qobject_cast(outView->model())->setConfig(nullptr); + qobject_cast(inView->model())->setConfig(nullptr); // actually move the ids - foreach(QList list, selectedBuffers) { - foreach(BufferId buffer, list) { + foreach (QList 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