diff --git a/src/libtomahawk/playlist/albummodel.cpp b/src/libtomahawk/playlist/albummodel.cpp index 7c629777d..5662d5036 100644 --- a/src/libtomahawk/playlist/albummodel.cpp +++ b/src/libtomahawk/playlist/albummodel.cpp @@ -254,6 +254,8 @@ AlbumModel::addCollection( const collection_ptr& collection, bool overwrite ) Database::instance()->enqueue( QSharedPointer( cmd ) ); m_title = tr( "All albums from %1" ).arg( collection->source()->friendlyName() ); + + emit loadingStarted(); } @@ -280,6 +282,8 @@ AlbumModel::addFilteredCollection( const collection_ptr& collection, unsigned in m_title = tr( "All albums from %1" ).arg( collection->source()->friendlyName() ); else m_title = tr( "All albums" ); + + emit loadingStarted(); } @@ -292,6 +296,8 @@ AlbumModel::addAlbums( const QList& albums ) if ( m_overwriteOnAdd ) clear(); + emit loadingFinished(); + int c = rowCount( QModelIndex() ); QPair< int, int > crows; crows.first = c; diff --git a/src/libtomahawk/playlist/albummodel.h b/src/libtomahawk/playlist/albummodel.h index 596bf5f42..6a73124ac 100644 --- a/src/libtomahawk/playlist/albummodel.h +++ b/src/libtomahawk/playlist/albummodel.h @@ -94,6 +94,8 @@ signals: void trackCountChanged( unsigned int tracks ); + void loadingStarted(); + void loadingFinished(); private slots: void onDataChanged(); diff --git a/src/libtomahawk/playlist/albumview.cpp b/src/libtomahawk/playlist/albumview.cpp index a077ffa4a..4718bdf41 100644 --- a/src/libtomahawk/playlist/albumview.cpp +++ b/src/libtomahawk/playlist/albumview.cpp @@ -32,6 +32,7 @@ #include "albummodel.h" #include "viewmanager.h" #include "utils/logger.h" +#include "dynamic/widgets/LoadingSpinner.h" #define SCROLL_TIMEOUT 280 @@ -42,7 +43,7 @@ AlbumView::AlbumView( QWidget* parent ) : QListView( parent ) , m_model( 0 ) , m_proxyModel( 0 ) -// , m_delegate( 0 ) + , m_loadingSpinner( new LoadingSpinner( this ) ) { setDragEnabled( true ); setDropIndicatorShown( false ); @@ -109,6 +110,9 @@ 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( loadingStarted() ), m_loadingSpinner, SLOT( fadeIn() ) ); + connect( m_model, SIGNAL( loadingFinished() ), m_loadingSpinner, SLOT( fadeOut() ) ); + setAcceptDrops( false ); onViewChanged(); // Fetch covers if albums were added to model before model was attached to view } diff --git a/src/libtomahawk/playlist/albumview.h b/src/libtomahawk/playlist/albumview.h index 68736c55e..d590bc050 100644 --- a/src/libtomahawk/playlist/albumview.h +++ b/src/libtomahawk/playlist/albumview.h @@ -28,6 +28,7 @@ #include "albumproxymodel.h" class AlbumModel; +class LoadingSpinner; class DLLEXPORT AlbumView : public QListView, public Tomahawk::ViewPage { @@ -74,7 +75,7 @@ private slots: private: AlbumModel* m_model; AlbumProxyModel* m_proxyModel; -// PlaylistItemDelegate* m_delegate; + LoadingSpinner* m_loadingSpinner; QTimer m_timer; }; diff --git a/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.cpp b/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.cpp index d7f12f7f3..83b739954 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010 Leo Franchi * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,6 +58,9 @@ LoadingSpinner::~LoadingSpinner() void LoadingSpinner::fadeIn() { + if ( isVisible() ) + return; + show(); m_anim->start(); @@ -71,6 +74,9 @@ LoadingSpinner::fadeIn() void LoadingSpinner::fadeOut() { + if ( !isVisible() ) + return; + m_showHide->setDirection( QTimeLine::Backward ); if ( m_showHide->state() != QTimeLine::Running ) diff --git a/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.h b/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.h index 5720df34c..c2602cfa2 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.h +++ b/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.h @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010 Leo Franchi * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by