mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
Allow resolvers to set a prettyName for their ScriptCollections.
This commit is contained in:
@@ -908,11 +908,13 @@ QtScriptResolver::loadCollections()
|
|||||||
!collectionInfo.contains( "description" ) )
|
!collectionInfo.contains( "description" ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
QString prettyname = collectionInfo.value( "prettyname" ).toString();
|
||||||
QString desc = collectionInfo.value( "description" ).toString();
|
QString desc = collectionInfo.value( "description" ).toString();
|
||||||
|
|
||||||
m_collections.clear();
|
m_collections.clear();
|
||||||
// at this point we assume that all the tracks browsable through a resolver belong to the local source
|
// 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 );
|
Tomahawk::ScriptCollection* sc = new Tomahawk::ScriptCollection( SourceList::instance()->getLocal(), this );
|
||||||
|
sc->setServiceName( prettyname );
|
||||||
sc->setDescription( desc );
|
sc->setDescription( desc );
|
||||||
|
|
||||||
if ( collectionInfo.contains( "trackcount" ) ) //a resolver might not expose this
|
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();
|
qDebug() << Q_FUNC_INFO << resolver->name() << name();
|
||||||
|
|
||||||
m_resolver = resolver;
|
m_resolver = resolver;
|
||||||
|
|
||||||
|
m_servicePrettyName = m_resolver->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -52,19 +54,26 @@ ScriptCollection::~ScriptCollection()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScriptCollection::setServiceName( const QString& name )
|
||||||
|
{
|
||||||
|
m_servicePrettyName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
ScriptCollection::prettyName() const
|
ScriptCollection::prettyName() const
|
||||||
{
|
{
|
||||||
return tr( "%1 Collection",
|
return tr( "%1 Collection",
|
||||||
"Name of a collection based on a resolver, e.g. Subsonic Collection" )
|
"Name of a collection based on a resolver, e.g. Subsonic Collection" )
|
||||||
.arg( m_resolver->name() );
|
.arg( m_servicePrettyName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
ScriptCollection::itemName() const
|
ScriptCollection::itemName() const
|
||||||
{
|
{
|
||||||
return m_resolver->name();
|
return m_servicePrettyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -42,6 +42,16 @@ public:
|
|||||||
QObject* parent = 0 );
|
QObject* parent = 0 );
|
||||||
virtual ~ScriptCollection();
|
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 prettyName() const;
|
||||||
virtual QString itemName() const;
|
virtual QString itemName() const;
|
||||||
virtual BackendType backendType() const { return ScriptCollectionType; }
|
virtual BackendType backendType() const { return ScriptCollectionType; }
|
||||||
@@ -62,6 +72,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ExternalResolver* m_resolver;
|
ExternalResolver* m_resolver;
|
||||||
|
QString m_servicePrettyName;
|
||||||
QString m_description;
|
QString m_description;
|
||||||
int m_trackCount;
|
int m_trackCount;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user