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)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: true
IndentCaseLabels: false
IndentCaseLabels: true
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None

View File

@ -30,7 +30,7 @@
# Other information:
# - supports Windows, Linux, *BSD, macOS, OS/2, Android,
# - 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,
# - if you wish to make packages for Windows, then you must initialize all submodules
# within repository before compilation,
@ -60,7 +60,7 @@ set(APP_AUTHOR "Martin Rotter")
set(APP_COPYRIGHT "\\251 2011-2022 ${APP_AUTHOR}")
set(APP_REVERSE_NAME "com.github.rssguard")
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_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)
# 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(QT_COMPONENTS

View File

@ -99,61 +99,62 @@ bool MessagesProxyModel::lessThan(const QModelIndex& left, const QModelIndex& ri
return false;
}
bool MessagesProxyModel::filterAcceptsMessage(Message currentMessage) const {
bool MessagesProxyModel::filterAcceptsMessage(const Message& current_message) const {
switch (m_filter) {
case MessageListFilter::NoFiltering:
return true;
case MessageListFilter::NoFiltering:
return true;
case MessageListFilter::ShowUnread:
return !currentMessage.m_isRead;
case MessageListFilter::ShowUnread:
return !current_message.m_isRead;
case MessageListFilter::ShowImportant:
return currentMessage.m_isImportant;
case MessageListFilter::ShowImportant:
return current_message.m_isImportant;
case MessageListFilter::ShowToday: {
const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDate currentDate = currentDateTime.date();
case MessageListFilter::ShowToday: {
const QDateTime currentDateTime = QDateTime::currentDateTime();
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: {
const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDate currentDate = currentDateTime.date();
case MessageListFilter::ShowYesterday: {
const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDate currentDate = currentDateTime.date();
return currentDate.addDays(-1).startOfDay() <= currentMessage.m_created &&
currentMessage.m_created <= currentDate.addDays(-1).endOfDay();
}
return currentDate.addDays(-1).startOfDay() <= current_message.m_created &&
current_message.m_created <= currentDate.addDays(-1).endOfDay();
}
case MessageListFilter::ShowLast24Hours: {
const QDateTime currentDateTime = QDateTime::currentDateTime();
case MessageListFilter::ShowLast24Hours: {
const QDateTime currentDateTime = QDateTime::currentDateTime();
return currentDateTime.addSecs(-24 * 60 * 60) <= currentMessage.m_created &&
currentMessage.m_created <= currentDateTime;
}
return currentDateTime.addSecs(-24 * 60 * 60) <= current_message.m_created &&
current_message.m_created <= currentDateTime;
}
case MessageListFilter::ShowLast48Hours: {
const QDateTime currentDateTime = QDateTime::currentDateTime();
case MessageListFilter::ShowLast48Hours: {
const QDateTime currentDateTime = QDateTime::currentDateTime();
return currentDateTime.addSecs(-48 * 60 * 60) <= currentMessage.m_created &&
currentMessage.m_created <= currentDateTime;
}
return currentDateTime.addSecs(-48 * 60 * 60) <= current_message.m_created &&
current_message.m_created <= currentDateTime;
}
case MessageListFilter::ShowThisWeek: {
const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDate currentDate = currentDateTime.date();
case MessageListFilter::ShowThisWeek: {
const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDate currentDate = currentDateTime.date();
return currentDate.year() == currentMessage.m_created.date().year() &&
currentDate.weekNumber() == currentMessage.m_created.date().weekNumber();
}
return currentDate.year() == current_message.m_created.date().year() &&
currentDate.weekNumber() == current_message.m_created.date().weekNumber();
}
case MessageListFilter::ShowLastWeek: {
const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDate currentDate = currentDateTime.date();
case MessageListFilter::ShowLastWeek: {
const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDate currentDate = currentDateTime.date();
return currentDate.addDays(-7).year() == currentMessage.m_created.date().year() &&
currentDate.addDays(-7).weekNumber() == currentMessage.m_created.date().weekNumber();
}
return currentDate.addDays(-7).year() == current_message.m_created.date().year() &&
currentDate.addDays(-7).weekNumber() == current_message.m_created.date().weekNumber();
}
}
return false;
@ -171,7 +172,7 @@ bool MessagesProxyModel::filterAcceptsRow(int source_row, const QModelIndex& sou
filterAcceptsMessage(m_sourceModel->messageAt(source_row)));
}
void MessagesProxyModel::setFilter(MessageListFilter filter) {
void MessagesProxyModel::setMessageListFilter(MessageListFilter filter) {
m_filter = filter;
}
@ -232,59 +233,59 @@ QModelIndexList MessagesProxyModel::match(const QModelIndex& start,
switch (match_type) {
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
case Qt::MatchFlag::MatchRegularExpression:
case Qt::MatchFlag::MatchRegularExpression:
#else
case Qt::MatchFlag::MatchRegExp:
case Qt::MatchFlag::MatchRegExp:
#endif
if (QRegularExpression(entered_text,
QRegularExpression::PatternOption::CaseInsensitiveOption |
QRegularExpression::PatternOption::UseUnicodePropertiesOption)
.match(item_text)
.hasMatch()) {
result.append(idx);
}
if (QRegularExpression(entered_text,
QRegularExpression::PatternOption::CaseInsensitiveOption |
QRegularExpression::PatternOption::UseUnicodePropertiesOption)
.match(item_text)
.hasMatch()) {
result.append(idx);
}
break;
break;
case Qt::MatchWildcard:
if (QRegularExpression(RegexFactory::wildcardToRegularExpression(entered_text),
QRegularExpression::PatternOption::CaseInsensitiveOption |
QRegularExpression::PatternOption::UseUnicodePropertiesOption)
.match(item_text)
.hasMatch()) {
result.append(idx);
}
case Qt::MatchWildcard:
if (QRegularExpression(RegexFactory::wildcardToRegularExpression(entered_text),
QRegularExpression::PatternOption::CaseInsensitiveOption |
QRegularExpression::PatternOption::UseUnicodePropertiesOption)
.match(item_text)
.hasMatch()) {
result.append(idx);
}
break;
break;
case Qt::MatchStartsWith:
if (item_text.startsWith(entered_text, case_sensitivity)) {
result.append(idx);
}
case Qt::MatchStartsWith:
if (item_text.startsWith(entered_text, case_sensitivity)) {
result.append(idx);
}
break;
break;
case Qt::MatchEndsWith:
if (item_text.endsWith(entered_text, case_sensitivity)) {
result.append(idx);
}
case Qt::MatchEndsWith:
if (item_text.endsWith(entered_text, case_sensitivity)) {
result.append(idx);
}
break;
break;
case Qt::MatchFixedString:
if (item_text.compare(entered_text, case_sensitivity) == 0) {
result.append(idx);
}
case Qt::MatchFixedString:
if (item_text.compare(entered_text, case_sensitivity) == 0) {
result.append(idx);
}
break;
break;
case Qt::MatchContains:
default:
if (item_text.contains(entered_text, case_sensitivity)) {
result.append(idx);
}
case Qt::MatchContains:
default:
if (item_text.contains(entered_text, case_sensitivity)) {
result.append(idx);
}
break;
break;
}
}
}

View File

@ -36,25 +36,26 @@ class MessagesProxyModel : public QSortFilterProxyModel {
QModelIndexList mapListToSource(const QModelIndexList& indexes) 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.
QModelIndexList match(const QModelIndex& start,
int role,
const QVariant& entered_value,
int hits,
Qt::MatchFlags flags) const;
virtual QModelIndexList match(const QModelIndex& start,
int role,
const QVariant& entered_value,
int hits,
Qt::MatchFlags flags) const;
// Performs sort of items.
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
void setFilter(MessageListFilter filter);
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
private:
QModelIndex getNextImportantItemIndex(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(Message currentMessage) const;
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
bool filterAcceptsMessage(const Message& current_message) 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.
MessagesModel* m_sourceModel;

View File

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