diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index e73bd8946..647262e02 100755 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -14,6 +14,7 @@ Changed: Fixed: +▪ Feeds are now (re)sorted when batch update finishes. (bug #150) ▪ Expand status if items in feed list are now persistent when performing sync-in of TT-RSS accounts. (bug #149) ▪ Fixed problem with importing invalid OPML 2.0 files. (bug #145) ▪ Fixed error in SQL initialization script which led to problems with in-memory SQLite DBs. (bug #140) diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index a7b791370..786e0fa75 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -145,7 +145,7 @@ void FeedsModel::updateFeeds(const QList &feeds) { connect(m_feedDownloaderThread, SIGNAL(finished()), m_feedDownloaderThread, SLOT(deleteLater())); connect(m_feedDownloader, SIGNAL(finished(FeedDownloadResults)), this, SLOT(onFeedUpdatesFinished(FeedDownloadResults))); connect(m_feedDownloader, SIGNAL(started()), this, SLOT(onFeedUpdatesStarted())); - connect(m_feedDownloader, SIGNAL(progress(Feed*,int,int)), this, SLOT(onFeedUpdatesProgress(Feed*,int,int))); + connect(m_feedDownloader, SIGNAL(progress(const Feed*,int,int)), this, SLOT(onFeedUpdatesProgress(const Feed*,int,int))); // Connections are made, start the feed downloader thread. m_feedDownloaderThread->start(); @@ -177,6 +177,7 @@ void FeedsModel::onFeedUpdatesFinished(const FeedDownloadResults &results) { } emit feedsUpdateFinished(); + emit sortingRequired(); } void FeedsModel::updateAllFeeds() { diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index 169eede84..9f899940d 100755 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -221,6 +221,9 @@ class FeedsModel : public QAbstractItemModel { // NOTE: View will probably expand dropped index. void requireItemValidationAfterDragDrop(const QModelIndex &source_index); + // When emitted, view (re)sorts items. + void sortingRequired(); + private: RootItem *m_rootItem; QList m_headerData; diff --git a/src/gui/discoverfeedsbutton.cpp b/src/gui/discoverfeedsbutton.cpp index aaeaa3a72..45c8a877f 100755 --- a/src/gui/discoverfeedsbutton.cpp +++ b/src/gui/discoverfeedsbutton.cpp @@ -59,7 +59,7 @@ void DiscoverFeedsButton::setFeedAddresses(const QStringList &addresses) { m_addresses = addresses; } -void DiscoverFeedsButton::linkTriggered(const QAction *action) { +void DiscoverFeedsButton::linkTriggered(QAction *action) { const QString url = action->property("url").toString(); ServiceRoot *root = static_cast(action->property("root").value()); diff --git a/src/gui/discoverfeedsbutton.h b/src/gui/discoverfeedsbutton.h index 8975cc6ad..5b8000737 100755 --- a/src/gui/discoverfeedsbutton.h +++ b/src/gui/discoverfeedsbutton.h @@ -35,7 +35,7 @@ class DiscoverFeedsButton : public QToolButton { private slots: // User chose any of addresses. - void linkTriggered(const QAction *action); + void linkTriggered(QAction *action); void fillMenu(); private: diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 075ea5336..3bc2cfbb8 100755 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -58,6 +58,7 @@ FeedsView::FeedsView(QWidget *parent) connect(m_sourceModel, SIGNAL(requireItemValidationAfterDragDrop(QModelIndex)), this, SLOT(validateItemAfterDragDrop(QModelIndex))); connect(m_sourceModel, SIGNAL(itemExpandRequested(QList,bool)), this, SLOT(onItemExpandRequested(QList,bool))); 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))); setModel(m_proxyModel); @@ -133,8 +134,27 @@ void FeedsView::loadAllExpandStates() { settings->value(GROUP(CategoriesExpandStates), setting_name, item->childCount() > 0).toBool()); } - sortByColumn(qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortColumnFeeds)).toInt(), - static_cast(qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortOrderFeeds)).toInt())); + sort(true); +} + +void FeedsView::sort(bool from_settings) { + int column; + Qt::SortOrder order; + + if (from_settings) { + column = qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortColumnFeeds)).toInt(); + order = static_cast(qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortOrderFeeds)).toInt()); + } + else { + column = header()->sortIndicatorSection(); + order = header()->sortIndicatorOrder(); + } + + sortByColumn(column, order); +} + +void FeedsView::reSort() { + m_proxyModel->sort(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); } void FeedsView::addFeedIntoSelectedAccount() { diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index efefccf6b..79231c743 100755 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -61,6 +61,10 @@ class FeedsView : public QTreeView { void loadAllExpandStates(); public slots: + // Sorts according to column/order taken from settings. + void sort(bool from_settings); + void reSort(); + void addFeedIntoSelectedAccount(); void addCategoryIntoSelectedAccount(); void expandCollapseCurrentItem();