From 8bafe8bb9a208ed70a25067449fedf4f09dc926b Mon Sep 17 00:00:00 2001
From: Jeff Mitchell <tomahawk@jefferai.org>
Date: Mon, 18 Apr 2011 10:12:37 -0400
Subject: [PATCH] Rename InfoCacheCriteria into something more generic since
 many plugins will probably use it for input data

---
 .../infosystem/infoplugins/lastfmplugin.cpp   |  8 ++---
 .../infosystem/infoplugins/lastfmplugin.h     |  2 +-
 src/libtomahawk/infosystem/infosystem.cpp     | 16 +++++-----
 src/libtomahawk/infosystem/infosystem.h       | 12 ++++----
 .../infosystem/infosystemcache.cpp            | 30 +++++++++----------
 src/libtomahawk/infosystem/infosystemcache.h  | 12 ++++----
 6 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/src/libtomahawk/infosystem/infoplugins/lastfmplugin.cpp b/src/libtomahawk/infosystem/infoplugins/lastfmplugin.cpp
index 407031f1e..20f09981e 100644
--- a/src/libtomahawk/infosystem/infoplugins/lastfmplugin.cpp
+++ b/src/libtomahawk/infosystem/infoplugins/lastfmplugin.cpp
@@ -195,7 +195,7 @@ LastFmPlugin::fetchCoverArt( const QString &caller, const InfoType type, const Q
         return;
     }
 
-    Tomahawk::InfoSystem::InfoCacheCriteria criteria;
+    Tomahawk::InfoSystem::InfoCriteriaHash criteria;
     criteria["artist"] = hash["artist"].toString();
     criteria["album"] = hash["album"].toString();
 
@@ -219,7 +219,7 @@ LastFmPlugin::fetchArtistImages( const QString &caller, const InfoType type, con
         return;
     }
 
-    Tomahawk::InfoSystem::InfoCacheCriteria criteria;
+    Tomahawk::InfoSystem::InfoCriteriaHash criteria;
     criteria["artist"] = hash["artist"].toString();
 
     emit getCachedInfo( criteria, 2419200000, caller, type, data, customData );
@@ -302,7 +302,7 @@ LastFmPlugin::coverArtReturned()
         );
 
         InfoCustomData origData = reply->property( "origData" ).value< Tomahawk::InfoSystem::InfoCustomData >();
-        Tomahawk::InfoSystem::InfoCacheCriteria criteria;
+        Tomahawk::InfoSystem::InfoCriteriaHash criteria;
         criteria["artist"] = origData["artist"].toString();
         criteria["album"] = origData["album"].toString();
         emit updateCache( criteria, 2419200000, type, returnedData );
@@ -353,7 +353,7 @@ LastFmPlugin::artistImagesReturned()
                   );
 
                   InfoCustomData origData = reply->property( "origData" ).value< Tomahawk::InfoSystem::InfoCustomData >();
-                  Tomahawk::InfoSystem::InfoCacheCriteria criteria;
+                  Tomahawk::InfoSystem::InfoCriteriaHash criteria;
                   criteria["artist"] = origData["artist"].toString();
                   emit updateCache( criteria, 2419200000, type, returnedData );
     }
diff --git a/src/libtomahawk/infosystem/infoplugins/lastfmplugin.h b/src/libtomahawk/infosystem/infoplugins/lastfmplugin.h
index 1b97b0e0c..55fb6b034 100644
--- a/src/libtomahawk/infosystem/infoplugins/lastfmplugin.h
+++ b/src/libtomahawk/infosystem/infoplugins/lastfmplugin.h
@@ -52,7 +52,7 @@ public slots:
     void coverArtReturned();
     void artistImagesReturned();
 
-    virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
+    virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
 
 private:
     void fetchCoverArt( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData );
diff --git a/src/libtomahawk/infosystem/infosystem.cpp b/src/libtomahawk/infosystem/infosystem.cpp
index 6c8357ed6..588ef2940 100644
--- a/src/libtomahawk/infosystem/infosystem.cpp
+++ b/src/libtomahawk/infosystem/infosystem.cpp
@@ -40,21 +40,21 @@ InfoPlugin::InfoPlugin(QObject *parent)
         {
             QObject::connect(
                 this,
-                SIGNAL( getCachedInfo( Tomahawk::InfoSystem::InfoCacheCriteria, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
+                SIGNAL( getCachedInfo( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
                 system->getCache(),
-                SLOT( getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) )
+                SLOT( getCachedInfoSlot( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) )
             );
             QObject::connect(
                 system->getCache(),
-                SIGNAL( notInCache( Tomahawk::InfoSystem::InfoCacheCriteria, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
+                SIGNAL( notInCache( Tomahawk::InfoSystem::InfoCriteriaHash, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
                 this,
-                SLOT( notInCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) )
+                SLOT( notInCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) )
             );
             QObject::connect(
                 this,
-                SIGNAL( updateCache( Tomahawk::InfoSystem::InfoCacheCriteria, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ),
+                SIGNAL( updateCache( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ),
                 system->getCache(),
-                SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) )
+                SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) )
             );
         }
     }
@@ -76,7 +76,7 @@ InfoSystem::InfoSystem(QObject *parent)
     qDebug() << Q_FUNC_INFO;
     qRegisterMetaType< QMap< QString, QMap< QString, QString > > >( "Tomahawk::InfoSystem::InfoGenericMap" );
     qRegisterMetaType< QHash< QString, QVariant > >( "Tomahawk::InfoSystem::InfoCustomData" );
-    qRegisterMetaType< QHash< QString, QString > >( "Tomahawk::InfoSystem::InfoCacheCriteria" );
+    qRegisterMetaType< QHash< QString, QString > >( "Tomahawk::InfoSystem::InfoCriteriaHash" );
     qRegisterMetaType< Tomahawk::InfoSystem::InfoType >( "Tomahawk::InfoSystem::InfoType" );
 
     m_infoSystemCacheThreadController = new QThread( this );
@@ -209,4 +209,4 @@ void InfoSystem::infoSlot(QString target, InfoType type, QVariant input, QVarian
 
 } //namespace InfoSystem
 
-} //namespace Tomahawk
\ No newline at end of file
+} //namespace Tomahawk
diff --git a/src/libtomahawk/infosystem/infosystem.h b/src/libtomahawk/infosystem/infosystem.h
index 75e674f49..2ccabc1aa 100644
--- a/src/libtomahawk/infosystem/infosystem.h
+++ b/src/libtomahawk/infosystem/infosystem.h
@@ -97,7 +97,7 @@ enum InfoType {
 typedef QMap< InfoType, QVariant > InfoMap;
 typedef QMap< QString, QMap< QString, QString > > InfoGenericMap;
 typedef QHash< QString, QVariant > InfoCustomData;
-typedef QHash< QString, QString > InfoCacheCriteria;
+typedef QHash< QString, QString > InfoCriteriaHash;
 
 class DLLEXPORT InfoPlugin : public QObject
 {
@@ -114,14 +114,14 @@ public:
     virtual void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData ) = 0;
 
 signals:
-    void getCachedInfo( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
-    void updateCache( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64, Tomahawk::InfoSystem::InfoType type, QVariant output );
+    void getCachedInfo( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
+    void updateCache( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64, Tomahawk::InfoSystem::InfoType type, QVariant output );
     void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
     void finished( QString, Tomahawk::InfoSystem::InfoType );
 
 public slots:
     //FIXME: Make pure virtual when everything supports it
-    virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
+    virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
     {
         Q_UNUSED( criteria );
         Q_UNUSED( caller );
@@ -180,7 +180,7 @@ private:
 
 }
 
-inline uint qHash( Tomahawk::InfoSystem::InfoCacheCriteria hash )
+inline uint qHash( Tomahawk::InfoSystem::InfoCriteriaHash hash )
 {
     QCryptographicHash md5( QCryptographicHash::Md5 );
     foreach( QString key, hash.keys()  )
@@ -200,6 +200,6 @@ inline uint qHash( Tomahawk::InfoSystem::InfoCacheCriteria hash )
 
 Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoGenericMap );
 Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCustomData );
-Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCacheCriteria );
+Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCriteriaHash );
 
 #endif // TOMAHAWK_INFOSYSTEM_H
diff --git a/src/libtomahawk/infosystem/infosystemcache.cpp b/src/libtomahawk/infosystem/infosystemcache.cpp
index 7b89539c1..d35091607 100644
--- a/src/libtomahawk/infosystem/infosystemcache.cpp
+++ b/src/libtomahawk/infosystem/infosystemcache.cpp
@@ -70,7 +70,7 @@ InfoSystemCache::~InfoSystemCache()
 
 
 void
-InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
+InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
 {
     qDebug() << Q_FUNC_INFO;
     if ( !m_dataCache.contains( type ) || !m_dataCache[type].contains( criteria ) )
@@ -82,16 +82,16 @@ InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria crit
     if ( m_cacheRemainingToLoad > 0 )
     {
         qDebug() << "Cache not fully loaded, punting request for a bit";
-        QMetaObject::invokeMethod( this, "getCachedInfoSlot", Qt::QueuedConnection,  Q_ARG( Tomahawk::InfoSystem::InfoCacheCriteria, criteria ), Q_ARG( qint64, newMaxAge ), Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( Tomahawk::InfoSystem::InfoCustomData, customData ) );
+        QMetaObject::invokeMethod( this, "getCachedInfoSlot", Qt::QueuedConnection,  Q_ARG( Tomahawk::InfoSystem::InfoCriteriaHash, criteria ), Q_ARG( qint64, newMaxAge ), Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( Tomahawk::InfoSystem::InfoCustomData, customData ) );
         return;
     }
     
-    QHash< InfoCacheCriteria, QDateTime > typemaxtimecache = m_maxTimeCache[type];
+    QHash< InfoCriteriaHash, QDateTime > typemaxtimecache = m_maxTimeCache[type];
     
     if ( typemaxtimecache[criteria].toMSecsSinceEpoch() < QDateTime::currentMSecsSinceEpoch() )
     {
-        QHash< InfoCacheCriteria, QVariant > typedatacache = m_dataCache[type];
-        QHash< InfoCacheCriteria, QDateTime > typeinserttimecache = m_insertTimeCache[type];
+        QHash< InfoCriteriaHash, QVariant > typedatacache = m_dataCache[type];
+        QHash< InfoCriteriaHash, QDateTime > typeinserttimecache = m_insertTimeCache[type];
         typemaxtimecache.remove( criteria );
         m_maxTimeCache[type] = typemaxtimecache;
         typedatacache.remove( criteria );
@@ -105,7 +105,7 @@ InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria crit
     
     if ( newMaxAge > 0 )
     {
-        QHash< InfoCacheCriteria, QDateTime > typemaxtimecache = m_maxTimeCache[type];
+        QHash< InfoCriteriaHash, QDateTime > typemaxtimecache = m_maxTimeCache[type];
         typemaxtimecache[criteria] = QDateTime::fromMSecsSinceEpoch( QDateTime::currentMSecsSinceEpoch() + newMaxAge );
         m_maxTimeCache[type] = typemaxtimecache;
         m_dirtySet.insert( type );
@@ -116,12 +116,12 @@ InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria crit
 
 
 void
-InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output )
+InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output )
 {
     qDebug() << Q_FUNC_INFO;
-    QHash< InfoCacheCriteria, QVariant > typedatacache = m_dataCache[type];
-    QHash< InfoCacheCriteria, QDateTime > typeinserttimecache = m_insertTimeCache[type];
-    QHash< InfoCacheCriteria, QDateTime > typemaxtimecache = m_maxTimeCache[type];
+    QHash< InfoCriteriaHash, QVariant > typedatacache = m_dataCache[type];
+    QHash< InfoCriteriaHash, QDateTime > typeinserttimecache = m_insertTimeCache[type];
+    QHash< InfoCriteriaHash, QDateTime > typemaxtimecache = m_maxTimeCache[type];
     typedatacache[criteria] = output;
     typeinserttimecache[criteria] = QDateTime::currentDateTimeUtc();
     typemaxtimecache[criteria] = QDateTime::fromMSecsSinceEpoch( QDateTime::currentMSecsSinceEpoch() + maxAge );
@@ -143,10 +143,10 @@ InfoSystemCache::loadCache( Tomahawk::InfoSystem::InfoType type, const QString &
         cachedSettings.beginGroup( group );
         if ( cachedSettings.value( "maxtime" ).toDateTime().toMSecsSinceEpoch() < QDateTime::currentMSecsSinceEpoch() )
             continue;
-        QHash< InfoCacheCriteria, QVariant > dataHash = m_dataCache[type];
-        QHash< InfoCacheCriteria, QDateTime > insertDateHash = m_insertTimeCache[type];
-        QHash< InfoCacheCriteria, QDateTime > maxDateHash = m_maxTimeCache[type];
-        InfoCacheCriteria criteria;
+        QHash< InfoCriteriaHash, QVariant > dataHash = m_dataCache[type];
+        QHash< InfoCriteriaHash, QDateTime > insertDateHash = m_insertTimeCache[type];
+        QHash< InfoCriteriaHash, QDateTime > maxDateHash = m_maxTimeCache[type];
+        InfoCriteriaHash criteria;
         int numCriteria = cachedSettings.beginReadArray( "criteria" );
         for ( int i = 0; i < numCriteria; i++ )
         {
@@ -187,7 +187,7 @@ InfoSystemCache::saveCache( Tomahawk::InfoSystem::InfoType type, const QString &
 
     int criteriaNumber = 0;
 
-    foreach( InfoCacheCriteria criteria, m_dataCache[type].keys() )
+    foreach( InfoCriteriaHash criteria, m_dataCache[type].keys() )
     {
         cachedSettings.beginGroup( "group_" +  QString::number( criteriaNumber ) );
         cachedSettings.beginWriteArray( "criteria" );
diff --git a/src/libtomahawk/infosystem/infosystemcache.h b/src/libtomahawk/infosystem/infosystemcache.h
index bf712c8d0..da0111a84 100644
--- a/src/libtomahawk/infosystem/infosystemcache.h
+++ b/src/libtomahawk/infosystem/infosystemcache.h
@@ -41,21 +41,21 @@ public:
     virtual ~InfoSystemCache();
 
 signals:
-    void notInCache( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
+    void notInCache( Tomahawk::InfoSystem::InfoCriteriaHash criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
     void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
 
 public slots:
-    void getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
-    void updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output );
+    void getCachedInfoSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
+    void updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output );
 
 private slots:
     void loadCache( Tomahawk::InfoSystem::InfoType type, const QString &cacheFile );
     void saveCache( Tomahawk::InfoSystem::InfoType type, const QString &cacheDir );
 
 private:
-    QHash< InfoType, QHash< InfoCacheCriteria, QVariant > > m_dataCache;
-    QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_insertTimeCache;
-    QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_maxTimeCache;
+    QHash< InfoType, QHash< InfoCriteriaHash, QVariant > > m_dataCache;
+    QHash< InfoType, QHash< InfoCriteriaHash, QDateTime > > m_insertTimeCache;
+    QHash< InfoType, QHash< InfoCriteriaHash, QDateTime > > m_maxTimeCache;
     QSet< InfoType > m_dirtySet;
     int m_cacheRemainingToLoad;
 };