1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-18 23:09:42 +01:00

Non-working save

This commit is contained in:
Leo Franchi 2012-02-10 19:38:36 -05:00
parent 369c8ecd98
commit 132460b797
11 changed files with 122 additions and 2 deletions

View File

@ -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() );
};

View File

@ -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() );
};

View File

@ -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

View File

@ -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 )

View File

@ -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;
};

View File

@ -0,0 +1,44 @@
/* === 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/>.
*/
#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() );
}

View File

@ -0,0 +1,41 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2012, 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 ACCOUNTMODELFILTERPROXY_H
#define ACCOUNTMODELFILTERPROXY_H
#include <QSortFilterProxyModel>
#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

View File

@ -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

View File

@ -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 );

View File

@ -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 );

View File

@ -121,7 +121,7 @@
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox"/>
<widget class="QComboBox" name="accountsFilterCombo"/>
</item>
</layout>
</item>