Sayonara Player
CoverLookup.h
1/* CoverLookup.h */
2
3/* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4 *
5 * This file is part of sayonara player
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21
22/*
23 * CoverLookup.h
24 *
25 * Created on: Apr 4, 2011
26 * Author: Michael Lugmair (Lucio Carreras)
27 */
28
29#ifndef SAYONARA_COVER_LOOKUP_H
30#define SAYONARA_COVER_LOOKUP_H
31
32#include "AbstractCoverLookup.h"
33#include "Utils/Pimpl.h"
34#include "Utils/CoverUtils.h"
35
36#include <QList>
37#include <any>
38
39class QPixmap;
40namespace Cover
41{
42 class Location;
43
48 class Lookup :
49 public LookupBase
50 {
51 Q_OBJECT
52 PIMPL(Lookup)
53
54 public:
55 Lookup(const Location& coverLocation, int n_covers, QObject* parent);
56 ~Lookup() override;
57
58 QList<QPixmap> pixmaps() const;
59 Util::Covers::Source source() const;
60
61 template<typename T>
62 void setUserData(const T t)
63 {
64 mUserData = t;
65 }
66
67 template<typename T>
68 auto userData() const -> T
69 {
70 try
71 {
72 return std::any_cast<T>(mUserData);
73 }
74 catch(...)
75 {
76 return T {};
77 }
78 }
79
80 void ignoreCache();
81
82 public slots:
83 void start();
84 void stop() override;
85
86 private slots:
87 void coverFound(int idx);
88 void threadFinished();
89 void extractorFinished();
90
91 private:
92 bool fetchFromDatabase();
93 void fetchFromExtractor();
94 bool fetchFromWWW();
95
96 bool startNewThread(const Location& coverLocation);
97 bool addNewCover(const QPixmap& pixmap, bool save);
98
99 void done(bool success);
100
101 std::any mUserData;
102 };
103}
104#endif /* SAYONARA_COVER_LOOKUP_H */
Definition: CoverLocation.h:39
The CoverLookupInterface class.
Definition: AbstractCoverLookup.h:39
The CoverLookup class.
Definition: CoverLookup.h:50
Definition: EngineUtils.h:33