1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-23 17:29:42 +01:00

Handle case where attica load is super slow

This commit is contained in:
Leo Franchi 2012-08-03 11:41:00 -04:00
parent 2f8b23b908
commit 3b083a2535
2 changed files with 15 additions and 2 deletions

View File

@ -38,8 +38,9 @@ using namespace Accounts;
AccountModel::AccountModel( QObject* parent )
: QAbstractListModel( parent )
, m_waitingForAtticaLoaded( true )
{
connect( AtticaManager::instance(), SIGNAL( resolversLoaded( Attica::Content::List ) ), this, SLOT( loadData() ) );
connect( AtticaManager::instance(), SIGNAL( resolversLoaded( Attica::Content::List ) ), this, SLOT( atticaLoaded() ) );
connect( AtticaManager::instance(), SIGNAL( startedInstalling( QString ) ), this, SLOT( onStartedInstalling( QString ) ) );
connect( AtticaManager::instance(), SIGNAL( resolverInstalled( QString ) ), this, SLOT( onFinishedInstalling( QString ) ) );
connect( AtticaManager::instance(), SIGNAL( resolverInstallationFailed( QString ) ), this, SLOT( resolverInstallFailed( QString ) ) );
@ -51,6 +52,15 @@ AccountModel::AccountModel( QObject* parent )
loadData();
}
void
AccountModel::atticaLoaded()
{
m_waitingForAtticaLoaded = false;
loadData();
}
void
AccountModel::loadData()
{
@ -644,7 +654,8 @@ AccountModel::accountAdded( Account* account )
if ( ResolverAccount* resolver = qobject_cast< ResolverAccount* >( account ) )
{
qDebug() << "Plain old manual resolver added, appending at end";
Q_ASSERT( qobject_cast< AtticaResolverAccount* >( account ) == 0 ); // should NOT get attica accounts here, should be caught above
if ( !m_waitingForAtticaLoaded )
Q_ASSERT( qobject_cast< AtticaResolverAccount* >( account ) == 0 ); // should NOT get attica accounts here, should be caught above
const int count = m_accounts.size();
beginInsertRows( QModelIndex(), count, count );
m_accounts << new AccountModelNode( resolver );

View File

@ -100,6 +100,7 @@ signals:
void errorInstalling( const QPersistentModelIndex& idx );
private slots:
void atticaLoaded();
void loadData();
void accountAdded( Tomahawk::Accounts::Account* );
@ -112,6 +113,7 @@ private slots:
private:
QModelIndex indexForAtticaId( const QString& resolverId ) const;
bool m_waitingForAtticaLoaded;
QList< AccountModelNode* > m_accounts;
QSet< QString > m_waitingForAtticaInstall;
};