From f0298cbaeb2cf89b18b45c3b5f9448cef3a621f6 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Thu, 21 Jan 2016 12:03:01 +0100 Subject: [PATCH] Maybe better now, it makes no sense to be fully dynamic. --- resources/text/CHANGELOG | 2 +- src/core/messagesproxymodel.cpp | 6 +----- src/core/messagesproxymodel.h | 2 -- src/gui/messagesview.cpp | 15 ++++++++------- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index 3980c6565..b2a922e49 100755 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -13,7 +13,7 @@ Fixed: Changed: -▪ Sorting of both views (feeds/messages) is now fully dynamic. +▪ Adjusted sorting, particularly in message list. ▪ Tweaked "remove duplicates" policy. ▪ TT-RSS plugin can now restore messages from local recycle bin. diff --git a/src/core/messagesproxymodel.cpp b/src/core/messagesproxymodel.cpp index 3e8369f1e..0c29440c0 100755 --- a/src/core/messagesproxymodel.cpp +++ b/src/core/messagesproxymodel.cpp @@ -30,7 +30,7 @@ MessagesProxyModel::MessagesProxyModel(QObject *parent) setFilterCaseSensitivity(Qt::CaseInsensitive); setFilterKeyColumn(-1); setFilterRole(Qt::EditRole); - setDynamicSortFilter(true); + setDynamicSortFilter(false); setSourceModel(m_sourceModel); } @@ -179,10 +179,6 @@ QModelIndexList MessagesProxyModel::match(const QModelIndex &start, int role, return result; } -void MessagesProxyModel::sort(int column, Qt::SortOrder order) { - QSortFilterProxyModel::sort(column, order); -} - QModelIndexList MessagesProxyModel::mapListToSource(const QModelIndexList &indexes) const { QModelIndexList source_indexes; diff --git a/src/core/messagesproxymodel.h b/src/core/messagesproxymodel.h index 93c48b221..3c7769f09 100755 --- a/src/core/messagesproxymodel.h +++ b/src/core/messagesproxymodel.h @@ -45,8 +45,6 @@ class MessagesProxyModel : public QSortFilterProxyModel { // 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; - void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); - private: QModelIndex getNextUnreadItemIndex(int default_row, int max_row) const; diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp index 39cabe212..ba97907f5 100755 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -80,7 +80,6 @@ void MessagesView::reloadSelections(bool mark_current_index_read) { // Reload the model now. m_sourceModel->fetchAllData(); - sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true); @@ -209,13 +208,15 @@ void MessagesView::selectionChanged(const QItemSelection &selected, const QItemS mapped_current_index.row(), mapped_current_index.column()); if (mapped_current_index.isValid() && selected_rows.count() == 1) { + Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(selected_rows.at(0)).row()); + if (!m_batchUnreadSwitch) { // Set this message as read only if current item // wasn't changed by "mark selected messages unread" action. m_sourceModel->setMessageRead(mapped_current_index.row(), RootItem::Read); } - emit currentMessagesChanged(QList() << m_sourceModel->messageAt(m_proxyModel->mapToSource(selected_rows.at(0)).row())); + emit currentMessagesChanged(QList() << message); } else { emit currentMessagesRemoved(); @@ -351,7 +352,7 @@ void MessagesView::setSelectedMessagesReadStatus(RootItem::ReadStatus read) { const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes); m_sourceModel->setBatchMessagesRead(mapped_indexes, read); - sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); + //sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true); current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(), mapped_current_index.column())); @@ -379,7 +380,7 @@ void MessagesView::deleteSelectedMessages() { const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes); m_sourceModel->setBatchMessagesDeleted(mapped_indexes); - sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); + //sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); const int row_count = m_sourceModel->rowCount(); @@ -408,7 +409,7 @@ void MessagesView::restoreSelectedMessages() { const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes); m_sourceModel->setBatchMessagesRestored(mapped_indexes); - sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); + //sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); int row_count = m_sourceModel->rowCount(); @@ -438,7 +439,7 @@ void MessagesView::switchSelectedMessagesImportance() { const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes); m_sourceModel->switchBatchMessageImportance(mapped_indexes); - sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); + //sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true); current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(), @@ -459,7 +460,7 @@ void MessagesView::reselectIndexes(const QModelIndexList &indexes) { selection.merge(QItemSelection(index, index), QItemSelectionModel::Select); } - selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows); + selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); } }