mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-19 15:31:59 +02:00
Allow resolvers to set a prettyName for their ScriptCollections.
This commit is contained in:
parent
9d827819d8
commit
7f82799a72
@ -908,11 +908,13 @@ QtScriptResolver::loadCollections()
|
||||
!collectionInfo.contains( "description" ) )
|
||||
return;
|
||||
|
||||
QString prettyname = collectionInfo.value( "prettyname" ).toString();
|
||||
QString desc = collectionInfo.value( "description" ).toString();
|
||||
|
||||
m_collections.clear();
|
||||
// at this point we assume that all the tracks browsable through a resolver belong to the local source
|
||||
Tomahawk::ScriptCollection* sc = new Tomahawk::ScriptCollection( SourceList::instance()->getLocal(), this );
|
||||
sc->setServiceName( prettyname );
|
||||
sc->setDescription( desc );
|
||||
|
||||
if ( collectionInfo.contains( "trackcount" ) ) //a resolver might not expose this
|
||||
|
@ -43,6 +43,8 @@ ScriptCollection::ScriptCollection( const source_ptr& source,
|
||||
qDebug() << Q_FUNC_INFO << resolver->name() << name();
|
||||
|
||||
m_resolver = resolver;
|
||||
|
||||
m_servicePrettyName = m_resolver->name();
|
||||
}
|
||||
|
||||
|
||||
@ -52,19 +54,26 @@ ScriptCollection::~ScriptCollection()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScriptCollection::setServiceName( const QString& name )
|
||||
{
|
||||
m_servicePrettyName = name;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
ScriptCollection::prettyName() const
|
||||
{
|
||||
return tr( "%1 Collection",
|
||||
"Name of a collection based on a resolver, e.g. Subsonic Collection" )
|
||||
.arg( m_resolver->name() );
|
||||
"Name of a collection based on a resolver, e.g. Subsonic Collection" )
|
||||
.arg( m_servicePrettyName );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
ScriptCollection::itemName() const
|
||||
{
|
||||
return m_resolver->name();
|
||||
return m_servicePrettyName;
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,6 +42,16 @@ public:
|
||||
QObject* parent = 0 );
|
||||
virtual ~ScriptCollection();
|
||||
|
||||
/**
|
||||
* @brief setServiceName sets the name of the service that provides the ScriptCollection.
|
||||
* Please note that by default, the pretty name is the same as the resolver's name, e.g.
|
||||
* "Ampache", thus prettyName and itemName yield "Ampache Collection" and "Ampache",
|
||||
* respectively.
|
||||
* However, a resolver might want to change this string to something more appropriate and
|
||||
* different from the resolver's name, to identify the specific service rather than just the
|
||||
* resolver.
|
||||
*/
|
||||
virtual void setServiceName( const QString& name );
|
||||
virtual QString prettyName() const;
|
||||
virtual QString itemName() const;
|
||||
virtual BackendType backendType() const { return ScriptCollectionType; }
|
||||
@ -62,6 +72,7 @@ public:
|
||||
|
||||
private:
|
||||
ExternalResolver* m_resolver;
|
||||
QString m_servicePrettyName;
|
||||
QString m_description;
|
||||
int m_trackCount;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user