Sayonara Player
CoverLookup.h
1 /* CoverLookup.h */
2 
3 /* Copyright (C) 2011-2019 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: Lucio Carreras
27  */
28 
29 #ifndef COVERLOOKUP_H_
30 #define COVERLOOKUP_H_
31 
32 #include "AbstractCoverLookup.h"
33 #include "Utils/Pimpl.h"
34 #include "CoverUtils.h"
35 
36 #include <QPixmap>
37 #include <QList>
38 
39 namespace Cover
40 {
41  class Location;
42 
47  class Lookup :
48  public LookupBase
49  {
50  Q_OBJECT
51  PIMPL(Lookup)
52 
53  public:
54 
55  Lookup(const Location& cl, int n_covers, QObject* parent);
56  ~Lookup() override;
57 
58 
64  void stop() override;
65 
70  bool is_thread_running() const;
71 
76  void set_user_data(void* data);
77 
82  void* user_data();
83 
88  QList<QPixmap> pixmaps() const;
89 
90  Cover::Source source() const;
91 
92  private:
93 
94  bool fetch_from_database();
95  bool fetch_from_extractor();
96  bool fetch_from_www();
97 
98 
99  bool start_extractor(const Location& cl);
104  bool start_new_thread(const Location& cl);
105 
106  bool add_new_cover(const QPixmap& pm, bool save);
107 
108  void emit_finished(bool success);
109 
110  public slots:
111  void start();
112 
113  private slots:
118  void cover_found(int idx);
119 
123  void thread_finished(bool);
124 
125  void extractor_finished();
126  };
127 
128 
133  using LookupPtr=std::shared_ptr<Lookup>;
134 
135 }
136 #endif /* COVERLOOKUP_H_ */
Cover::Lookup::pixmaps
QList< QPixmap > pixmaps() const
Get a copy of all pixmaps that where fetched.
QList
Definition: EngineUtils.h:33
Cover::Lookup::user_data
void * user_data()
Fetch your custom data again.
Cover::LookupPtr
std::shared_ptr< Lookup > LookupPtr
CoverLookupPtr.
Definition: CoverLookup.h:133
Cover::Lookup
The CoverLookup class.
Definition: CoverLookup.h:47
Cover::Location
The CoverLocation class.
Definition: CoverLocation.h:42
Cover::Lookup::stop
void stop() override
Stop the Cover::FetchThread if running and retrieve the sig_finished signal If no Cover::FetchThread ...
Cover::Lookup::is_thread_running
bool is_thread_running() const
indicates if the Cover::FetchThread is running
Cover::LookupBase
The CoverLookupInterface class.
Definition: AbstractCoverLookup.h:37
Cover::Lookup::set_user_data
void set_user_data(void *data)
Set some custom data you can retrieve later.