Some refactorings for feed view.

This commit is contained in:
Martin Rotter 2013-12-22 13:23:48 +01:00
parent 86c22db046
commit 046322fa9d
2 changed files with 11 additions and 3 deletions

View File

@ -27,6 +27,13 @@ void FeedsView::setSortingEnabled(bool enable) {
header()->setSortIndicatorShown(false);
}
QList<FeedsModelFeed *> FeedsView::selectedFeeds() const {
QModelIndexList selection = selectionModel()->selectedRows();
QModelIndexList mapped_selection = m_proxyModel->mapListToSource(selection);
return m_sourceModel->feedsForIndexes(mapped_selection);
}
void FeedsView::updateCountsOfSelectedFeeds() {
QModelIndexList selected_rows = selectionModel()->selectedRows();
QModelIndexList mapped_rows = m_proxyModel->mapListToSource(selected_rows);
@ -65,9 +72,7 @@ void FeedsView::selectionChanged(const QItemSelection &selected,
const QItemSelection &deselected) {
QTreeView::selectionChanged(selected, deselected);
QModelIndexList selection = selectionModel()->selectedRows();
QModelIndexList mapped_selection = m_proxyModel->mapListToSource(selection);
QList<FeedsModelFeed*> selected_feeds = m_sourceModel->feedsForIndexes(mapped_selection);
QList<FeedsModelFeed*> selected_feeds = selectedFeeds();
QList<int> feed_ids;
foreach (FeedsModelFeed *feed, selected_feeds) {

View File

@ -6,6 +6,7 @@
class FeedsModel;
class FeedsProxyModel;
class FeedsModelFeed;
class FeedsView : public QTreeView {
Q_OBJECT
@ -17,6 +18,8 @@ class FeedsView : public QTreeView {
void setSortingEnabled(bool enable);
QList<FeedsModelFeed*> selectedFeeds() const;
public slots:
// Reloads count for selected feeds.
void updateCountsOfSelectedFeeds();