diff --git a/src/accounts/twitter/twitteraccount.h b/src/accounts/twitter/twitteraccount.h index d943b2591..e4c706ce2 100644 --- a/src/accounts/twitter/twitteraccount.h +++ b/src/accounts/twitter/twitteraccount.h @@ -48,6 +48,7 @@ public: QString factoryId() const { return "twitteraccount"; } QString description() const { return tr( "Connect to your Twitter followers." ); } QPixmap icon() const { return QPixmap( ":/twitter-icon.png" ); } + AccountTypes types() const { return AccountTypes( SipType ); }; Account* createAccount( const QString& pluginId = QString() ); }; diff --git a/src/accounts/xmpp/xmppaccount.h b/src/accounts/xmpp/xmppaccount.h index 77ba97904..5692c2c20 100644 --- a/src/accounts/xmpp/xmppaccount.h +++ b/src/accounts/xmpp/xmppaccount.h @@ -50,6 +50,7 @@ public: QString description() const { return tr( "Log on to your Jabber/XMPP account to connect to your friends" ); } QString factoryId() const { return "xmppaccount"; } QPixmap icon() const { return QPixmap( ":/xmpp-icon.png" ); } + AccountTypes types() const { return AccountTypes( SipType ); }; Account* createAccount( const QString& pluginId = QString() ); }; diff --git a/src/accounts/zeroconf/zeroconfaccount.h b/src/accounts/zeroconf/zeroconfaccount.h index 726e5c5a2..29a6673fd 100644 --- a/src/accounts/zeroconf/zeroconfaccount.h +++ b/src/accounts/zeroconf/zeroconfaccount.h @@ -41,6 +41,7 @@ public: virtual QString prettyName() const { return "Local Network"; } QString description() const { return tr( "Automatically connect to Tomahawks on the local network" ); } virtual bool isUnique() const { return true; } + AccountTypes types() const { return AccountTypes( SipType ); }; #ifndef ENABLE_HEADLESS virtual QPixmap icon() const; #endif diff --git a/src/libtomahawk/accounts/Account.cpp b/src/libtomahawk/accounts/Account.cpp index 9227c7f5c..73dffaded 100644 --- a/src/libtomahawk/accounts/Account.cpp +++ b/src/libtomahawk/accounts/Account.cpp @@ -25,6 +25,21 @@ namespace Tomahawk namespace Accounts { +QString +accountTypeToString( AccountType type ) +{ + switch ( type ) + { + case SipType: + return tr( "Friend Finders" ); + case ResolverType: + return tr( "Music Finders" ); + case InfoType: + return tr( "Status Updaters" ); + } +} + + Account::Account( const QString& accountId ) : QObject() , m_enabled( false ) diff --git a/src/libtomahawk/accounts/Account.h b/src/libtomahawk/accounts/Account.h index b8164d200..73448fd2b 100644 --- a/src/libtomahawk/accounts/Account.h +++ b/src/libtomahawk/accounts/Account.h @@ -53,6 +53,8 @@ enum AccountType ResolverType = 0x04 }; +DLLEXPORT QString accountTypeToString( AccountType type ); + Q_DECLARE_FLAGS(AccountTypes, AccountType); inline QString generateId( const QString &factoryId ) @@ -173,6 +175,9 @@ public: virtual QPixmap icon() const { return QPixmap(); } virtual bool allowUserCreation() const { return true; } + // What are the supported types for accounts this factory creates? + virtual AccountTypes types() const = 0; + virtual Account* createAccount( const QString& accountId = QString() ) = 0; }; diff --git a/src/libtomahawk/accounts/AccountModelFilterProxy.cpp b/src/libtomahawk/accounts/AccountModelFilterProxy.cpp new file mode 100644 index 000000000..faf14c7cb --- /dev/null +++ b/src/libtomahawk/accounts/AccountModelFilterProxy.cpp @@ -0,0 +1,44 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Leo Franchi + * + * 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 . + */ + +#include "AccountModelFilterProxy.h" + +#include "AccountModel.h" + +using namespace Tomahawk; +using namespace Accounts; + +AccountModelFilterProxy::AccountModelFilterProxy( QObject* parent ) + : QSortFilterProxyModel(parent) +{ + +} + +bool +AccountModelFilterProxy::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const +{ + if ( m_filterType == NoType ) + return true; + + const QModeIndex idx = sourceParent.child( sourceRow, 0 ); + const AccountModel::RowType rowType = static_cast< AccountModel::RowType >( idx.data( AccountModel::RowTypeRole ).toInt() ); + + + +} + diff --git a/src/libtomahawk/accounts/AccountModelFilterProxy.h b/src/libtomahawk/accounts/AccountModelFilterProxy.h new file mode 100644 index 000000000..02ebb161a --- /dev/null +++ b/src/libtomahawk/accounts/AccountModelFilterProxy.h @@ -0,0 +1,41 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2012, Leo Franchi + * + * 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 . + */ + +#ifndef ACCOUNTMODELFILTERPROXY_H +#define ACCOUNTMODELFILTERPROXY_H + +#include +#include "Account.h" + + +class AccountModelFilterProxy : public QSortFilterProxyModel +{ + Q_OBJECT +public: + AccountModelFilterProxy( QObject* parent = 0 ); + + void setFilterType( Tomahawk::Accounts::AccountType type ); + +protected: + virtual bool filterAcceptsRow ( int sourceRow, const QModelIndex& sourceParent ) const; + +private: + Tomahawk::Accounts::AccountType m_filterType; +}; + +#endif // ACCOUNTMODELFILTERPROXY_H diff --git a/src/libtomahawk/accounts/ResolverAccount.h b/src/libtomahawk/accounts/ResolverAccount.h index 9ee94bee4..f3cf4a594 100644 --- a/src/libtomahawk/accounts/ResolverAccount.h +++ b/src/libtomahawk/accounts/ResolverAccount.h @@ -38,6 +38,7 @@ public: virtual QString factoryId() const { return "resolveraccount"; } virtual QString description() const { return QString(); } virtual QString prettyName() const { return QString(); } // Internal, not displayed + AccountTypes types() const { return AccountTypes( ResolverType ); }; virtual bool allowUserCreation() const { return false; } // Used to create a new resolver from a script on disk, either chosen by diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 29a0471d1..e48c060d5 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -101,7 +101,7 @@ SettingsDialog::SettingsDialog( QWidget *parent ) p->setFixedSize( 0, 0 ); #endif - // SIP PLUGINS + // Accounts AccountDelegate* accountDelegate = new AccountDelegate( this ); ui->accountsView->setItemDelegate( accountDelegate ); ui->accountsView->setContextMenuPolicy( Qt::CustomContextMenu ); @@ -118,6 +118,13 @@ SettingsDialog::SettingsDialog( QWidget *parent ) connect( m_accountModel, SIGNAL( createAccount( Tomahawk::Accounts::AccountFactory* ) ), this, SLOT( createAccountFromFactory( Tomahawk::Accounts::AccountFactory* ) ) ); + ui->accountsFilterCombo->addItem( tr( "All" ), Accounts::NoType ); + ui->accountsFilterCombo->addItem( accountTypeToString( SipType ), SipType ); + ui->accountsFilterCombo->addItem( accountTypeToString( ResolverType ), ResolverType ); + ui->accountsFilterCombo->addItem( accountTypeToString( InfoType ), InfoType ); + + connect( ui->accountsFilterCombo, SIGNAL( activated( int ) ), this, SLOT( accountsFilterChanged( int ) ) ); + if ( !Servent::instance()->isReady() ) { m_sipSpinner = new LoadingSpinner( ui->accountsView ); @@ -125,6 +132,8 @@ SettingsDialog::SettingsDialog( QWidget *parent ) connect( Servent::instance(), SIGNAL( ready() ), this, SLOT( serventReady() ) ); } + + // ADVANCED ui->staticHostName->setText( s->externalHostname() ); ui->staticPort->setValue( s->externalPort() ); ui->proxyButton->setVisible( true ); diff --git a/src/settingsdialog.h b/src/settingsdialog.h index 363dc3a2f..544b1ff70 100644 --- a/src/settingsdialog.h +++ b/src/settingsdialog.h @@ -88,6 +88,8 @@ private slots: void testLastFmLogin(); void onLastFmFinished(); + void accountsFilterChanged( int ); + void createAccountFromFactory( Tomahawk::Accounts::AccountFactory* ); void openAccountConfig( Tomahawk::Accounts::Account*, bool showDelete = false ); diff --git a/src/stackedsettingsdialog.ui b/src/stackedsettingsdialog.ui index 584a89ace..69664c495 100644 --- a/src/stackedsettingsdialog.ui +++ b/src/stackedsettingsdialog.ui @@ -121,7 +121,7 @@ - +