1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 08:19:42 +01:00

* Added LoadingSpinner support to ArtistView / TreeModel.

This commit is contained in:
Christian Muehlhaeuser 2011-05-19 05:46:41 +02:00
parent f5bf6279bb
commit 9f1778a519
5 changed files with 18 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#include <QScrollBar>
#include "audio/audioengine.h"
#include "dynamic/widgets/LoadingSpinner.h"
#include "tomahawksettings.h"
#include "treeheader.h"
@ -44,6 +45,7 @@ ArtistView::ArtistView( QWidget* parent )
, m_model( 0 )
, m_proxyModel( 0 )
// , m_delegate( 0 )
, m_loadingSpinner( new LoadingSpinner( this ) )
{
setAlternatingRowColors( true );
setDragEnabled( true );
@ -108,6 +110,9 @@ ArtistView::setModel( TreeModel* model )
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 ) ) );
setAcceptDrops( false );

View File

@ -29,6 +29,7 @@
#include "dllmacro.h"
class TreeHeader;
class LoadingSpinner;
class DLLEXPORT ArtistView : public QTreeView, public Tomahawk::ViewPage
{
@ -80,6 +81,8 @@ private:
TreeProxyModel* m_proxyModel;
// PlaylistItemDelegate* m_delegate;
LoadingSpinner* m_loadingSpinner;
QTimer m_timer;
};

View File

@ -82,6 +82,7 @@ private slots:
void onFilterChanged( const QString& filter );
void copyLink();
private:
QString m_guid;
TrackModel* m_model;

View File

@ -361,6 +361,7 @@ TreeModel::addAllCollections()
{
qDebug() << Q_FUNC_INFO;
emit loadingStarted();
DatabaseCommand_AllArtists* cmd = new DatabaseCommand_AllArtists();
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;
emit loadingStarted();
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( m_collection, artist );
cmd->setData( parent.row() );
@ -392,6 +394,7 @@ TreeModel::addTracks( const album_ptr& album, const QModelIndex& parent )
{
qDebug() << Q_FUNC_INFO;
emit loadingStarted();
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_collection );
cmd->setAlbum( album.data() );
// cmd->setArtist( album->artist().data() );
@ -479,6 +482,7 @@ TreeModel::onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists )
emit endInsertRows();
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 ) );
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 ) );
qDebug() << rowCount( parent );
emit loadingFinished();
}

View File

@ -110,6 +110,9 @@ signals:
void trackCountChanged( unsigned int tracks );
void loadingStarted();
void loadingFinished();
protected:
bool canFetchMore( const QModelIndex& parent ) const;
void fetchMore( const QModelIndex& parent );