From f7fcfcb4529db48a94494ae6d4a1016dbc0eb27a Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 20 Apr 2012 16:04:36 -0400 Subject: [PATCH] start towards info --- src/AccountDelegate.cpp | 16 ++++++++++++++-- src/AccountDelegate.h | 5 +++++ src/libtomahawk/accounts/AccountModel.cpp | 5 +++++ src/libtomahawk/accounts/AccountModel.h | 2 ++ .../accounts/AccountModelFilterProxy.cpp | 2 ++ .../accounts/AccountModelFilterProxy.h | 3 +++ src/libtomahawk/utils/LoadingSpinnerPixmap.cpp | 6 ++++++ src/settingsdialog.cpp | 2 ++ 8 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/libtomahawk/utils/LoadingSpinnerPixmap.cpp diff --git a/src/AccountDelegate.cpp b/src/AccountDelegate.cpp index 278b29497..5e9e94ad0 100644 --- a/src/AccountDelegate.cpp +++ b/src/AccountDelegate.cpp @@ -134,9 +134,9 @@ AccountDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option, QFont authorFont = opt.font; authorFont.setItalic( true ); authorFont.setPointSize( authorFont.pointSize() - 1 ); - #ifdef Q_OS_MAC +#ifdef Q_OS_MAC authorFont.setPointSize( authorFont.pointSize() - 1 ); - #endif +#endif const QFontMetrics authorMetrics( authorFont ); QFont descFont = authorFont; @@ -658,4 +658,16 @@ AccountDelegate::checkRectForIndex( const QStyleOptionViewItem& option, const QM } +void +AccountDelegate::startInstalling( const QPersistentModelIndex& idx ) +{ + qDebug() << "START INSTALLING:" << idx.data( Qt::DisplayRole ).toString(); +} + +void +AccountDelegate::doneInstalling ( const QPersistentModelIndex& idx ) +{ + qDebug() << "STOP INSTALLING:" << idx.data( Qt::DisplayRole ).toString(); + +} diff --git a/src/AccountDelegate.h b/src/AccountDelegate.h index 01c7f6a9c..cb2e37cc9 100644 --- a/src/AccountDelegate.h +++ b/src/AccountDelegate.h @@ -38,6 +38,10 @@ public: virtual void paint ( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const; virtual QSize sizeHint ( const QStyleOptionViewItem& option, const QModelIndex& index ) const; +public slots: + void startInstalling( const QPersistentModelIndex& idx ); + void doneInstalling ( const QPersistentModelIndex& idx ); + protected: virtual bool editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index ); @@ -64,6 +68,7 @@ private: mutable QHash< QPersistentModelIndex, QRect > m_cachedStarRects; mutable QHash< QPersistentModelIndex, QRect > m_cachedConfigRects; mutable QHash< QPersistentModelIndex, QSize > m_sizeHints; + mutable QHash< QPersistentModelIndex, QMovie* > m_loadingSpinners; mutable int m_accountRowHeight; }; diff --git a/src/libtomahawk/accounts/AccountModel.cpp b/src/libtomahawk/accounts/AccountModel.cpp index 450ecf506..f58014435 100644 --- a/src/libtomahawk/accounts/AccountModel.cpp +++ b/src/libtomahawk/accounts/AccountModel.cpp @@ -451,6 +451,7 @@ AccountModel::setData( const QModelIndex& index, const QVariant& value, int role qDebug() << "Kicked off fetch+install, now waiting"; m_waitingForAtticaInstall.insert( resolver.id() ); + emit startInstalling( index ); AtticaManager::instance()->installResolver( resolver ); return true; } @@ -571,6 +572,10 @@ AccountModel::accountAdded( Account* account ) AccountManager::instance()->enableAccount( account ); m_waitingForAtticaInstall.remove( attica->atticaId() ); + + // find index to emit doneInstalling for + const QModelIndex idx = index( i, 0, QModelIndex() ); + emit doneInstalling( idx ); } if ( thisIsTheOne ) diff --git a/src/libtomahawk/accounts/AccountModel.h b/src/libtomahawk/accounts/AccountModel.h index 4396dcd7a..db52e5a32 100644 --- a/src/libtomahawk/accounts/AccountModel.h +++ b/src/libtomahawk/accounts/AccountModel.h @@ -94,6 +94,8 @@ signals: void createAccount( Tomahawk::Accounts::AccountFactory* factory ); void scrollTo( const QModelIndex& idx ); + void startInstalling( const QPersistentModelIndex& idx ); + void doneInstalling( const QPersistentModelIndex& idx ); private slots: void loadData(); diff --git a/src/libtomahawk/accounts/AccountModelFilterProxy.cpp b/src/libtomahawk/accounts/AccountModelFilterProxy.cpp index 23dca5dfc..5aa005e6c 100644 --- a/src/libtomahawk/accounts/AccountModelFilterProxy.cpp +++ b/src/libtomahawk/accounts/AccountModelFilterProxy.cpp @@ -36,6 +36,8 @@ void AccountModelFilterProxy::setSourceModel( QAbstractItemModel* sourceModel ) { connect( sourceModel, SIGNAL( scrollTo( QModelIndex ) ), this, SLOT( onScrollTo( QModelIndex ) ) ); + connect( sourceModel, SIGNAL( startInstalling( QPersistentModelIndex ) ), this, SIGNAL( startInstalling( QPersistentModelIndex ) ) ); + connect( sourceModel, SIGNAL( doneInstalling( QPersistentModelIndex ) ), this, SIGNAL( doneInstalling( QPersistentModelIndex ) ) ); QSortFilterProxyModel::setSourceModel( sourceModel ); } diff --git a/src/libtomahawk/accounts/AccountModelFilterProxy.h b/src/libtomahawk/accounts/AccountModelFilterProxy.h index 92c61d469..527a8b067 100644 --- a/src/libtomahawk/accounts/AccountModelFilterProxy.h +++ b/src/libtomahawk/accounts/AccountModelFilterProxy.h @@ -40,6 +40,9 @@ public: signals: void scrollTo( const QModelIndex& idx ); + void startInstalling( const QPersistentModelIndex& idx ); + void doneInstalling( const QPersistentModelIndex& idx ); + protected: virtual bool filterAcceptsRow ( int sourceRow, const QModelIndex& sourceParent ) const; diff --git a/src/libtomahawk/utils/LoadingSpinnerPixmap.cpp b/src/libtomahawk/utils/LoadingSpinnerPixmap.cpp new file mode 100644 index 000000000..06203fb91 --- /dev/null +++ b/src/libtomahawk/utils/LoadingSpinnerPixmap.cpp @@ -0,0 +1,6 @@ +#include "LoadingSpinnerPixmap.h" + +LoadingSpinnerPixmap::LoadingSpinnerPixmap(QObject *parent) : + QObject(parent) +{ +} diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 31b2084bd..4cd7c49d7 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -114,6 +114,8 @@ SettingsDialog::SettingsDialog( QWidget *parent ) m_accountProxy = new AccountModelFilterProxy( m_accountModel ); m_accountProxy->setSourceModel( m_accountModel ); + connect( m_accountProxy, SIGNAL( startInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( startInstalling(QPersistentModelIndex) ) ); + connect( m_accountProxy, SIGNAL( doneInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( doneInstalling(QPersistentModelIndex) ) ); connect( m_accountProxy, SIGNAL( scrollTo( QModelIndex ) ), this, SLOT( scrollTo( QModelIndex ) ) ); ui->accountsView->setModel( m_accountProxy );