1 /***************************************************************************
2 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhnFreespirit@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef SERVICEALBUMCOVERDOWNLOADER_H
21 #define SERVICEALBUMCOVERDOWNLOADER_H
24 #include "servicemetabase.h"
26 #include "amarok_export.h"
27 #include <kio/jobclasses.h>
38 class ServiceAlbumCoverDownloader
;
40 class AMAROK_EXPORT ServiceAlbumWithCover
: public ServiceAlbum
44 mutable QImage m_cover
;
45 mutable bool m_hasFetchedCover
;
46 mutable bool m_isFetchingCover
;
47 QString m_coverDownloadPath
;
48 mutable ServiceAlbumCoverDownloader
* m_coverDownloader
;
52 ServiceAlbumWithCover( QString name
);
53 ServiceAlbumWithCover( QStringList resultRow
);
55 virtual ~ServiceAlbumWithCover();
57 virtual QString
downloadPrefix() const = 0;
59 virtual void setCoverUrl( const QString
&coverUrl
) = 0;
60 virtual QString
coverUrl() const = 0;
62 void setImage( const QImage
& image
) const;
63 void imageDownloadCanceled() const;
65 virtual QPixmap
image( int size
= 1, bool withShadow
= false); //overridden from Meta::Album
70 A helper class for fetching covers from online services
74 class ServiceAlbumCoverDownloader
: public QObject
80 ServiceAlbumCoverDownloader();
81 ~ServiceAlbumCoverDownloader();
83 void downloadCover( const Meta::ServiceAlbumWithCover
* album
);
87 void coverDownloadComplete( KJob
* downloadJob
);
88 void coverDownloadCanceled( KJob
* downloadJob
);
90 const ServiceAlbumWithCover
* m_album
;
91 QString m_coverDownloadPath
;
92 KIO::FileCopyJob
* m_albumDownloadJob
;