2010-06-12 19:13:01 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-06-12 19:13:01 +02:00
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ALBUMCOVERSEARCHER_H
|
|
|
|
#define ALBUMCOVERSEARCHER_H
|
|
|
|
|
2011-04-02 15:34:06 +02:00
|
|
|
#include "covers/albumcoverfetcher.h"
|
2012-02-13 21:44:04 +01:00
|
|
|
#include "covers/albumcoverloaderoptions.h"
|
2010-06-12 19:13:01 +02:00
|
|
|
|
|
|
|
#include <QDialog>
|
2010-12-20 16:46:38 +01:00
|
|
|
#include <QIcon>
|
2011-07-26 14:02:59 +02:00
|
|
|
#include <QStyledItemDelegate>
|
2010-06-12 19:13:01 +02:00
|
|
|
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
|
|
|
class AlbumCoverLoader;
|
2012-02-12 14:41:50 +01:00
|
|
|
class Application;
|
2010-06-12 19:13:01 +02:00
|
|
|
class Ui_AlbumCoverSearcher;
|
|
|
|
|
|
|
|
class QModelIndex;
|
2011-06-20 01:15:29 +02:00
|
|
|
class QStandardItem;
|
|
|
|
class QStandardItemModel;
|
|
|
|
|
2010-06-12 19:13:01 +02:00
|
|
|
|
2011-07-26 14:02:59 +02:00
|
|
|
class SizeOverlayDelegate : public QStyledItemDelegate {
|
|
|
|
public:
|
|
|
|
static const int kMargin;
|
|
|
|
static const int kPaddingX;
|
|
|
|
static const int kPaddingY;
|
|
|
|
static const qreal kBorder;
|
|
|
|
static const qreal kFontPointSize;
|
|
|
|
static const int kBorderAlpha;
|
|
|
|
static const int kBackgroundAlpha;
|
|
|
|
|
|
|
|
SizeOverlayDelegate(QObject* parent = NULL);
|
|
|
|
|
|
|
|
void paint(QPainter* painter, const QStyleOptionViewItem& option,
|
|
|
|
const QModelIndex& index) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-12-26 21:19:12 +01:00
|
|
|
// This is a dialog that lets the user search for album covers
|
2010-06-12 19:13:01 +02:00
|
|
|
class AlbumCoverSearcher : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2012-02-12 14:41:50 +01:00
|
|
|
AlbumCoverSearcher(const QIcon& no_cover_icon, Application* app, QWidget* parent);
|
2010-06-12 19:13:01 +02:00
|
|
|
~AlbumCoverSearcher();
|
|
|
|
|
|
|
|
enum Role {
|
|
|
|
Role_ImageURL = Qt::UserRole + 1,
|
|
|
|
Role_ImageRequestId,
|
2011-06-20 01:15:29 +02:00
|
|
|
Role_ImageFetchFinished,
|
2011-07-26 14:02:59 +02:00
|
|
|
Role_ImageDimensions, // width * height
|
|
|
|
Role_ImageSize,
|
2010-06-12 19:13:01 +02:00
|
|
|
};
|
|
|
|
|
2010-12-26 21:19:12 +01:00
|
|
|
void Init(AlbumCoverFetcher* fetcher);
|
2010-06-12 19:13:01 +02:00
|
|
|
|
2011-06-22 21:07:15 +02:00
|
|
|
QImage Exec(const QString& artist, const QString& album);
|
2010-06-12 19:13:01 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void keyPressEvent(QKeyEvent *);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void Search();
|
2011-04-02 15:34:06 +02:00
|
|
|
void SearchFinished(quint64 id, const CoverSearchResults& results);
|
2010-06-12 19:13:01 +02:00
|
|
|
void ImageLoaded(quint64 id, const QImage& image);
|
|
|
|
|
|
|
|
void CoverDoubleClicked(const QModelIndex& index);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ui_AlbumCoverSearcher* ui_;
|
|
|
|
|
2012-02-12 14:41:50 +01:00
|
|
|
Application* app_;
|
2011-06-20 01:15:29 +02:00
|
|
|
QStandardItemModel* model_;
|
|
|
|
|
2010-12-20 16:46:38 +01:00
|
|
|
QIcon no_cover_icon_;
|
2012-02-13 21:44:04 +01:00
|
|
|
AlbumCoverLoaderOptions options_;
|
2010-06-12 19:13:01 +02:00
|
|
|
AlbumCoverFetcher* fetcher_;
|
|
|
|
|
|
|
|
quint64 id_;
|
2011-06-20 01:15:29 +02:00
|
|
|
QMap<quint64, QStandardItem*> cover_loading_tasks_;
|
2010-06-12 19:13:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ALBUMCOVERSEARCHER_H
|