Fully dynamic sorting.
This commit is contained in:
parent
36d3f2120a
commit
12c0d3d463
@ -13,6 +13,7 @@ Fixed:
|
|||||||
|
|
||||||
Changed:
|
Changed:
|
||||||
|
|
||||||
|
▪ Sorting of both views (feeds/messages) is now fully dynamic.
|
||||||
▪ 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.
|
||||||
|
|
||||||
|
@ -177,7 +177,6 @@ void FeedsModel::onFeedUpdatesFinished(const FeedDownloadResults &results) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit feedsUpdateFinished();
|
emit feedsUpdateFinished();
|
||||||
//emit sortingRequired();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::updateAllFeeds() {
|
void FeedsModel::updateAllFeeds() {
|
||||||
|
@ -211,9 +211,6 @@ class FeedsModel : public QAbstractItemModel {
|
|||||||
// NOTE: View will probably expand dropped index.
|
// NOTE: View will probably expand dropped index.
|
||||||
void requireItemValidationAfterDragDrop(const QModelIndex &source_index);
|
void requireItemValidationAfterDragDrop(const QModelIndex &source_index);
|
||||||
|
|
||||||
// When emitted, view (re)sorts items.
|
|
||||||
void sortingRequired();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RootItem *m_rootItem;
|
RootItem *m_rootItem;
|
||||||
QList<QString> m_headerData;
|
QList<QString> m_headerData;
|
||||||
|
@ -179,6 +179,10 @@ 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;
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ 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;
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ FeedsView::FeedsView(QWidget *parent)
|
|||||||
connect(m_sourceModel, SIGNAL(requireItemValidationAfterDragDrop(QModelIndex)), this, SLOT(validateItemAfterDragDrop(QModelIndex)));
|
connect(m_sourceModel, SIGNAL(requireItemValidationAfterDragDrop(QModelIndex)), this, SLOT(validateItemAfterDragDrop(QModelIndex)));
|
||||||
connect(m_sourceModel, SIGNAL(itemExpandRequested(QList<RootItem*>,bool)), this, SLOT(onItemExpandRequested(QList<RootItem*>,bool)));
|
connect(m_sourceModel, SIGNAL(itemExpandRequested(QList<RootItem*>,bool)), this, SLOT(onItemExpandRequested(QList<RootItem*>,bool)));
|
||||||
connect(m_sourceModel, SIGNAL(itemExpandStateSaveRequested(RootItem*)), this, SLOT(onItemExpandStateSaveRequested(RootItem*)));
|
connect(m_sourceModel, SIGNAL(itemExpandStateSaveRequested(RootItem*)), this, SLOT(onItemExpandStateSaveRequested(RootItem*)));
|
||||||
connect(m_sourceModel, SIGNAL(sortingRequired()), this, SLOT(reSort()));
|
|
||||||
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
|
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
|
||||||
|
|
||||||
setModel(m_proxyModel);
|
setModel(m_proxyModel);
|
||||||
@ -134,27 +133,20 @@ void FeedsView::loadAllExpandStates() {
|
|||||||
settings->value(GROUP(CategoriesExpandStates), setting_name, item->childCount() > 0).toBool());
|
settings->value(GROUP(CategoriesExpandStates), setting_name, item->childCount() > 0).toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
sort(true);
|
sortByColumn(qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortColumnFeeds)).toInt(),
|
||||||
|
static_cast<Qt::SortOrder>(qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortOrderFeeds)).toInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::sort(bool from_settings) {
|
void FeedsView::sortByColumn(int column, Qt::SortOrder order) {
|
||||||
int column;
|
const int old_column = header()->sortIndicatorSection();
|
||||||
Qt::SortOrder order;
|
const Qt::SortOrder old_order = header()->sortIndicatorOrder();
|
||||||
|
|
||||||
if (from_settings) {
|
if (column == old_column && order == old_order) {
|
||||||
column = qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortColumnFeeds)).toInt();
|
m_proxyModel->sort(column, order);
|
||||||
order = static_cast<Qt::SortOrder>(qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortOrderFeeds)).toInt());
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
column = header()->sortIndicatorSection();
|
QTreeView::sortByColumn(column, order);
|
||||||
order = header()->sortIndicatorOrder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sortByColumn(column, order);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FeedsView::reSort() {
|
|
||||||
m_proxyModel->sort(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::addFeedIntoSelectedAccount() {
|
void FeedsView::addFeedIntoSelectedAccount() {
|
||||||
|
@ -61,9 +61,7 @@ class FeedsView : public QTreeView {
|
|||||||
void loadAllExpandStates();
|
void loadAllExpandStates();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// Sorts according to column/order taken from settings.
|
void sortByColumn(int column, Qt::SortOrder order);
|
||||||
void sort(bool from_settings);
|
|
||||||
void reSort();
|
|
||||||
|
|
||||||
void addFeedIntoSelectedAccount();
|
void addFeedIntoSelectedAccount();
|
||||||
void addCategoryIntoSelectedAccount();
|
void addCategoryIntoSelectedAccount();
|
||||||
|
@ -245,6 +245,18 @@ void MessagesView::loadItem(RootItem *item) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessagesView::sortByColumn(int column, Qt::SortOrder order) {
|
||||||
|
const int old_column = header()->sortIndicatorSection();
|
||||||
|
const Qt::SortOrder old_order = header()->sortIndicatorOrder();
|
||||||
|
|
||||||
|
if (column == old_column && order == old_order) {
|
||||||
|
m_proxyModel->sort(column, order);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QTreeView::sortByColumn(column, order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MessagesView::openSelectedSourceMessagesExternally() {
|
void MessagesView::openSelectedSourceMessagesExternally() {
|
||||||
foreach (const QModelIndex &index, selectionModel()->selectedRows()) {
|
foreach (const QModelIndex &index, selectionModel()->selectedRows()) {
|
||||||
const QString link = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()).m_url;
|
const QString link = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()).m_url;
|
||||||
|
@ -59,6 +59,8 @@ class MessagesView : public QTreeView {
|
|||||||
// Loads un-deleted messages from selected feeds.
|
// Loads un-deleted messages from selected feeds.
|
||||||
void loadItem(RootItem *item);
|
void loadItem(RootItem *item);
|
||||||
|
|
||||||
|
void sortByColumn(int column, Qt::SortOrder order);
|
||||||
|
|
||||||
// Message manipulators.
|
// Message manipulators.
|
||||||
void openSelectedSourceMessagesExternally();
|
void openSelectedSourceMessagesExternally();
|
||||||
void openSelectedSourceMessagesInternally();
|
void openSelectedSourceMessagesInternally();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user