From 79c55f1699e164453d0fc285f2ee9dd39b7a9909 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Fri, 29 Jun 2012 02:27:41 +0200 Subject: [PATCH] * Adjust inheriting models to new PlayableModel API. --- .../playlist/PlayableProxyModel.cpp | 12 ++++----- src/libtomahawk/playlist/PlayableProxyModel.h | 6 ++--- src/libtomahawk/playlist/PlaylistModel.cpp | 25 ++----------------- src/libtomahawk/playlist/PlaylistModel.h | 5 +--- .../playlist/dynamic/DynamicModel.cpp | 6 ++--- 5 files changed, 15 insertions(+), 39 deletions(-) diff --git a/src/libtomahawk/playlist/PlayableProxyModel.cpp b/src/libtomahawk/playlist/PlayableProxyModel.cpp index d4aa3d662..5efe43514 100644 --- a/src/libtomahawk/playlist/PlayableProxyModel.cpp +++ b/src/libtomahawk/playlist/PlayableProxyModel.cpp @@ -188,19 +188,19 @@ PlayableProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourcePa void -PlayableProxyModel::remove( const QModelIndex& index ) +PlayableProxyModel::removeIndex( const QModelIndex& index ) { if ( !sourceModel() ) return; if ( !index.isValid() ) return; - sourceModel()->remove( mapToSource( index ) ); + sourceModel()->removeIndex( mapToSource( index ) ); } void -PlayableProxyModel::remove( const QModelIndexList& indexes ) +PlayableProxyModel::removeIndexes( const QModelIndexList& indexes ) { if ( !sourceModel() ) return; @@ -212,12 +212,12 @@ PlayableProxyModel::remove( const QModelIndexList& indexes ) pil << mapToSource( idx ); } - sourceModel()->remove( pil ); + sourceModel()->removeIndexes( pil ); } void -PlayableProxyModel::remove( const QList< QPersistentModelIndex >& indexes ) +PlayableProxyModel::removeIndexes( const QList< QPersistentModelIndex >& indexes ) { if ( !sourceModel() ) return; @@ -229,7 +229,7 @@ PlayableProxyModel::remove( const QList< QPersistentModelIndex >& indexes ) pil << mapToSource( idx ); } - sourceModel()->remove( pil ); + sourceModel()->removeIndexes( pil ); } diff --git a/src/libtomahawk/playlist/PlayableProxyModel.h b/src/libtomahawk/playlist/PlayableProxyModel.h index 5a53ee566..dd4cf0d9d 100644 --- a/src/libtomahawk/playlist/PlayableProxyModel.h +++ b/src/libtomahawk/playlist/PlayableProxyModel.h @@ -44,9 +44,9 @@ public: virtual QPersistentModelIndex currentIndex() const { return mapFromSource( m_model->currentItem() ); } virtual void setCurrentIndex( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); } - virtual void remove( const QModelIndex& index ); - virtual void remove( const QModelIndexList& indexes ); - virtual void remove( const QList< QPersistentModelIndex >& indexes ); + virtual void removeIndex( const QModelIndex& index ); + virtual void removeIndexes( const QModelIndexList& indexes ); + virtual void removeIndexes( const QList< QPersistentModelIndex >& indexes ); virtual bool showOfflineResults() const { return m_showOfflineResults; } virtual void setShowOfflineResults( bool b ); diff --git a/src/libtomahawk/playlist/PlaylistModel.cpp b/src/libtomahawk/playlist/PlaylistModel.cpp index 7eae940c9..6f40cc161 100644 --- a/src/libtomahawk/playlist/PlaylistModel.cpp +++ b/src/libtomahawk/playlist/PlaylistModel.cpp @@ -488,14 +488,7 @@ PlaylistModel::playlistEntries() const void -PlaylistModel::remove( int row, bool moreToCome ) -{ - PlayableModel::remove( row, moreToCome ); -} - - -void -PlaylistModel::remove( const QModelIndex& index, bool moreToCome ) +PlaylistModel::removeIndex( const QModelIndex& index, bool moreToCome ) { PlayableItem* item = itemFromIndex( index ); @@ -513,27 +506,13 @@ PlaylistModel::remove( const QModelIndex& index, bool moreToCome ) if ( item && !m_isLoading ) m_savedRemoveTracks << item->query(); - PlayableModel::remove( index, moreToCome ); + PlayableModel::removeIndex( index, moreToCome ); if ( !moreToCome ) endPlaylistChanges(); } -void -PlaylistModel::remove( const QList& indexes ) -{ - PlayableModel::remove( indexes ); -} - - -void -PlaylistModel::remove( const QList& indexes ) -{ - PlayableModel::remove( indexes ); -} - - bool PlaylistModel::isTemporary() const { diff --git a/src/libtomahawk/playlist/PlaylistModel.h b/src/libtomahawk/playlist/PlaylistModel.h index e7a3341d3..9d2d4dcdb 100644 --- a/src/libtomahawk/playlist/PlaylistModel.h +++ b/src/libtomahawk/playlist/PlaylistModel.h @@ -68,10 +68,7 @@ public slots: virtual void insert( const QList< Tomahawk::query_ptr >& queries, int row = 0 ); virtual void insert( const QList< Tomahawk::plentry_ptr >& entries, int row = 0 ); - virtual void remove( int row, bool moreToCome = false ); - virtual void remove( const QModelIndex& index, bool moreToCome = false ); - virtual void remove( const QList& indexes ); - virtual void remove( const QList& indexes ); + virtual void removeIndex( const QModelIndex& index, bool moreToCome = false ); signals: void repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode ); diff --git a/src/libtomahawk/playlist/dynamic/DynamicModel.cpp b/src/libtomahawk/playlist/dynamic/DynamicModel.cpp index a75a92f86..7c0fd171b 100644 --- a/src/libtomahawk/playlist/dynamic/DynamicModel.cpp +++ b/src/libtomahawk/playlist/dynamic/DynamicModel.cpp @@ -328,7 +328,7 @@ DynamicModel::addToPlaylist( const QList< query_ptr >& entries, bool clearFirst void -DynamicModel::remove(const QModelIndex& idx, bool moreToCome) +DynamicModel::removeIndex( const QModelIndex& idx, bool moreToCome ) { if ( m_playlist->mode() == Static && isReadOnly() ) return; @@ -340,10 +340,10 @@ DynamicModel::remove(const QModelIndex& idx, bool moreToCome) { // if the user is manually removing the last one, re-add as we're a station newTrackLoading(); } - PlayableModel::remove( idx ); + PlayableModel::removeIndex( idx ); } else - PlaylistModel::remove( idx, moreToCome ); + PlaylistModel::removeIndex( idx, moreToCome ); // don't call onPlaylistChanged. if( !moreToCome )