From cf9389a0deae1eb34bb26f6b76f84ac672fa0d37 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Sun, 22 Jan 2012 20:08:32 -0500 Subject: [PATCH] work towards integrating resolvers in accounts refactor --- src/CMakeLists.txt | 4 - src/accounts/xmpp/xmppaccount.h | 8 +- src/libtomahawk/CMakeLists.txt | 2 + src/libtomahawk/ExternalResolver.h | 4 +- src/libtomahawk/accounts/Account.h | 2 +- src/libtomahawk/accounts/AccountManager.cpp | 49 +++- src/libtomahawk/accounts/AccountManager.h | 3 + src/libtomahawk/accounts/AccountModel.cpp | 6 +- src/libtomahawk/accounts/AccountModel.h | 1 - src/libtomahawk/pipeline.cpp | 31 +-- src/libtomahawk/pipeline.h | 4 +- src/libtomahawk/resolvers/scriptresolver.cpp | 2 + src/libtomahawk/tomahawksettings.cpp | 28 ++- src/libtomahawk/typedefs.h | 4 + src/resolverconfigdelegate.cpp | 2 +- src/resolversmodel.cpp | 251 ------------------- src/resolversmodel.h | 64 ----- src/settingsdialog.cpp | 40 ++- src/settingsdialog.h | 7 - 19 files changed, 123 insertions(+), 389 deletions(-) delete mode 100644 src/resolversmodel.cpp delete mode 100644 src/resolversmodel.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 48d6d4fec..31591e961 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -76,9 +76,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui} diagnosticsdialog.cpp configdelegatebase.cpp AccountDelegate.cpp - resolverconfigdelegate.cpp settingslistdelegate.cpp - resolversmodel.cpp tomahawkwindow.cpp LoadXSPFDialog.cpp ) @@ -127,10 +125,8 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui} settingsdialog.h diagnosticsdialog.h configdelegatebase.h - resolverconfigdelegate.h AccountDelegate.h settingslistdelegate.h - resolversmodel.h delegateconfigwrapper.h tomahawkwindow.h LoadXSPFDialog.h diff --git a/src/accounts/xmpp/xmppaccount.h b/src/accounts/xmpp/xmppaccount.h index ff8961129..7295df7c1 100644 --- a/src/accounts/xmpp/xmppaccount.h +++ b/src/accounts/xmpp/xmppaccount.h @@ -40,6 +40,8 @@ class ACCOUNTDLLEXPORT XmppAccountFactory : public AccountFactory Q_OBJECT Q_INTERFACES( Tomahawk::Accounts::AccountFactory ) + // for settings access + friend class XmppConfigWidget; public: XmppAccountFactory() {} virtual ~XmppAccountFactory() {} @@ -76,12 +78,6 @@ public: protected: QWeakPointer< QWidget > m_configWidget; // so the google wrapper can change the config dialog a bit QWeakPointer< XmppSipPlugin > m_xmppSipPlugin; - -private: - - - // for settings access - friend class XmppConfigWidget; }; }; diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index 9c92ee5c6..6444822d6 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -308,6 +308,7 @@ set( libSources accounts/AccountManager.cpp accounts/Account.cpp accounts/AccountModel.cpp + accounts/ResolverAccount.cpp sip/SipPlugin.cpp sip/SipHandler.cpp @@ -439,6 +440,7 @@ set( libHeaders accounts/Account.h accounts/AccountManager.h accounts/AccountModel.h + accounts/ResolverAccount.h EchonestCatalogSynchronizer.h diff --git a/src/libtomahawk/ExternalResolver.h b/src/libtomahawk/ExternalResolver.h index a63f42396..bf3a01082 100644 --- a/src/libtomahawk/ExternalResolver.h +++ b/src/libtomahawk/ExternalResolver.h @@ -1,6 +1,7 @@ /* === This file is part of Tomahawk Player - === * * Copyright 2010-2011, Christian Muehlhaeuser + * 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 @@ -24,6 +25,7 @@ #include "dllmacro.h" #include "resolver.h" +#include #include @@ -64,7 +66,7 @@ public slots: virtual void stop() = 0; signals: - void changed(); // if config widget was added/removed + void changed(); // if config widget was added/removed, name changed, etc protected: void setFilePath( const QString& path ) { m_filePath = path; } diff --git a/src/libtomahawk/accounts/Account.h b/src/libtomahawk/accounts/Account.h index 83b37aece..a46007b19 100644 --- a/src/libtomahawk/accounts/Account.h +++ b/src/libtomahawk/accounts/Account.h @@ -113,7 +113,7 @@ public: void setAcl( const QVariantMap &acl ) { QMutexLocker locker( &m_mutex ); m_acl = acl; } void setTypes( AccountTypes types ); - virtual void sync() { QMutexLocker locker( &m_mutex ); syncConfig(); }; + void sync() { QMutexLocker locker( &m_mutex ); syncConfig(); }; /** * Removes all the settings held in the config file for this account instance diff --git a/src/libtomahawk/accounts/AccountManager.cpp b/src/libtomahawk/accounts/AccountManager.cpp index dd17b45ef..a400353fc 100644 --- a/src/libtomahawk/accounts/AccountManager.cpp +++ b/src/libtomahawk/accounts/AccountManager.cpp @@ -20,6 +20,7 @@ #include "AccountManager.h" #include "config.h" #include "sourcelist.h" +#include "ResolverAccount.h" #include #include @@ -53,6 +54,10 @@ AccountManager::AccountManager( QObject *parent ) connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( onSettingsChanged() ) ); loadPluginFactories( findPluginFactories() ); + + // We include the resolver factory manually, not in a plugin + ResolverAccountFactory* f = new ResolverAccountFactory(); + m_accountFactories[ f->factoryId() ] = f; } @@ -170,13 +175,40 @@ AccountManager::loadPluginFactory( const QString& path ) +void +AccountManager::enableAccount( Account* account ) +{ + if ( account->isAuthenticated() ) + return; + + account->authenticate(); + + account->setEnabled( true ); + m_enabledAccounts << account; +} + + +void +AccountManager::disableAccount( Account* account ) +{ + if ( !account->isAuthenticated() ) + return; + + account->deauthenticate(); + account->setEnabled( false ); + m_enabledAccounts.removeAll( account ); +} + + void AccountManager::connectAll() { foreach( Account* acc, m_accounts ) { - if ( acc->types() & Accounts::SipType && acc->sipPlugin() ) - acc->sipPlugin()->connectPlugin(); + acc->authenticate(); + m_enabledAccounts << acc; +// if ( acc->types() & Accounts::SipType && acc->sipPlugin() ) +// acc->sipPlugin()->connectPlugin(); } m_connected = true; @@ -186,9 +218,10 @@ AccountManager::connectAll() void AccountManager::disconnectAll() { - foreach( Account* acc, m_connectedAccounts ) - acc->sipPlugin()->disconnectPlugin(); + foreach( Account* acc, m_enabledAccounts ) + acc->deauthenticate(); + m_enabledAccounts.clear(); SourceList::instance()->removeAllRemote(); m_connected = false; } @@ -224,9 +257,8 @@ void AccountManager::initSIP() { tDebug() << Q_FUNC_INFO; - foreach( Account* account, accounts( Tomahawk::Accounts::SipType ) ) + foreach( Account* account, accounts() ) { - tDebug() << Q_FUNC_INFO << "adding plugin " << account->accountId(); hookupAndEnable( account, true ); } } @@ -300,7 +332,8 @@ void AccountManager::hookupAndEnable( Account* account, bool startup ) { SipPlugin* p = account->sipPlugin(); - SipHandler::instance()->hookUpPlugin( p ); + if ( p ) + SipHandler::instance()->hookUpPlugin( p ); if ( account->enabled() && ( !startup || account->autoConnect() ) ) { @@ -363,4 +396,4 @@ AccountManager::onStateChanged( Account::ConnectionState state ) }; -}; +}; \ No newline at end of file diff --git a/src/libtomahawk/accounts/AccountManager.h b/src/libtomahawk/accounts/AccountManager.h index 2894dad6e..969edd27f 100644 --- a/src/libtomahawk/accounts/AccountManager.h +++ b/src/libtomahawk/accounts/AccountManager.h @@ -47,6 +47,9 @@ public: void loadFromConfig(); void initSIP(); + void enableAccount( Account* account ); + void disableAccount( Account* account ); + QList< AccountFactory* > factories() const { return m_accountFactories.values(); } bool hasPluginWithFactory( const QString& factory ) const; AccountFactory* factoryForAccount( Account* account ) const; diff --git a/src/libtomahawk/accounts/AccountModel.cpp b/src/libtomahawk/accounts/AccountModel.cpp index d5cd8b30c..80f04444b 100644 --- a/src/libtomahawk/accounts/AccountModel.cpp +++ b/src/libtomahawk/accounts/AccountModel.cpp @@ -84,10 +84,12 @@ AccountModel::setData( const QModelIndex& index, const QVariant& value, int role Account* account = accounts[ index.row() ]; if( state == Qt::Checked && !account->enabled() ) { - account->setEnabled( true ); + AccountManager::instance()->enableAccount( account ); } else if( state == Qt::Unchecked ) { - account->setEnabled( false ); + AccountManager::instance()->disableAccount( account ); } + + account->sync(); dataChanged( index, index ); return true; diff --git a/src/libtomahawk/accounts/AccountModel.h b/src/libtomahawk/accounts/AccountModel.h index 5ad2c6402..e905a7ca2 100644 --- a/src/libtomahawk/accounts/AccountModel.h +++ b/src/libtomahawk/accounts/AccountModel.h @@ -40,7 +40,6 @@ public: enum Roles { AccountName = Qt::UserRole + 15, AccountIcon = Qt::UserRole + 16, - HeadlineText = Qt::UserRole + 17, AccountTypeRole = Qt::UserRole + 19, ConnectionStateRole = Qt::UserRole + 20, HasConfig = Qt::UserRole + 21, diff --git a/src/libtomahawk/pipeline.cpp b/src/libtomahawk/pipeline.cpp index 73d14fce4..0fdc9c563 100644 --- a/src/libtomahawk/pipeline.cpp +++ b/src/libtomahawk/pipeline.cpp @@ -64,7 +64,10 @@ Pipeline::~Pipeline() m_running = false; // stop script resolvers - qDeleteAll( m_scriptResolvers ); + foreach ( QWeakPointer< ExternalResolver > r, m_scriptResolvers ) + if ( !r.isNull() ) + r.data()->deleteLater(); + m_scriptResolvers.clear(); } @@ -133,7 +136,7 @@ Pipeline::addScriptResolver( const QString& path, bool start ) if ( !res ) continue; - m_scriptResolvers << res; + m_scriptResolvers << QWeakPointer< ExternalResolver >( res ); if ( start ) res->start(); @@ -147,10 +150,10 @@ Pipeline::addScriptResolver( const QString& path, bool start ) void Pipeline::stopScriptResolver( const QString& path ) { - foreach ( ExternalResolver* res, m_scriptResolvers ) + foreach ( QWeakPointer< ExternalResolver > res, m_scriptResolvers ) { - if ( res->filePath() == path ) - res->stop(); + if ( res.data()->filePath() == path ) + res.data()->stop(); } } @@ -158,18 +161,18 @@ Pipeline::stopScriptResolver( const QString& path ) void Pipeline::removeScriptResolver( const QString& scriptPath ) { - ExternalResolver* r = 0; - foreach ( ExternalResolver* res, m_scriptResolvers ) + QWeakPointer< ExternalResolver > r; + foreach ( QWeakPointer< ExternalResolver > res, m_scriptResolvers ) { - if ( res->filePath() == scriptPath ) + if ( res.data()->filePath() == scriptPath ) r = res; } m_scriptResolvers.removeAll( r ); - if ( r ) + if ( !r.isNull() ) { - r->stop(); - r->deleteLater(); + r.data()->stop(); + r.data()->deleteLater(); } } @@ -177,10 +180,10 @@ Pipeline::removeScriptResolver( const QString& scriptPath ) ExternalResolver* Pipeline::resolverForPath( const QString& scriptPath ) { - foreach ( ExternalResolver* res, m_scriptResolvers ) + foreach ( QWeakPointer< ExternalResolver > res, m_scriptResolvers ) { - if ( res->filePath() == scriptPath ) - return res; + if ( res.data()->filePath() == scriptPath ) + return res.data(); } return 0; } diff --git a/src/libtomahawk/pipeline.h b/src/libtomahawk/pipeline.h index 8ef9a607b..5fa88a2d7 100644 --- a/src/libtomahawk/pipeline.h +++ b/src/libtomahawk/pipeline.h @@ -59,7 +59,7 @@ public: Tomahawk::ExternalResolver* addScriptResolver( const QString& scriptPath, bool start = true ); void stopScriptResolver( const QString& scriptPath ); void removeScriptResolver( const QString& scriptPath ); - QList< Tomahawk::ExternalResolver* > scriptResolvers() const { return m_scriptResolvers; } + QList< QWeakPointer< ExternalResolver > > scriptResolvers() const { return m_scriptResolvers; } Tomahawk::ExternalResolver* resolverForPath( const QString& scriptPath ); void addResolver( Resolver* r ); @@ -106,7 +106,7 @@ private: int decQIDState( const Tomahawk::query_ptr& query ); QList< Resolver* > m_resolvers; - QList< Tomahawk::ExternalResolver* > m_scriptResolvers; + QList< QWeakPointer > m_scriptResolvers; QList< ResolverFactoryFunc > m_resolverFactories; QMap< QID, bool > m_qidsTimeout; QMap< QID, unsigned int > m_qidsState; diff --git a/src/libtomahawk/resolvers/scriptresolver.cpp b/src/libtomahawk/resolvers/scriptresolver.cpp index 37fd4ec05..e03ac5d9f 100644 --- a/src/libtomahawk/resolvers/scriptresolver.cpp +++ b/src/libtomahawk/resolvers/scriptresolver.cpp @@ -342,6 +342,8 @@ ScriptResolver::doSetup( const QVariantMap& m ) if ( !m_stopped ) Tomahawk::Pipeline::instance()->addResolver( this ); + + emit changed(); } diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp index 029faf615..63305d912 100644 --- a/src/libtomahawk/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -255,8 +255,34 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion ) remove( sipPlugin ); } - setValue( "accounts/allaccounts", accounts ); remove( "sip" ); + + // Migrate all resolvers from old resolvers settings to new accounts system + const QStringList allResolvers = value( "script/resolvers" ).toStringList(); + const QStringList enabledResolvers = value( "script/loadedresolvers" ).toStringList(); + + foreach ( const QString& resolver, allResolvers ) + { + const QString accountKey = QString( "resolveraccount_%1" ).arg( QUuid::createUuid().toString().mid( 1, 8 ) ); + accounts << accountKey; + + beginGroup( "accounts/" + accountKey ); + setValue( "enabled", enabledResolvers.contains( resolver ) == true ); + setValue( "autoconnect", true ); + setValue( "types", QStringList() << "ResolverType" ); + + QVariantHash configuration; + configuration[ "path" ] = resolver; + setValue( "configuration", configuration ); + + endGroup(); + + } + + remove( "script/resolvers" ); + remove( "script/loadedresolvers" ); + + setValue( "accounts/allaccounts", accounts ); } } diff --git a/src/libtomahawk/typedefs.h b/src/libtomahawk/typedefs.h index b972009ba..ffe6b23ab 100644 --- a/src/libtomahawk/typedefs.h +++ b/src/libtomahawk/typedefs.h @@ -22,6 +22,7 @@ #include #include #include +#include //template class QSharedPointer; @@ -69,6 +70,9 @@ namespace Tomahawk InfoSystemMode }; + class ExternalResolver; + typedef boost::function ResolverFactoryFunc; + }; // ns typedef int AudioErrorCode; diff --git a/src/resolverconfigdelegate.cpp b/src/resolverconfigdelegate.cpp index 592d1a768..96f2274f2 100644 --- a/src/resolverconfigdelegate.cpp +++ b/src/resolverconfigdelegate.cpp @@ -18,7 +18,7 @@ #include "resolverconfigdelegate.h" -#include "resolversmodel.h" +// #include "resolversmodel.h" #include "ExternalResolverGui.h" #include diff --git a/src/resolversmodel.cpp b/src/resolversmodel.cpp deleted file mode 100644 index c38b02b44..000000000 --- a/src/resolversmodel.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/* === 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 "resolversmodel.h" - -#include - -#include "tomahawksettings.h" -#include "tomahawkapp.h" -#include "ExternalResolverGui.h" -#include "pipeline.h" -#include "config.h" -#include "AtticaManager.h" -#include "utils/logger.h" - -ResolversModel::ResolversModel( QObject* parent ) - : QAbstractListModel( parent ) -{ - addInstalledResolvers(); -} - - -ResolversModel::~ResolversModel() -{ - -} - - -QVariant -ResolversModel::data( const QModelIndex& index, int role ) const -{ - if( !index.isValid() || !hasIndex( index.row(), index.column(), QModelIndex() ) ) - return QVariant(); - - Tomahawk::ExternalResolver* r = Tomahawk::Pipeline::instance()->scriptResolvers().at( index.row() ); - Tomahawk::ExternalResolverGui* res = qobject_cast< Tomahawk::ExternalResolverGui* >( r ); - Q_ASSERT(res); // this is part of the gui, so there should be no non-gui resolvers - switch( role ) - { - case Qt::DisplayRole: - case ResolversModel::ResolverName: - return res->name(); - case ResolversModel::ResolverPath: - return res->filePath(); - case ResolversModel::HasConfig: - return res->configUI() != 0; - case ResolversModel::ErrorState: - return res->error(); - case Qt::CheckStateRole: - return res->running() ? Qt::Checked : Qt::Unchecked; - case Qt::ToolTipRole: - return res->filePath(); - default: - return QVariant(); - } -} - - -bool -ResolversModel::setData( const QModelIndex& index, const QVariant& value, int role ) -{ - if ( !hasIndex( index.row(), index.column(), QModelIndex() ) ) - return false; - - Tomahawk::ExternalResolver* r = Tomahawk::Pipeline::instance()->scriptResolvers().at( index.row() ); - if ( r && r->error() == Tomahawk::ExternalResolver::FileNotFound ) // give it a shot to see if the user manually fixed paths - { - r->reload(); - - if( r->error() == Tomahawk::ExternalResolver::FileNotFound ) // Nope, no luck. Doesn't exist on disk, don't let user mess with it - return false; - } - else if ( !r && !QFile::exists( r->filePath() ) ) - { - return false; - } - - if ( role == Qt::CheckStateRole ) - { - Qt::CheckState state = static_cast< Qt::CheckState >( value.toInt() ); - - if ( state == Qt::Checked && !r->running() ) { - r->start(); - } - else if ( state == Qt::Unchecked ) - { - r->stop(); - } - - emit dataChanged( index, index ); - return true; - } - return false; -} - - -int -ResolversModel::rowCount( const QModelIndex& parent ) const -{ - Q_UNUSED( parent ); - return Tomahawk::Pipeline::instance()->scriptResolvers().count(); -} - - -int -ResolversModel::columnCount(const QModelIndex& parent) const -{ - Q_UNUSED( parent ); - return 1; -} - - -Qt::ItemFlags -ResolversModel::flags( const QModelIndex& index ) const -{ - return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable; -} - - -void -ResolversModel::addResolver( const QString& resolver, bool enable ) -{ - const int count = rowCount( QModelIndex() ); - beginInsertRows( QModelIndex(), count, count ); - Tomahawk::ExternalResolver* r = Tomahawk::Pipeline::instance()->addScriptResolver( resolver, enable ); - Tomahawk::ExternalResolverGui* res = qobject_cast< Tomahawk::ExternalResolverGui* >( r ); - Q_ASSERT(res); // this is part of the gui, so there should be no non-gui resolvers - connect( res, SIGNAL( changed() ), this, SLOT( resolverChanged() ) ); - endInsertRows(); - - if ( res->configUI() ) - emit openConfig( res->filePath() ); - else - m_waitingForLoad << resolver; -} - - -void -ResolversModel::atticaResolverInstalled( const QString& resolverId ) -{ -#ifdef LIBATTICA_FOUND - Tomahawk::ExternalResolver* r = Tomahawk::Pipeline::instance()->resolverForPath( AtticaManager::instance()->pathFromId( resolverId ) ); - if ( !r ) - return; - const int idx = Tomahawk::Pipeline::instance()->scriptResolvers().indexOf( r ); - if ( idx >= 0 ) - { - beginInsertRows( QModelIndex(), idx, idx ); - endInsertRows(); - } -#endif -} - - -void -ResolversModel::removeResolver( const QString& resolver ) -{ - const int idx = Tomahawk::Pipeline::instance()->scriptResolvers().indexOf( Tomahawk::Pipeline::instance()->resolverForPath( resolver ) ); - if ( idx < 0 ) - return; - - beginRemoveRows( QModelIndex(), idx, idx ); - Tomahawk::Pipeline::instance()->removeScriptResolver( resolver ); - endRemoveRows(); -} - - -void -ResolversModel::resolverChanged() -{ - Tomahawk::ExternalResolver* res = qobject_cast< Tomahawk::ExternalResolver* >( sender() ); - Q_ASSERT( res ); - - if ( Tomahawk::Pipeline::instance()->scriptResolvers().contains( res ) ) - { - qDebug() << "Got resolverChanged signal, does it have a config UI yet?" << qobject_cast< Tomahawk::ExternalResolverGui* >(res)->configUI(); - const QModelIndex idx = index( Tomahawk::Pipeline::instance()->scriptResolvers().indexOf( res ), 0, QModelIndex() ); - emit dataChanged( idx, idx ); - - if ( m_waitingForLoad.contains( res->filePath() ) ) - { - m_waitingForLoad.remove( res->filePath() ); - emit openConfig( res->filePath() ); - } - } -} - - -void -ResolversModel::addInstalledResolvers() -{ - QList< QDir > pluginDirs; - - QDir appDir( qApp->applicationDirPath() ); - QDir libDir( CMAKE_INSTALL_PREFIX "/lib" ); - QDir libexecDir( CMAKE_INSTALL_FULL_LIBEXECDIR ); - - QDir lib64Dir( appDir ); - lib64Dir.cdUp(); - lib64Dir.cd( "lib64" ); - - pluginDirs << appDir << libDir << lib64Dir << libexecDir; - foreach ( const QDir& pluginDir, pluginDirs ) - { - qDebug() << "Checking directory for resolvers:" << pluginDir; - foreach ( QString fileName, pluginDir.entryList( QStringList() << "*_tomahawkresolver*", QDir::Files ) ){ - if ( fileName.contains( "_tomahawkresolver" ) ) { - const QString path = pluginDir.absoluteFilePath( fileName ); - bool found = false; - foreach ( Tomahawk::ExternalResolver* res, Tomahawk::Pipeline::instance()->scriptResolvers() ) - { - if ( res->filePath() == path ) - found = true; - } - if ( !found ) { - Tomahawk::Pipeline::instance()->addScriptResolver( path, false ); - } - } - } - } -} - - -void -ResolversModel::saveScriptResolvers() -{ - QStringList enabled, all; - foreach ( Tomahawk::ExternalResolver* res, Tomahawk::Pipeline::instance()->scriptResolvers() ) - { - all << res->filePath(); - if ( res->running() ) - enabled << res->filePath(); - } - TomahawkSettings::instance()->setAllScriptResolvers( all ); - TomahawkSettings::instance()->setEnabledScriptResolvers( enabled ); -} diff --git a/src/resolversmodel.h b/src/resolversmodel.h deleted file mode 100644 index 9aee76f72..000000000 --- a/src/resolversmodel.h +++ /dev/null @@ -1,64 +0,0 @@ -/* === 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 . - */ - - -#ifndef RESOLVERSMODEL_H -#define RESOLVERSMODEL_H - -#include -#include -#include - -class ResolversModel : public QAbstractListModel -{ - Q_OBJECT -public: - enum Roles { - ResolverName = Qt::UserRole + 15, - ResolverPath = Qt::UserRole + 16, - HasConfig = Qt::UserRole + 17, - ErrorState = Qt::UserRole + 18 - }; - - explicit ResolversModel( QObject* parent = 0 ); - virtual ~ResolversModel(); - - virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const; - virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const; - virtual int columnCount( const QModelIndex& parent ) const; - virtual Qt::ItemFlags flags(const QModelIndex& index) const; - virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); - - void addResolver( const QString& resolver, bool enable = false ); - void atticaResolverInstalled ( const QString& resolverId ); - void removeResolver( const QString& resolver ); - - void saveScriptResolvers(); - -signals: - void openConfig( const QString& filePath ); - -private slots: - void resolverChanged(); - -private: - void addInstalledResolvers(); - QSet m_waitingForLoad; -}; - -#endif // RESOLVERSMODEL_H diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index ca188dbbd..2785971dd 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -44,8 +44,6 @@ #include "pipeline.h" #include "resolver.h" #include "ExternalResolverGui.h" -#include "resolverconfigdelegate.h" -#include "resolversmodel.h" #include "scanmanager.h" #include "settingslistdelegate.h" #include "AccountDelegate.h" @@ -77,7 +75,6 @@ SettingsDialog::SettingsDialog( QWidget *parent ) , m_proxySettings( this ) , m_rejected( false ) , m_accountModel( 0 ) - , m_resolversModel( 0 ) , m_sipSpinner( 0 ) { ui->setupUi( this ); @@ -183,13 +180,7 @@ SettingsDialog::SettingsDialog( QWidget *parent ) // SCRIPT RESOLVER ui->removeScript->setEnabled( false ); - ResolverConfigDelegate* del = new ResolverConfigDelegate( this ); - connect( del, SIGNAL( openConfig( QString ) ), SLOT( openResolverConfig( QString ) ) ); - ui->scriptList->setItemDelegate( del ); - m_resolversModel = new ResolversModel( this ); - ui->scriptList->setModel( m_resolversModel ); ui->scriptList->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); - connect( m_resolversModel, SIGNAL( openConfig( QString ) ), SLOT( openResolverConfig( QString ) ) ); #ifdef LIBATTICA_FOUND connect( ui->getMoreResolvers, SIGNAL( clicked() ), this, SLOT( getMoreResolvers() ) ); @@ -242,8 +233,6 @@ SettingsDialog::~SettingsDialog() s->setLastFmUsername( ui->lineEditLastfmUsername->text() ); s->setLastFmPassword( ui->lineEditLastfmPassword->text() ); - m_resolversModel->saveScriptResolvers(); - s->applyChanges(); s->sync(); } @@ -485,14 +474,13 @@ SettingsDialog::onLastFmFinished() #endif } - +/* void SettingsDialog::addScriptResolver() { QString resolver = QFileDialog::getOpenFileName( this, tr( "Load script resolver file" ), TomahawkSettings::instance()->scriptDefaultPath() ); if( !resolver.isEmpty() ) { - m_resolversModel->addResolver( resolver, true ); QFileInfo resolverAbsoluteFilePath = resolver; TomahawkSettings::instance()->setScriptDefaultPath( resolverAbsoluteFilePath.absolutePath() ); @@ -512,7 +500,7 @@ SettingsDialog::removeScriptResolver() #endif m_resolversModel->removeResolver( resolver ); } -} +}*/ void @@ -532,18 +520,18 @@ SettingsDialog::getMoreResolvers() #ifdef LIBATTICA_FOUND -void -SettingsDialog::atticaResolverInstalled( const QString& resolverId ) -{ - m_resolversModel->atticaResolverInstalled( resolverId ); -} - - -void -SettingsDialog::atticaResolverUninstalled ( const QString& resolverId ) -{ - m_resolversModel->removeResolver( AtticaManager::instance()->pathFromId( resolverId ) ); -} +// void +// SettingsDialog::atticaResolverInstalled( const QString& resolverId ) +// { +// m_resolversModel->atticaResolverInstalled( resolverId ); +// } +// +// +// void +// SettingsDialog::atticaResolverUninstalled ( const QString& resolverId ) +// { +// m_resolversModel->removeResolver( AtticaManager::instance()->pathFromId( resolverId ) ); +// } #endif diff --git a/src/settingsdialog.h b/src/settingsdialog.h index 995f5fffd..b0a26a482 100644 --- a/src/settingsdialog.h +++ b/src/settingsdialog.h @@ -87,15 +87,9 @@ private slots: void testLastFmLogin(); void onLastFmFinished(); - void addScriptResolver(); void scriptSelectionChanged(); - void removeScriptResolver(); void getMoreResolvers(); void getMoreResolversFinished( int ); -#ifdef LIBATTICA_FOUND - void atticaResolverInstalled( const QString& ); - void atticaResolverUninstalled( const QString& ); -#endif void openResolverConfig( const QString& ); @@ -129,7 +123,6 @@ private: ProxyDialog m_proxySettings; bool m_rejected; Tomahawk::Accounts::AccountModel* m_accountModel; - ResolversModel* m_resolversModel; LoadingSpinner* m_sipSpinner; };