1 // (c) 2004 Mark Kretschmann <markey@web.de>
2 // (c) 2004 Stefan Bogner <bochi@online.ms>
3 // See COPYING file for licensing information.
5 #ifndef AMAROK_COVERFETCHER_H
6 #define AMAROK_COVERFETCHER_H
10 #include <QImage> //stack allocated
11 #include <QLabel> //baseclass
13 #include <QObject> //baseclass
14 #include <QStringList> //stack allocated
18 class CoverLabel
: public QLabel
{
20 explicit CoverLabel ( QWidget
* parent
, Qt::WindowFlags f
= 0 );
22 void setInformation( const QString artist
, const QString album
) {
28 virtual void mouseReleaseEvent(QMouseEvent
*pEvent
);
35 class CoverFetcherSingleton
;
37 namespace KIO
{ class Job
; }
39 class CoverFetcher
: public QObject
41 friend class EditSearchDialog
;
44 static const uint MAX_COVERS_CHOICE
= 10;
48 AMAROK_EXPORT
static CoverFetcher
* instance();
52 /// allow the user to edit the query?
53 void setUserCanEditQuery( bool b
) { m_userCanEditQuery
= b
; }
57 void manualFetch( Meta::AlbumPtr album
);
59 QString
amazonURL() const { return m_amazonURL
; }
60 QString
asin() const { return m_asin
; }
61 QImage
image() const { return m_image
; }
63 AMAROK_EXPORT
void queueAlbum( Meta::AlbumPtr album
);
64 AMAROK_EXPORT
void queueAlbums( Meta::AlbumList albums
);
66 bool wasError() const { return !m_success
; }
67 QStringList
errors() const { return m_errors
; }
69 enum Locale
{ International
=0, France
, Germany
, Japan
, UK
, Canada
};
70 static QString
localeIDToString( int id
);
71 static int localeStringToID( const QString
&locale
);
74 void finishedXmlFetch( KJob
* job
);
75 void finishedImageFetch( KJob
* job
);
76 void changeLocale( int id
);
79 friend class CoverFetcherSingleton
;
81 Meta::AlbumList m_albums
;
82 Meta::AlbumPtr m_albumPtr
;
86 bool m_userCanEditQuery
;
87 QString m_userQuery
; /// the query from the query edit dialog
94 QStringList m_queries
;
95 QStringList m_userQueries
;
96 QStringList m_coverAsins
;
97 QStringList m_coverAmazonUrls
;
98 QStringList m_coverUrls
;
99 QStringList m_coverNames
;
100 QString m_currentCoverName
;
101 QStringList m_errors
;
107 void buildQueries( Meta::AlbumPtr album
);
110 void startFetch( Meta::AlbumPtr album
);
112 /// The fetch was successful!
115 /// The fetch failed, finish up and log an error message
116 void finishWithError( const QString
&message
, KJob
*job
= 0 );
118 /// Prompt the user for a query
119 void getUserQuery( QString explanation
= QString() );
121 /// Will try all available queries, and then prompt the user, if allowed
122 void attemptAnotherFetch();
124 /// Show the cover that has been found
130 inline CoverFetcher
*coverFetcher() { return CoverFetcher::instance(); }
133 #endif /* AMAROK_COVERFETCHER_H */