diff --git a/src/libtomahawk/playlist/albumproxymodel.cpp b/src/libtomahawk/playlist/albumproxymodel.cpp index 97f2130c7..c3b3fe29c 100644 --- a/src/libtomahawk/playlist/albumproxymodel.cpp +++ b/src/libtomahawk/playlist/albumproxymodel.cpp @@ -41,15 +41,18 @@ AlbumProxyModel::AlbumProxyModel( QObject* parent ) setSourceModel( 0 ); } - void AlbumProxyModel::setSourceModel( QAbstractItemModel* sourceModel ) { - AlbumModel* amodel = static_cast< AlbumModel* >( sourceModel ); - if( !amodel ) - return; - else - m_model = amodel; + Q_UNUSED( sourceModel ); + qDebug() << "Explicitly use setSourceAlbumModel instead"; + Q_ASSERT( false ); +} + +void +AlbumProxyModel::setSourceAlbumModel( AlbumModel* sourceModel ) +{ + m_model = sourceModel; connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SIGNAL( sourceTrackCountChanged( unsigned int ) ) ); diff --git a/src/libtomahawk/playlist/albumproxymodel.h b/src/libtomahawk/playlist/albumproxymodel.h index 87535bbb1..7427cc85f 100644 --- a/src/libtomahawk/playlist/albumproxymodel.h +++ b/src/libtomahawk/playlist/albumproxymodel.h @@ -34,6 +34,7 @@ public: explicit AlbumProxyModel( QObject* parent = 0 ); virtual AlbumModel* sourceModel() const { return m_model; } + virtual void setSourceAlbumModel( AlbumModel* sourceModel ); virtual void setSourceModel( QAbstractItemModel* sourceModel ); virtual QList tracks() { Q_ASSERT( FALSE ); QList queries; return queries; } diff --git a/src/libtomahawk/playlist/albumview.cpp b/src/libtomahawk/playlist/albumview.cpp index 4d652d1f4..9f6ad1a57 100644 --- a/src/libtomahawk/playlist/albumview.cpp +++ b/src/libtomahawk/playlist/albumview.cpp @@ -74,16 +74,20 @@ AlbumView::setProxyModel( AlbumProxyModel* model ) void AlbumView::setModel( QAbstractItemModel* model ) { - AlbumModel *amodel = static_cast< AlbumModel* >( model ); + Q_UNUSED( model ); + qDebug() << "Explicitly use setAlbumModel instead"; + Q_ASSERT( false ); +} - if ( !amodel ) - return; - else - m_model = amodel; + +void +AlbumView::setAlbumModel( AlbumModel* model ) +{ + m_model = model; if ( m_proxyModel ) { - m_proxyModel->setSourceModel( model ); + m_proxyModel->setSourceModel( m_model ); m_proxyModel->sort( 0 ); } @@ -147,6 +151,7 @@ AlbumView::onFilterChanged( const QString& ) void AlbumView::startDrag( Qt::DropActions supportedActions ) { + Q_UNUSED( supportedActions ); } @@ -154,5 +159,6 @@ AlbumView::startDrag( Qt::DropActions supportedActions ) QPixmap AlbumView::createDragPixmap( int itemCount ) const { + Q_UNUSED( itemCount ); return QPixmap(); } diff --git a/src/libtomahawk/playlist/albumview.h b/src/libtomahawk/playlist/albumview.h index 013cb349a..194eab8d7 100644 --- a/src/libtomahawk/playlist/albumview.h +++ b/src/libtomahawk/playlist/albumview.h @@ -42,6 +42,7 @@ public: AlbumProxyModel* proxyModel() const { return m_proxyModel; } // PlaylistItemDelegate* delegate() { return m_delegate; } + void setAlbumModel( AlbumModel* model ); void setModel( QAbstractItemModel* model ); virtual QWidget* widget() { return this; } diff --git a/src/libtomahawk/playlist/collectionview.cpp b/src/libtomahawk/playlist/collectionview.cpp index e5a72cd19..9f3b439ef 100644 --- a/src/libtomahawk/playlist/collectionview.cpp +++ b/src/libtomahawk/playlist/collectionview.cpp @@ -53,14 +53,18 @@ CollectionView::~CollectionView() void CollectionView::setModel( QAbstractItemModel* model ) { - TrackModel *tmodel = static_cast< TrackModel* >( model ); - if ( !tmodel ) - return; + qDebug() << "Explicitly use setTrackModel instead"; + Q_ASSERT( false ); +} - TrackView::setModel( tmodel ); + +void +CollectionView::setTrackModel( TrackModel* model ) +{ + TrackView::setModel( model ); setGuid( "collectionview" ); - connect( tmodel, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) ); + connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) ); } diff --git a/src/libtomahawk/playlist/collectionview.h b/src/libtomahawk/playlist/collectionview.h index 54fa0b47a..1fe261646 100644 --- a/src/libtomahawk/playlist/collectionview.h +++ b/src/libtomahawk/playlist/collectionview.h @@ -36,6 +36,7 @@ public: explicit CollectionView( QWidget* parent = 0 ); ~CollectionView(); + virtual void setTrackModel( TrackModel* model ); virtual void setModel( QAbstractItemModel* model ); virtual QWidget* widget() { return this; } diff --git a/src/libtomahawk/playlist/dynamic/DynamicView.cpp b/src/libtomahawk/playlist/dynamic/DynamicView.cpp index 05b2c9c9d..85b87aa53 100644 --- a/src/libtomahawk/playlist/dynamic/DynamicView.cpp +++ b/src/libtomahawk/playlist/dynamic/DynamicView.cpp @@ -71,13 +71,13 @@ DynamicView::~DynamicView() } void -DynamicView::setModel( DynamicModel* model) +DynamicView::setDynamicModel( DynamicModel* model) { m_model = model; - PlaylistView::setModel( model ); + PlaylistView::setModel( m_model ); - connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) ); - connect( model, SIGNAL( checkForOverflow() ), this, SLOT( checkForOverflow() ) ); + connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) ); + connect( m_model, SIGNAL( checkForOverflow() ), this, SLOT( checkForOverflow() ) ); } void diff --git a/src/libtomahawk/playlist/dynamic/DynamicView.h b/src/libtomahawk/playlist/dynamic/DynamicView.h index 3ea371d3a..39826fe97 100644 --- a/src/libtomahawk/playlist/dynamic/DynamicView.h +++ b/src/libtomahawk/playlist/dynamic/DynamicView.h @@ -40,7 +40,7 @@ public: explicit DynamicView( QWidget* parent = 0 ); virtual ~DynamicView(); - virtual void setModel( DynamicModel* model ); + virtual void setDynamicModel( DynamicModel* model ); void setOnDemand( bool onDemand ); void setReadOnly( bool readOnly ); diff --git a/src/libtomahawk/playlist/playlistview.cpp b/src/libtomahawk/playlist/playlistview.cpp index e6a06ea0c..0ba3373db 100644 --- a/src/libtomahawk/playlist/playlistview.cpp +++ b/src/libtomahawk/playlist/playlistview.cpp @@ -47,14 +47,18 @@ PlaylistView::~PlaylistView() void PlaylistView::setModel( QAbstractItemModel* model ) { - PlaylistModel* pmodel = static_cast< PlaylistModel* >( model ); + Q_UNUSED( model ); + qDebug() << "Explicitly use setPlaylistModel instead"; + Q_ASSERT( false ); +} - if ( !pmodel ) - return; - else - m_model = pmodel; - TrackView::setModel( model ); +void +PlaylistView::setPlaylistModel( PlaylistModel* model ) +{ + m_model = model; + + TrackView::setModel( m_model ); setColumnHidden( 5, true ); // Hide age column per default if ( !m_model->playlist().isNull() ) diff --git a/src/libtomahawk/playlist/playlistview.h b/src/libtomahawk/playlist/playlistview.h index dbf653625..84df64805 100644 --- a/src/libtomahawk/playlist/playlistview.h +++ b/src/libtomahawk/playlist/playlistview.h @@ -39,6 +39,7 @@ public: ~PlaylistView(); PlaylistModel* playlistModel() const { return m_model; } + virtual void setPlaylistModel( PlaylistModel* model ); virtual void setModel( QAbstractItemModel* model ); virtual QWidget* widget() { return this; } diff --git a/src/libtomahawk/playlist/trackproxymodel.cpp b/src/libtomahawk/playlist/trackproxymodel.cpp index f69670057..2c11bcd6d 100644 --- a/src/libtomahawk/playlist/trackproxymodel.cpp +++ b/src/libtomahawk/playlist/trackproxymodel.cpp @@ -45,19 +45,23 @@ TrackProxyModel::TrackProxyModel( QObject* parent ) void -TrackProxyModel::setSourceModel( QAbstractItemModel* sourceModel ) +TrackProxyModel::setSourceModel( QAbstractItemModel* model ) { - TrackModel* tmodel = static_cast< TrackModel* >( sourceModel ); + Q_UNUSED( model ); + qDebug() << "Explicitly use setSourceTrackModel instead"; + Q_ASSERT( false ); +} - if ( !tmodel ) - return; - else - m_model = tmodel; + +void +TrackProxyModel::setSourceTrackModel( TrackModel* sourceModel ) +{ + m_model = sourceModel; connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SIGNAL( sourceTrackCountChanged( unsigned int ) ) ); - QSortFilterProxyModel::setSourceModel( sourceModel ); + QSortFilterProxyModel::setSourceModel( m_model ); } diff --git a/src/libtomahawk/playlist/trackproxymodel.h b/src/libtomahawk/playlist/trackproxymodel.h index ac626f0a5..853a512d8 100644 --- a/src/libtomahawk/playlist/trackproxymodel.h +++ b/src/libtomahawk/playlist/trackproxymodel.h @@ -34,7 +34,8 @@ public: explicit TrackProxyModel ( QObject* parent = 0 ); virtual TrackModel* sourceModel() const { return m_model; } - virtual void setSourceModel( QAbstractItemModel* sourceModel ); + virtual void setSourceTrackModel( TrackModel* sourceModel ); + virtual void setSourceModel( QAbstractItemModel* model ); virtual QPersistentModelIndex currentItem() const { return mapFromSource( m_model->currentItem() ); } virtual void setCurrentItem( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); } diff --git a/src/libtomahawk/playlist/trackview.cpp b/src/libtomahawk/playlist/trackview.cpp index 8b851ba33..3e7b11bef 100644 --- a/src/libtomahawk/playlist/trackview.cpp +++ b/src/libtomahawk/playlist/trackview.cpp @@ -33,6 +33,7 @@ #include "queueview.h" #include "trackmodel.h" #include "trackproxymodel.h" +#include using namespace Tomahawk; @@ -109,16 +110,20 @@ TrackView::setProxyModel( TrackProxyModel* model ) void TrackView::setModel( QAbstractItemModel* model ) { - TrackModel* tmodel = static_cast< TrackModel* >( model ); + Q_UNUSED( model ); + qDebug() << "Explicitly use setTrackModel instead"; + Q_ASSERT( false ); +} - if ( !tmodel ) - return; - else - m_model = tmodel; + +void +TrackView::setTrackModel( TrackModel* model ) +{ + m_model = model; if ( m_proxyModel ) { - m_proxyModel->setSourceModel( model ); + m_proxyModel->setSourceModel( m_model ); } connect( m_model, SIGNAL( itemSizeChanged( QModelIndex ) ), SLOT( onItemResized( QModelIndex ) ) ); diff --git a/src/libtomahawk/playlist/trackview.h b/src/libtomahawk/playlist/trackview.h index 2d9707f26..aac8b2a11 100644 --- a/src/libtomahawk/playlist/trackview.h +++ b/src/libtomahawk/playlist/trackview.h @@ -44,6 +44,7 @@ public: virtual QString guid() const { return m_guid; } virtual void setGuid( const QString& guid ); + virtual void setTrackModel( TrackModel* model ); virtual void setModel( QAbstractItemModel* model ); void setProxyModel( TrackProxyModel* model );