0001-Add-option-for-chat-monitor-to-look-in-the-backlog.patch
| src/qtui/chatmonitorfilter.cpp | ||
|---|---|---|
| 39 | 39 |
QString showHighlightsSettingsId = "ShowHighlights"; |
| 40 | 40 |
QString operationModeSettingsId = "OperationMode"; |
| 41 | 41 |
QString buffersSettingsId = "Buffers"; |
| 42 |
QString showBacklogSettingsId = "ShowBacklog"; |
|
| 42 | 43 | |
| 43 | 44 |
_showHighlights = viewSettings.value(showHighlightsSettingsId, false).toBool(); |
| 44 | 45 |
_operationMode = viewSettings.value(operationModeSettingsId, 0).toInt(); |
| 45 | 46 |
// read configured list of buffers to monitor/ignore |
| 46 | 47 |
foreach(QVariant v, viewSettings.value(buffersSettingsId, QVariant()).toList()) |
| 47 | 48 |
_bufferIds << v.value<BufferId>(); |
| 49 |
_showBacklog = viewSettings.value(showBacklogSettingsId, true).toBool(); |
|
| 48 | 50 | |
| 49 | 51 |
viewSettings.notify(showHighlightsSettingsId, this, SLOT(showHighlightsSettingChanged(const QVariant &))); |
| 50 | 52 |
viewSettings.notify(operationModeSettingsId, this, SLOT(operationModeSettingChanged(const QVariant &))); |
| 51 | 53 |
viewSettings.notify(buffersSettingsId, this, SLOT(buffersSettingChanged(const QVariant &))); |
| 54 |
viewSettings.notify(showBacklogSettingsId, this, SLOT(showBacklogSettingChanged(const QVariant &))); |
|
| 52 | 55 |
} |
| 53 | 56 | |
| 54 | 57 |
bool ChatMonitorFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
|
| 55 | 58 |
Q_UNUSED(sourceParent) |
| 56 | 59 | |
| 57 | 60 |
QModelIndex source_index = sourceModel()->index(sourceRow, 0); |
| 61 |
BufferId bufferId = source_index.data(MessageModel::BufferIdRole).value<BufferId>(); |
|
| 58 | 62 | |
| 59 | 63 |
Message::Flags flags = (Message::Flags)source_index.data(MessageModel::FlagsRole).toInt(); |
| 60 |
if(flags & Message::Backlog || (!_showOwnMessages && flags & Message::Self)) |
|
| 64 |
if ((flags & Message::Backlog) && (!_showBacklog || |
|
| 65 |
(Client::networkModel()->lastSeenMsgId(bufferId) >= sourceModel()->data(source_index, MessageModel::MsgIdRole).value<MsgId>()))) |
|
| 66 |
return false; |
|
| 67 | ||
| 68 |
if (!_showOwnMessages && flags & Message::Self) |
|
| 61 | 69 |
return false; |
| 62 | 70 | |
| 63 | 71 |
Message::Type type = (Message::Type)source_index.data(MessageModel::TypeRole).toInt(); |
| 64 | 72 |
if(!(type & (Message::Plain | Message::Notice | Message::Action))) |
| 65 | 73 |
return false; |
| 66 | 74 | |
| 67 |
BufferId bufferId = source_index.data(MessageModel::BufferIdRole).value<BufferId>(); |
|
| 68 | ||
| 69 | 75 |
// ChatMonitorSettingsPage |
| 70 | 76 |
if(_operationMode == ChatViewSettings::OptOut |
| 71 | 77 |
&& !(_showHighlights && flags & Message::Highlight) |
| ... | ... | |
| 167 | 173 |
} |
| 168 | 174 |
invalidateFilter(); |
| 169 | 175 |
} |
| 176 | ||
| 177 |
void ChatMonitorFilter::showBacklogSettingChanged(const QVariant &newValue) {
|
|
| 178 |
_showBacklog = newValue.toBool(); |
|
| 179 |
} |
|
| src/qtui/chatmonitorfilter.h | ||
|---|---|---|
| 57 | 57 |
void showHighlightsSettingChanged(const QVariant &newValue); |
| 58 | 58 |
void operationModeSettingChanged(const QVariant &newValue); |
| 59 | 59 |
void buffersSettingChanged(const QVariant &newValue); |
| 60 |
void showBacklogSettingChanged(const QVariant &newValue); |
|
| 60 | 61 | |
| 61 | 62 |
private: |
| 62 | 63 |
int _showFields; |
| ... | ... | |
| 64 | 65 |
QList<BufferId> _bufferIds; |
| 65 | 66 |
bool _showHighlights; |
| 66 | 67 |
int _operationMode; |
| 68 |
bool _showBacklog; |
|
| 67 | 69 |
}; |
| 68 | 70 | |
| 69 | 71 |
#endif |
| src/qtui/settingspages/chatmonitorsettingspage.cpp | ||
|---|---|---|
| 62 | 62 |
connect(ui.operationMode, SIGNAL(currentIndexChanged(int)), SLOT(switchOperationMode(int))); |
| 63 | 63 |
connect(ui.showHighlights, SIGNAL(toggled(bool)), SLOT(widgetHasChanged())); |
| 64 | 64 |
connect(ui.showOwnMessages, SIGNAL(toggled(bool)), SLOT(widgetHasChanged())); |
| 65 |
connect(ui.showBacklog, SIGNAL(toggled(bool)), SLOT(widgetHasChanged())); |
|
| 65 | 66 |
} |
| 66 | 67 | |
| 67 | 68 |
bool ChatMonitorSettingsPage::hasDefaults() const {
|
| ... | ... | |
| 74 | 75 |
settings["ShowOwnMsgs"] = false; |
| 75 | 76 |
settings["Buffers"] = QVariant(); |
| 76 | 77 |
settings["Default"] = true; |
| 78 |
settings["ShowBacklog"] = true; |
|
| 77 | 79 |
load(); |
| 78 | 80 |
widgetHasChanged(); |
| 79 | 81 |
} |
| ... | ... | |
| 88 | 90 |
ui.operationMode->setCurrentIndex(settings["OperationMode"].toInt() - 1); |
| 89 | 91 |
ui.showHighlights->setChecked(settings["ShowHighlights"].toBool()); |
| 90 | 92 |
ui.showOwnMessages->setChecked(settings["ShowOwnMsgs"].toBool()); |
| 93 |
ui.showBacklog->setChecked(settings["ShowBacklog"].toBool()); |
|
| 91 | 94 | |
| 92 | 95 |
// get all available buffer Ids |
| 93 | 96 |
QList<BufferId> allBufferIds = Client::networkModel()->allBufferIds(); |
| ... | ... | |
| 118 | 121 |
settings["ShowHighlights"] = chatViewSettings.value("ShowHighlights", false);
|
| 119 | 122 |
settings["ShowOwnMsgs"] = chatViewSettings.value("ShowOwnMsgs", false);
|
| 120 | 123 |
settings["Buffers"] = chatViewSettings.value("Buffers", QVariantList());
|
| 124 |
settings["ShowBacklog"] = chatViewSettings.value("ShowBacklog", true);
|
|
| 121 | 125 |
} |
| 122 | 126 | |
| 123 | 127 |
void ChatMonitorSettingsPage::save() {
|
| ... | ... | |
| 126 | 130 |
chatViewSettings.setValue("OperationMode", ui.operationMode->currentIndex() + 1);
|
| 127 | 131 |
chatViewSettings.setValue("ShowHighlights", ui.showHighlights->isChecked());
|
| 128 | 132 |
chatViewSettings.setValue("ShowOwnMsgs", ui.showOwnMessages->isChecked());
|
| 133 |
chatViewSettings.setValue("ShowBacklog", ui.showBacklog->isChecked());
|
|
| 129 | 134 | |
| 130 | 135 |
// save list of active buffers |
| 131 | 136 |
QVariantList saveableBufferIdList; |
| ... | ... | |
| 150 | 155 |
return true; |
| 151 | 156 |
if(settings["ShowOwnMsgs"].toBool() != ui.showOwnMessages->isChecked()) |
| 152 | 157 |
return true; |
| 158 |
if(settings["ShowBacklog"].toBool() != ui.showBacklog->isChecked()) |
|
| 159 |
return true; |
|
| 153 | 160 | |
| 154 | 161 |
if(_configActive->bufferList().count() != settings["Buffers"].toList().count()) |
| 155 | 162 |
return true; |
| src/qtui/settingspages/chatmonitorsettingspage.ui | ||
|---|---|---|
| 158 | 158 |
</property> |
| 159 | 159 |
</widget> |
| 160 | 160 |
</item> |
| 161 |
<item> |
|
| 162 |
<widget class="QCheckBox" name="showBacklog"> |
|
| 163 |
<property name="toolTip"> |
|
| 164 |
<string>Display messages from backlog on reconnect</string> |
|
| 165 |
</property> |
|
| 166 |
<property name="text"> |
|
| 167 |
<string>Show messages from backlog</string> |
|
| 168 |
</property> |
|
| 169 |
</widget> |
|
| 170 |
</item> |
|
| 161 | 171 |
</layout> |
| 162 | 172 |
</widget> |
| 163 | 173 |
<customwidgets> |
| 164 |
- |
|