mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-28 11:42:42 +01:00
Reimplemented updateEntries and handled connection states better.
This commit is contained in:
parent
fbee760723
commit
20cd15662e
@ -44,13 +44,22 @@ AccountListWidget::AccountListWidget( AccountModelFactoryProxy* model, QWidget*
|
||||
void
|
||||
AccountListWidget::updateEntries( const QModelIndex& topLeft, const QModelIndex& bottomRight )
|
||||
{
|
||||
Q_UNUSED( topLeft )
|
||||
Q_UNUSED( bottomRight )
|
||||
for ( QHash< QPersistentModelIndex, QList< AccountWidget* > >::iterator it
|
||||
= m_entries.begin();
|
||||
it != m_entries.end(); ++it )
|
||||
for( int row = topLeft.row(); row <= bottomRight.row(); ++row )
|
||||
{
|
||||
updateEntry( it.key() );
|
||||
QPersistentModelIndex idx( m_model->index( row, 0 ) );
|
||||
|
||||
int newCount = idx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole )
|
||||
.value< QList< Tomahawk::Accounts::Account* > >().count();
|
||||
|
||||
if( m_entries.value( idx ).count() == newCount )
|
||||
{
|
||||
updateEntry( idx );
|
||||
}
|
||||
else
|
||||
{
|
||||
removeEntries( idx.parent(), idx.row(), idx.row() );
|
||||
insertEntries( idx.parent(), idx.row(), idx.row() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,7 +110,10 @@ AccountListWidget::insertEntries( const QModelIndex& parent, int start, int end
|
||||
|
||||
updateEntry( idx );
|
||||
for ( int j = 0; j < entryAccounts.length(); ++j )
|
||||
{
|
||||
entryAccounts[ j ]->update( idx, j );
|
||||
entryAccounts[ j ]->setupConnections( idx, j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,8 +127,6 @@ AccountListWidget::removeEntries( const QModelIndex& parent, int start, int end
|
||||
for ( int j = 0; j < entryAccounts.count(); ++j )
|
||||
{
|
||||
AccountWidget *a = entryAccounts.at( j );
|
||||
qDebug() << "Removing entry " << idx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole )
|
||||
.value< QList< Tomahawk::Accounts::Account* > >().at( j )->accountId();
|
||||
m_layout->removeWidget( a );
|
||||
a->deleteLater();
|
||||
}
|
||||
|
@ -170,27 +170,39 @@ AccountWidget::update( const QPersistentModelIndex& idx, int accountIdx )
|
||||
|
||||
switch ( account->connectionState() )
|
||||
{
|
||||
case Tomahawk::Accounts::Account::Disconnected:
|
||||
m_spinner->fadeOut();
|
||||
m_statusToggle->setChecked( false );
|
||||
m_statusToggle->setBackChecked( false );
|
||||
setInviteWidgetsEnabled( false );
|
||||
break;
|
||||
case Tomahawk::Accounts::Account::Connecting:
|
||||
m_spinner->fadeIn();
|
||||
m_statusToggle->setChecked( true );
|
||||
m_statusToggle->setBackChecked( false );
|
||||
setInviteWidgetsEnabled( false );
|
||||
break;
|
||||
case Tomahawk::Accounts::Account::Connected:
|
||||
if ( account->enabled() )
|
||||
m_statusToggle->setChecked( true );
|
||||
else
|
||||
qDebug() << "AccountWidget warning:" << account->accountFriendlyName()
|
||||
<< "is Connected but Disabled!";
|
||||
m_spinner->fadeOut();
|
||||
m_statusToggle->setChecked( true );
|
||||
m_statusToggle->setBackChecked( true );
|
||||
setInviteWidgetsEnabled( true );
|
||||
break;
|
||||
case Tomahawk::Accounts::Account::Disconnecting:
|
||||
case Tomahawk::Accounts::Account::Connecting:
|
||||
if ( !account->enabled() )
|
||||
qDebug() << "AccountWidget warning:" << account->accountFriendlyName()
|
||||
<< "is Connecting but Disabled!";
|
||||
m_spinner->fadeIn();
|
||||
m_statusToggle->setBackChecked( false );
|
||||
setInviteWidgetsEnabled( false );
|
||||
break;
|
||||
case Tomahawk::Accounts::Account::Disconnected:
|
||||
if ( !account->enabled() )
|
||||
m_statusToggle->setChecked( false );
|
||||
else
|
||||
qDebug() << "AccountWidget warning:" << account->accountFriendlyName()
|
||||
<< "is Disconnected but Enabled!";
|
||||
m_spinner->fadeOut();
|
||||
m_statusToggle->setBackChecked( false );
|
||||
setInviteWidgetsEnabled( false );
|
||||
break;
|
||||
case Tomahawk::Accounts::Account::Disconnecting:
|
||||
if ( account->enabled() )
|
||||
qDebug() << "AccountWidget warning:" << account->accountFriendlyName()
|
||||
<< "is Disconnecting but Enabled!";
|
||||
m_spinner->fadeIn();
|
||||
m_statusToggle->setChecked( false );
|
||||
m_statusToggle->setBackChecked( true );
|
||||
setInviteWidgetsEnabled( false );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user