From 6a23954539dc887f0354a5f4cf8be6724d2cf1fc Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 3 Jul 2012 02:49:31 +0200 Subject: [PATCH] * Added setFilter methods to proxy models. --- src/libtomahawk/playlist/PlayableProxyModel.cpp | 11 +++++++++++ src/libtomahawk/playlist/PlayableProxyModel.h | 5 ++--- src/libtomahawk/playlist/TreeProxyModel.cpp | 12 ++---------- src/libtomahawk/playlist/TreeProxyModel.h | 5 ++--- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/libtomahawk/playlist/PlayableProxyModel.cpp b/src/libtomahawk/playlist/PlayableProxyModel.cpp index b281a2d9b..65a674c81 100644 --- a/src/libtomahawk/playlist/PlayableProxyModel.cpp +++ b/src/libtomahawk/playlist/PlayableProxyModel.cpp @@ -578,3 +578,14 @@ PlayableProxyModel::updateDetailedInfo( const QModelIndex& index ) item->query()->loadSocialActions(); } } + + +void +PlayableProxyModel::setFilter( const QString& pattern ) +{ + if ( pattern != filterRegExp().pattern() ) + { + setFilterRegExp( pattern ); + emit filterChanged( pattern ); + } +} diff --git a/src/libtomahawk/playlist/PlayableProxyModel.h b/src/libtomahawk/playlist/PlayableProxyModel.h index 79b496317..3c689f167 100644 --- a/src/libtomahawk/playlist/PlayableProxyModel.h +++ b/src/libtomahawk/playlist/PlayableProxyModel.h @@ -66,8 +66,6 @@ public: virtual int maxVisibleItems() const { return m_maxVisibleItems; } virtual void setMaxVisibleItems( int items ); - virtual void emitFilterChanged( const QString &pattern ) { emit filterChanged( pattern ); } - virtual PlayableItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); } virtual Tomahawk::playlistinterface_ptr playlistInterface(); @@ -78,7 +76,8 @@ public: virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const; virtual QVariant headerData( int section, Qt::Orientation orientation, int role ) const; - void updateDetailedInfo( const QModelIndex& index ); + virtual void setFilter( const QString& pattern ); + virtual void updateDetailedInfo( const QModelIndex& index ); signals: void filterChanged( const QString& filter ); diff --git a/src/libtomahawk/playlist/TreeProxyModel.cpp b/src/libtomahawk/playlist/TreeProxyModel.cpp index 8d181af65..19a6a8065 100644 --- a/src/libtomahawk/playlist/TreeProxyModel.cpp +++ b/src/libtomahawk/playlist/TreeProxyModel.cpp @@ -92,7 +92,7 @@ TreeProxyModel::onModelReset() void -TreeProxyModel::newFilterFromPlaylistInterface( const QString& pattern ) +TreeProxyModel::setFilter( const QString& pattern ) { emit filteringStarted(); @@ -170,16 +170,8 @@ TreeProxyModel::filterFinished() { m_artistsFilterCmd = 0; - if ( qobject_cast< Tomahawk::TreeProxyModelPlaylistInterface* >( m_playlistInterface.data() )->vanillaFilter() != m_filter ) - { - emit filterChanged( m_filter ); - } - - qobject_cast< Tomahawk::TreeProxyModelPlaylistInterface* >( m_playlistInterface )->setVanillaFilter( m_filter ); setFilterRegExp( m_filter ); - - qobject_cast< Tomahawk::TreeProxyModelPlaylistInterface* >( m_playlistInterface )->sendTrackCount(); - + emit filterChanged( m_filter ); emit filteringFinished(); } diff --git a/src/libtomahawk/playlist/TreeProxyModel.h b/src/libtomahawk/playlist/TreeProxyModel.h index bca8676b0..ef49a702a 100644 --- a/src/libtomahawk/playlist/TreeProxyModel.h +++ b/src/libtomahawk/playlist/TreeProxyModel.h @@ -42,11 +42,10 @@ public: virtual ~TreeProxyModel() {} virtual void setSourcePlayableModel( TreeModel* model ); - - virtual void newFilterFromPlaylistInterface( const QString& pattern ); - virtual Tomahawk::playlistinterface_ptr playlistInterface(); + virtual void setFilter( const QString& pattern ); + signals: protected: