From 9a741cd2db294e56d97888b30e230bf01828b3ea Mon Sep 17 00:00:00 2001 From: Enno Gottschalk Date: Wed, 2 Mar 2016 17:11:01 +0100 Subject: [PATCH] Czeched, polished and finnished --- src/libtomahawk/accounts/Account.cpp | 2 +- src/libtomahawk/accounts/Account.h | 2 +- .../accounts/DelegateConfigWrapper.cpp | 17 ++++++----------- src/libtomahawk/accounts/ResolverAccount.cpp | 6 +++--- src/libtomahawk/resolvers/ScriptJob.cpp | 5 +++-- src/libtomahawk/resolvers/ScriptJob.h | 3 +-- src/libtomahawk/resolvers/SyncScriptJob.cpp | 2 +- 7 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/libtomahawk/accounts/Account.cpp b/src/libtomahawk/accounts/Account.cpp index 3c3851a33..9b2ee15be 100644 --- a/src/libtomahawk/accounts/Account.cpp +++ b/src/libtomahawk/accounts/Account.cpp @@ -153,7 +153,7 @@ Account::removeFromConfig() void Account::testConfig() { - emit configTestResult( ConfigTestResultSuccess, "" ); + emit configTestResult( ConfigTestResultSuccess ); } diff --git a/src/libtomahawk/accounts/Account.h b/src/libtomahawk/accounts/Account.h index ec1006fa8..c6eb641a1 100644 --- a/src/libtomahawk/accounts/Account.h +++ b/src/libtomahawk/accounts/Account.h @@ -167,7 +167,7 @@ signals: void connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState state ); void configurationChanged(); - void configTestResult( int, const QString& ); + void configTestResult( int, const QString& = QString() ); protected: virtual void loadFromConfig( const QString &accountId ); diff --git a/src/libtomahawk/accounts/DelegateConfigWrapper.cpp b/src/libtomahawk/accounts/DelegateConfigWrapper.cpp index 6c7650bb1..e78b64aec 100644 --- a/src/libtomahawk/accounts/DelegateConfigWrapper.cpp +++ b/src/libtomahawk/accounts/DelegateConfigWrapper.cpp @@ -227,12 +227,7 @@ DelegateConfigWrapper::onConfigTestResult( int code, const QString& message ) m_invalidData = m_widget->readData(); - QString msg; - if (message.isEmpty()){ - msg = getTestConfigMessage(code); - } else { - msg = message; - } + QString msg = !message.isEmpty() ? message : getTestConfigMessage( code ); m_errorLabel->setText( QString( "%1" ).arg( msg ) ); } } @@ -242,15 +237,15 @@ DelegateConfigWrapper::getTestConfigMessage( int code ) { switch(code) { case Tomahawk::Accounts::ConfigTestResultCommunicationError: - return QObject::tr( "Unable to authenticate. Please check your connection." ); + return tr( "Unable to authenticate. Please check your connection." ); case Tomahawk::Accounts::ConfigTestResultInvalidCredentials: - return QObject::tr( "Username or password incorrect." ); + return tr( "Username or password incorrect." ); case Tomahawk::Accounts::ConfigTestResultInvalidAccount: - return QObject::tr( "Account rejected by server." ); + return tr( "Account rejected by server." ); case Tomahawk::Accounts::ConfigTestResultPlayingElsewhere: - return QObject::tr( "Action not allowed, account is in use elsewhere." ); + return tr( "Action not allowed, account is in use elsewhere." ); case Tomahawk::Accounts::ConfigTestResultAccountExpired: - return QObject::tr( "Your account has expired." ); + return tr( "Your account has expired." ); } } diff --git a/src/libtomahawk/accounts/ResolverAccount.cpp b/src/libtomahawk/accounts/ResolverAccount.cpp index f7d5036a8..e808e4137 100644 --- a/src/libtomahawk/accounts/ResolverAccount.cpp +++ b/src/libtomahawk/accounts/ResolverAccount.cpp @@ -547,7 +547,7 @@ ResolverAccount::testConfig() } else { - emit configTestResult( Accounts::ConfigTestResultSuccess, "" ); + emit configTestResult( Accounts::ConfigTestResultSuccess ); } } @@ -564,13 +564,13 @@ ResolverAccount::onTestConfig( const QVariant& result ) { tLog() << Q_FUNC_INFO << result; - if (result.type() == QMetaType::QString) + if ( result.type() == QMetaType::QString ) { emit configTestResult( Accounts::ConfigTestResultOther, result.toString() ); } else { - emit configTestResult( result.toInt(), "" ); + emit configTestResult( result.toInt() ); } sender()->deleteLater(); diff --git a/src/libtomahawk/resolvers/ScriptJob.cpp b/src/libtomahawk/resolvers/ScriptJob.cpp index 7738fa2da..783b313bc 100644 --- a/src/libtomahawk/resolvers/ScriptJob.cpp +++ b/src/libtomahawk/resolvers/ScriptJob.cpp @@ -92,7 +92,7 @@ ScriptJob::reportResultsMap( const QVariantMap& data ) void ScriptJob::reportResults( const QVariant& data ) { - m_data_primitive = data; + m_data = data; emit done( data ); } @@ -102,5 +102,6 @@ ScriptJob::reportFailure( const QString& errorMessage ) { emit error( errorMessage ); - reportResultsMap( QVariantMap() ); + reportResults(); + reportResultsMap(); } diff --git a/src/libtomahawk/resolvers/ScriptJob.h b/src/libtomahawk/resolvers/ScriptJob.h index 8f500aff8..6b8f66b81 100644 --- a/src/libtomahawk/resolvers/ScriptJob.h +++ b/src/libtomahawk/resolvers/ScriptJob.h @@ -65,8 +65,7 @@ protected: bool m_error; QString m_id; scriptobject_ptr m_scriptObject; - QVariantMap m_data; - QVariant m_data_primitive; + QVariant m_data; QString m_methodName; QVariantMap m_arguments; }; diff --git a/src/libtomahawk/resolvers/SyncScriptJob.cpp b/src/libtomahawk/resolvers/SyncScriptJob.cpp index 3eb2163a3..9f2506300 100644 --- a/src/libtomahawk/resolvers/SyncScriptJob.cpp +++ b/src/libtomahawk/resolvers/SyncScriptJob.cpp @@ -30,5 +30,5 @@ Tomahawk::SyncScriptJob::SyncScriptJob( const QVariantMap& resultData ) void Tomahawk::SyncScriptJob::start() { - QMetaObject::invokeMethod( this, "reportResultsMap", Qt::QueuedConnection, Q_ARG( QVariantMap, m_data ) ); + QMetaObject::invokeMethod( this, "reportResultsMap", Qt::QueuedConnection, Q_ARG( QVariantMap, m_data.toMap() ) ); }