This commit is contained in:
Martin Rotter 2022-04-09 09:55:11 +02:00
parent 3e24129bf1
commit 62bda35fc8
5 changed files with 99 additions and 97 deletions

View file

@ -98,7 +98,7 @@ IncludeCategories:
IncludeIsMainRegex: '(Test)?$' IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: '' IncludeIsMainSourceRegex: ''
IndentAccessModifiers: true IndentAccessModifiers: true
IndentCaseLabels: false IndentCaseLabels: true
IndentCaseBlocks: false IndentCaseBlocks: false
IndentGotoLabels: true IndentGotoLabels: true
IndentPPDirectives: None IndentPPDirectives: None

View file

@ -30,7 +30,7 @@
# Other information: # Other information:
# - supports Windows, Linux, *BSD, macOS, OS/2, Android, # - supports Windows, Linux, *BSD, macOS, OS/2, Android,
# - Qt 5.12.0 or newer is required, # - Qt 5.12.0 or newer is required,
# - Qt 6.2.3 or newer is required, # - Qt 6.3.0 or newer is required,
# - cmake 3.9.0 or newer is required, # - cmake 3.9.0 or newer is required,
# - if you wish to make packages for Windows, then you must initialize all submodules # - if you wish to make packages for Windows, then you must initialize all submodules
# within repository before compilation, # within repository before compilation,
@ -60,7 +60,7 @@ set(APP_AUTHOR "Martin Rotter")
set(APP_COPYRIGHT "\\251 2011-2022 ${APP_AUTHOR}") set(APP_COPYRIGHT "\\251 2011-2022 ${APP_AUTHOR}")
set(APP_REVERSE_NAME "com.github.rssguard") set(APP_REVERSE_NAME "com.github.rssguard")
set(APP_DONATE_URL "https://github.com/sponsors/martinrotter") set(APP_DONATE_URL "https://github.com/sponsors/martinrotter")
set(APP_VERSION "4.2.1") set(APP_VERSION "4.3.1")
set(APP_URL "https://github.com/martinrotter/rssguard") set(APP_URL "https://github.com/martinrotter/rssguard")
set(APP_URL_DOCUMENTATION "https://github.com/martinrotter/rssguard/blob/master/resources/docs/Documentation.md") set(APP_URL_DOCUMENTATION "https://github.com/martinrotter/rssguard/blob/master/resources/docs/Documentation.md")
@ -108,7 +108,7 @@ option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GCC/Clang only)
option(REVISION_FROM_GIT "Get revision using `git rev-parse`" ON) option(REVISION_FROM_GIT "Get revision using `git rev-parse`" ON)
# Import Qt libraries. # Import Qt libraries.
set(QT6_MIN_VERSION 6.2.3) set(QT6_MIN_VERSION 6.3.0)
set(QT5_MIN_VERSION 5.12.0) set(QT5_MIN_VERSION 5.12.0)
set(QT_COMPONENTS set(QT_COMPONENTS

View file

@ -99,60 +99,61 @@ bool MessagesProxyModel::lessThan(const QModelIndex& left, const QModelIndex& ri
return false; return false;
} }
bool MessagesProxyModel::filterAcceptsMessage(Message currentMessage) const { bool MessagesProxyModel::filterAcceptsMessage(const Message& current_message) const {
switch (m_filter) { switch (m_filter) {
case MessageListFilter::NoFiltering: case MessageListFilter::NoFiltering:
return true; return true;
case MessageListFilter::ShowUnread: case MessageListFilter::ShowUnread:
return !currentMessage.m_isRead; return !current_message.m_isRead;
case MessageListFilter::ShowImportant: case MessageListFilter::ShowImportant:
return currentMessage.m_isImportant; return current_message.m_isImportant;
case MessageListFilter::ShowToday: { case MessageListFilter::ShowToday: {
const QDateTime currentDateTime = QDateTime::currentDateTime(); const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDate currentDate = currentDateTime.date(); const QDate currentDate = currentDateTime.date();
return currentDate.startOfDay() <= currentMessage.m_created && currentMessage.m_created <= currentDate.endOfDay(); return currentDate.startOfDay() <= current_message.m_created &&
current_message.m_created <= currentDate.endOfDay();
} }
case MessageListFilter::ShowYesterday: { case MessageListFilter::ShowYesterday: {
const QDateTime currentDateTime = QDateTime::currentDateTime(); const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDate currentDate = currentDateTime.date(); const QDate currentDate = currentDateTime.date();
return currentDate.addDays(-1).startOfDay() <= currentMessage.m_created && return currentDate.addDays(-1).startOfDay() <= current_message.m_created &&
currentMessage.m_created <= currentDate.addDays(-1).endOfDay(); current_message.m_created <= currentDate.addDays(-1).endOfDay();
} }
case MessageListFilter::ShowLast24Hours: { case MessageListFilter::ShowLast24Hours: {
const QDateTime currentDateTime = QDateTime::currentDateTime(); const QDateTime currentDateTime = QDateTime::currentDateTime();
return currentDateTime.addSecs(-24 * 60 * 60) <= currentMessage.m_created && return currentDateTime.addSecs(-24 * 60 * 60) <= current_message.m_created &&
currentMessage.m_created <= currentDateTime; current_message.m_created <= currentDateTime;
} }
case MessageListFilter::ShowLast48Hours: { case MessageListFilter::ShowLast48Hours: {
const QDateTime currentDateTime = QDateTime::currentDateTime(); const QDateTime currentDateTime = QDateTime::currentDateTime();
return currentDateTime.addSecs(-48 * 60 * 60) <= currentMessage.m_created && return currentDateTime.addSecs(-48 * 60 * 60) <= current_message.m_created &&
currentMessage.m_created <= currentDateTime; current_message.m_created <= currentDateTime;
} }
case MessageListFilter::ShowThisWeek: { case MessageListFilter::ShowThisWeek: {
const QDateTime currentDateTime = QDateTime::currentDateTime(); const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDate currentDate = currentDateTime.date(); const QDate currentDate = currentDateTime.date();
return currentDate.year() == currentMessage.m_created.date().year() && return currentDate.year() == current_message.m_created.date().year() &&
currentDate.weekNumber() == currentMessage.m_created.date().weekNumber(); currentDate.weekNumber() == current_message.m_created.date().weekNumber();
} }
case MessageListFilter::ShowLastWeek: { case MessageListFilter::ShowLastWeek: {
const QDateTime currentDateTime = QDateTime::currentDateTime(); const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDate currentDate = currentDateTime.date(); const QDate currentDate = currentDateTime.date();
return currentDate.addDays(-7).year() == currentMessage.m_created.date().year() && return currentDate.addDays(-7).year() == current_message.m_created.date().year() &&
currentDate.addDays(-7).weekNumber() == currentMessage.m_created.date().weekNumber(); currentDate.addDays(-7).weekNumber() == current_message.m_created.date().weekNumber();
} }
} }
@ -171,7 +172,7 @@ bool MessagesProxyModel::filterAcceptsRow(int source_row, const QModelIndex& sou
filterAcceptsMessage(m_sourceModel->messageAt(source_row))); filterAcceptsMessage(m_sourceModel->messageAt(source_row)));
} }
void MessagesProxyModel::setFilter(MessageListFilter filter) { void MessagesProxyModel::setMessageListFilter(MessageListFilter filter) {
m_filter = filter; m_filter = filter;
} }

View file

@ -36,25 +36,26 @@ class MessagesProxyModel : public QSortFilterProxyModel {
QModelIndexList mapListToSource(const QModelIndexList& indexes) const; QModelIndexList mapListToSource(const QModelIndexList& indexes) const;
QModelIndexList mapListFromSource(const QModelIndexList& indexes, bool deep = false) const; QModelIndexList mapListFromSource(const QModelIndexList& indexes, bool deep = false) const;
void setMessageListFilter(MessageListFilter filter);
// Fix for matching indexes with respect to specifics of the message model. // Fix for matching indexes with respect to specifics of the message model.
QModelIndexList match(const QModelIndex& start, virtual QModelIndexList match(const QModelIndex& start,
int role, int role,
const QVariant& entered_value, const QVariant& entered_value,
int hits, int hits,
Qt::MatchFlags flags) const; Qt::MatchFlags flags) const;
// Performs sort of items. // Performs sort of items.
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
void setFilter(MessageListFilter filter);
private: private:
QModelIndex getNextImportantItemIndex(int default_row, int max_row) const; QModelIndex getNextImportantItemIndex(int default_row, int max_row) const;
QModelIndex getNextUnreadItemIndex(int default_row, int max_row) const; QModelIndex getNextUnreadItemIndex(int default_row, int max_row) const;
bool lessThan(const QModelIndex& left, const QModelIndex& right) const; bool filterAcceptsMessage(const Message& current_message) const;
bool filterAcceptsMessage(Message currentMessage) const;
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const; virtual bool lessThan(const QModelIndex& left, const QModelIndex& right) const;
virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
// Source model pointer. // Source model pointer.
MessagesModel* m_sourceModel; MessagesModel* m_sourceModel;

View file

@ -500,7 +500,7 @@ void MessagesView::loadItem(RootItem* item) {
} }
void MessagesView::changeFilter(MessagesProxyModel::MessageListFilter filter) { void MessagesView::changeFilter(MessagesProxyModel::MessageListFilter filter) {
m_proxyModel->setFilter(filter); m_proxyModel->setMessageListFilter(filter);
reloadSelections(); reloadSelections();
} }