Sayonara Player
CoverFetchThread.h
1 /* CoverFetchThread.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  * CoverFetchThread.h
24  *
25  * Created on: Jun 28, 2011
26  * Author: Michael Lugmair (Lucio Carreras)
27  */
28 
29 #ifndef COVERFETCHTHREAD_H_
30 #define COVERFETCHTHREAD_H_
31 
32 #include <QObject>
33 #include "Utils/Pimpl.h"
34 
35 class QImage;
36 class AsyncWebAccess;
37 
38 namespace Cover
39 {
40  class Location;
41 
42 
47  class FetchThread :
48  public QObject
49  {
50  Q_OBJECT
51  PIMPL(FetchThread)
52 
53  signals:
58  void sigFinished(bool b);
59 
64  void sigCoverFound(int idx);
65 
66 
67  public:
68  FetchThread()=delete;
69  FetchThread(QObject* parent, const Cover::Location& cl, const int n_covers);
70  virtual ~FetchThread();
71 
77  bool start();
78 
83  bool fetchNextCover();
84 
88  void stop();
89 
94  QString url(int idx) const;
95  QPixmap pixmap(int idx) const;
96  int foundImageCount() const;
97 
98 
99  private slots:
105  void singleImageFetched();
106 
112  void multiImageFetched();
113 
118  void contentFetched();
119 
120  private:
121  void emitFinished(bool success);
122  };
123 }
124 
125 #endif /* COVERFETCHTHREAD_H_ */
AsyncWebAccess
Asynchgronous web access class.
Definition: AsyncWebAccess.h:35
Cover::FetchThread::fetchNextCover
bool fetchNextCover()
fetch next cover
Cover::FetchThread
The CoverFetchThread class, This is not a real QThread class, but behaves like one because of AsyncWe...
Definition: CoverFetchThread.h:47
Cover::FetchThread::url
QString url(int idx) const
Google, Amazon, Last.Fm.
Cover::Location
The CoverLocation class.
Definition: CoverLocation.h:38
Cover::FetchThread::sigCoverFound
void sigCoverFound(int idx)
emitted, when covers has been found
Cover::FetchThread::stop
void stop()
stops the current search
Cover::FetchThread::start
bool start()
start fetching covers, if the url does not contain "google", a direct link to an image is assumed and...
Cover::FetchThread::sigFinished
void sigFinished(bool b)
emitted, when thread has finished