1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 19:30:21 +02:00

Refactor Job error display into own function

This commit is contained in:
Uwe L. Korn
2014-10-27 19:00:40 +01:00
parent c0ecbb45ac
commit 9e4f46a567
2 changed files with 15 additions and 12 deletions

View File

@@ -109,15 +109,13 @@ ResolverAccountFactory::createFromPath( const QString& path, const QString& fact
MANUALRESOLVERS_DIR ) ); MANUALRESOLVERS_DIR ) );
if ( !( dir.exists() && dir.isReadable() ) ) //decompression fubar if ( !( dir.exists() && dir.isReadable() ) ) //decompression fubar
{ {
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( displayError( tr( "Resolver installation error: cannot open bundle." ) );
tr( "Resolver installation error: cannot open bundle." ) ) );
return 0; return 0;
} }
if ( !dir.cd( "content" ) ) //more fubar if ( !dir.cd( "content" ) ) //more fubar
{ {
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( displayError( tr( "Resolver installation error: incomplete bundle." ) );
tr( "Resolver installation error: incomplete bundle." ) ) );
return 0; return 0;
} }
@@ -155,8 +153,7 @@ ResolverAccountFactory::createFromPath( const QString& path, const QString& fact
realPath = configuration[ "path" ].toString(); realPath = configuration[ "path" ].toString();
if ( realPath.isEmpty() ) if ( realPath.isEmpty() )
{ {
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( displayError( tr( "Resolver installation error: bad metadata in bundle." ) );
tr( "Resolver installation error: bad metadata in bundle." ) ) );
return 0; return 0;
} }
} }
@@ -193,8 +190,7 @@ ResolverAccountFactory::createFromPath( const QString& path, const QString& fact
if ( !myPlatform.contains( platform ) ) if ( !myPlatform.contains( platform ) )
{ {
tDebug() << "Wrong resolver platform."; tDebug() << "Wrong resolver platform.";
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( displayError( tr( "Resolver installation error: platform mismatch." ) );
tr( "Resolver installation error: platform mismatch." ) ) );
return 0; return 0;
} }
} }
@@ -206,9 +202,8 @@ ResolverAccountFactory::createFromPath( const QString& path, const QString& fact
if ( TomahawkUtils::compareVersionStrings( thVer, requiredVer ) < 0 ) if ( TomahawkUtils::compareVersionStrings( thVer, requiredVer ) < 0 )
{ {
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( displayError( tr( "Resolver installation error: Tomahawk %1 or newer is required." )
tr( "Resolver installation error: Tomahawk %1 or newer is required." ) .arg( requiredVer ) );
.arg( requiredVer ) ) );
return 0; return 0;
} }
} }
@@ -282,6 +277,13 @@ ResolverAccountFactory::expandPaths( const QDir& contentDir, QVariantHash& confi
} }
void
ResolverAccountFactory::displayError( const QString& error )
{
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( error ) );
}
ResolverAccount::ResolverAccount( const QString& accountId ) ResolverAccount::ResolverAccount( const QString& accountId )
: Account( accountId ) : Account( accountId )
{ {

View File

@@ -56,8 +56,9 @@ public:
static Account* createFromPath( const QString& path, const QString& factoryId, bool isAttica ); static Account* createFromPath( const QString& path, const QString& factoryId, bool isAttica );
private: private:
static QVariantHash metadataFromJsonFile( const QString& path ); static void displayError( const QString& error );
static void expandPaths( const QDir& contentDir, QVariantHash& configuration ); static void expandPaths( const QDir& contentDir, QVariantHash& configuration );
static QVariantHash metadataFromJsonFile( const QString& path );
}; };
/** /**