#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);
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()
widgetHasChanged();
}
-
void ChatMonitorSettingsPage::load()
{
if (settings.contains("Default"))
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>());
}
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);
settings["IncludeRead"] = chatViewSettings.value("IncludeRead", false);
}
-
void ChatMonitorSettingsPage::save()
{
ChatViewSettings chatViewSettings("ChatMonitor");
// save list of active buffers
QVariantList saveableBufferIdList;
- foreach(BufferId id, _configActive->bufferList()) {
+ foreach (BufferId id, _configActive->bufferList()) {
saveableBufferIdList << QVariant::fromValue<BufferId>(id);
}
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)
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:
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);
}
widgetHasChanged();
}
-
void ChatMonitorSettingsPage::on_activateBuffer_clicked()
{
if (ui.availableBuffers->currentIndex().isValid() && ui.availableBuffers->selectionModel()->hasSelection()) {
}
}
-
void ChatMonitorSettingsPage::on_deactivateBuffer_clicked()
{
if (ui.activeBuffers->currentIndex().isValid() && ui.activeBuffers->selectionModel()->hasSelection()) {
}
}
-
/*
switchOperationMode gets called on combobox signal currentIndexChanged.
modeIndex is the row id in combobox itemlist