From e3f4fdfdd85f6e415214b2ecdc973653582c9b74 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 17 Feb 2012 13:16:21 -0500 Subject: [PATCH] Some more work + debug to try to fix j's issue --- src/libtomahawk/AtticaManager.cpp | 14 ++++++++++++++ src/libtomahawk/AtticaManager.h | 2 ++ src/libtomahawk/accounts/AccountModel.cpp | 14 ++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/AtticaManager.cpp b/src/libtomahawk/AtticaManager.cpp index 96cd70fc6..e6a64bd60 100644 --- a/src/libtomahawk/AtticaManager.cpp +++ b/src/libtomahawk/AtticaManager.cpp @@ -125,6 +125,20 @@ AtticaManager::resolvers() const } +Content +AtticaManager::resolverForId( const QString& id ) const +{ + foreach ( const Attica::Content& c, m_resolvers ) + { + if ( c.id() == id ) + return c; + } + + return Content(); +} + + + AtticaManager::ResolverState AtticaManager::resolverState ( const Content& resolver ) const { diff --git a/src/libtomahawk/AtticaManager.h b/src/libtomahawk/AtticaManager.h index 88333cf54..3876583ed 100644 --- a/src/libtomahawk/AtticaManager.h +++ b/src/libtomahawk/AtticaManager.h @@ -71,6 +71,8 @@ public: bool resolversLoaded() const; Attica::Content::List resolvers() const; + Attica::Content resolverForId( const QString& id ) const; + ResolverState resolverState( const Attica::Content& resolver ) const; QPixmap iconForResolver( const Attica::Content& id ); // Looks up in icon cache diff --git a/src/libtomahawk/accounts/AccountModel.cpp b/src/libtomahawk/accounts/AccountModel.cpp index d3f88cfdc..9da527024 100644 --- a/src/libtomahawk/accounts/AccountModel.cpp +++ b/src/libtomahawk/accounts/AccountModel.cpp @@ -38,8 +38,6 @@ AccountModel::AccountModel( QObject* parent ) connect( AccountManager::instance(), SIGNAL( removed( Tomahawk::Accounts::Account* ) ), this, SLOT( accountRemoved( Tomahawk::Accounts::Account* ) ) ); connect( AccountManager::instance(), SIGNAL( stateChanged( Account* ,Accounts::Account::ConnectionState ) ), this, SLOT( accountStateChanged( Account*, Accounts::Account::ConnectionState ) ) ); - connect( AtticaManager::instance(), SIGNAL( resolverInstalled( QString ) ), this, SLOT( atticaInstalled( QString ) ) ); - loadData(); } @@ -319,20 +317,24 @@ AccountModel::setData( const QModelIndex& index, const QVariant& value, int role Attica::Content resolver = node->atticaContent; AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( resolver ); + qDebug() << "Attica resolver was checked! Current state is:" << state << "and so.."; if ( state == AtticaManager::Installed && !node->resolverAccount ) { // Something is wrong, reinstall + qDebug() << "Found installed state but no resolver, uninstalling first"; AtticaManager::instance()->uninstallResolver( resolver ); state = AtticaManager::Uninstalled; } if ( state == AtticaManager::Installed ) { + qDebug() << "Already installed with resolver, just enabling"; acct = node->atticaAccount; break; } else { + qDebug() << "Kicked off fetch+install, now waiting"; m_waitingForAtticaInstall.insert( resolver.id() ); AtticaManager::instance()->installResolver( resolver ); @@ -441,8 +443,15 @@ AccountModel::accountAdded( Account* account ) } else if ( attica && n->atticaContent.id() == attica->atticaId() ) { + n->resolverAccount = attica; + n->atticaContent = AtticaManager::instance()->resolverForId( attica->atticaId() ); thisIsTheOne = true; + + if ( m_waitingForAtticaInstall.contains( attica->atticaId() ) ) + AccountManager::instance()->enableAccount( account ); + + m_waitingForAtticaInstall.remove( attica->atticaId() ); } if ( thisIsTheOne ) @@ -605,6 +614,7 @@ AccountModel::atticaInstalled( const QString& atticaId ) AccountManager::instance()->enableAccount( acct ); node->atticaAccount = acct; + node->atticaContent = AtticaManager::instance()->resolverForId( atticaId ); const QModelIndex idx = index( m_accounts.indexOf( node ), 0, QModelIndex() ); emit dataChanged( idx, idx ); }