mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 23:57:34 +02:00
* Added LoadingSpinner support to ArtistView / TreeModel.
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
|
||||||
#include "audio/audioengine.h"
|
#include "audio/audioengine.h"
|
||||||
|
#include "dynamic/widgets/LoadingSpinner.h"
|
||||||
|
|
||||||
#include "tomahawksettings.h"
|
#include "tomahawksettings.h"
|
||||||
#include "treeheader.h"
|
#include "treeheader.h"
|
||||||
@@ -44,6 +45,7 @@ ArtistView::ArtistView( QWidget* parent )
|
|||||||
, m_model( 0 )
|
, m_model( 0 )
|
||||||
, m_proxyModel( 0 )
|
, m_proxyModel( 0 )
|
||||||
// , m_delegate( 0 )
|
// , m_delegate( 0 )
|
||||||
|
, m_loadingSpinner( new LoadingSpinner( this ) )
|
||||||
{
|
{
|
||||||
setAlternatingRowColors( true );
|
setAlternatingRowColors( true );
|
||||||
setDragEnabled( true );
|
setDragEnabled( true );
|
||||||
@@ -108,6 +110,9 @@ ArtistView::setModel( TreeModel* model )
|
|||||||
m_proxyModel->sort( 0 );
|
m_proxyModel->sort( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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( false );
|
setAcceptDrops( false );
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
class TreeHeader;
|
class TreeHeader;
|
||||||
|
class LoadingSpinner;
|
||||||
|
|
||||||
class DLLEXPORT ArtistView : public QTreeView, public Tomahawk::ViewPage
|
class DLLEXPORT ArtistView : public QTreeView, public Tomahawk::ViewPage
|
||||||
{
|
{
|
||||||
@@ -80,6 +81,8 @@ private:
|
|||||||
TreeProxyModel* m_proxyModel;
|
TreeProxyModel* m_proxyModel;
|
||||||
// PlaylistItemDelegate* m_delegate;
|
// PlaylistItemDelegate* m_delegate;
|
||||||
|
|
||||||
|
LoadingSpinner* m_loadingSpinner;
|
||||||
|
|
||||||
QTimer m_timer;
|
QTimer m_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -82,6 +82,7 @@ private slots:
|
|||||||
void onFilterChanged( const QString& filter );
|
void onFilterChanged( const QString& filter );
|
||||||
|
|
||||||
void copyLink();
|
void copyLink();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_guid;
|
QString m_guid;
|
||||||
TrackModel* m_model;
|
TrackModel* m_model;
|
||||||
|
@@ -361,6 +361,7 @@ TreeModel::addAllCollections()
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
emit loadingStarted();
|
||||||
DatabaseCommand_AllArtists* cmd = new DatabaseCommand_AllArtists();
|
DatabaseCommand_AllArtists* cmd = new DatabaseCommand_AllArtists();
|
||||||
|
|
||||||
connect( cmd, SIGNAL( artists( QList<Tomahawk::artist_ptr> ) ),
|
connect( cmd, SIGNAL( artists( QList<Tomahawk::artist_ptr> ) ),
|
||||||
@@ -377,6 +378,7 @@ TreeModel::addAlbums( const artist_ptr& artist, const QModelIndex& parent )
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
emit loadingStarted();
|
||||||
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( m_collection, artist );
|
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( m_collection, artist );
|
||||||
cmd->setData( parent.row() );
|
cmd->setData( parent.row() );
|
||||||
|
|
||||||
@@ -392,6 +394,7 @@ TreeModel::addTracks( const album_ptr& album, const QModelIndex& parent )
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
emit loadingStarted();
|
||||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_collection );
|
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_collection );
|
||||||
cmd->setAlbum( album.data() );
|
cmd->setAlbum( album.data() );
|
||||||
// cmd->setArtist( album->artist().data() );
|
// cmd->setArtist( album->artist().data() );
|
||||||
@@ -479,6 +482,7 @@ TreeModel::onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists )
|
|||||||
|
|
||||||
emit endInsertRows();
|
emit endInsertRows();
|
||||||
qDebug() << rowCount( QModelIndex() );
|
qDebug() << rowCount( QModelIndex() );
|
||||||
|
emit loadingFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -525,6 +529,7 @@ TreeModel::onAlbumsAdded( const QList<Tomahawk::album_ptr>& albums, const QVaria
|
|||||||
emit dataChanged( albumitem->index, albumitem->index.sibling( albumitem->index.row(), columnCount( QModelIndex() ) - 1 ) );
|
emit dataChanged( albumitem->index, albumitem->index.sibling( albumitem->index.row(), columnCount( QModelIndex() ) - 1 ) );
|
||||||
|
|
||||||
qDebug() << rowCount( parent );
|
qDebug() << rowCount( parent );
|
||||||
|
emit loadingFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -566,6 +571,7 @@ TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QVaria
|
|||||||
emit dataChanged( item->index, item->index.sibling( item->index.row(), columnCount( QModelIndex() ) - 1 ) );
|
emit dataChanged( item->index, item->index.sibling( item->index.row(), columnCount( QModelIndex() ) - 1 ) );
|
||||||
|
|
||||||
qDebug() << rowCount( parent );
|
qDebug() << rowCount( parent );
|
||||||
|
emit loadingFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -110,6 +110,9 @@ signals:
|
|||||||
|
|
||||||
void trackCountChanged( unsigned int tracks );
|
void trackCountChanged( unsigned int tracks );
|
||||||
|
|
||||||
|
void loadingStarted();
|
||||||
|
void loadingFinished();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool canFetchMore( const QModelIndex& parent ) const;
|
bool canFetchMore( const QModelIndex& parent ) const;
|
||||||
void fetchMore( const QModelIndex& parent );
|
void fetchMore( const QModelIndex& parent );
|
||||||
|
Reference in New Issue
Block a user