1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-20 16:02:07 +02:00

move loading spinner to each trackview

This commit is contained in:
Leo Franchi 2011-03-17 19:52:12 -04:00
parent 9934b6e1d4
commit 9f7e1b5f75
7 changed files with 17 additions and 24 deletions

View File

@ -51,19 +51,17 @@ CollectionFlatModel::addCollections( const QList< collection_ptr >& collections
qDebug() << Q_FUNC_INFO << "Adding collections!";
foreach( const collection_ptr& col, collections )
{
if( !col->isLoaded() )
m_loadingCollections << col.data();
addCollection( col );
}
if( m_loadingCollections.isEmpty() )
emit doneLoadingCollections();
// we are waiting for some to load
if( !m_loadingCollections.isEmpty() )
emit loadingStarted();
}
void
CollectionFlatModel::addCollection( const collection_ptr& collection )
CollectionFlatModel::addCollection( const collection_ptr& collection, bool sendNotifications )
{
qDebug() << Q_FUNC_INFO << collection->name()
<< collection->source()->id()
@ -81,6 +79,8 @@ CollectionFlatModel::addCollection( const collection_ptr& collection )
collection->tracks(); // data will arrive via signals
m_loadingCollections << collection.data();
if( sendNotifications )
emit loadingStarted();
}
if ( collection->source()->isLocal() )
@ -191,7 +191,7 @@ CollectionFlatModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
m_loadingCollections.removeAll( qobject_cast< Collection* >( sender() ) );
}
if( m_loadingCollections.isEmpty() )
emit doneLoadingCollections();
emit loadingFinished();
bool kickOff = m_tracksToAdd.isEmpty();
m_tracksToAdd << tracks;

View File

@ -36,7 +36,7 @@ public:
void addCollections( const QList< Tomahawk::collection_ptr >& collections );
void addCollection( const Tomahawk::collection_ptr& collection );
void addCollection( const Tomahawk::collection_ptr& collection, bool sendNotifications = true );
void removeCollection( const Tomahawk::collection_ptr& collection );
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllTracks::SortOrder order );
@ -49,8 +49,6 @@ signals:
void itemSizeChanged( const QModelIndex& index );
void doneLoadingCollections();
private slots:
void onDataChanged();

View File

@ -27,7 +27,6 @@
#include "widgets/welcomewidget.h"
#include "widgets/infowidgets/sourceinfowidget.h"
#include "dynamic/widgets/LoadingSpinner.h"
#define FILTER_TIMEOUT 280
@ -48,7 +47,6 @@ PlaylistManager::PlaylistManager( QObject* parent )
, m_widget( new QWidget() )
, m_welcomeWidget( new WelcomeWidget() )
, m_currentMode( 0 )
, m_loadingSpinner( 0 )
{
s_instance = this;
@ -101,9 +99,6 @@ PlaylistManager::PlaylistManager( QObject* parent )
m_widget->layout()->setMargin( 0 );
m_widget->layout()->setSpacing( 0 );
m_loadingSpinner = new LoadingSpinner( m_widget );
connect( m_superCollectionFlatModel, SIGNAL( doneLoadingCollections() ), m_loadingSpinner, SLOT( fadeOut() ) );
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
connect( m_topbar, SIGNAL( filterTextChanged( QString ) ),
@ -256,8 +251,6 @@ PlaylistManager::show( const Tomahawk::collection_ptr& collection )
view->setFrameShape( QFrame::NoFrame );
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
m_loadingSpinner->fadeIn();
connect( model, SIGNAL( doneLoadingCollections() ), m_loadingSpinner, SLOT( fadeOut() ) );
model->addCollection( collection );
m_collectionViews.insert( collection, view );
@ -339,18 +332,13 @@ 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" ) );
}

View File

@ -11,7 +11,6 @@
#include "dllmacro.h"
class LoadingSpinner;
class AnimatedSplitter;
class AlbumModel;
class AlbumView;
@ -144,7 +143,6 @@ private:
CollectionFlatModel* m_superCollectionFlatModel;
CollectionView* m_superCollectionView;
WelcomeWidget* m_welcomeWidget;
LoadingSpinner* m_loadingSpinner;
QList< Tomahawk::collection_ptr > m_superCollections;

View File

@ -70,6 +70,8 @@ signals:
void trackCountChanged( unsigned int tracks );
void loadingStarted();
void loadingFinished();
public slots:
virtual void setCurrentItem( const QModelIndex& index );

View File

@ -8,6 +8,7 @@
#include "audio/audioengine.h"
#include "utils/tomahawkutils.h"
#include "widgets/overlaywidget.h"
#include "dynamic/widgets/LoadingSpinner.h"
#include "trackheader.h"
#include "playlistmanager.h"
@ -25,6 +26,7 @@ TrackView::TrackView( QWidget* parent )
, m_delegate( 0 )
, m_header( new TrackHeader( this ) )
, m_overlay( new OverlayWidget( this ) )
, m_loadingSpinner( new LoadingSpinner( this ) )
, m_resizing( false )
{
setSortingEnabled( false );
@ -92,6 +94,9 @@ TrackView::setModel( TrackModel* model )
}
connect( m_model, SIGNAL( itemSizeChanged( QModelIndex ) ), SLOT( onItemResized( QModelIndex ) ) );
connect( m_model, SIGNAL( loadingStarted() ), m_loadingSpinner, SLOT( fadeIn() ) );
connect( m_model, SIGNAL( loadingFinished() ), m_loadingSpinner, SLOT( fadeOut() ) );
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
setAcceptDrops( true );

View File

@ -8,6 +8,7 @@
#include "dllmacro.h"
class LoadingSpinner;
class PlaylistInterface;
class TrackHeader;
class TrackModel;
@ -67,6 +68,7 @@ private:
PlaylistItemDelegate* m_delegate;
TrackHeader* m_header;
OverlayWidget* m_overlay;
LoadingSpinner* m_loadingSpinner;
bool m_resizing;
bool m_dragging;