Make show msgs unread only persistent across RSS Guard app startups.
This commit is contained in:
parent
daad0760e1
commit
8bc36ccbd2
7 changed files with 47 additions and 22 deletions
|
@ -37,6 +37,11 @@ void MessagesModel::setupIcons() {
|
||||||
m_enclosuresIcon = qApp->icons()->fromTheme(QSL("mail-attachment"));
|
m_enclosuresIcon = qApp->icons()->fromTheme(QSL("mail-attachment"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessagesModelCache* MessagesModel::cache() const
|
||||||
|
{
|
||||||
|
return m_cache;
|
||||||
|
}
|
||||||
|
|
||||||
void MessagesModel::repopulate() {
|
void MessagesModel::repopulate() {
|
||||||
m_cache->clear();
|
m_cache->clear();
|
||||||
setQuery(selectStatement(), m_db);
|
setQuery(selectStatement(), m_db);
|
||||||
|
|
|
@ -49,6 +49,7 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
||||||
RootItem::Importance messageImportance(int row_index) const;
|
RootItem::Importance messageImportance(int row_index) const;
|
||||||
|
|
||||||
RootItem* loadedItem() const;
|
RootItem* loadedItem() const;
|
||||||
|
MessagesModelCache* cache() const;
|
||||||
|
|
||||||
void setupFonts();
|
void setupFonts();
|
||||||
void updateDateFormat();
|
void updateDateFormat();
|
||||||
|
|
|
@ -17,24 +17,27 @@ class MessagesModelCache : public QObject {
|
||||||
explicit MessagesModelCache(QObject* parent = nullptr);
|
explicit MessagesModelCache(QObject* parent = nullptr);
|
||||||
virtual ~MessagesModelCache() = default;
|
virtual ~MessagesModelCache() = default;
|
||||||
|
|
||||||
inline bool containsData(int row_idx) const {
|
bool containsData(int row_idx) const;
|
||||||
return m_msgCache.contains(row_idx);
|
QSqlRecord record(int row_idx) const;
|
||||||
}
|
|
||||||
|
|
||||||
inline QSqlRecord record(int row_idx) const {
|
|
||||||
return m_msgCache.value(row_idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void clear() {
|
|
||||||
m_msgCache.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setData(const QModelIndex& index, const QVariant& value, const QSqlRecord& record);
|
|
||||||
|
|
||||||
QVariant data(const QModelIndex& idx);
|
QVariant data(const QModelIndex& idx);
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
void setData(const QModelIndex& index, const QVariant& value, const QSqlRecord& record);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<int, QSqlRecord> m_msgCache;
|
QHash<int, QSqlRecord> m_msgCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline bool MessagesModelCache::containsData(int row_idx) const {
|
||||||
|
return m_msgCache.contains(row_idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QSqlRecord MessagesModelCache::record(int row_idx) const {
|
||||||
|
return m_msgCache.value(row_idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void MessagesModelCache::clear() {
|
||||||
|
m_msgCache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
#endif // MESSAGESMODELCACHE_H
|
#endif // MESSAGESMODELCACHE_H
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
#include "core/messagesproxymodel.h"
|
#include "core/messagesproxymodel.h"
|
||||||
|
|
||||||
#include "core/messagesmodel.h"
|
#include "core/messagesmodel.h"
|
||||||
|
#include "core/messagesmodelcache.h"
|
||||||
|
#include "miscellaneous/application.h"
|
||||||
#include "miscellaneous/regexfactory.h"
|
#include "miscellaneous/regexfactory.h"
|
||||||
|
#include "miscellaneous/settings.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
@ -66,9 +69,16 @@ bool MessagesProxyModel::lessThan(const QModelIndex& left, const QModelIndex& ri
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessagesProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const {
|
bool MessagesProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const {
|
||||||
|
// We want to show only regexped messages when "all" should be visible
|
||||||
|
// and we want to show only regexped AND unread messages when unread should be visible.
|
||||||
|
//
|
||||||
|
// But also, we want to see messages which have their dirty states cached, because
|
||||||
|
// otherwise they would just disappeaar from the list for example when batch marked as read
|
||||||
|
// which is distracting.
|
||||||
return
|
return
|
||||||
(!m_showUnreadOnly || !m_sourceModel->messageAt(source_row).m_isRead) &&
|
QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent) &&
|
||||||
QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
(m_sourceModel->cache()->containsData(source_row) ||
|
||||||
|
(!m_showUnreadOnly || !m_sourceModel->messageAt(source_row).m_isRead));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessagesProxyModel::showUnreadOnly() const {
|
bool MessagesProxyModel::showUnreadOnly() const {
|
||||||
|
@ -77,6 +87,7 @@ bool MessagesProxyModel::showUnreadOnly() const {
|
||||||
|
|
||||||
void MessagesProxyModel::setShowUnreadOnly(bool show_unread_only) {
|
void MessagesProxyModel::setShowUnreadOnly(bool show_unread_only) {
|
||||||
m_showUnreadOnly = show_unread_only;
|
m_showUnreadOnly = show_unread_only;
|
||||||
|
qApp->settings()->setValue(GROUP(Messages), Messages::ShowOnlyUnreadMessages, show_unread_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesProxyModel::invalidateUnreadMessagesFilter(bool set_new_value, bool show_unread_only) {
|
void MessagesProxyModel::invalidateUnreadMessagesFilter(bool set_new_value, bool show_unread_only) {
|
||||||
|
|
|
@ -581,8 +581,11 @@ void FormMain::loadSize() {
|
||||||
m_ui->m_actionSwitchListHeaders->setChecked(settings->value(GROUP(GUI), SETTING(GUI::ListHeadersVisible)).toBool());
|
m_ui->m_actionSwitchListHeaders->setChecked(settings->value(GROUP(GUI), SETTING(GUI::ListHeadersVisible)).toBool());
|
||||||
m_ui->m_actionSwitchStatusBar->setChecked(settings->value(GROUP(GUI), SETTING(GUI::StatusBarVisible)).toBool());
|
m_ui->m_actionSwitchStatusBar->setChecked(settings->value(GROUP(GUI), SETTING(GUI::StatusBarVisible)).toBool());
|
||||||
|
|
||||||
// Make sure that only unread feeds are shown if user has that feature set on.
|
// Make sure that only unread feeds/messages are shown if user has that feature set on.
|
||||||
m_ui->m_actionShowOnlyUnreadItems->setChecked(settings->value(GROUP(Feeds), SETTING(Feeds::ShowOnlyUnreadFeeds)).toBool());
|
m_ui->m_actionShowOnlyUnreadItems->setChecked(settings->value(GROUP(Feeds),
|
||||||
|
SETTING(Feeds::ShowOnlyUnreadFeeds)).toBool());
|
||||||
|
m_ui->m_actionShowOnlyUnreadMessages->setChecked(settings->value(GROUP(Messages),
|
||||||
|
SETTING(Messages::ShowOnlyUnreadMessages)).toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormMain::saveSize() {
|
void FormMain::saveSize() {
|
||||||
|
|
|
@ -101,6 +101,9 @@ DKEY Messages::KeepCursorInCenter = "keep_cursor_center";
|
||||||
|
|
||||||
DVALUE(bool) Messages::KeepCursorInCenterDef = false;
|
DVALUE(bool) Messages::KeepCursorInCenterDef = false;
|
||||||
|
|
||||||
|
DKEY Messages::ShowOnlyUnreadMessages = "show_only_unread_messages";
|
||||||
|
DVALUE(bool) Messages::ShowOnlyUnreadMessagesDef = false;
|
||||||
|
|
||||||
DKEY Messages::PreviewerFontStandard = "previewer_font_standard";
|
DKEY Messages::PreviewerFontStandard = "previewer_font_standard";
|
||||||
|
|
||||||
NON_CONST_DVALUE(QString) Messages::PreviewerFontStandardDef = QFont(QFont().family(), 12).toString();
|
NON_CONST_DVALUE(QString) Messages::PreviewerFontStandardDef = QFont(QFont().family(), 12).toString();
|
||||||
|
|
|
@ -113,19 +113,18 @@ namespace Messages {
|
||||||
VALUE(bool) UseCustomDateDef;
|
VALUE(bool) UseCustomDateDef;
|
||||||
|
|
||||||
KEY CustomDateFormat;
|
KEY CustomDateFormat;
|
||||||
|
|
||||||
VALUE(char*) CustomDateFormatDef;
|
VALUE(char*) CustomDateFormatDef;
|
||||||
|
|
||||||
KEY ClearReadOnExit;
|
KEY ClearReadOnExit;
|
||||||
|
|
||||||
VALUE(bool) ClearReadOnExitDef;
|
VALUE(bool) ClearReadOnExitDef;
|
||||||
|
|
||||||
KEY KeepCursorInCenter;
|
KEY KeepCursorInCenter;
|
||||||
|
|
||||||
VALUE(bool) KeepCursorInCenterDef;
|
VALUE(bool) KeepCursorInCenterDef;
|
||||||
|
|
||||||
KEY PreviewerFontStandard;
|
KEY ShowOnlyUnreadMessages;
|
||||||
|
VALUE(bool) ShowOnlyUnreadMessagesDef;
|
||||||
|
|
||||||
|
KEY PreviewerFontStandard;
|
||||||
NON_CONST_VALUE(QString) PreviewerFontStandardDef;
|
NON_CONST_VALUE(QString) PreviewerFontStandardDef;
|
||||||
|
|
||||||
KEY ListFont;
|
KEY ListFont;
|
||||||
|
|
Loading…
Add table
Reference in a new issue