mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-18 23:09:42 +01:00
fix first start issues
This commit is contained in:
parent
7e9fa7c2a7
commit
0c231d5532
@ -82,13 +82,19 @@ AccountDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex
|
||||
return QSize( 200, TOPLEVEL_ACCOUNT_HEIGHT );
|
||||
else if ( rowType == AccountModel::TopLevelFactory )
|
||||
{
|
||||
// Make more space for eacha ccount we have to show.
|
||||
// Make more space for each account we have to show.
|
||||
AccountFactory* fac = qobject_cast< AccountFactory* >( index.data( AccountModel::AccountData ).value< QObject* >() );
|
||||
if ( fac->isUnique() )
|
||||
return QSize( 200, TOPLEVEL_ACCOUNT_HEIGHT );
|
||||
|
||||
const QList< Account* > accts = index.data( AccountModel::ChildrenOfFactoryRole ).value< QList< Tomahawk::Accounts::Account* > >();
|
||||
return QSize( 200, TOPLEVEL_ACCOUNT_HEIGHT + 12 * accts.size()-1 );
|
||||
const QSize s = QSize( 200, TOPLEVEL_ACCOUNT_HEIGHT + 12 * accts.size()-1 );
|
||||
|
||||
if ( s != m_sizeHints[ index ] )
|
||||
const_cast< AccountDelegate* >( this )->sizeHintChanged( index ); // FU KTHBBQ
|
||||
|
||||
m_sizeHints[ index ] = s;
|
||||
return s;
|
||||
}
|
||||
|
||||
return QSize();
|
||||
|
@ -63,6 +63,7 @@ private:
|
||||
mutable QHash< QPersistentModelIndex, QRect > m_cachedButtonRects;
|
||||
mutable QHash< QPersistentModelIndex, QRect > m_cachedStarRects;
|
||||
mutable QHash< QPersistentModelIndex, QRect > m_cachedConfigRects;
|
||||
mutable QHash< QPersistentModelIndex, QSize > m_sizeHints;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -246,6 +246,8 @@ AtticaManager::resolversList( BaseJob* j )
|
||||
}
|
||||
|
||||
syncServerData();
|
||||
|
||||
emit resolversLoaded( m_resolvers );
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,7 +86,7 @@ public slots:
|
||||
void upgradeResolver( const Attica::Content& resolver );
|
||||
|
||||
signals:
|
||||
void resolversReloaded( const Attica::Content::List& resolvers );
|
||||
void resolversLoaded( const Attica::Content::List& resolvers );
|
||||
|
||||
void resolverStateChanged( const QString& resolverId );
|
||||
void resolverInstalled( const QString& resolverId );
|
||||
|
@ -32,6 +32,7 @@ using namespace Accounts;
|
||||
AccountModel::AccountModel( QObject* parent )
|
||||
: QAbstractListModel( parent )
|
||||
{
|
||||
connect( AtticaManager::instance(), SIGNAL( resolversLoaded( Attica::Content::List ) ), this, SLOT( loadData() ) );
|
||||
loadData();
|
||||
}
|
||||
|
||||
@ -41,6 +42,7 @@ AccountModel::loadData()
|
||||
beginResetModel();
|
||||
|
||||
qDeleteAll( m_accounts );
|
||||
m_accounts.clear();
|
||||
|
||||
// Add all factories
|
||||
QList< AccountFactory* > factories = AccountManager::instance()->factories();
|
||||
@ -73,6 +75,8 @@ AccountModel::loadData()
|
||||
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 ) ) );
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
|
||||
@ -216,7 +220,7 @@ AccountModel::data( const QModelIndex& index, int role ) const
|
||||
if ( node->type == AccountModelNode::ManualResolverType )
|
||||
acct = node->resolverAccount;
|
||||
else if ( node->type == AccountModelNode::UniqueFactoryType )
|
||||
acct = node->accounts.first();
|
||||
acct = node->accounts.isEmpty() ? 0 : node->accounts.first();
|
||||
|
||||
// If there's no account*, then it means it's a unique factory that hasn't been created
|
||||
if ( !acct )
|
||||
@ -443,6 +447,8 @@ AccountModel::accountAdded( Account* account )
|
||||
beginInsertRows( QModelIndex(), count, count );
|
||||
m_accounts << new AccountModelNode( resolver );
|
||||
endInsertRows();
|
||||
|
||||
emit scrollTo( index( m_accounts.size() - 1, 0, QModelIndex() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,16 +91,18 @@ public:
|
||||
|
||||
signals:
|
||||
void createAccount( Tomahawk::Accounts::AccountFactory* factory );
|
||||
void scrollTo( const QModelIndex& idx );
|
||||
|
||||
private slots:
|
||||
void loadData();
|
||||
|
||||
void accountAdded( Tomahawk::Accounts::Account* );
|
||||
void accountRemoved( Tomahawk::Accounts::Account* );
|
||||
void accountStateChanged( Account*, Accounts::Account::ConnectionState );
|
||||
|
||||
void atticaInstalled( const QString& atticaId );
|
||||
private:
|
||||
void loadData();
|
||||
|
||||
private:
|
||||
QList< AccountModelNode* > m_accounts;
|
||||
QSet< QString > m_waitingForAtticaInstall;
|
||||
};
|
||||
|
@ -31,6 +31,15 @@ AccountModelFilterProxy::AccountModelFilterProxy( QObject* parent )
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AccountModelFilterProxy::setSourceModel( QAbstractItemModel* sourceModel )
|
||||
{
|
||||
connect( sourceModel, SIGNAL( scrollTo( QModelIndex ) ), this, SLOT( onScrollTo( QModelIndex ) ) );
|
||||
QSortFilterProxyModel::setSourceModel( sourceModel );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
AccountModelFilterProxy::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
||||
{
|
||||
@ -54,3 +63,10 @@ AccountModelFilterProxy::setFilterType( AccountType type )
|
||||
m_filterType = type;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AccountModelFilterProxy::onScrollTo( const QModelIndex& idx )
|
||||
{
|
||||
emit scrollTo( mapFromSource( idx ) );
|
||||
}
|
||||
|
@ -35,9 +35,17 @@ public:
|
||||
|
||||
void setFilterType( Tomahawk::Accounts::AccountType type );
|
||||
|
||||
virtual void setSourceModel( QAbstractItemModel* sourceModel );
|
||||
|
||||
signals:
|
||||
void scrollTo( const QModelIndex& idx );
|
||||
|
||||
protected:
|
||||
virtual bool filterAcceptsRow ( int sourceRow, const QModelIndex& sourceParent ) const;
|
||||
|
||||
private slots:
|
||||
void onScrollTo( const QModelIndex& idx );
|
||||
|
||||
private:
|
||||
Tomahawk::Accounts::AccountType m_filterType;
|
||||
};
|
||||
|
@ -118,11 +118,12 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
||||
m_accountProxy = new AccountModelFilterProxy( m_accountModel );
|
||||
m_accountProxy->setSourceModel( m_accountModel );
|
||||
|
||||
connect( m_accountProxy, SIGNAL( scrollTo( QModelIndex ) ), this, SLOT( scrollTo( QModelIndex ) ) );
|
||||
|
||||
ui->accountsView->setModel( m_accountProxy );
|
||||
|
||||
connect( ui->installFromFileBtn, SIGNAL( clicked( bool ) ), this, SLOT( installFromFile() ) );
|
||||
connect( m_accountModel, SIGNAL( createAccount( Tomahawk::Accounts::AccountFactory* ) ), this, SLOT( createAccountFromFactory( Tomahawk::Accounts::AccountFactory* ) ) );
|
||||
connect( AccountManager::instance(), SIGNAL( added( Tomahawk::Accounts::Account* ) ), ui->accountsView, SLOT( scrollToBottom() ) );
|
||||
|
||||
ui->accountsFilterCombo->addItem( tr( "All" ), Accounts::NoType );
|
||||
ui->accountsFilterCombo->addItem( accountTypeToString( SipType ), SipType );
|
||||
@ -628,6 +629,13 @@ SettingsDialog::installFromFile()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::scrollTo( const QModelIndex& idx )
|
||||
{
|
||||
ui->accountsView->scrollTo( idx, QAbstractItemView::PositionAtBottom );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::requiresRestart()
|
||||
{
|
||||
|
@ -100,6 +100,7 @@ private slots:
|
||||
void accountCreateConfigClosed( int value );
|
||||
|
||||
void installFromFile();
|
||||
void scrollTo( const QModelIndex& );
|
||||
|
||||
void updateScanOptionsView();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user