From 8902594059810bf050f4d7312fb12253fa314de3 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 8 Mar 2022 09:21:09 +0100 Subject: [PATCH] fix sorting --- resources/sql/db_update_sqlite_1_2.sql | 4 ++-- src/librssguard/core/feedsproxymodel.cpp | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/resources/sql/db_update_sqlite_1_2.sql b/resources/sql/db_update_sqlite_1_2.sql index adc30c504..d4882b63b 100644 --- a/resources/sql/db_update_sqlite_1_2.sql +++ b/resources/sql/db_update_sqlite_1_2.sql @@ -20,8 +20,8 @@ CREATE TABLE Feeds ( FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE ); -- ! -INSERT INTO Feeds (id, ordr, title, description, date_created, icon, category, source, update_type, update_interval, account_id, custom_id, custom_data) -SELECT id, id, title, description, date_created, icon, category, source, update_type, update_interval, account_id, custom_id, custom_data +INSERT INTO Feeds (id, title, description, date_created, icon, category, source, update_type, update_interval, account_id, custom_id, custom_data) +SELECT id, title, description, date_created, icon, category, source, update_type, update_interval, account_id, custom_id, custom_data FROM backup_Feeds; -- ! DROP TABLE backup_Feeds; \ No newline at end of file diff --git a/src/librssguard/core/feedsproxymodel.cpp b/src/librssguard/core/feedsproxymodel.cpp index 19403968e..720d6511e 100644 --- a/src/librssguard/core/feedsproxymodel.cpp +++ b/src/librssguard/core/feedsproxymodel.cpp @@ -164,7 +164,6 @@ bool FeedsProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right // feeds are queued one after another too. // Moreover, sort everything alphabetically or // by item counts, depending on the sort column. - if (left_item->keepOnTop()) { return sortOrder() == Qt::SortOrder::AscendingOrder; } @@ -172,10 +171,15 @@ bool FeedsProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right return sortOrder() == Qt::SortOrder::DescendingOrder; } else if (left_item->kind() == right_item->kind()) { - // We sort items alphabetically. - return sortOrder() == Qt::SortOrder::AscendingOrder - ? QString::localeAwareCompare(left_item->title().toLower(), right_item->title().toLower()) < 0 - : QString::localeAwareCompare(left_item->title().toLower(), right_item->title().toLower()) > 0; + // Both items are of the same type. + if (left.column() == FDS_MODEL_COUNTS_INDEX) { + // User wants to sort according to counts. + return left_item->countOfUnreadMessages() < right_item->countOfUnreadMessages(); + } + else { + // In other cases, sort by title. + return QString::localeAwareCompare(left_item->title().toLower(), right_item->title().toLower()) < 0; + } } else { // We sort using priorities.