diff --git a/src/libtomahawk/playlist/collectionflatmodel.cpp b/src/libtomahawk/playlist/collectionflatmodel.cpp index 8268df1fb..5cbf2ab56 100644 --- a/src/libtomahawk/playlist/collectionflatmodel.cpp +++ b/src/libtomahawk/playlist/collectionflatmodel.cpp @@ -44,6 +44,7 @@ CollectionFlatModel::headerData( int section, Qt::Orientation orientation, int r return TrackModel::headerData( section, orientation, role ); } + void CollectionFlatModel::addCollections( const QList< collection_ptr >& collections ) { @@ -184,13 +185,14 @@ CollectionFlatModel::onTracksAdded( const QList& tracks ) { qDebug() << Q_FUNC_INFO << tracks.count() << rowCount( QModelIndex() ); - if( !m_loadingCollections.isEmpty() && sender() && qobject_cast< Collection* >( sender() ) ) { // we are keeping track and are called as a slot + if( !m_loadingCollections.isEmpty() && sender() && qobject_cast< Collection* >( sender() ) ) + { + // we are keeping track and are called as a slot m_loadingCollections.removeAll( qobject_cast< Collection* >( sender() ) ); - - if( m_loadingCollections.isEmpty() ) - emit doneLoadingCollections(); } - + if( m_loadingCollections.isEmpty() ) + emit doneLoadingCollections(); + bool kickOff = m_tracksToAdd.isEmpty(); m_tracksToAdd << tracks; diff --git a/src/libtomahawk/playlist/collectionflatmodel.h b/src/libtomahawk/playlist/collectionflatmodel.h index 5e32ce030..9eeafee52 100644 --- a/src/libtomahawk/playlist/collectionflatmodel.h +++ b/src/libtomahawk/playlist/collectionflatmodel.h @@ -35,7 +35,7 @@ public: QVariant headerData( int section, Qt::Orientation orientation, int role ) const; void addCollections( const QList< Tomahawk::collection_ptr >& collections ); - + void addCollection( const Tomahawk::collection_ptr& collection ); void removeCollection( const Tomahawk::collection_ptr& collection ); @@ -50,6 +50,7 @@ signals: void itemSizeChanged( const QModelIndex& index ); void doneLoadingCollections(); + private slots: void onDataChanged(); diff --git a/src/libtomahawk/playlist/playlistmanager.cpp b/src/libtomahawk/playlist/playlistmanager.cpp index 158de0f12..9de989a64 100644 --- a/src/libtomahawk/playlist/playlistmanager.cpp +++ b/src/libtomahawk/playlist/playlistmanager.cpp @@ -255,10 +255,10 @@ PlaylistManager::show( const Tomahawk::collection_ptr& collection ) view->setModel( model ); view->setFrameShape( QFrame::NoFrame ); view->setAttribute( Qt::WA_MacShowFocusRect, 0 ); - model->addCollection( collection ); - + m_loadingSpinner->fadeIn(); connect( model, SIGNAL( doneLoadingCollections() ), m_loadingSpinner, SLOT( fadeOut() ) ); + model->addCollection( collection ); m_collectionViews.insert( collection, view ); } @@ -339,18 +339,23 @@ PlaylistManager::showSuperCollection() QList< collection_ptr > toAdd; foreach( const Tomahawk::source_ptr& source, SourceList::instance()->sources() ) { + bool addedStuff = false; if ( !m_superCollections.contains( source->collection() ) ) { m_superCollections.append( source->collection() ); toAdd << source->collection(); m_superAlbumModel->addCollection( source->collection() ); + addedStuff = true; } + if ( addedStuff ) + m_loadingSpinner->fadeIn(); + m_superCollectionFlatModel->setTitle( tr( "All available tracks" ) ); m_superAlbumModel->setTitle( tr( "All available albums" ) ); } m_superCollectionFlatModel->addCollections( toAdd ); - + if ( m_currentMode == 0 ) { setPage( m_superCollectionView ); @@ -359,9 +364,7 @@ PlaylistManager::showSuperCollection() { setPage( m_superAlbumView ); } - - m_loadingSpinner->fadeIn(); - + emit numSourcesChanged( m_superCollections.count() ); return true;