Make show msgs unread only persistent across RSS Guard app startups.
This commit is contained in:
parent
daad0760e1
commit
8bc36ccbd2
@ -37,6 +37,11 @@ void MessagesModel::setupIcons() {
|
||||
m_enclosuresIcon = qApp->icons()->fromTheme(QSL("mail-attachment"));
|
||||
}
|
||||
|
||||
MessagesModelCache* MessagesModel::cache() const
|
||||
{
|
||||
return m_cache;
|
||||
}
|
||||
|
||||
void MessagesModel::repopulate() {
|
||||
m_cache->clear();
|
||||
setQuery(selectStatement(), m_db);
|
||||
|
@ -49,6 +49,7 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
||||
RootItem::Importance messageImportance(int row_index) const;
|
||||
|
||||
RootItem* loadedItem() const;
|
||||
MessagesModelCache* cache() const;
|
||||
|
||||
void setupFonts();
|
||||
void updateDateFormat();
|
||||
|
@ -17,24 +17,27 @@ class MessagesModelCache : public QObject {
|
||||
explicit MessagesModelCache(QObject* parent = nullptr);
|
||||
virtual ~MessagesModelCache() = default;
|
||||
|
||||
inline bool containsData(int row_idx) const {
|
||||
return m_msgCache.contains(row_idx);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
bool containsData(int row_idx) const;
|
||||
QSqlRecord record(int row_idx) const;
|
||||
QVariant data(const QModelIndex& idx);
|
||||
|
||||
void clear();
|
||||
void setData(const QModelIndex& index, const QVariant& value, const QSqlRecord& record);
|
||||
|
||||
private:
|
||||
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
|
||||
|
@ -3,7 +3,10 @@
|
||||
#include "core/messagesproxymodel.h"
|
||||
|
||||
#include "core/messagesmodel.h"
|
||||
#include "core/messagesmodelcache.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/regexfactory.h"
|
||||
#include "miscellaneous/settings.h"
|
||||
|
||||
#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 {
|
||||
// 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
|
||||
(!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 {
|
||||
@ -77,6 +87,7 @@ bool MessagesProxyModel::showUnreadOnly() const {
|
||||
|
||||
void MessagesProxyModel::setShowUnreadOnly(bool 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) {
|
||||
|
@ -581,8 +581,11 @@ void FormMain::loadSize() {
|
||||
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());
|
||||
|
||||
// Make sure that only unread feeds are shown if user has that feature set on.
|
||||
m_ui->m_actionShowOnlyUnreadItems->setChecked(settings->value(GROUP(Feeds), SETTING(Feeds::ShowOnlyUnreadFeeds)).toBool());
|
||||
// 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_actionShowOnlyUnreadMessages->setChecked(settings->value(GROUP(Messages),
|
||||
SETTING(Messages::ShowOnlyUnreadMessages)).toBool());
|
||||
}
|
||||
|
||||
void FormMain::saveSize() {
|
||||
|
@ -101,6 +101,9 @@ DKEY Messages::KeepCursorInCenter = "keep_cursor_center";
|
||||
|
||||
DVALUE(bool) Messages::KeepCursorInCenterDef = false;
|
||||
|
||||
DKEY Messages::ShowOnlyUnreadMessages = "show_only_unread_messages";
|
||||
DVALUE(bool) Messages::ShowOnlyUnreadMessagesDef = false;
|
||||
|
||||
DKEY Messages::PreviewerFontStandard = "previewer_font_standard";
|
||||
|
||||
NON_CONST_DVALUE(QString) Messages::PreviewerFontStandardDef = QFont(QFont().family(), 12).toString();
|
||||
|
@ -113,19 +113,18 @@ namespace Messages {
|
||||
VALUE(bool) UseCustomDateDef;
|
||||
|
||||
KEY CustomDateFormat;
|
||||
|
||||
VALUE(char*) CustomDateFormatDef;
|
||||
|
||||
KEY ClearReadOnExit;
|
||||
|
||||
VALUE(bool) ClearReadOnExitDef;
|
||||
|
||||
KEY KeepCursorInCenter;
|
||||
|
||||
VALUE(bool) KeepCursorInCenterDef;
|
||||
|
||||
KEY PreviewerFontStandard;
|
||||
KEY ShowOnlyUnreadMessages;
|
||||
VALUE(bool) ShowOnlyUnreadMessagesDef;
|
||||
|
||||
KEY PreviewerFontStandard;
|
||||
NON_CONST_VALUE(QString) PreviewerFontStandardDef;
|
||||
|
||||
KEY ListFont;
|
||||
|
Loading…
x
Reference in New Issue
Block a user