diff --git a/src/libtomahawk/playlist/albummodel.cpp b/src/libtomahawk/playlist/albummodel.cpp index 83e35bc73..5845855b6 100644 --- a/src/libtomahawk/playlist/albummodel.cpp +++ b/src/libtomahawk/playlist/albummodel.cpp @@ -226,6 +226,8 @@ AlbumModel::removeIndex( const QModelIndex& index ) delete item; emit endRemoveRows(); } + + emit itemCountChanged( rowCount( QModelIndex() ) ); } @@ -259,7 +261,7 @@ AlbumModel::addCollection( const collection_ptr& collection, bool overwrite ) if ( collection.isNull() ) { - connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) ); + connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ), Qt::UniqueConnection ); QList sources = SourceList::instance()->sources(); foreach ( const source_ptr& source, sources ) @@ -289,6 +291,7 @@ AlbumModel::addFilteredCollection( const collection_ptr& collection, unsigned in cmd->setSortOrder( order ); cmd->setSortDescending( true ); m_overwriteOnAdd = overwrite; + m_collection = collection; connect( cmd, SIGNAL( albums( QList, QVariant ) ), SLOT( addAlbums( QList ) ) ); @@ -313,7 +316,10 @@ AlbumModel::addAlbums( const QList& albums ) clear(); if ( !albums.count() ) + { + emit itemCountChanged( rowCount( QModelIndex() ) ); return; + } int c = rowCount( QModelIndex() ); QPair< int, int > crows; @@ -332,6 +338,7 @@ AlbumModel::addAlbums( const QList& albums ) } emit endInsertRows(); + emit itemCountChanged( rowCount( QModelIndex() ) ); } @@ -345,10 +352,7 @@ AlbumModel::onSourceAdded( const Tomahawk::source_ptr& source ) void AlbumModel::onCollectionChanged() { - if ( m_collection ) - addCollection( m_collection, true ); - else - addCollection( m_collection, true ); + addCollection( m_collection, true ); } @@ -395,7 +399,6 @@ AlbumModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, Q if ( requestData.caller != s_tmInfoIdentifier || ( requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt && requestData.type != Tomahawk::InfoSystem::InfoArtistImages ) ) { -// qDebug() << "Info of wrong type or not with our identifier"; return; } diff --git a/src/libtomahawk/playlist/albummodel.h b/src/libtomahawk/playlist/albummodel.h index 0980d97ba..099423007 100644 --- a/src/libtomahawk/playlist/albummodel.h +++ b/src/libtomahawk/playlist/albummodel.h @@ -61,6 +61,8 @@ public: virtual QStringList mimeTypes() const; virtual Qt::ItemFlags flags( const QModelIndex& index ) const; + Tomahawk::collection_ptr collection() const { return m_collection; } + void clear(); void addCollection( const Tomahawk::collection_ptr& collection, bool overwrite = false ); void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllAlbums::SortOrder order, bool overwrite = false ); @@ -92,7 +94,7 @@ signals: void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode ); void shuffleModeChanged( bool enabled ); - void trackCountChanged( unsigned int tracks ); + void itemCountChanged( unsigned int items ); void loadingStarted(); void loadingFinished(); diff --git a/src/libtomahawk/playlist/albumview.cpp b/src/libtomahawk/playlist/albumview.cpp index d0a117a95..a83130457 100644 --- a/src/libtomahawk/playlist/albumview.cpp +++ b/src/libtomahawk/playlist/albumview.cpp @@ -45,6 +45,7 @@ AlbumView::AlbumView( QWidget* parent ) , m_proxyModel( 0 ) , m_delegate( 0 ) , m_loadingSpinner( new LoadingSpinner( this ) ) + , m_overlay( new OverlayWidget( this ) ) { setDragEnabled( true ); setDropIndicatorShown( false ); @@ -111,6 +112,7 @@ AlbumView::setAlbumModel( AlbumModel* model ) connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) ); connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) ); + connect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onItemCountChanged( unsigned int ) ) ); connect( m_model, SIGNAL( loadingStarted() ), m_loadingSpinner, SLOT( fadeIn() ) ); connect( m_model, SIGNAL( loadingFinished() ), m_loadingSpinner, SLOT( fadeOut() ) ); @@ -143,6 +145,23 @@ AlbumView::onViewChanged() } +void +AlbumView::onItemCountChanged( unsigned int items ) +{ + if ( items == 0 ) + { + if ( m_model->collection().isNull() || ( !m_model->collection().isNull() && m_model->collection()->source()->isLocal() ) ) + m_overlay->setText( tr( "After you have scanned your music collection you will find your latest album additions right here." ) ); + else + m_overlay->setText( tr( "This collection doesn't have any recent albums." ) ); + + m_overlay->show(); + } + else + m_overlay->hide(); +} + + void AlbumView::onScrollTimeout() { diff --git a/src/libtomahawk/playlist/albumview.h b/src/libtomahawk/playlist/albumview.h index b16f9e898..f453ad4f8 100644 --- a/src/libtomahawk/playlist/albumview.h +++ b/src/libtomahawk/playlist/albumview.h @@ -24,8 +24,9 @@ #include #include "viewpage.h" -#include "dllmacro.h" #include "albumproxymodel.h" +#include "widgets/overlaywidget.h" +#include "dllmacro.h" class AlbumModel; class LoadingSpinner; @@ -68,6 +69,8 @@ protected: void resizeEvent( QResizeEvent* event ); private slots: + void onItemCountChanged( unsigned int items ); + void onFilterChanged( const QString& filter ); void onViewChanged(); @@ -78,6 +81,7 @@ private: AlbumProxyModel* m_proxyModel; AlbumItemDelegate* m_delegate; LoadingSpinner* m_loadingSpinner; + OverlayWidget* m_overlay; QTimer m_timer; }; diff --git a/src/libtomahawk/playlist/artistview.cpp b/src/libtomahawk/playlist/artistview.cpp index 708a97a4a..8927eb896 100644 --- a/src/libtomahawk/playlist/artistview.cpp +++ b/src/libtomahawk/playlist/artistview.cpp @@ -130,6 +130,7 @@ ArtistView::setTreeModel( TreeModel* model ) connect( m_proxyModel, SIGNAL( filteringStarted() ), SLOT( onFilteringStarted() ) ); connect( m_proxyModel, SIGNAL( filteringFinished() ), m_loadingSpinner, SLOT( fadeOut() ) ); + connect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onItemCountChanged( unsigned int ) ) ); connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) ); connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) ); @@ -167,6 +168,7 @@ ArtistView::onItemActivated( const QModelIndex& index ) } } + void ArtistView::keyPressEvent( QKeyEvent* event ) { @@ -206,6 +208,23 @@ ArtistView::resizeEvent( QResizeEvent* event ) } +void +ArtistView::onItemCountChanged( unsigned int items ) +{ + if ( items == 0 ) + { + if ( m_model->collection().isNull() || ( !m_model->collection().isNull() && m_model->collection()->source()->isLocal() ) ) + m_overlay->setText( tr( "After you have scanned your music collection you will find your tracks right here." ) ); + else + m_overlay->setText( tr( "This collection is currently empty." ) ); + + m_overlay->show(); + } + else + m_overlay->hide(); +} + + void ArtistView::onFilterChanged( const QString& ) { diff --git a/src/libtomahawk/playlist/artistview.h b/src/libtomahawk/playlist/artistview.h index 756bb8960..f53026857 100644 --- a/src/libtomahawk/playlist/artistview.h +++ b/src/libtomahawk/playlist/artistview.h @@ -81,6 +81,7 @@ protected: void keyPressEvent( QKeyEvent* event ); private slots: + void onItemCountChanged( unsigned int items ); void onFilterChanged( const QString& filter ); void onFilteringStarted(); void onViewChanged(); diff --git a/src/libtomahawk/playlist/playlistmodel.cpp b/src/libtomahawk/playlist/playlistmodel.cpp index 74d597e0f..bd2744232 100644 --- a/src/libtomahawk/playlist/playlistmodel.cpp +++ b/src/libtomahawk/playlist/playlistmodel.cpp @@ -192,9 +192,6 @@ PlaylistModel::insert( const Tomahawk::query_ptr& query, int row ) void PlaylistModel::insert( const QList< Tomahawk::query_ptr >& queries, int row ) { - if ( !queries.count() ) - return; - QList< Tomahawk::plentry_ptr > entries; foreach( const query_ptr& query, queries ) { @@ -221,7 +218,10 @@ void PlaylistModel::insert( const QList< Tomahawk::plentry_ptr >& entries, int row ) { if ( !entries.count() ) + { + emit trackCountChanged( rowCount( QModelIndex() ) ); return; + } int c = row; QPair< int, int > crows; diff --git a/src/libtomahawk/playlist/playlistview.cpp b/src/libtomahawk/playlist/playlistview.cpp index 5582c8445..2a4815b7e 100644 --- a/src/libtomahawk/playlist/playlistview.cpp +++ b/src/libtomahawk/playlist/playlistview.cpp @@ -81,7 +81,6 @@ PlaylistView::setPlaylistModel( PlaylistModel* model ) } - void PlaylistView::keyPressEvent( QKeyEvent* event ) { diff --git a/src/libtomahawk/playlist/playlistview.h b/src/libtomahawk/playlist/playlistview.h index 63424eef9..d2b1d56d9 100644 --- a/src/libtomahawk/playlist/playlistview.h +++ b/src/libtomahawk/playlist/playlistview.h @@ -52,7 +52,6 @@ public: virtual bool jumpToCurrentTrack(); virtual bool isTemporaryPage() const; - signals: void nameChanged( const QString& title ); void destroyed( QWidget* widget ); @@ -60,7 +59,6 @@ signals: protected: void keyPressEvent( QKeyEvent* event ); - private slots: void onTrackCountChanged( unsigned int tracks ); void onMenuTriggered( int action ); @@ -73,7 +71,6 @@ private: PlaylistModel* m_model; QString m_customTitle; QString m_customDescripton; - }; #endif // PLAYLISTVIEW_H diff --git a/src/libtomahawk/playlist/trackmodel.cpp b/src/libtomahawk/playlist/trackmodel.cpp index 708f8ba3e..e69c1a4b8 100644 --- a/src/libtomahawk/playlist/trackmodel.cpp +++ b/src/libtomahawk/playlist/trackmodel.cpp @@ -367,7 +367,10 @@ void TrackModel::insert( const QList< Tomahawk::query_ptr >& queries, int row ) { if ( !queries.count() ) + { + emit trackCountChanged( rowCount( QModelIndex() ) ); return; + } int c = row; QPair< int, int > crows; diff --git a/src/libtomahawk/playlist/treemodel.cpp b/src/libtomahawk/playlist/treemodel.cpp index d2ace7c54..4fb5175d3 100644 --- a/src/libtomahawk/playlist/treemodel.cpp +++ b/src/libtomahawk/playlist/treemodel.cpp @@ -568,8 +568,6 @@ TreeModel::removeIndexes( const QList& indexes ) void TreeModel::addAllCollections() { - qDebug() << Q_FUNC_INFO; - emit loadingStarted(); DatabaseCommand_AllArtists* cmd = new DatabaseCommand_AllArtists(); @@ -578,7 +576,7 @@ TreeModel::addAllCollections() Database::instance()->enqueue( QSharedPointer( cmd ) ); - connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) ); + connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ), Qt::UniqueConnection ); QList sources = SourceList::instance()->sources(); foreach ( const source_ptr& source, sources ) @@ -753,7 +751,10 @@ TreeModel::onArtistsAdded( const QList& artists ) { emit loadingFinished(); if ( !artists.count() ) + { + emit itemCountChanged( rowCount( QModelIndex() ) ); return; + } int c = rowCount( QModelIndex() ); QPair< int, int > crows; @@ -771,6 +772,7 @@ TreeModel::onArtistsAdded( const QList& artists ) } emit endInsertRows(); + emit itemCountChanged( rowCount( QModelIndex() ) ); } diff --git a/src/libtomahawk/playlist/treemodel.h b/src/libtomahawk/playlist/treemodel.h index 952ae1306..f0b9c44f1 100644 --- a/src/libtomahawk/playlist/treemodel.h +++ b/src/libtomahawk/playlist/treemodel.h @@ -132,7 +132,7 @@ signals: void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode ); void shuffleModeChanged( bool enabled ); - void trackCountChanged( unsigned int tracks ); + void itemCountChanged( unsigned int items ); void loadingStarted(); void loadingFinished();