1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-05 21:57:41 +02:00

Remove MusixMatchHash

This commit is contained in:
Jeff Mitchell
2011-03-28 13:31:00 -04:00
parent dd61f4a3cc
commit 1dd0f26fff
4 changed files with 16 additions and 19 deletions

View File

@@ -94,7 +94,6 @@ enum InfoType {
typedef QMap< InfoType, QVariant > InfoMap; typedef QMap< InfoType, QVariant > InfoMap;
typedef QMap< QString, QMap< QString, QString > > InfoGenericMap; typedef QMap< QString, QMap< QString, QString > > InfoGenericMap;
typedef QHash< QString, QVariant > InfoCustomDataHash; typedef QHash< QString, QVariant > InfoCustomDataHash;
typedef QHash< QString, QString > MusixMatchHash;
class InfoPlugin : public QObject class InfoPlugin : public QObject
{ {
@@ -168,6 +167,5 @@ private:
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoGenericMap ) Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoGenericMap )
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCustomDataHash ); Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCustomDataHash );
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::MusixMatchHash )
#endif // TOMAHAWK_INFOSYSTEM_H #endif // TOMAHAWK_INFOSYSTEM_H

View File

@@ -45,11 +45,11 @@ MusixMatchPlugin::~MusixMatchPlugin()
void MusixMatchPlugin::getInfo(const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomDataHash customData) void MusixMatchPlugin::getInfo(const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomDataHash customData)
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
if( !isValidTrackData(caller, data, customData) || !data.canConvert<Tomahawk::InfoSystem::MusixMatchHash>()) if( !isValidTrackData(caller, data, customData) || !data.canConvert<Tomahawk::InfoSystem::InfoCustomDataHash>())
return; return;
Tomahawk::InfoSystem::MusixMatchHash hash = data.value<Tomahawk::InfoSystem::MusixMatchHash>(); Tomahawk::InfoSystem::InfoCustomDataHash hash = data.value<Tomahawk::InfoSystem::InfoCustomDataHash>();
QString artist = hash["artistName"]; QString artist = hash["artistName"].toString();
QString track = hash["trackName"]; QString track = hash["trackName"].toString();
if( artist.isEmpty() || track.isEmpty() ) if( artist.isEmpty() || track.isEmpty() )
{ {
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, data, QVariant(), customData); emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, data, QVariant(), customData);
@@ -73,22 +73,22 @@ void MusixMatchPlugin::getInfo(const QString &caller, const InfoType type, const
bool MusixMatchPlugin::isValidTrackData(const QString &caller, const QVariant& data, Tomahawk::InfoSystem::InfoCustomDataHash &customData) bool MusixMatchPlugin::isValidTrackData(const QString &caller, const QVariant& data, Tomahawk::InfoSystem::InfoCustomDataHash &customData)
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
if (data.isNull() || !data.isValid() || !data.canConvert<Tomahawk::InfoSystem::MusixMatchHash>()) if (data.isNull() || !data.isValid() || !data.canConvert<Tomahawk::InfoSystem::InfoCustomDataHash>())
{ {
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, data, QVariant(), customData); emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, data, QVariant(), customData);
emit finished(caller, Tomahawk::InfoSystem::InfoTrackLyrics); emit finished(caller, Tomahawk::InfoSystem::InfoTrackLyrics);
qDebug() << "MusixMatchPlugin::isValidTrackData: Data null, invalid, or can't convert"; qDebug() << "MusixMatchPlugin::isValidTrackData: Data null, invalid, or can't convert";
return false; return false;
} }
MusixMatchHash hash = data.value<Tomahawk::InfoSystem::MusixMatchHash>(); InfoCustomDataHash hash = data.value<Tomahawk::InfoSystem::InfoCustomDataHash>();
if (hash["trackName"].isEmpty() ) if (hash["trackName"].toString().isEmpty() )
{ {
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, data, QVariant(), customData); emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, data, QVariant(), customData);
emit finished(caller, Tomahawk::InfoSystem::InfoTrackLyrics); emit finished(caller, Tomahawk::InfoSystem::InfoTrackLyrics);
qDebug() << "MusixMatchPlugin::isValidTrackData: Track name is empty"; qDebug() << "MusixMatchPlugin::isValidTrackData: Track name is empty";
return false; return false;
} }
if (hash["artistName"].isEmpty() ) if (hash["artistName"].toString().isEmpty() )
{ {
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, data, QVariant(), customData); emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, data, QVariant(), customData);
emit finished(caller, Tomahawk::InfoSystem::InfoTrackLyrics); emit finished(caller, Tomahawk::InfoSystem::InfoTrackLyrics);

View File

@@ -47,7 +47,6 @@ InfoSystem::InfoSystem(QObject *parent)
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
qRegisterMetaType<QMap< QString, QMap< QString, QString > > >("Tomahawk::InfoSystem::InfoGenericMap"); qRegisterMetaType<QMap< QString, QMap< QString, QString > > >("Tomahawk::InfoSystem::InfoGenericMap");
qRegisterMetaType<QHash<QString, QVariant > >("Tomahawk::InfoSystem::InfoCustomDataHash"); qRegisterMetaType<QHash<QString, QVariant > >("Tomahawk::InfoSystem::InfoCustomDataHash");
qRegisterMetaType<QHash<QString, QString > >("Tomahawk::InfoSystem::MusixMatchHash");
m_infoSystemCacheThreadController = new QThread( this ); m_infoSystemCacheThreadController = new QThread( this );
m_cache = new Tomahawk::InfoSystem::InfoSystemCache(); m_cache = new Tomahawk::InfoSystem::InfoSystemCache();

View File

@@ -215,10 +215,10 @@ void XMPPBot::handleMessage(const Message& msg, MessageSession* session)
infoMap[InfoArtistFamiliarity] = m_currTrack.data()->artist()->name(); infoMap[InfoArtistFamiliarity] = m_currTrack.data()->artist()->name();
if (token == "lyrics") if (token == "lyrics")
{ {
MusixMatchHash myhash; InfoCustomDataHash myhash;
myhash["trackName"] = m_currTrack.data()->track(); myhash["trackName"] = QVariant::fromValue<QString>(m_currTrack.data()->track());
myhash["artistName"] = m_currTrack.data()->artist()->name(); myhash["artistName"] = QVariant::fromValue<QString>(m_currTrack.data()->artist()->name());
infoMap[InfoTrackLyrics] = QVariant::fromValue<Tomahawk::InfoSystem::MusixMatchHash>(myhash); infoMap[InfoTrackLyrics] = QVariant::fromValue<Tomahawk::InfoSystem::InfoCustomDataHash>(myhash);
} }
} }
@@ -364,15 +364,15 @@ void XMPPBot::infoReturnedSlot(QString caller, Tomahawk::InfoSystem::InfoType ty
{ {
qDebug() << "Lyrics requested"; qDebug() << "Lyrics requested";
if (!output.canConvert<QString>() || if (!output.canConvert<QString>() ||
!input.canConvert<Tomahawk::InfoSystem::MusixMatchHash>() !input.canConvert<Tomahawk::InfoSystem::InfoCustomDataHash>()
) )
{ {
qDebug() << "Variants failed to be valid"; qDebug() << "Variants failed to be valid";
break; break;
} }
MusixMatchHash inHash = input.value<MusixMatchHash>(); InfoCustomDataHash inHash = input.value<InfoCustomDataHash>();
QString artist = inHash["artistName"]; QString artist = inHash["artistName"].toString();
QString track = inHash["trackName"]; QString track = inHash["trackName"].toString();
QString lyrics = output.toString(); QString lyrics = output.toString();
qDebug() << "lyrics = " << lyrics; qDebug() << "lyrics = " << lyrics;
m_currReturnMessage += QString("\nLyrics for \"%1\" by %2:\n\n%3\n").arg(track).arg(artist).arg(lyrics); m_currReturnMessage += QString("\nLyrics for \"%1\" by %2:\n\n%3\n").arg(track).arg(artist).arg(lyrics);