mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 13:17:34 +02:00
* Added lyrics support to Query class.
This commit is contained in:
@@ -110,6 +110,7 @@ Query::Query( const QString& artist, const QString& track, const QString& album,
|
|||||||
, m_track( track )
|
, m_track( track )
|
||||||
, m_socialActionsLoaded( false )
|
, m_socialActionsLoaded( false )
|
||||||
, m_simTracksLoaded( false )
|
, m_simTracksLoaded( false )
|
||||||
|
, m_lyricsLoaded( false )
|
||||||
, m_infoJobs( 0 )
|
, m_infoJobs( 0 )
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
@@ -810,6 +811,39 @@ Query::similarTracks() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList
|
||||||
|
Query::lyrics() const
|
||||||
|
{
|
||||||
|
if ( !m_lyricsLoaded )
|
||||||
|
{
|
||||||
|
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||||
|
trackInfo["artist"] = artist();
|
||||||
|
trackInfo["track"] = track();
|
||||||
|
|
||||||
|
Tomahawk::InfoSystem::InfoRequestData requestData;
|
||||||
|
requestData.caller = id();
|
||||||
|
requestData.customData = QVariantMap();
|
||||||
|
|
||||||
|
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
||||||
|
requestData.type = Tomahawk::InfoSystem::InfoTrackLyrics;
|
||||||
|
requestData.requestId = TomahawkUtils::infosystemRequestId();
|
||||||
|
|
||||||
|
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||||
|
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||||
|
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection );
|
||||||
|
|
||||||
|
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||||
|
SIGNAL( finished( QString ) ),
|
||||||
|
SLOT( infoSystemFinished( QString ) ), Qt::UniqueConnection );
|
||||||
|
|
||||||
|
m_infoJobs++;
|
||||||
|
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_lyrics;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Query::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
Query::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||||
{
|
{
|
||||||
@@ -819,6 +853,15 @@ Query::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVaria
|
|||||||
QVariantMap returnedData = output.value< QVariantMap >();
|
QVariantMap returnedData = output.value< QVariantMap >();
|
||||||
switch ( requestData.type )
|
switch ( requestData.type )
|
||||||
{
|
{
|
||||||
|
case InfoSystem::InfoTrackLyrics:
|
||||||
|
{
|
||||||
|
m_lyrics = output.value< QVariant >().toString().split( "\n" );
|
||||||
|
|
||||||
|
m_lyricsLoaded = true;
|
||||||
|
emit lyricsLoaded();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case InfoSystem::InfoTrackSimilars:
|
case InfoSystem::InfoTrackSimilars:
|
||||||
{
|
{
|
||||||
const QStringList artists = returnedData["artists"].toStringList();
|
const QStringList artists = returnedData["artists"].toStringList();
|
||||||
|
@@ -161,6 +161,7 @@ public:
|
|||||||
QString socialActionDescription( const QString& action, DescriptionMode mode ) const;
|
QString socialActionDescription( const QString& action, DescriptionMode mode ) const;
|
||||||
|
|
||||||
QList<Tomahawk::query_ptr> similarTracks() const;
|
QList<Tomahawk::query_ptr> similarTracks() const;
|
||||||
|
QStringList lyrics() const;
|
||||||
|
|
||||||
QWeakPointer< Tomahawk::Query > weakRef() { return m_ownRef; }
|
QWeakPointer< Tomahawk::Query > weakRef() { return m_ownRef; }
|
||||||
void setWeakRef( QWeakPointer< Tomahawk::Query > weakRef ) { m_ownRef = weakRef; }
|
void setWeakRef( QWeakPointer< Tomahawk::Query > weakRef ) { m_ownRef = weakRef; }
|
||||||
@@ -182,6 +183,8 @@ signals:
|
|||||||
void socialActionsLoaded();
|
void socialActionsLoaded();
|
||||||
void statsLoaded();
|
void statsLoaded();
|
||||||
void similarTracksLoaded();
|
void similarTracksLoaded();
|
||||||
|
void lyricsLoaded();
|
||||||
|
|
||||||
void updated();
|
void updated();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -264,11 +267,14 @@ private:
|
|||||||
bool m_simTracksLoaded;
|
bool m_simTracksLoaded;
|
||||||
QList<Tomahawk::query_ptr> m_similarTracks;
|
QList<Tomahawk::query_ptr> m_similarTracks;
|
||||||
|
|
||||||
|
bool m_lyricsLoaded;
|
||||||
|
QStringList m_lyrics;
|
||||||
|
|
||||||
mutable int m_infoJobs;
|
mutable int m_infoJobs;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; //ns
|
}; //ns
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Tomahawk::query_ptr);
|
Q_DECLARE_METATYPE( Tomahawk::query_ptr );
|
||||||
|
|
||||||
#endif // QUERY_H
|
#endif // QUERY_H
|
||||||
|
Reference in New Issue
Block a user