From a4cba7a7497d8b71942d5f5e81ef3c04f5c6bad5 Mon Sep 17 00:00:00 2001 From: Adam Harwood Date: Sat, 21 Dec 2013 17:31:13 +0000 Subject: [PATCH] Add option to include read messages in chat monitor When the show backlog option is used, give users the option to include previously read messages. --- src/qtui/chatmonitorfilter.cpp | 11 ++++- src/qtui/chatmonitorfilter.h | 2 + .../settingspages/chatmonitorsettingspage.cpp | 9 ++++ .../settingspages/chatmonitorsettingspage.ui | 41 ++++++++++++++++++- 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/qtui/chatmonitorfilter.cpp b/src/qtui/chatmonitorfilter.cpp index 85272178..db0c8892 100644 --- a/src/qtui/chatmonitorfilter.cpp +++ b/src/qtui/chatmonitorfilter.cpp @@ -40,6 +40,7 @@ ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent) QString operationModeSettingsId = "OperationMode"; QString buffersSettingsId = "Buffers"; QString showBacklogSettingsId = "ShowBacklog"; + QString includeReadSettingsId = "IncludeRead"; _showHighlights = viewSettings.value(showHighlightsSettingsId, false).toBool(); _operationMode = viewSettings.value(operationModeSettingsId, 0).toInt(); @@ -47,11 +48,13 @@ ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent) foreach(QVariant v, viewSettings.value(buffersSettingsId, QVariant()).toList()) _bufferIds << v.value(); _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 &))); } @@ -63,8 +66,8 @@ bool ChatMonitorFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourc BufferId bufferId = source_index.data(MessageModel::BufferIdRole).value(); Message::Flags flags = (Message::Flags)source_index.data(MessageModel::FlagsRole).toInt(); - if ((flags & Message::Backlog) && (!_showBacklog || - (Client::networkModel()->lastSeenMsgId(bufferId) >= sourceModel()->data(source_index, MessageModel::MsgIdRole).value()))) + if ((flags & Message::Backlog) && (!_showBacklog || (!_includeRead && + (Client::networkModel()->lastSeenMsgId(bufferId) >= sourceModel()->data(source_index, MessageModel::MsgIdRole).value())))) return false; if (!_showOwnMessages && flags & Message::Self) @@ -197,3 +200,7 @@ void ChatMonitorFilter::buffersSettingChanged(const QVariant &newValue) void ChatMonitorFilter::showBacklogSettingChanged(const QVariant &newValue) { _showBacklog = newValue.toBool(); } + +void ChatMonitorFilter::includeReadSettingChanged(const QVariant &newValue) { + _includeRead = newValue.toBool(); +} diff --git a/src/qtui/chatmonitorfilter.h b/src/qtui/chatmonitorfilter.h index f6d8a944..945e4018 100644 --- a/src/qtui/chatmonitorfilter.h +++ b/src/qtui/chatmonitorfilter.h @@ -59,6 +59,7 @@ private slots: void operationModeSettingChanged(const QVariant &newValue); void buffersSettingChanged(const QVariant &newValue); void showBacklogSettingChanged(const QVariant &newValue); + void includeReadSettingChanged(const QVariant &newValue); private: int _showFields; @@ -67,6 +68,7 @@ private: bool _showHighlights; int _operationMode; bool _showBacklog; + bool _includeRead; }; diff --git a/src/qtui/settingspages/chatmonitorsettingspage.cpp b/src/qtui/settingspages/chatmonitorsettingspage.cpp index 34f8cb94..535c987c 100644 --- a/src/qtui/settingspages/chatmonitorsettingspage.cpp +++ b/src/qtui/settingspages/chatmonitorsettingspage.cpp @@ -64,6 +64,7 @@ ChatMonitorSettingsPage::ChatMonitorSettingsPage(QWidget *parent) connect(ui.showHighlights, SIGNAL(toggled(bool)), SLOT(widgetHasChanged())); connect(ui.showOwnMessages, SIGNAL(toggled(bool)), SLOT(widgetHasChanged())); connect(ui.showBacklog, SIGNAL(toggled(bool)), SLOT(widgetHasChanged())); + connect(ui.includeRead, SIGNAL(toggled(bool)), SLOT(widgetHasChanged())); } @@ -81,6 +82,7 @@ void ChatMonitorSettingsPage::defaults() settings["Buffers"] = QVariant(); settings["Default"] = true; settings["ShowBacklog"] = true; + settings["IncludeRead"] = false; load(); widgetHasChanged(); } @@ -98,6 +100,7 @@ void ChatMonitorSettingsPage::load() ui.showHighlights->setChecked(settings["ShowHighlights"].toBool()); ui.showOwnMessages->setChecked(settings["ShowOwnMsgs"].toBool()); ui.showBacklog->setChecked(settings["ShowBacklog"].toBool()); + ui.includeRead->setChecked(settings["IncludeRead"].toBool()); // get all available buffer Ids QList allBufferIds = Client::networkModel()->allBufferIds(); @@ -131,6 +134,7 @@ void ChatMonitorSettingsPage::loadSettings() settings["ShowOwnMsgs"] = chatViewSettings.value("ShowOwnMsgs", false); settings["Buffers"] = chatViewSettings.value("Buffers", QVariantList()); settings["ShowBacklog"] = chatViewSettings.value("ShowBacklog", true); + settings["IncludeRead"] = chatViewSettings.value("IncludeRead", true); } @@ -142,6 +146,7 @@ void ChatMonitorSettingsPage::save() chatViewSettings.setValue("ShowHighlights", ui.showHighlights->isChecked()); chatViewSettings.setValue("ShowOwnMsgs", ui.showOwnMessages->isChecked()); chatViewSettings.setValue("ShowBacklog", ui.showBacklog->isChecked()); + chatViewSettings.setValue("IncludeRead", ui.includeRead->isChecked()); // save list of active buffers QVariantList saveableBufferIdList; @@ -170,6 +175,10 @@ bool ChatMonitorSettingsPage::testHasChanged() return true; if (settings["ShowOwnMsgs"].toBool() != ui.showOwnMessages->isChecked()) return true; + if (settings["ShowBacklog"].toBool() != ui.showBacklog->isChecked()) + return true; + if (settings["IncludeRead"].toBool() != ui.includeRead->isChecked()) + return true; if (_configActive->bufferList().count() != settings["Buffers"].toList().count()) return true; diff --git a/src/qtui/settingspages/chatmonitorsettingspage.ui b/src/qtui/settingspages/chatmonitorsettingspage.ui index e630926a..2a986057 100644 --- a/src/qtui/settingspages/chatmonitorsettingspage.ui +++ b/src/qtui/settingspages/chatmonitorsettingspage.ui @@ -168,6 +168,36 @@ p, li { white-space: pre-wrap; } + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 16 + + + + + + + + Include read messages from backlog on reconnect + + + Include read messages + + + + + @@ -185,7 +215,16 @@ p, li { white-space: pre-wrap; } activeBuffers showHighlights showOwnMessages + showBacklog + includeRead - + + + showBacklog + toggled(bool) + includeRead + setEnabled(bool) + + -- 2.20.1