mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 08:34:34 +02:00
move loading spinner to each trackview
This commit is contained in:
@@ -51,19 +51,17 @@ CollectionFlatModel::addCollections( const QList< collection_ptr >& collections
|
|||||||
qDebug() << Q_FUNC_INFO << "Adding collections!";
|
qDebug() << Q_FUNC_INFO << "Adding collections!";
|
||||||
foreach( const collection_ptr& col, collections )
|
foreach( const collection_ptr& col, collections )
|
||||||
{
|
{
|
||||||
if( !col->isLoaded() )
|
|
||||||
m_loadingCollections << col.data();
|
|
||||||
|
|
||||||
addCollection( col );
|
addCollection( col );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_loadingCollections.isEmpty() )
|
// we are waiting for some to load
|
||||||
emit doneLoadingCollections();
|
if( !m_loadingCollections.isEmpty() )
|
||||||
|
emit loadingStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CollectionFlatModel::addCollection( const collection_ptr& collection )
|
CollectionFlatModel::addCollection( const collection_ptr& collection, bool sendNotifications )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << collection->name()
|
qDebug() << Q_FUNC_INFO << collection->name()
|
||||||
<< collection->source()->id()
|
<< collection->source()->id()
|
||||||
@@ -81,6 +79,8 @@ CollectionFlatModel::addCollection( const collection_ptr& collection )
|
|||||||
collection->tracks(); // data will arrive via signals
|
collection->tracks(); // data will arrive via signals
|
||||||
|
|
||||||
m_loadingCollections << collection.data();
|
m_loadingCollections << collection.data();
|
||||||
|
if( sendNotifications )
|
||||||
|
emit loadingStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( collection->source()->isLocal() )
|
if ( collection->source()->isLocal() )
|
||||||
@@ -191,7 +191,7 @@ CollectionFlatModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
|||||||
m_loadingCollections.removeAll( qobject_cast< Collection* >( sender() ) );
|
m_loadingCollections.removeAll( qobject_cast< Collection* >( sender() ) );
|
||||||
}
|
}
|
||||||
if( m_loadingCollections.isEmpty() )
|
if( m_loadingCollections.isEmpty() )
|
||||||
emit doneLoadingCollections();
|
emit loadingFinished();
|
||||||
|
|
||||||
bool kickOff = m_tracksToAdd.isEmpty();
|
bool kickOff = m_tracksToAdd.isEmpty();
|
||||||
m_tracksToAdd << tracks;
|
m_tracksToAdd << tracks;
|
||||||
|
@@ -36,7 +36,7 @@ public:
|
|||||||
|
|
||||||
void addCollections( const QList< Tomahawk::collection_ptr >& collections );
|
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 removeCollection( const Tomahawk::collection_ptr& collection );
|
||||||
|
|
||||||
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllTracks::SortOrder order );
|
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 itemSizeChanged( const QModelIndex& index );
|
||||||
|
|
||||||
void doneLoadingCollections();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDataChanged();
|
void onDataChanged();
|
||||||
|
|
||||||
|
@@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
#include "widgets/welcomewidget.h"
|
#include "widgets/welcomewidget.h"
|
||||||
#include "widgets/infowidgets/sourceinfowidget.h"
|
#include "widgets/infowidgets/sourceinfowidget.h"
|
||||||
#include "dynamic/widgets/LoadingSpinner.h"
|
|
||||||
|
|
||||||
#define FILTER_TIMEOUT 280
|
#define FILTER_TIMEOUT 280
|
||||||
|
|
||||||
@@ -48,7 +47,6 @@ PlaylistManager::PlaylistManager( QObject* parent )
|
|||||||
, m_widget( new QWidget() )
|
, m_widget( new QWidget() )
|
||||||
, m_welcomeWidget( new WelcomeWidget() )
|
, m_welcomeWidget( new WelcomeWidget() )
|
||||||
, m_currentMode( 0 )
|
, m_currentMode( 0 )
|
||||||
, m_loadingSpinner( 0 )
|
|
||||||
{
|
{
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
|
|
||||||
@@ -101,9 +99,6 @@ PlaylistManager::PlaylistManager( QObject* parent )
|
|||||||
m_widget->layout()->setMargin( 0 );
|
m_widget->layout()->setMargin( 0 );
|
||||||
m_widget->layout()->setSpacing( 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_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
|
||||||
|
|
||||||
connect( m_topbar, SIGNAL( filterTextChanged( QString ) ),
|
connect( m_topbar, SIGNAL( filterTextChanged( QString ) ),
|
||||||
@@ -256,8 +251,6 @@ PlaylistManager::show( const Tomahawk::collection_ptr& collection )
|
|||||||
view->setFrameShape( QFrame::NoFrame );
|
view->setFrameShape( QFrame::NoFrame );
|
||||||
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||||
|
|
||||||
m_loadingSpinner->fadeIn();
|
|
||||||
connect( model, SIGNAL( doneLoadingCollections() ), m_loadingSpinner, SLOT( fadeOut() ) );
|
|
||||||
model->addCollection( collection );
|
model->addCollection( collection );
|
||||||
|
|
||||||
m_collectionViews.insert( collection, view );
|
m_collectionViews.insert( collection, view );
|
||||||
@@ -339,18 +332,13 @@ PlaylistManager::showSuperCollection()
|
|||||||
QList< collection_ptr > toAdd;
|
QList< collection_ptr > toAdd;
|
||||||
foreach( const Tomahawk::source_ptr& source, SourceList::instance()->sources() )
|
foreach( const Tomahawk::source_ptr& source, SourceList::instance()->sources() )
|
||||||
{
|
{
|
||||||
bool addedStuff = false;
|
|
||||||
if ( !m_superCollections.contains( source->collection() ) )
|
if ( !m_superCollections.contains( source->collection() ) )
|
||||||
{
|
{
|
||||||
m_superCollections.append( source->collection() );
|
m_superCollections.append( source->collection() );
|
||||||
toAdd << source->collection();
|
toAdd << source->collection();
|
||||||
m_superAlbumModel->addCollection( source->collection() );
|
m_superAlbumModel->addCollection( source->collection() );
|
||||||
addedStuff = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( addedStuff )
|
|
||||||
m_loadingSpinner->fadeIn();
|
|
||||||
|
|
||||||
m_superCollectionFlatModel->setTitle( tr( "All available tracks" ) );
|
m_superCollectionFlatModel->setTitle( tr( "All available tracks" ) );
|
||||||
m_superAlbumModel->setTitle( tr( "All available albums" ) );
|
m_superAlbumModel->setTitle( tr( "All available albums" ) );
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
class LoadingSpinner;
|
|
||||||
class AnimatedSplitter;
|
class AnimatedSplitter;
|
||||||
class AlbumModel;
|
class AlbumModel;
|
||||||
class AlbumView;
|
class AlbumView;
|
||||||
@@ -144,7 +143,6 @@ private:
|
|||||||
CollectionFlatModel* m_superCollectionFlatModel;
|
CollectionFlatModel* m_superCollectionFlatModel;
|
||||||
CollectionView* m_superCollectionView;
|
CollectionView* m_superCollectionView;
|
||||||
WelcomeWidget* m_welcomeWidget;
|
WelcomeWidget* m_welcomeWidget;
|
||||||
LoadingSpinner* m_loadingSpinner;
|
|
||||||
|
|
||||||
QList< Tomahawk::collection_ptr > m_superCollections;
|
QList< Tomahawk::collection_ptr > m_superCollections;
|
||||||
|
|
||||||
|
@@ -70,6 +70,8 @@ signals:
|
|||||||
|
|
||||||
void trackCountChanged( unsigned int tracks );
|
void trackCountChanged( unsigned int tracks );
|
||||||
|
|
||||||
|
void loadingStarted();
|
||||||
|
void loadingFinished();
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setCurrentItem( const QModelIndex& index );
|
virtual void setCurrentItem( const QModelIndex& index );
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
#include "audio/audioengine.h"
|
#include "audio/audioengine.h"
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
#include "widgets/overlaywidget.h"
|
#include "widgets/overlaywidget.h"
|
||||||
|
#include "dynamic/widgets/LoadingSpinner.h"
|
||||||
|
|
||||||
#include "trackheader.h"
|
#include "trackheader.h"
|
||||||
#include "playlistmanager.h"
|
#include "playlistmanager.h"
|
||||||
@@ -25,6 +26,7 @@ TrackView::TrackView( QWidget* parent )
|
|||||||
, m_delegate( 0 )
|
, m_delegate( 0 )
|
||||||
, m_header( new TrackHeader( this ) )
|
, m_header( new TrackHeader( this ) )
|
||||||
, m_overlay( new OverlayWidget( this ) )
|
, m_overlay( new OverlayWidget( this ) )
|
||||||
|
, m_loadingSpinner( new LoadingSpinner( this ) )
|
||||||
, m_resizing( false )
|
, m_resizing( false )
|
||||||
{
|
{
|
||||||
setSortingEnabled( false );
|
setSortingEnabled( false );
|
||||||
@@ -92,6 +94,9 @@ TrackView::setModel( TrackModel* model )
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect( m_model, SIGNAL( itemSizeChanged( QModelIndex ) ), SLOT( onItemResized( QModelIndex ) ) );
|
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 ) ) );
|
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
||||||
|
|
||||||
setAcceptDrops( true );
|
setAcceptDrops( true );
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
class LoadingSpinner;
|
||||||
class PlaylistInterface;
|
class PlaylistInterface;
|
||||||
class TrackHeader;
|
class TrackHeader;
|
||||||
class TrackModel;
|
class TrackModel;
|
||||||
@@ -67,6 +68,7 @@ private:
|
|||||||
PlaylistItemDelegate* m_delegate;
|
PlaylistItemDelegate* m_delegate;
|
||||||
TrackHeader* m_header;
|
TrackHeader* m_header;
|
||||||
OverlayWidget* m_overlay;
|
OverlayWidget* m_overlay;
|
||||||
|
LoadingSpinner* m_loadingSpinner;
|
||||||
|
|
||||||
bool m_resizing;
|
bool m_resizing;
|
||||||
bool m_dragging;
|
bool m_dragging;
|
||||||
|
Reference in New Issue
Block a user