1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 14:16:32 +02:00

Fix unchecking of unique factories

This commit is contained in:
Leo Franchi
2012-02-24 11:30:22 -06:00
parent 55d7fe9e53
commit b51480f122

View File

@@ -368,15 +368,22 @@ AccountModel::setData( const QModelIndex& index, const QVariant& value, int role
switch ( node->type ) switch ( node->type )
{ {
case AccountModelNode::UniqueFactoryType: case AccountModelNode::UniqueFactoryType:
if ( node->accounts.isEmpty() ) {
const Qt::CheckState state = static_cast< Qt::CheckState >( value.toInt() );
if ( node->accounts.isEmpty() && state == Qt::Checked )
{ {
// No account for this unique factory, create it // No account for this unique factory, create it
// Don't add it to node->accounts here, slot attached to accountmanager::accountcreated will do it for us // Don't add it to node->accounts here, slot attached to accountmanager::accountcreated will do it for us
acct = node->factory->createAccount(); acct = node->factory->createAccount();
AccountManager::instance()->addAccount( acct ); AccountManager::instance()->addAccount( acct );
TomahawkSettings::instance()->addAccount( acct->accountId() ); TomahawkSettings::instance()->addAccount( acct->accountId() );
} else if ( !node->accounts.isEmpty() )
{
Q_ASSERT( node->accounts.size() == 1 );
acct = node->accounts.first();
} }
break; break;
}
case AccountModelNode::AtticaType: case AccountModelNode::AtticaType:
{ {
// This may or may not be installed. if it's not installed yet, install it, then go ahead and enable it // This may or may not be installed. if it's not installed yet, install it, then go ahead and enable it