1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 08:34:34 +02:00

Begin work on overhauled account UI, again

This commit is contained in:
Leo Franchi
2012-01-29 19:33:12 -05:00
parent f2b1cc6ae3
commit 8eba4c171f
8 changed files with 483 additions and 191 deletions

View File

@@ -42,7 +42,7 @@ public:
virtual QRect checkRectForIndex( const QStyleOptionViewItem &option, const QModelIndex &idx, int role ) const; virtual QRect checkRectForIndex( const QStyleOptionViewItem &option, const QModelIndex &idx, int role ) const;
virtual QRect configRectForIndex( const QStyleOptionViewItem& option, const QModelIndex& idx ) const; virtual QRect configRectForIndex( const QStyleOptionViewItem& option, const QModelIndex& idx ) const;
virtual QList<int> extraCheckRoles() const { return QList<int>() << (int)AccountModel::AccountTypeRole; } // virtual QList<int> extraCheckRoles() const { return QList<int>() << (int)AccountModel::AccountTypeRole; }
private slots: private slots:
void askedForEdit( const QModelIndex& idx ); void askedForEdit( const QModelIndex& idx );

View File

@@ -75,7 +75,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
settingsdialog.cpp settingsdialog.cpp
diagnosticsdialog.cpp diagnosticsdialog.cpp
configdelegatebase.cpp configdelegatebase.cpp
AccountDelegate.cpp # AccountDelegate.cpp
settingslistdelegate.cpp settingslistdelegate.cpp
tomahawkwindow.cpp tomahawkwindow.cpp
LoadXSPFDialog.cpp LoadXSPFDialog.cpp
@@ -125,7 +125,7 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
settingsdialog.h settingsdialog.h
diagnosticsdialog.h diagnosticsdialog.h
configdelegatebase.h configdelegatebase.h
AccountDelegate.h # AccountDelegate.h
settingslistdelegate.h settingslistdelegate.h
delegateconfigwrapper.h delegateconfigwrapper.h
tomahawkwindow.h tomahawkwindow.h

View File

@@ -21,17 +21,6 @@
#include <QDesktopServices> #include <QDesktopServices>
#include "settingsdialog.h" #include "settingsdialog.h"
// #include <QDir>
//
// #include "sip/SipHandler.h"
// #include "playlistinterface.h"
//
// #include "utils/logger.h"
// #include "utils/tomahawkutils.h"
//
// #include "database/databasecommand_updatesearchindex.h"
// #include "database/database.h"
using namespace Tomahawk; using namespace Tomahawk;
TomahawkSettingsGui* TomahawkSettingsGui*

View File

@@ -1,42 +1,75 @@
/* /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
Copyright (C) 2011 Leo Franchi <lfranchi@kde.org> *
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
This program is free software: you can redistribute it and/or modify *
it under the terms of the GNU General Public License as published by * Tomahawk is free software: you can redistribute it and/or modify
the Free Software Foundation, either version 3 of the License, or * it under the terms of the GNU General Public License as published by
(at your option) any later version. * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
This program is distributed in the hope that it will be useful, *
but WITHOUT ANY WARRANTY; without even the implied warranty of * Tomahawk is distributed in the hope that it will be useful,
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
You should have received a copy of the GNU General Public License *
along with this program. If not, see <http://www.gnu.org/licenses/>. * You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "AccountModel.h" #include "AccountModel.h"
#include "tomahawksettings.h" #include "Account.h"
#include "accounts/AccountManager.h" #include "AccountModelNode.h"
#include "accounts/Account.h" #include "AccountManager.h"
#include "AtticaManager.h"
#include "ResolverAccount.h"
#include "utils/logger.h" #include <attica/content.h>
using namespace Tomahawk; using namespace Tomahawk;
using namespace Accounts; using namespace Accounts;
AccountModel::AccountModel( QObject* parent ) AccountModel::AccountModel( QObject* parent )
: QAbstractListModel( parent ) : QAbstractItemModel( parent )
, m_rootItem( 0 )
{ {
connect( AccountManager::instance(), SIGNAL( added( Tomahawk::Accounts::Account* ) ), this, SLOT( accountAdded( Tomahawk::Accounts::Account* ) ) ); loadData();
connect( AccountManager::instance(), SIGNAL( removed( Tomahawk::Accounts::Account* ) ), this, SLOT( accountRemoved( Tomahawk::Accounts::Account* ) ) );
} }
void
AccountModel::~AccountModel() AccountModel::loadData()
{ {
beginResetModel();
delete m_rootItem;
m_rootItem = new AccountModelNode();
// Add all factories
QList< AccountFactory* > factories = AccountManager::instance()->factories();
QList< Account* > allAccounts = AccountManager::instance()->accounts();
foreach ( AccountFactory* fac, factories )
{
if ( !fac->allowUserCreation() )
continue;
qDebug() << "Creating factory node:" << fac->prettyName();
new AccountModelNode( m_rootItem, fac );
}
// add all attica resolvers (installed or uninstalled)
Attica::Content::List fromAttica = AtticaManager::instance()->resolvers();
foreach ( const Attica::Content& content, fromAttica )
new AccountModelNode( m_rootItem, content );
// Add all non-attica manually installed resolvers
foreach ( Account* acct, allAccounts )
{
if ( qobject_cast< ResolverAccount* >( acct ) && !qobject_cast< AtticaResolverAccount* >( acct ) )
{
new AccountModelNode( m_rootItem, qobject_cast< ResolverAccount* >( acct ) );
}
}
} }
@@ -46,111 +79,210 @@ AccountModel::data( const QModelIndex& index, int role ) const
if ( !index.isValid() ) if ( !index.isValid() )
return QVariant(); return QVariant();
QList< Account* > accounts = AccountManager::instance()->accounts(); if ( !hasIndex( index.row(), index.column(), index.parent() ) )
Q_ASSERT( index.row() <= accounts.size() ); return QVariant();
Account* account = accounts[ index.row() ];
AccountModelNode* node = nodeFromIndex( index );
if ( node->parent == m_rootItem ) {
// This is a top-level item. 3 cases
Q_ASSERT( node->type != AccountModelNode::AccountType ); // must not be of this type, these should be children (other branch of if)
switch ( node->type )
{
case AccountModelNode::FactoryType:
{
AccountFactory* fac = node->factory;
Q_ASSERT( fac );
switch ( role ) switch ( role )
{ {
case Qt::DisplayRole: case Qt::DisplayRole:
case AccountModel::AccountName: return fac->prettyName();
return account->accountFriendlyName();
case AccountModel::ConnectionStateRole:
return account->connectionState();
case AccountModel::HasConfig:
return ( account->configurationWidget() != 0 );
case AccountModel::AccountTypeRole:
return (int)account->types();
case Qt::DecorationRole: case Qt::DecorationRole:
return account->icon(); return fac->icon();
case AccountModel::AccountData: case StateRole:
return QVariant::fromValue< QObject* >( account ); return ShippedWithTomahawk;
case Qt::CheckStateRole: case AccountDescription:
return account->enabled() ? Qt::Checked : Qt::Unchecked; return fac->description();
case AuthorRole:
return "Tomahawk Team";
case RowType:
return TopLevelFactory;
default: default:
return QVariant(); return QVariant();
} }
}
case AccountModelNode::AtticaType:
{
Attica::Content c = node->atticaContent;
Q_ASSERT( !c.id().isNull() );
switch( role )
{
case Qt::DisplayRole:
return c.name();
case Qt::DecorationRole:
return QVariant::fromValue< QPixmap >( AtticaManager::instance()->iconForResolver( c ) );
case StateRole:
return (int)AtticaManager::instance()->resolverState( c );
case AccountDescription:
return c.description();
case AuthorRole:
return c.author();
case RatingRole:
return c.rating() / 20; // rating is out of 100
case DownloadCounterRole:
return c.downloads();
case VersionRole:
return c.version();
case UserHasRatedRole:
return AtticaManager::instance()->userHasRated( c );
default:
;
}
AtticaResolverAccount* atticaAcct = node->atticaAccount;
if ( atticaAcct )
{
// If the resolver is installed or on disk, we expose some additional data
switch ( role )
{
case HasConfig:
return atticaAcct->configurationWidget() != 0;
case Qt::CheckStateRole:
return atticaAcct->enabled() ? Qt::Checked : Qt::Unchecked;
case AccountData:
return QVariant::fromValue< QObject* >( atticaAcct );
case RowType:
return TopLevelAccount;
case ConnectionStateRole:
return atticaAcct->connectionState();
default:
;
}
}
return QVariant();
}
case AccountModelNode::ManualResolverType:
{
ResolverAccount* resolver = node->resolverAccount;
Q_ASSERT( resolver );
switch ( role )
{
case Qt::DisplayRole:
return resolver->accountFriendlyName();
case Qt::DecorationRole:
return resolver->icon();
case AccountDescription:
return QString();
case Qt::CheckStateRole:
return resolver->enabled() ? Qt::Checked : Qt::Unchecked;
case AccountData:
return QVariant::fromValue< QObject* >( resolver );
case RowType:
return TopLevelAccount;
case ConnectionStateRole:
return resolver->connectionState();
default:
return QVariant();
}
}
}
}
else
{
// This is a child account* of an accountfactory*
Q_ASSERT( node->type == AccountModelNode::AccountType );
Q_ASSERT( node->children.isEmpty() );
Q_ASSERT( node->account );
Account* acc = node->account;
switch ( role )
{
case RowType:
return ChildAccount;
case Qt::DisplayRole:
return acc->accountFriendlyName();
case ConnectionStateRole:
return acc->connectionState();
case HasConfig:
return ( acc->configurationWidget() != 0 );
case ErrorString:
return acc->errorMessage();
case Qt::CheckStateRole:
return acc->enabled() ? Qt::Checked : Qt::Unchecked;
case AccountData:
return QVariant::fromValue< QObject* >( acc );
default:
return QVariant();
}
}
return QVariant(); return QVariant();
} }
int
bool AccountModel::columnCount( const QModelIndex& parent ) const
AccountModel::setData( const QModelIndex& index, const QVariant& value, int role )
{ {
Q_ASSERT( index.isValid() && index.row() <= AccountManager::instance()->accounts().count() ); return 1;
if ( role == Qt::CheckStateRole ) {
Qt::CheckState state = static_cast< Qt::CheckState >( value.toInt() );
QList< Account* > accounts = AccountManager::instance()->accounts();
Account* account = accounts[ index.row() ];
if( state == Qt::Checked && !account->enabled() ) {
AccountManager::instance()->enableAccount( account );
} else if( state == Qt::Unchecked ) {
AccountManager::instance()->disableAccount( account );
}
account->sync();
dataChanged( index, index );
return true;
}
else if ( role == AccountTypeRole )
{
// TODO
}
return false;
} }
int int
AccountModel::rowCount( const QModelIndex& ) const AccountModel::rowCount( const QModelIndex& parent ) const
{ {
return AccountManager::instance()->accounts().size(); if ( !parent.isValid() )
{
return m_rootItem->children.count();
} }
Qt::ItemFlags // If it's a top-level item, return child count. Only factories will have any.
AccountModel::flags( const QModelIndex& index ) const return nodeFromIndex( parent )->children.count();
{
return QAbstractListModel::flags( index ) | Qt::ItemIsUserCheckable;
} }
QModelIndex
void AccountModel::parent( const QModelIndex& child ) const
AccountModel::accountAdded( Account* account )
{ {
// TODO HACK we assume account plugins are added at the end of the list. if ( !child.isValid() )
Q_ASSERT( AccountManager::instance()->accounts().last() == account ); {
if ( account->types() & SipType ) return QModelIndex();
connect( account, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ), this, SLOT( accountStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) );
int size = AccountManager::instance()->accounts().count() - 1;
beginInsertRows( QModelIndex(), size, size );
endInsertRows();
} }
AccountModelNode* node = nodeFromIndex( child );
AccountModelNode* parent = node->parent;
void // top level, none
AccountModel::accountRemoved( Account* account ) if( parent == m_rootItem )
{ return QModelIndex();
int idx = AccountManager::instance()->accounts().indexOf( account );
beginRemoveRows( QModelIndex(), idx, idx ); // child Account* of an AccountFactory*
endRemoveRows(); Q_ASSERT( m_rootItem->children.contains( parent ) );
return createIndex( m_rootItem->children.indexOf( parent ), 0, parent );
} }
QModelIndex
AccountModel::index( int row, int column, const QModelIndex& parent ) const
{
if( row < 0 || column < 0 )
return QModelIndex();
void if( hasIndex( row, column, parent ) )
AccountModel::accountStateChanged( Tomahawk::Accounts::Account::ConnectionState )
{ {
Account* account = qobject_cast< Account* >( sender() ); AccountModelNode *parentNode = nodeFromIndex( parent );
Q_ASSERT( account ); AccountModelNode *childNode = parentNode->children.at( row );
return createIndex( row, column, childNode );
for ( int i = 0; i < AccountManager::instance()->accounts().size(); i++ )
{
if ( AccountManager::instance()->accounts()[i] == account )
{
QModelIndex idx = index( i, 0, QModelIndex() );
emit dataChanged( idx, idx );
return;
}
}
} }
return QModelIndex();
}
AccountModelNode*
AccountModel::nodeFromIndex( const QModelIndex& idx ) const
{
if( !idx.isValid() )
return m_rootItem;
Q_ASSERT( idx.internalPointer() );
return reinterpret_cast< AccountModelNode* >( idx.internalPointer() );
}

View File

@@ -1,68 +1,94 @@
/* /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
Copyright (C) 2011 Leo Franchi <lfranchi@kde.org> *
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
This program is free software: you can redistribute it and/or modify *
it under the terms of the GNU General Public License as published by * Tomahawk is free software: you can redistribute it and/or modify
the Free Software Foundation, either version 3 of the License, or * it under the terms of the GNU General Public License as published by
(at your option) any later version. * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
This program is distributed in the hope that it will be useful, *
but WITHOUT ANY WARRANTY; without even the implied warranty of * Tomahawk is distributed in the hope that it will be useful,
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
You should have received a copy of the GNU General Public License *
along with this program. If not, see <http://www.gnu.org/licenses/>. * You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TOMAHAWK_ACCOUNTS_ACCOUNTMODEL_H
#ifndef SIPMODEL_H #define TOMAHAWK_ACCOUNTS_ACCOUNTMODEL_H
#define SIPMODEL_H
#include "dllmacro.h" #include "dllmacro.h"
#include "sip/SipPlugin.h"
#include <QAbstractListModel> #include <QAbstractItemModel>
#include <QModelIndex>
#include <QStringList>
namespace Tomahawk
{
namespace Accounts
{
class Account; namespace Tomahawk {
class DLLEXPORT AccountModel : public QAbstractListModel namespace Accounts {
class AccountModelNode;
class DLLEXPORT AccountModel : public QAbstractItemModel
{ {
Q_OBJECT Q_OBJECT
public: public:
enum Roles { enum Roles {
AccountName = Qt::UserRole + 15, RowType = Qt::UserRole + 1, // RowType enum
AccountIcon = Qt::UserRole + 16,
AccountTypeRole = Qt::UserRole + 19, // Used by top-level accounts
ConnectionStateRole = Qt::UserRole + 20, AccountDescription = Qt::UserRole + 17,
HasConfig = Qt::UserRole + 21, StateRole = Qt::UserRole + 18, // ItemState,
ErrorString = Qt::UserRole + 22, RatingRole = Qt::UserRole + 19,
AccountData = Qt::UserRole + 23 // raw plugin DownloadCounterRole = Qt::UserRole + 20,
VersionRole = Qt::UserRole + 21,
AuthorRole = Qt::UserRole + 22,
UserHasRatedRole = Qt::UserRole + 24,
// used by both
ConnectionStateRole = Qt::UserRole + 25,
HasConfig = Qt::UserRole + 26,
ErrorString = Qt::UserRole + 27,
// used by individual accounts, needed still?
AccountData = Qt::UserRole + 28 // raw plugin
};
enum RowType {
TopLevelFactory,
TopLevelAccount,
ChildAccount
};
enum ItemState {
Uninstalled = 0,
Installing,
Installed,
NeedsUpgrade,
Upgrading,
Failed,
ShippedWithTomahawk // Can't uninstall or uninstall, just enable/disable
}; };
explicit AccountModel( QObject* parent = 0 ); explicit AccountModel( QObject* parent = 0 );
virtual ~AccountModel();
virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const; virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
virtual int columnCount( const QModelIndex& parent = QModelIndex() ) const;
virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const; virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const;
virtual Qt::ItemFlags flags(const QModelIndex& index) const; virtual QModelIndex parent( const QModelIndex& child ) const;
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); virtual QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const;
private slots: private:
void accountAdded( Tomahawk::Accounts::Account* p ); AccountModelNode* nodeFromIndex( const QModelIndex& index ) const;
void accountRemoved( Tomahawk::Accounts::Account* p ); void loadData();
void accountStateChanged( Tomahawk::Accounts::Account::ConnectionState );
AccountModelNode* m_rootItem;
}; };
} }
} }
#endif // SIPMODEL_H #endif // TOMAHAWK_ACCOUNTS_ACCOUNTMODEL_H

View File

@@ -0,0 +1,145 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TOMAHAWK_ACCOUNTS_ACCOUNTMODELNODE_H
#define TOMAHAWK_ACCOUNTS_ACCOUNTMODELNODE_H
#include "Account.h"
#include "AccountManager.h"
#include "ResolverAccount.h"
#include <attica/content.h>
namespace Tomahawk {
namespace Accounts {
/**
* Node for account tree.
*
* Basically a union with possible types:
* 1) AccountFactory* for accounts that are not unique (jabber, google, twitter)
* 2) Account* for accounts that are associated with an AccountFactory (children of AccountFactory)
* 3) Attica::Content for AtticaResolverAccounts (with associated AtticaResolverAccount*) (all synchroton resolvers)
* 4) ResolverAccount* for manually added resolvers (from file).
*
* These are the top-level items in tree.
*
* Top level nodes all look the same to the user. The only difference is that services that have login (and thus
* can have multiple logins at once) allow a user to create multiple children with specific login information.
* All other top level accounts (Account*, Attica::Content, ResolverAccount*) behave the same to the user, they can
* simply click "Install" or toggle on/off.
*
*/
struct AccountModelNode {
enum NodeType {
FactoryType,
AccountType,
AtticaType,
ManualResolverType
};
AccountModelNode* parent;
NodeType type;
QList< AccountModelNode* > children; // list of children accounts (actually existing and configured accounts)
/// 1.
AccountFactory* factory;
/// 2.
Account* account;
/// 3.
Attica::Content atticaContent;
AtticaResolverAccount* atticaAccount;
/// 4.
ResolverAccount* resolverAccount;
// Construct in one of four ways. Then access the corresponding members
explicit AccountModelNode( AccountModelNode* p, AccountFactory* fac ) : parent( p ), type( FactoryType )
{
init();
factory = fac;
// Initialize factory nodes with their children
foreach ( Account* acct, AccountManager::instance()->accounts() )
{
if ( AccountManager::instance()->factoryForAccount( acct ) == fac )
{
qDebug() << "Found account for factory:" << acct->accountFriendlyName();
new AccountModelNode( this, acct );
}
}
}
AccountModelNode( AccountModelNode* p, Account* acct ) : parent( p ), type( AccountType )
{
init();
account = acct;
}
explicit AccountModelNode( AccountModelNode* p, Attica::Content cnt ) : parent( p ), type( AtticaType )
{
init();
atticaContent = cnt;
qDebug() << "Creating attica model node for resolver:" << cnt.id();
foreach ( Account* acct, AccountManager::instance()->accounts( Accounts::ResolverType ) )
{
if ( AtticaResolverAccount* resolver = qobject_cast< AtticaResolverAccount* >( acct ) )
{
if ( resolver->atticaId() == atticaContent.id() )
{
qDebug() << "found atticaaccount :" << resolver->accountFriendlyName();
atticaAccount = resolver;
break;
}
}
}
}
explicit AccountModelNode( AccountModelNode* p, ResolverAccount* ra ) : parent( p ), type( ManualResolverType )
{
init();
resolverAccount = ra;
}
AccountModelNode() : parent( 0 ) {}
~AccountModelNode()
{
qDeleteAll( children );
}
void init()
{
parent->children.append( this );
factory = 0;
account = 0;
atticaAccount = 0;
resolverAccount = 0;
}
};
}
}
#endif // TOMAHAWK_ACCOUNTS_ACCOUNTMODELNODE_H

View File

@@ -102,12 +102,12 @@ SettingsDialog::SettingsDialog( QWidget *parent )
#endif #endif
// SIP PLUGINS // SIP PLUGINS
AccountDelegate* sipdel = new AccountDelegate( this ); // AccountDelegate* sipdel = new AccountDelegate( this );
ui->accountsView->setItemDelegate( sipdel ); // ui->accountsView->setItemDelegate( sipdel );
ui->accountsView->setContextMenuPolicy( Qt::CustomContextMenu ); ui->accountsView->setContextMenuPolicy( Qt::CustomContextMenu );
ui->accountsView->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); ui->accountsView->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
connect( sipdel, SIGNAL( openConfig( Tomahawk::Accounts::Account* ) ), this, SLOT( openAccountConfig( Tomahawk::Accounts::Account* ) ) ); // connect( sipdel, SIGNAL( openConfig( Tomahawk::Accounts::Account* ) ), this, SLOT( openAccountConfig( Tomahawk::Accounts::Account* ) ) );
connect( ui->accountsView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( accountContextMenuRequest( QPoint ) ) ); connect( ui->accountsView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( accountContextMenuRequest( QPoint ) ) );
m_accountModel = new AccountModel( this ); m_accountModel = new AccountModel( this );
ui->accountsView->setModel( m_accountModel ); ui->accountsView->setModel( m_accountModel );
@@ -598,11 +598,11 @@ SettingsDialog::accountContextMenuRequest( const QPoint& p )
// if it's an account, allow to delete // if it's an account, allow to delete
if( idx.isValid() ) if( idx.isValid() )
{ {
QList< QAction* > acts; // QList< QAction* > acts;
acts << new QAction( tr( "Delete Service" ), this ); // acts << new QAction( tr( "Delete Service" ), this );
acts.first()->setProperty( "accountplugin", idx.data( AccountModel::AccountData ) ); // acts.first()->setProperty( "accountplugin", idx.data( AccountModel::AccountData ) );
connect( acts.first(), SIGNAL( triggered( bool ) ), this, SLOT( onAccountRowDeleted( bool ) ) ); // connect( acts.first(), SIGNAL( triggered( bool ) ), this, SLOT( onAccountRowDeleted( bool ) ) );
QMenu::exec( acts, ui->accountsView->mapToGlobal( p ) ); // QMenu::exec( acts, ui->accountsView->mapToGlobal( p ) );
} }
} }
@@ -625,8 +625,8 @@ SettingsDialog::accountDeleted( bool )
{ {
if( idx.isValid() ) if( idx.isValid() )
{ {
Account* account = qobject_cast< Account* >( idx.data( AccountModel::AccountData ).value< QObject* >() ); // Account* account = qobject_cast< Account* >( idx.data( AccountModel::AccountData ).value< QObject* >() );
AccountManager::instance()->removeAccount( account ); // AccountManager::instance()->removeAccount( account );
} }
} }
} }

View File

@@ -129,10 +129,10 @@
<item> <item>
<widget class="QTreeView" name="accountsView"> <widget class="QTreeView" name="accountsView">
<property name="indentation"> <property name="indentation">
<number>0</number> <number>6</number>
</property> </property>
<property name="rootIsDecorated"> <property name="rootIsDecorated">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="uniformRowHeights"> <property name="uniformRowHeights">
<bool>false</bool> <bool>false</bool>