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