Maybe better now, it makes no sense to be fully dynamic.

This commit is contained in:
Martin Rotter 2016-01-21 12:03:01 +01:00
parent 12c0d3d463
commit f0298cbaeb
4 changed files with 10 additions and 15 deletions

View File

@ -13,7 +13,7 @@ Fixed:
Changed: Changed:
Sorting of both views (feeds/messages) is now fully dynamic. Adjusted sorting, particularly in message list.
▪ Tweaked "remove duplicates" policy. ▪ Tweaked "remove duplicates" policy.
▪ TT-RSS plugin can now restore messages from local recycle bin. ▪ TT-RSS plugin can now restore messages from local recycle bin.

View File

@ -30,7 +30,7 @@ MessagesProxyModel::MessagesProxyModel(QObject *parent)
setFilterCaseSensitivity(Qt::CaseInsensitive); setFilterCaseSensitivity(Qt::CaseInsensitive);
setFilterKeyColumn(-1); setFilterKeyColumn(-1);
setFilterRole(Qt::EditRole); setFilterRole(Qt::EditRole);
setDynamicSortFilter(true); setDynamicSortFilter(false);
setSourceModel(m_sourceModel); setSourceModel(m_sourceModel);
} }
@ -179,10 +179,6 @@ QModelIndexList MessagesProxyModel::match(const QModelIndex &start, int role,
return result; return result;
} }
void MessagesProxyModel::sort(int column, Qt::SortOrder order) {
QSortFilterProxyModel::sort(column, order);
}
QModelIndexList MessagesProxyModel::mapListToSource(const QModelIndexList &indexes) const { QModelIndexList MessagesProxyModel::mapListToSource(const QModelIndexList &indexes) const {
QModelIndexList source_indexes; QModelIndexList source_indexes;

View File

@ -45,8 +45,6 @@ class MessagesProxyModel : public QSortFilterProxyModel {
// 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, int role, const QVariant &entered_value, int hits, Qt::MatchFlags flags) const; 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: private:
QModelIndex getNextUnreadItemIndex(int default_row, int max_row) const; QModelIndex getNextUnreadItemIndex(int default_row, int max_row) const;

View File

@ -80,7 +80,6 @@ void MessagesView::reloadSelections(bool mark_current_index_read) {
// Reload the model now. // Reload the model now.
m_sourceModel->fetchAllData(); m_sourceModel->fetchAllData();
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true); 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()); mapped_current_index.row(), mapped_current_index.column());
if (mapped_current_index.isValid() && selected_rows.count() == 1) { 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) { if (!m_batchUnreadSwitch) {
// Set this message as read only if current item // Set this message as read only if current item
// wasn't changed by "mark selected messages unread" action. // wasn't changed by "mark selected messages unread" action.
m_sourceModel->setMessageRead(mapped_current_index.row(), RootItem::Read); m_sourceModel->setMessageRead(mapped_current_index.row(), RootItem::Read);
} }
emit currentMessagesChanged(QList<Message>() << m_sourceModel->messageAt(m_proxyModel->mapToSource(selected_rows.at(0)).row())); emit currentMessagesChanged(QList<Message>() << message);
} }
else { else {
emit currentMessagesRemoved(); emit currentMessagesRemoved();
@ -351,7 +352,7 @@ void MessagesView::setSelectedMessagesReadStatus(RootItem::ReadStatus read) {
const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes); const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
m_sourceModel->setBatchMessagesRead(mapped_indexes, read); m_sourceModel->setBatchMessagesRead(mapped_indexes, read);
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); //sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true); selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true);
current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(), mapped_current_index.column())); 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); const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
m_sourceModel->setBatchMessagesDeleted(mapped_indexes); m_sourceModel->setBatchMessagesDeleted(mapped_indexes);
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); //sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
const int row_count = m_sourceModel->rowCount(); const int row_count = m_sourceModel->rowCount();
@ -408,7 +409,7 @@ void MessagesView::restoreSelectedMessages() {
const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes); const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
m_sourceModel->setBatchMessagesRestored(mapped_indexes); m_sourceModel->setBatchMessagesRestored(mapped_indexes);
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); //sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
int row_count = m_sourceModel->rowCount(); int row_count = m_sourceModel->rowCount();
@ -438,7 +439,7 @@ void MessagesView::switchSelectedMessagesImportance() {
const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes); const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
m_sourceModel->switchBatchMessageImportance(mapped_indexes); m_sourceModel->switchBatchMessageImportance(mapped_indexes);
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); //sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true); selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true);
current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(), 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); selection.merge(QItemSelection(index, index), QItemSelectionModel::Select);
} }
selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows); selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
} }
} }