add mp3 and ogg torrent url info to JamendoAlbum
[amarok.git] / src / coverfetcher.h
blob20148fab9d5d2d65d3e4e2abba21f1d3305dd3b0
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
8 #include <QImage> //stack allocated
9 #include <QLabel> //baseclass
10 #include <QObject> //baseclass
11 #include <QStringList> //stack allocated
14 namespace Amarok {
15 void coverContextMenu( QWidget *parent, QPoint point, const QString &artist, const QString &album, bool showCoverManager = true );
18 class KJob;
20 class CoverLabel : public QLabel {
21 public:
22 explicit CoverLabel ( QWidget * parent, Qt::WindowFlags f = 0 );
24 void setInformation( const QString artist, const QString album ) {
25 m_artist = artist;
26 m_album = album;
29 protected:
30 virtual void mouseReleaseEvent(QMouseEvent *pEvent);
32 private:
33 QString m_artist;
34 QString m_album;
39 namespace KIO { class Job; }
41 class CoverFetcher : public QObject
43 friend class EditSearchDialog;
44 Q_OBJECT
46 static const uint MAX_COVERS_CHOICE = 10;
48 public:
49 CoverFetcher( QWidget *parent, const QString &artist, QString album );
50 ~CoverFetcher();
52 /// allow the user to edit the query?
53 void setUserCanEditQuery( bool b ) { m_userCanEditQuery = b; }
55 /// starts the fetch
56 void startFetch();
58 QString artist() const { return m_artist; }
59 QString album() const { return m_album; }
60 QString amazonURL() const { return m_amazonURL; }
61 QString asin() const { return m_asin; }
62 QImage image() const { return m_image; }
64 bool wasError() const { return !m_success; }
65 QStringList errors() const { return m_errors; }
67 enum Locale { International=0, France, Germany, Japan, UK, Canada };
68 static QString localeIDToString( int id );
69 static int localeStringToID( const QString &locale );
71 signals:
72 /// The CollectionDB can get the cover information using the pointer
73 void result( CoverFetcher* );
75 private slots:
76 void finishedXmlFetch( KJob * job );
77 void finishedImageFetch( KJob * job );
78 void changeLocale( int id );
80 private:
81 const QString m_artist;
82 const QString m_album;
84 bool m_userCanEditQuery;
85 QString m_userQuery; /// the query from the query edit dialog
86 QString m_xml;
87 QImage m_image;
88 QString m_amazonURL;
89 QString m_asin;
90 int m_size;
92 QStringList m_queries;
93 QStringList m_coverAsins;
94 QStringList m_coverAmazonUrls;
95 QStringList m_coverUrls;
96 QStringList m_coverNames;
97 QString m_currentCoverName;
98 QStringList m_errors;
100 bool m_success;
102 private:
103 /// The fetch was successful!
104 void finish();
106 /// The fetch failed, finish up and log an error message
107 void finishWithError( const QString &message, KJob *job = 0 );
109 /// Prompt the user for a query
110 void getUserQuery( QString explanation = QString() );
112 /// Will try all available queries, and then prompt the user, if allowed
113 void attemptAnotherFetch();
115 /// Show the cover that has been found
116 void showCover();
119 #endif /* AMAROK_COVERFETCHER_H */