]> git.sur5r.net Git - minitube/blob - src/yt/singlevideosource.h
New upstream version 3.8
[minitube] / src / yt / singlevideosource.h
1 #ifndef SINGLEVIDEOSOURCE_H
2 #define SINGLEVIDEOSOURCE_H
3
4 #include <QtCore>
5
6 #include "video.h"
7 #include "videosource.h"
8
9 class SingleVideoSource : public VideoSource {
10     Q_OBJECT
11
12 public:
13     SingleVideoSource(QObject *parent = nullptr);
14
15     void setVideo(Video *value);
16     void setVideoId(const QString &value);
17
18     void loadVideos(int max, int startIndex);
19     bool hasMoreVideos();
20     void abort() { aborted = true; }
21     QString getName();
22     const QList<QAction *> &getActions();
23     int maxResults();
24
25 private:
26     template <typename SourceType> SourceType setupSource(SourceType s) {
27         if (video)
28             s->setVideo(video);
29         else
30             s->setVideoId(videoId);
31         return s;
32     }
33     void connectSource(int max, int startIndex);
34
35     Video *video = nullptr;
36     QString videoId;
37     VideoSource *source = nullptr;
38     bool aborted = false;
39     QStringList emittedVideoIds;
40 };
41
42 #endif // SINGLEVIDEOSOURCE_H