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