mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-22 17:01:51 +02:00
More robust install feedback, see if it works for binary resolvers too
This commit is contained in:
parent
675841e9a7
commit
48b089c3c4
src/libtomahawk
@ -438,6 +438,8 @@ AtticaManager::installResolver( const Content& resolver, bool autoCreateAccount
|
||||
{
|
||||
Q_ASSERT( !resolver.id().isNull() );
|
||||
|
||||
emit startedInstalling( resolver.id() );
|
||||
|
||||
if ( m_resolverStates[ resolver.id() ].state != Upgrading )
|
||||
m_resolverStates[ resolver.id() ].state = Installing;
|
||||
|
||||
|
@ -115,6 +115,7 @@ signals:
|
||||
void resolverUninstalled( const QString& resolverId );
|
||||
void resolverInstallationFailed( const QString& resolverId );
|
||||
|
||||
void startedInstalling( const QString& resolverId );
|
||||
private slots:
|
||||
void providerAdded( const Attica::Provider& );
|
||||
void categoriesReturned( Attica::BaseJob* );
|
||||
|
@ -40,6 +40,8 @@ AccountModel::AccountModel( QObject* parent )
|
||||
: QAbstractListModel( parent )
|
||||
{
|
||||
connect( AtticaManager::instance(), SIGNAL( resolversLoaded( Attica::Content::List ) ), this, SLOT( loadData() ) );
|
||||
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 ) ) );
|
||||
|
||||
connect( AccountManager::instance(), SIGNAL( added( Tomahawk::Accounts::Account* ) ), this, SLOT( accountAdded( Tomahawk::Accounts::Account* ) ) );
|
||||
@ -457,7 +459,6 @@ 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;
|
||||
}
|
||||
@ -593,10 +594,6 @@ 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 )
|
||||
@ -713,17 +710,52 @@ AccountModel::accountRemoved( Account* account )
|
||||
|
||||
void
|
||||
AccountModel::resolverInstallFailed( const QString& resolverId )
|
||||
{
|
||||
const QModelIndex idx = indexForAtticaId( resolverId );
|
||||
if ( idx.isValid() )
|
||||
{
|
||||
qDebug() << "Got failed attica install in account mode, emitting signal!";
|
||||
emit errorInstalling( idx );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QModelIndex
|
||||
AccountModel::indexForAtticaId( const QString& resolverId ) const
|
||||
{
|
||||
for ( int i = 0; i < m_accounts.size(); i++ )
|
||||
{
|
||||
if ( m_accounts[ i ]->type == AccountModelNode::AtticaType && m_accounts[ i ]->atticaContent.id() == resolverId )
|
||||
{
|
||||
qDebug() << "Got failed attica install in account mode, emitting signal!";
|
||||
emit errorInstalling( index( i, 0, QModelIndex() ) );
|
||||
|
||||
return;
|
||||
return index( i, 0, QModelIndex() );
|
||||
}
|
||||
}
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AccountModel::onStartedInstalling( const QString& resolverId )
|
||||
{
|
||||
const QModelIndex idx = indexForAtticaId( resolverId );
|
||||
if ( idx.isValid() )
|
||||
{
|
||||
qDebug() << "Got resolver that is beginning to install, emitting signal";
|
||||
emit startInstalling( idx );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AccountModel::onFinishedInstalling( const QString& resolverId )
|
||||
{
|
||||
const QModelIndex idx = indexForAtticaId( resolverId );
|
||||
if ( idx.isValid() )
|
||||
{
|
||||
qDebug() << "Got resolver that is beginning to install, emitting signal";
|
||||
emit doneInstalling( idx );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,8 +106,12 @@ private slots:
|
||||
void accountRemoved( Tomahawk::Accounts::Account* );
|
||||
void accountStateChanged( Account*, Accounts::Account::ConnectionState );
|
||||
|
||||
void onStartedInstalling( const QString& resolverId );
|
||||
void onFinishedInstalling( const QString& resolverId );
|
||||
void resolverInstallFailed( const QString& resolverId );
|
||||
private:
|
||||
QModelIndex indexForAtticaId( const QString& resolverId ) const;
|
||||
|
||||
QList< AccountModelNode* > m_accounts;
|
||||
QSet< QString > m_waitingForAtticaInstall;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user