1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-17 14:28:24 +01: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 ) );
if ( !( dir.exists() && dir.isReadable() ) ) //decompression fubar
{
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage(
tr( "Resolver installation error: cannot open bundle." ) ) );
displayError( tr( "Resolver installation error: cannot open bundle." ) );
return 0;
}
if ( !dir.cd( "content" ) ) //more fubar
{
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage(
tr( "Resolver installation error: incomplete bundle." ) ) );
displayError( tr( "Resolver installation error: incomplete bundle." ) );
return 0;
}
@ -155,8 +153,7 @@ ResolverAccountFactory::createFromPath( const QString& path, const QString& fact
realPath = configuration[ "path" ].toString();
if ( realPath.isEmpty() )
{
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage(
tr( "Resolver installation error: bad metadata in bundle." ) ) );
displayError( tr( "Resolver installation error: bad metadata in bundle." ) );
return 0;
}
}
@ -193,8 +190,7 @@ ResolverAccountFactory::createFromPath( const QString& path, const QString& fact
if ( !myPlatform.contains( platform ) )
{
tDebug() << "Wrong resolver platform.";
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage(
tr( "Resolver installation error: platform mismatch." ) ) );
displayError( tr( "Resolver installation error: platform mismatch." ) );
return 0;
}
}
@ -206,9 +202,8 @@ ResolverAccountFactory::createFromPath( const QString& path, const QString& fact
if ( TomahawkUtils::compareVersionStrings( thVer, requiredVer ) < 0 )
{
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage(
tr( "Resolver installation error: Tomahawk %1 or newer is required." )
.arg( requiredVer ) ) );
displayError( tr( "Resolver installation error: Tomahawk %1 or newer is required." )
.arg( requiredVer ) );
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 )
: Account( accountId )
{

View File

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