From 752c1b38a0e058b46554dfd8478633740f233675 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 3 Jul 2012 02:47:46 +0200 Subject: [PATCH] * Implemented new ViewPage API for various classes. --- src/libtomahawk/playlist/FlexibleView.cpp | 13 +++++++++++++ src/libtomahawk/playlist/FlexibleView.h | 1 + src/libtomahawk/playlist/GridView.cpp | 8 ++++++++ src/libtomahawk/playlist/GridView.h | 1 + src/libtomahawk/playlist/TrackView.cpp | 12 ++++++++++-- src/libtomahawk/playlist/TrackView.h | 1 + src/libtomahawk/playlist/TreeView.cpp | 12 ++++++++++-- src/libtomahawk/playlist/TreeView.h | 1 + 8 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/libtomahawk/playlist/FlexibleView.cpp b/src/libtomahawk/playlist/FlexibleView.cpp index 73d5b8474..faf09383d 100644 --- a/src/libtomahawk/playlist/FlexibleView.cpp +++ b/src/libtomahawk/playlist/FlexibleView.cpp @@ -235,3 +235,16 @@ FlexibleView::jumpToCurrentTrack() m_gridView->jumpToCurrentTrack(); return true; } + + +bool +FlexibleView::setFilter( const QString& filter ) +{ + ViewPage::setFilter( filter ); + + m_trackView->setFilter( filter ); + m_detailedView->setFilter( filter ); + m_gridView->setFilter( filter ); + + return true; +} diff --git a/src/libtomahawk/playlist/FlexibleView.h b/src/libtomahawk/playlist/FlexibleView.h index 838842c46..85e229849 100644 --- a/src/libtomahawk/playlist/FlexibleView.h +++ b/src/libtomahawk/playlist/FlexibleView.h @@ -53,6 +53,7 @@ public: // virtual void setShowModes( bool b ) { m_showModes = b; } virtual bool showModes() const { return false; } + virtual bool setFilter( const QString& filter ); virtual bool jumpToCurrentTrack(); void setTrackView( TrackView* view ); diff --git a/src/libtomahawk/playlist/GridView.cpp b/src/libtomahawk/playlist/GridView.cpp index 912db36e0..e5036f439 100644 --- a/src/libtomahawk/playlist/GridView.cpp +++ b/src/libtomahawk/playlist/GridView.cpp @@ -347,3 +347,11 @@ GridView::onCustomContextMenu( const QPoint& pos ) m_contextMenu->exec( viewport()->mapToGlobal( pos ) ); } + + +bool +GridView::setFilter( const QString& filter ) +{ + ViewPage::setFilter( filter ); + m_proxyModel->setFilter( filter ); +} diff --git a/src/libtomahawk/playlist/GridView.h b/src/libtomahawk/playlist/GridView.h index e3cbd7a5c..e2d733641 100644 --- a/src/libtomahawk/playlist/GridView.h +++ b/src/libtomahawk/playlist/GridView.h @@ -71,6 +71,7 @@ public: virtual bool showModes() const { return true; } + virtual bool setFilter( const QString& filter ); virtual bool jumpToCurrentTrack() { return false; } public slots: diff --git a/src/libtomahawk/playlist/TrackView.cpp b/src/libtomahawk/playlist/TrackView.cpp index 2d655bbde..1626b6d8a 100644 --- a/src/libtomahawk/playlist/TrackView.cpp +++ b/src/libtomahawk/playlist/TrackView.cpp @@ -503,9 +503,9 @@ TrackView::onFilterChanged( const QString& ) if ( selectedIndexes().count() ) scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter ); - if ( !proxyModel()->playlistInterface()->filter().isEmpty() && !proxyModel()->playlistInterface()->trackCount() && model()->trackCount() ) + if ( !filter().isEmpty() && !proxyModel()->playlistInterface()->trackCount() && model()->trackCount() ) { - m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->playlistInterface()->filter() ) ); + m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( filter() ) ); m_overlay->show(); } else @@ -743,3 +743,11 @@ TrackView::jumpToCurrentTrack() scrollTo( proxyModel()->currentIndex(), QAbstractItemView::PositionAtCenter ); return true; } + + +bool +TrackView::setFilter( const QString& filter ) +{ + ViewPage::setFilter( filter ); + m_proxyModel->setFilter( filter ); +} diff --git a/src/libtomahawk/playlist/TrackView.h b/src/libtomahawk/playlist/TrackView.h index 24f119a7e..737aaad9d 100644 --- a/src/libtomahawk/playlist/TrackView.h +++ b/src/libtomahawk/playlist/TrackView.h @@ -72,6 +72,7 @@ public: virtual bool showModes() const { return true; } virtual bool showFilter() const { return true; } + virtual bool setFilter( const QString& filter ); virtual bool jumpToCurrentTrack(); QModelIndex hoveredIndex() const { return m_hoveredIndex; } diff --git a/src/libtomahawk/playlist/TreeView.cpp b/src/libtomahawk/playlist/TreeView.cpp index 16755e5d6..5a9817aa5 100644 --- a/src/libtomahawk/playlist/TreeView.cpp +++ b/src/libtomahawk/playlist/TreeView.cpp @@ -293,9 +293,9 @@ TreeView::onFilterChangeFinished() if ( selectedIndexes().count() ) scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter ); - if ( !proxyModel()->playlistInterface()->filter().isEmpty() && !proxyModel()->playlistInterface()->trackCount() && model()->trackCount() ) + if ( !filter().isEmpty() && !proxyModel()->playlistInterface()->trackCount() && model()->trackCount() ) { - m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->playlistInterface()->filter() ) ); + m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( filter() ) ); m_overlay->show(); } else @@ -529,3 +529,11 @@ TreeView::guid() const return m_guid; } + + +bool +TreeView::setFilter( const QString& filter ) +{ + ViewPage::setFilter( filter ); + m_proxyModel->setFilter( filter ); +} diff --git a/src/libtomahawk/playlist/TreeView.h b/src/libtomahawk/playlist/TreeView.h index 27099db55..33f717903 100644 --- a/src/libtomahawk/playlist/TreeView.h +++ b/src/libtomahawk/playlist/TreeView.h @@ -76,6 +76,7 @@ public: virtual void setShowModes( bool b ) { m_showModes = b; } virtual bool showModes() const { return m_showModes; } + virtual bool setFilter( const QString& filter ); virtual bool jumpToCurrentTrack(); QModelIndex hoveredIndex() const { return m_hoveredIndex; }