]> git.sur5r.net Git - minitube/blob - src/video.h
e0c8e44d097e171ecd9b31e36e1136ced0f6ed4e
[minitube] / src / video.h
1 /* $BEGIN_LICENSE
2
3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
5
6 Minitube is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 Minitube is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Minitube.  If not, see <http://www.gnu.org/licenses/>.
18
19 $END_LICENSE */
20
21 #ifndef VIDEO_H
22 #define VIDEO_H
23
24 #include <QtCore>
25 #include <QtGui>
26
27 class YTVideo;
28
29 class Video : public QObject {
30     Q_OBJECT
31
32 public:
33     Video();
34     ~Video();
35     Video *clone();
36
37     enum License { LicenseYouTube = 1, LicenseCC };
38     Q_ENUM(License)
39
40     const QString &getTitle() const { return title; }
41     void setTitle(const QString &value) { title = value; }
42
43     const QString &getDescription() const { return description; }
44     void setDescription(const QString &value) { description = value; }
45
46     const QString &getChannelTitle() const { return channelTitle; }
47     void setChannelTitle(const QString &value) { channelTitle = value; }
48
49     const QString &getChannelId() const { return channelId; }
50     void setChannelId(const QString &value) { channelId = value; }
51
52     const QString &getWebpage();
53     void setWebpage(const QString &value);
54
55     void loadThumbnail();
56     const QPixmap &getThumbnail() const { return thumbnail; }
57
58     const QString &getThumbnailUrl() const { return thumbnailUrl; }
59     void setThumbnailUrl(const QString &value) { thumbnailUrl = value; }
60
61     const QString &getMediumThumbnailUrl() const { return mediumThumbnailUrl; }
62     void setMediumThumbnailUrl(const QString &value) { mediumThumbnailUrl = value; }
63
64     const QString &getLargeThumbnailUrl() const { return largeThumbnailUrl; }
65     void setLargeThumbnailUrl(const QString &value) { largeThumbnailUrl = value; }
66
67     int getDuration() const { return duration; }
68     void setDuration(int value);
69     const QString &getFormattedDuration() const { return formattedDuration; }
70
71     int getViewCount() const { return viewCount; }
72     void setViewCount(int value) { viewCount = value; }
73
74     const QDateTime &getPublished() const { return published; }
75     void setPublished(const QDateTime &value);
76     const QString &getFormattedPublished() const { return formattedPublished; }
77
78     int getDefinitionCode() const { return definitionCode; }
79
80     void loadStreamUrl();
81     const QUrl &getStreamUrl() { return streamUrl; }
82
83     const QString &getId() const { return id; }
84     void setId(const QString &value) { id = value; }
85
86     License getLicense() const { return license; }
87     void setLicense(License value) { license = value; }
88
89 signals:
90     void gotThumbnail();
91     void gotMediumThumbnail(const QByteArray &bytes);
92     void gotLargeThumbnail(const QByteArray &bytes);
93     void gotStreamUrl(const QUrl &streamUrl);
94     void errorStreamUrl(const QString &message);
95
96 private slots:
97     void setThumbnail(const QByteArray &bytes);
98     void streamUrlLoaded(const QUrl &streamUrl);
99
100 private:
101     QString title;
102     QString description;
103     QString channelTitle;
104     QString channelId;
105     QString webpage;
106     QUrl streamUrl;
107     QPixmap thumbnail;
108     QString thumbnailUrl;
109     QString mediumThumbnailUrl;
110     QString largeThumbnailUrl;
111     int duration;
112     QString formattedDuration;
113
114     QDateTime published;
115     QString formattedPublished;
116     int viewCount;
117     License license;
118     QString id;
119     int definitionCode;
120
121     bool loadingThumbnail;
122
123     YTVideo *ytVideo;
124 };
125
126 // This is required in order to use QPointer<Video> as a QVariant
127 // as used by the Model/View playlist
128 typedef QPointer<Video> VideoPointer;
129 Q_DECLARE_METATYPE(VideoPointer)
130
131 #endif // VIDEO_H