-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtraktepisode.cpp
144 lines (119 loc) · 2.99 KB
/
traktepisode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include "traktepisode.h"
#include <QVariantMap>
#include "traktseason.h"
#include "traktshow.h"
TraktEpisode::TraktEpisode(TraktSeason *season) :
TraktItem(season),
m_number(0),
m_rating(0),
m_votes(0),
m_season(season)
{
}
TraktEpisode::TraktEpisode(const QVariantMap &data, TraktSeason *season) :
TraktItem(season),
m_rating(0),
m_votes(0),
m_season(season)
{
m_ids = new TraktIds(data.value("ids").toMap(), "episodes", this);
m_title = data.value("title").toString();
m_number = data.value("number").toInt();
m_images = new TraktImageSet(data.value("images").toMap(), this);
}
int TraktEpisode::number() const
{
return m_number;
}
void TraktEpisode::setNumber(int number)
{
m_number = number;
emit numberChanged();
}
QString TraktEpisode::overview() const
{
return m_overview;
}
void TraktEpisode::setOverview(const QString &overview)
{
m_overview = overview;
emit overviewChanged();
}
QDateTime TraktEpisode::firstAired() const
{
return m_firstAired;
}
void TraktEpisode::setFirstAired(const QDateTime &firstAired)
{
m_firstAired = firstAired;
emit firstAiredChanged();
}
QDateTime TraktEpisode::updatedAt() const
{
return m_updatedAt;
}
void TraktEpisode::setUpdatedAt(const QDateTime &updatedAt)
{
m_updatedAt = updatedAt;
emit updatedAtChanged();
}
double TraktEpisode::rating() const
{
return m_rating;
}
void TraktEpisode::setRating(double rating)
{
m_rating = rating;
emit ratingChanged();
}
int TraktEpisode::votes() const
{
return m_votes;
}
void TraktEpisode::setVotes(int votes)
{
m_votes = votes;
emit votesChanged();
}
QStringList TraktEpisode::availableTranslations() const
{
return m_availableTranslations;
}
void TraktEpisode::setAvailableTranslations(const QStringList &availableTranslations)
{
m_availableTranslations = availableTranslations;
emit availableTranslationsChanged();
}
TraktSeason *TraktEpisode::season() const
{
return m_season;
}
void TraktEpisode::setSeason(TraktSeason *season)
{
m_season = season;
emit seasonChanged();
}
TraktImages *TraktEpisode::image() const
{
return m_images->screenshot();
}
void TraktEpisode::parse(const QVariantMap &data)
{
setTitle(data.value("title").toString());
setNumber(data.value("number").toInt());
setOverview(data.value("overview").toString());
setFirstAired(data.value("first_aired").toDateTime());
setUpdatedAt(data.value("updated_at").toDateTime());
setRating(data.value("rating").toDouble());
setVotes(data.value("votes").toInt());
setAvailableTranslations(data.value("available_translations").toStringList());
setLoaded(true);
}
QString TraktEpisode::itemUrl() const
{
return QString("/shows/%1/seasons/%2/episodes/%3").arg(m_season->show()->ids()->trakt()).arg(m_season->number()).arg(number());
}
void TraktEpisode::connectImageChanged(TraktImageSet *images) const
{
connect(images, &TraktImageSet::screenshotChanged, this, &TraktEpisode::imageChanged);
}