Merge lp:~nik90/cliffhanger/add-watchlist-feature into lp:~flashback-dev/cliffhanger/trunk
- add-watchlist-feature
- Merge into trunk
Proposed by
Nekhelesh Ramananthan
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 30 | ||||
Proposed branch: | lp:~nik90/cliffhanger/add-watchlist-feature | ||||
Merge into: | lp:~flashback-dev/cliffhanger/trunk | ||||
Diff against target: |
410 lines (+163/-4) 13 files modified
Flashback.qml (+9/-0) backend/backend.js (+8/-0) components/TraktPopup.qml (+18/-0) models/AiringShows.qml (+2/-0) models/Show.qml (+2/-0) models/TraktUserWatchlist.qml (+9/-0) models/TraktWatchlist.qml (+15/-0) ui/EpisodePage.qml (+1/-0) ui/HomeTab.qml (+17/-3) ui/MoviePage.qml (+36/-0) ui/SeasonPage.qml (+1/-0) ui/TvPage.qml (+38/-1) ui/TvTab.qml (+7/-0) |
||||
To merge this branch: | bzr merge lp:~nik90/cliffhanger/add-watchlist-feature | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Flashback Dev | Pending | ||
Review via email: mp+202374@code.launchpad.net |
Commit message
Added user watchlist feature
Description of the change
Added user watchlist feature
To post a comment you must log in.
- 34. By Nekhelesh Ramananthan
-
Small fixes
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Flashback.qml' | |||
2 | --- Flashback.qml 2014-01-03 14:01:43 +0000 | |||
3 | +++ Flashback.qml 2014-01-20 22:13:50 +0000 | |||
4 | @@ -117,6 +117,15 @@ | |||
5 | 117 | } | 117 | } |
6 | 118 | } | 118 | } |
7 | 119 | 119 | ||
8 | 120 | // Document to store the user's watchlist activity on Trakt | ||
9 | 121 | U1db.Document { | ||
10 | 122 | id: watchlistActivityDocument | ||
11 | 123 | database: db | ||
12 | 124 | docId: "traktWatchlistActivity" | ||
13 | 125 | create: true | ||
14 | 126 | defaults: { "movie": "default", "show": "default" } | ||
15 | 127 | } | ||
16 | 128 | |||
17 | 120 | Loader { id: userActivityLoader } | 129 | Loader { id: userActivityLoader } |
18 | 121 | 130 | ||
19 | 122 | Component { | 131 | Component { |
20 | 123 | 132 | ||
21 | === modified file 'backend/backend.js' | |||
22 | --- backend/backend.js 2014-01-19 23:00:52 +0000 | |||
23 | +++ backend/backend.js 2014-01-20 22:13:50 +0000 | |||
24 | @@ -169,6 +169,14 @@ | |||
25 | 169 | return credentials.trakt_baseUrl + "/user/calendar/shows.json/" + credentials.trakt_apiKey + "/" + username + "/" + startDate + "/" + noOfDays | 169 | return credentials.trakt_baseUrl + "/user/calendar/shows.json/" + credentials.trakt_apiKey + "/" + username + "/" + startDate + "/" + noOfDays |
26 | 170 | } | 170 | } |
27 | 171 | 171 | ||
28 | 172 | function traktWatchlistUrl(type) { | ||
29 | 173 | return credentials.trakt_baseUrl + "/" + type + "/watchlist/" + credentials.trakt_apiKey | ||
30 | 174 | } | ||
31 | 175 | |||
32 | 176 | function traktUnwatchlistUrl(type) { | ||
33 | 177 | return credentials.trakt_baseUrl + "/" + type + "/unwatchlist/" + credentials.trakt_apiKey | ||
34 | 178 | } | ||
35 | 179 | |||
36 | 172 | function userWatchlistMovies(username) { | 180 | function userWatchlistMovies(username) { |
37 | 173 | return credentials.trakt_baseUrl + "/user/watchlist/movies.json/" + credentials.trakt_apiKey + "/" + username | 181 | return credentials.trakt_baseUrl + "/user/watchlist/movies.json/" + credentials.trakt_apiKey + "/" + username |
38 | 174 | } | 182 | } |
39 | 175 | 183 | ||
40 | === modified file 'components/TraktPopup.qml' | |||
41 | --- components/TraktPopup.qml 2013-12-28 18:30:08 +0000 | |||
42 | +++ components/TraktPopup.qml 2014-01-20 22:13:50 +0000 | |||
43 | @@ -15,10 +15,14 @@ | |||
44 | 15 | // Property to set the seen message | 15 | // Property to set the seen message |
45 | 16 | property alias seenMessage: _seenAction.text | 16 | property alias seenMessage: _seenAction.text |
46 | 17 | 17 | ||
47 | 18 | // Property to set the watchlist message | ||
48 | 19 | property alias watchlistMessage: _watchlistAction.text | ||
49 | 20 | |||
50 | 18 | // Properties to set the visibility of the individual actions | 21 | // Properties to set the visibility of the individual actions |
51 | 19 | property bool showConfigureAction: traktLogin.contents.status === "disabled" | 22 | property bool showConfigureAction: traktLogin.contents.status === "disabled" |
52 | 20 | property bool showCheckInAction: traktLogin.contents.status !== "disabled" | 23 | property bool showCheckInAction: traktLogin.contents.status !== "disabled" |
53 | 21 | property bool showSeenAction: traktLogin.contents.status !== "disabled" | 24 | property bool showSeenAction: traktLogin.contents.status !== "disabled" |
54 | 25 | property bool showWatchlistAction: traktLogin.contents.status !== "disabled" | ||
55 | 22 | property bool showCommentAction: true | 26 | property bool showCommentAction: true |
56 | 23 | 27 | ||
57 | 24 | // Signal triggered when the checked-in action is triggered | 28 | // Signal triggered when the checked-in action is triggered |
58 | @@ -30,6 +34,9 @@ | |||
59 | 30 | // Signal triggered when the comments action is triggered | 34 | // Signal triggered when the comments action is triggered |
60 | 31 | signal commented() | 35 | signal commented() |
61 | 32 | 36 | ||
62 | 37 | // Signal triggered when the watchlist action is triggered | ||
63 | 38 | signal watchlisted() | ||
64 | 39 | |||
65 | 33 | Column { | 40 | Column { |
66 | 34 | id: containerLayout | 41 | id: containerLayout |
67 | 35 | anchors { | 42 | anchors { |
68 | @@ -61,6 +68,17 @@ | |||
69 | 61 | } | 68 | } |
70 | 62 | 69 | ||
71 | 63 | Standard { | 70 | Standard { |
72 | 71 | id: _watchlistAction | ||
73 | 72 | visible: showWatchlistAction | ||
74 | 73 | iconSource: Qt.resolvedUrl("../graphics/watchlist_black.png") | ||
75 | 74 | iconFrame: false | ||
76 | 75 | onClicked: { | ||
77 | 76 | popover.watchlisted() | ||
78 | 77 | PopupUtils.close(popover) | ||
79 | 78 | } | ||
80 | 79 | } | ||
81 | 80 | |||
82 | 81 | Standard { | ||
83 | 64 | id: _seenAction | 82 | id: _seenAction |
84 | 65 | visible: showSeenAction | 83 | visible: showSeenAction |
85 | 66 | iconSource: Qt.resolvedUrl("../graphics/watched_black.png") | 84 | iconSource: Qt.resolvedUrl("../graphics/watched_black.png") |
86 | 67 | 85 | ||
87 | === added file 'graphics/watchlist_black.png' | |||
88 | 68 | Binary files graphics/watchlist_black.png 1970-01-01 00:00:00 +0000 and graphics/watchlist_black.png 2014-01-20 22:13:50 +0000 differ | 86 | Binary files graphics/watchlist_black.png 1970-01-01 00:00:00 +0000 and graphics/watchlist_black.png 2014-01-20 22:13:50 +0000 differ |
89 | === modified file 'models/AiringShows.qml' | |||
90 | --- models/AiringShows.qml 2014-01-02 14:31:26 +0000 | |||
91 | +++ models/AiringShows.qml 2014-01-20 22:13:50 +0000 | |||
92 | @@ -4,6 +4,8 @@ | |||
93 | 4 | BasePostModel { | 4 | BasePostModel { |
94 | 5 | id: airingShowsModel | 5 | id: airingShowsModel |
95 | 6 | 6 | ||
96 | 7 | property string lastUpdated: "default" | ||
97 | 8 | |||
98 | 7 | function fetchData(username, password, date, days) { | 9 | function fetchData(username, password, date, days) { |
99 | 8 | source = Backend.userShows(username, date, days) | 10 | source = Backend.userShows(username, date, days) |
100 | 9 | createMessage(username, password) | 11 | createMessage(username, password) |
101 | 10 | 12 | ||
102 | === modified file 'models/Show.qml' | |||
103 | --- models/Show.qml 2013-12-30 15:03:51 +0000 | |||
104 | +++ models/Show.qml 2014-01-20 22:13:50 +0000 | |||
105 | @@ -16,6 +16,7 @@ | |||
106 | 16 | 'voteUp': 0, | 16 | 'voteUp': 0, |
107 | 17 | 'voteDown': 0, | 17 | 'voteDown': 0, |
108 | 18 | 'userVote': 0, | 18 | 'userVote': 0, |
109 | 19 | 'in_watchlist': '', | ||
110 | 19 | 'number_of_seasons': 0, | 20 | 'number_of_seasons': 0, |
111 | 20 | 'networks': '', | 21 | 'networks': '', |
112 | 21 | 'genres': [], | 22 | 'genres': [], |
113 | @@ -38,6 +39,7 @@ | |||
114 | 38 | 'voteUp': parseInt(reply.ratings.loved), | 39 | 'voteUp': parseInt(reply.ratings.loved), |
115 | 39 | 'voteDown': parseInt(reply.ratings.hated), | 40 | 'voteDown': parseInt(reply.ratings.hated), |
116 | 40 | 'userVote': parseInt(reply.rating_advanced), | 41 | 'userVote': parseInt(reply.rating_advanced), |
117 | 42 | 'in_watchlist': reply.in_watchlist ? reply.in_watchlist.toString() : "", | ||
118 | 41 | 'in_production': reply.status, | 43 | 'in_production': reply.status, |
119 | 42 | 'networks': reply.network, | 44 | 'networks': reply.network, |
120 | 43 | 'genres': reply.genres, | 45 | 'genres': reply.genres, |
121 | 44 | 46 | ||
122 | === modified file 'models/TraktUserWatchlist.qml' | |||
123 | --- models/TraktUserWatchlist.qml 2014-01-02 21:25:37 +0000 | |||
124 | +++ models/TraktUserWatchlist.qml 2014-01-20 22:13:50 +0000 | |||
125 | @@ -1,8 +1,17 @@ | |||
126 | 1 | import QtQuick 2.0 | 1 | import QtQuick 2.0 |
127 | 2 | import "../backend/backend.js" as Backend | ||
128 | 2 | 3 | ||
129 | 3 | BasePostModel { | 4 | BasePostModel { |
130 | 4 | id: traktUserWatchlist | 5 | id: traktUserWatchlist |
131 | 5 | 6 | ||
132 | 7 | property string lastUpdated: "default" | ||
133 | 8 | |||
134 | 9 | function fetchData(username, password) { | ||
135 | 10 | source = Backend.userWatchlistMovies(username) | ||
136 | 11 | createMessage(username, password) | ||
137 | 12 | sendMessage() | ||
138 | 13 | } | ||
139 | 14 | |||
140 | 6 | function updateJSONModel() { | 15 | function updateJSONModel() { |
141 | 7 | model.clear() | 16 | model.clear() |
142 | 8 | for ( var key in reply ) { | 17 | for ( var key in reply ) { |
143 | 9 | 18 | ||
144 | === added file 'models/TraktWatchlist.qml' | |||
145 | --- models/TraktWatchlist.qml 1970-01-01 00:00:00 +0000 | |||
146 | +++ models/TraktWatchlist.qml 2014-01-20 22:13:50 +0000 | |||
147 | @@ -0,0 +1,15 @@ | |||
148 | 1 | import QtQuick 2.0 | ||
149 | 2 | |||
150 | 3 | BasePostModel { | ||
151 | 4 | id: traktWatchlist | ||
152 | 5 | |||
153 | 6 | // Function to create a JSON String with movie information | ||
154 | 7 | function createMovieMessage(username, password, imdb_id, title, year) { | ||
155 | 8 | message = JSON.stringify({username: username, password: password, movies: [{imdb_id: imdb_id, title: title, year: year}]}) | ||
156 | 9 | } | ||
157 | 10 | |||
158 | 11 | // Function to create a JSON String with tv show information | ||
159 | 12 | function createShowMessage(username, password, tvdb_id, title, year) { | ||
160 | 13 | message = JSON.stringify({username: username, password: password, shows: [{tvdb_id: tvdb_id, title: title, year: year}]}) | ||
161 | 14 | } | ||
162 | 15 | } | ||
163 | 0 | 16 | ||
164 | === modified file 'ui/EpisodePage.qml' | |||
165 | --- ui/EpisodePage.qml 2014-01-04 15:06:19 +0000 | |||
166 | +++ ui/EpisodePage.qml 2014-01-20 22:13:50 +0000 | |||
167 | @@ -127,6 +127,7 @@ | |||
168 | 127 | Component { | 127 | Component { |
169 | 128 | id: sharePopoverComponent | 128 | id: sharePopoverComponent |
170 | 129 | TraktPopup { | 129 | TraktPopup { |
171 | 130 | showWatchlistAction: false | ||
172 | 130 | checkInMessage: showActivityDocument.contents.name !== "default" ? i18n.tr("Cancel current episode check-in") : i18n.tr("Check-in episode into Trakt") | 131 | checkInMessage: showActivityDocument.contents.name !== "default" ? i18n.tr("Cancel current episode check-in") : i18n.tr("Check-in episode into Trakt") |
173 | 131 | seenMessage: isEpisodeSeen ? i18n.tr("Mark episode an unseen") : i18n.tr("Mark episode as seen") | 132 | seenMessage: isEpisodeSeen ? i18n.tr("Mark episode an unseen") : i18n.tr("Mark episode as seen") |
174 | 132 | onCheckedIn: { | 133 | onCheckedIn: { |
175 | 133 | 134 | ||
176 | === modified file 'ui/HomeTab.qml' | |||
177 | --- ui/HomeTab.qml 2014-01-02 21:25:37 +0000 | |||
178 | +++ ui/HomeTab.qml 2014-01-20 22:13:50 +0000 | |||
179 | @@ -8,6 +8,8 @@ | |||
180 | 8 | Page { | 8 | Page { |
181 | 9 | id: homePage | 9 | id: homePage |
182 | 10 | 10 | ||
183 | 11 | flickable: null | ||
184 | 12 | |||
185 | 11 | Component.onCompleted: console.log("[LOG]: Home Tab Loaded") | 13 | Component.onCompleted: console.log("[LOG]: Home Tab Loaded") |
186 | 12 | 14 | ||
187 | 13 | actions: [ | 15 | actions: [ |
188 | @@ -30,11 +32,16 @@ | |||
189 | 30 | id: userWatchlistModel | 32 | id: userWatchlistModel |
190 | 31 | username: traktLogin.contents.username | 33 | username: traktLogin.contents.username |
191 | 32 | password: traktLogin.contents.password | 34 | password: traktLogin.contents.password |
192 | 35 | lastUpdated: watchlistActivityDocument.contents.movie | ||
193 | 33 | onPasswordChanged: { | 36 | onPasswordChanged: { |
194 | 34 | console.log("[LOG]: Retrieving user movie watchlist") | 37 | console.log("[LOG]: Retrieving user movie watchlist") |
198 | 35 | source = Backend.userWatchlistMovies(username) | 38 | fetchData(username, password) |
199 | 36 | createMessage(username, password) | 39 | } |
200 | 37 | sendMessage() | 40 | onLastUpdatedChanged: { |
201 | 41 | if(username !== "") { | ||
202 | 42 | console.log("[LOG]: Retrieving user movie watchlist") | ||
203 | 43 | fetchData(username, password) | ||
204 | 44 | } | ||
205 | 38 | } | 45 | } |
206 | 39 | } | 46 | } |
207 | 40 | 47 | ||
208 | @@ -42,10 +49,17 @@ | |||
209 | 42 | id: airingShowsModel | 49 | id: airingShowsModel |
210 | 43 | username: traktLogin.contents.username | 50 | username: traktLogin.contents.username |
211 | 44 | password: traktLogin.contents.password | 51 | password: traktLogin.contents.password |
212 | 52 | lastUpdated: watchlistActivityDocument.contents.show | ||
213 | 45 | onPasswordChanged: { | 53 | onPasswordChanged: { |
214 | 46 | console.log("[LOG]: Retrieving shows airing today") | 54 | console.log("[LOG]: Retrieving shows airing today") |
215 | 47 | fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 1) | 55 | fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 1) |
216 | 48 | } | 56 | } |
217 | 57 | onLastUpdatedChanged: { | ||
218 | 58 | if(username !== "") { | ||
219 | 59 | console.log("[LOG]: Retrieving shows airing today") | ||
220 | 60 | fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 1) | ||
221 | 61 | } | ||
222 | 62 | } | ||
223 | 49 | } | 63 | } |
224 | 50 | 64 | ||
225 | 51 | LoadingIndicator { | 65 | LoadingIndicator { |
226 | 52 | 66 | ||
227 | === modified file 'ui/MoviePage.qml' | |||
228 | --- ui/MoviePage.qml 2014-01-04 15:06:19 +0000 | |||
229 | +++ ui/MoviePage.qml 2014-01-20 22:13:50 +0000 | |||
230 | @@ -14,6 +14,7 @@ | |||
231 | 14 | 14 | ||
232 | 15 | property string movie_id | 15 | property string movie_id |
233 | 16 | property bool isMovieSeen | 16 | property bool isMovieSeen |
234 | 17 | property bool isMovieWatchlisted | ||
235 | 17 | 18 | ||
236 | 18 | property int upVotes: 0 | 19 | property int upVotes: 0 |
237 | 19 | property int downVotes: 0 | 20 | property int downVotes: 0 |
238 | @@ -54,6 +55,7 @@ | |||
239 | 54 | averageVote = reply.ratings.percentage | 55 | averageVote = reply.ratings.percentage |
240 | 55 | if (traktLogin.contents.status !== "disabled") { | 56 | if (traktLogin.contents.status !== "disabled") { |
241 | 56 | isMovieSeen = reply.watched | 57 | isMovieSeen = reply.watched |
242 | 58 | isMovieWatchlisted = reply.in_watchlist | ||
243 | 57 | userVote = reply.rating_advanced | 59 | userVote = reply.rating_advanced |
244 | 58 | } | 60 | } |
245 | 59 | } | 61 | } |
246 | @@ -109,10 +111,31 @@ | |||
247 | 109 | } | 111 | } |
248 | 110 | } | 112 | } |
249 | 111 | 113 | ||
250 | 114 | TraktWatchlist { | ||
251 | 115 | id: movieWatchlist | ||
252 | 116 | function updateJSONModel() { | ||
253 | 117 | if(reply.status === "success") { | ||
254 | 118 | loadingIndicator.visible = false | ||
255 | 119 | if(!isMovieWatchlisted) { | ||
256 | 120 | console.log("[LOG]: Movie watchlist success") | ||
257 | 121 | isMovieWatchlisted = true | ||
258 | 122 | } | ||
259 | 123 | else { | ||
260 | 124 | console.log("[LOG]: Movie Unwatchlist success") | ||
261 | 125 | isMovieWatchlisted = false | ||
262 | 126 | } | ||
263 | 127 | var tempData = watchlistActivityDocument.contents | ||
264 | 128 | tempData.movie = Qt.formatDateTime(new Date(), "yyyyMMdd hh:mm:ss") | ||
265 | 129 | watchlistActivityDocument.contents = tempData | ||
266 | 130 | } | ||
267 | 131 | } | ||
268 | 132 | } | ||
269 | 133 | |||
270 | 112 | Component { | 134 | Component { |
271 | 113 | id: sharePopoverComponent | 135 | id: sharePopoverComponent |
272 | 114 | TraktPopup { | 136 | TraktPopup { |
273 | 115 | checkInMessage: movieActivityDocument.contents.name !== "default" ? i18n.tr("Cancel current movie check-in") : i18n.tr("Check-in movie into Trakt") | 137 | checkInMessage: movieActivityDocument.contents.name !== "default" ? i18n.tr("Cancel current movie check-in") : i18n.tr("Check-in movie into Trakt") |
274 | 138 | watchlistMessage: isMovieWatchlisted ? i18n.tr("Remove movie from watchlist") : i18n.tr("Add movie to watchlist") | ||
275 | 116 | seenMessage: isMovieSeen ? i18n.tr("Mark movie as unseen") : i18n.tr("Mark movie as seen") | 139 | seenMessage: isMovieSeen ? i18n.tr("Mark movie as unseen") : i18n.tr("Mark movie as seen") |
276 | 117 | onCheckedIn: { | 140 | onCheckedIn: { |
277 | 118 | if(movieActivityDocument.contents.name !== "default") { | 141 | if(movieActivityDocument.contents.name !== "default") { |
278 | @@ -137,6 +160,19 @@ | |||
279 | 137 | movieUnsee.sendMessage() | 160 | movieUnsee.sendMessage() |
280 | 138 | } | 161 | } |
281 | 139 | } | 162 | } |
282 | 163 | onWatchlisted: { | ||
283 | 164 | loadingIndicator.loadingText = !isMovieWatchlisted ? i18n.tr("Adding movie to watchlist") : i18n.tr("Removing movie from watchlist") | ||
284 | 165 | loadingIndicator.visible = true | ||
285 | 166 | if(!isMovieWatchlisted) { | ||
286 | 167 | movieWatchlist.source = Backend.traktWatchlistUrl("movie") | ||
287 | 168 | movieWatchlist.createMovieMessage(traktLogin.contents.username, traktLogin.contents.password, movie.attributes.imdb_id, movie.attributes.title, movie.attributes.releaseDate.split('-')[0]) | ||
288 | 169 | } | ||
289 | 170 | else { | ||
290 | 171 | movieWatchlist.source = Backend.traktUnwatchlistUrl("movie") | ||
291 | 172 | movieWatchlist.createMovieMessage(traktLogin.contents.username, traktLogin.contents.password, movie.attributes.imdb_id, movie.attributes.title, movie.attributes.releaseDate.split('-')[0]) | ||
292 | 173 | } | ||
293 | 174 | movieWatchlist.sendMessage() | ||
294 | 175 | } | ||
295 | 140 | onCommented: pagestack.push(Qt.resolvedUrl("CommentsPage.qml"), {id: movie_id, type: "Movie", name: movie.attributes.title, year: movie.attributes.releaseDate.split('-')[0]}) | 176 | onCommented: pagestack.push(Qt.resolvedUrl("CommentsPage.qml"), {id: movie_id, type: "Movie", name: movie.attributes.title, year: movie.attributes.releaseDate.split('-')[0]}) |
296 | 141 | } | 177 | } |
297 | 142 | } | 178 | } |
298 | 143 | 179 | ||
299 | === modified file 'ui/SeasonPage.qml' | |||
300 | --- ui/SeasonPage.qml 2014-01-04 15:06:19 +0000 | |||
301 | +++ ui/SeasonPage.qml 2014-01-20 22:13:50 +0000 | |||
302 | @@ -74,6 +74,7 @@ | |||
303 | 74 | TraktPopup { | 74 | TraktPopup { |
304 | 75 | showCheckInAction: false | 75 | showCheckInAction: false |
305 | 76 | showCommentAction: false | 76 | showCommentAction: false |
306 | 77 | showWatchlistAction: false | ||
307 | 77 | seenMessage: !isSeasonSeen ? i18n.tr("Mark season as seen") : i18n.tr("Season has been watched!") | 78 | seenMessage: !isSeasonSeen ? i18n.tr("Mark season as seen") : i18n.tr("Season has been watched!") |
308 | 78 | onWatched: { | 79 | onWatched: { |
309 | 79 | if(!isSeasonSeen) { | 80 | if(!isSeasonSeen) { |
310 | 80 | 81 | ||
311 | === modified file 'ui/TvPage.qml' | |||
312 | --- ui/TvPage.qml 2014-01-04 15:06:19 +0000 | |||
313 | +++ ui/TvPage.qml 2014-01-20 22:13:50 +0000 | |||
314 | @@ -14,6 +14,7 @@ | |||
315 | 14 | 14 | ||
316 | 15 | property string tv_id | 15 | property string tv_id |
317 | 16 | property int userVote: 0 | 16 | property int userVote: 0 |
318 | 17 | property bool isShowWatchlisted | ||
319 | 17 | 18 | ||
320 | 18 | actions: [ | 19 | actions: [ |
321 | 19 | Action { | 20 | Action { |
322 | @@ -41,6 +42,26 @@ | |||
323 | 41 | } | 42 | } |
324 | 42 | } | 43 | } |
325 | 43 | 44 | ||
326 | 45 | TraktWatchlist { | ||
327 | 46 | id: showWatchlist | ||
328 | 47 | function updateJSONModel() { | ||
329 | 48 | if(reply.status === "success") { | ||
330 | 49 | loadingIndicator.visible = false | ||
331 | 50 | if(!isShowWatchlisted) { | ||
332 | 51 | console.log("[LOG]: Show watchlist success") | ||
333 | 52 | isShowWatchlisted = true | ||
334 | 53 | } | ||
335 | 54 | else { | ||
336 | 55 | console.log("[LOG]: Show Unwatchlist success") | ||
337 | 56 | isShowWatchlisted = false | ||
338 | 57 | } | ||
339 | 58 | var tempData = watchlistActivityDocument.contents | ||
340 | 59 | tempData.show = Qt.formatDateTime(new Date(), "yyyyMMdd hh:mm:ss") | ||
341 | 60 | watchlistActivityDocument.contents = tempData | ||
342 | 61 | } | ||
343 | 62 | } | ||
344 | 63 | } | ||
345 | 64 | |||
346 | 44 | LoadingIndicator { | 65 | LoadingIndicator { |
347 | 45 | id: loadingIndicator | 66 | id: loadingIndicator |
348 | 46 | visible: false | 67 | visible: false |
349 | @@ -51,6 +72,7 @@ | |||
350 | 51 | TraktPopup { | 72 | TraktPopup { |
351 | 52 | showCheckInAction: false | 73 | showCheckInAction: false |
352 | 53 | seenMessage: i18n.tr("Mark show as seen") | 74 | seenMessage: i18n.tr("Mark show as seen") |
353 | 75 | watchlistMessage: isShowWatchlisted ? i18n.tr("Remove show from watchlist") : i18n.tr("Add show to watchlist") | ||
354 | 54 | onWatched: { | 76 | onWatched: { |
355 | 55 | loadingIndicator.loadingText = i18n.tr("Marking show as seen") | 77 | loadingIndicator.loadingText = i18n.tr("Marking show as seen") |
356 | 56 | loadingIndicator.visible = true | 78 | loadingIndicator.visible = true |
357 | @@ -58,6 +80,19 @@ | |||
358 | 58 | showSee.createShowMessage(traktLogin.contents.username, traktLogin.contents.password, tv_id, show.imdb_id, show.name, show.year) | 80 | showSee.createShowMessage(traktLogin.contents.username, traktLogin.contents.password, tv_id, show.imdb_id, show.name, show.year) |
359 | 59 | showSee.sendMessage() | 81 | showSee.sendMessage() |
360 | 60 | } | 82 | } |
361 | 83 | onWatchlisted: { | ||
362 | 84 | loadingIndicator.loadingText = !isShowWatchlisted ? i18n.tr("Adding show to watchlist") : i18n.tr("Removing show from watchlist") | ||
363 | 85 | loadingIndicator.visible = true | ||
364 | 86 | if(!isShowWatchlisted) { | ||
365 | 87 | showWatchlist.source = Backend.traktWatchlistUrl("show") | ||
366 | 88 | showWatchlist.createShowMessage(traktLogin.contents.username, traktLogin.contents.password, tv_id, show.name, show.year) | ||
367 | 89 | } | ||
368 | 90 | else { | ||
369 | 91 | showWatchlist.source = Backend.traktUnwatchlistUrl("show") | ||
370 | 92 | showWatchlist.createShowMessage(traktLogin.contents.username, traktLogin.contents.password, tv_id, show.name, show.year) | ||
371 | 93 | } | ||
372 | 94 | showWatchlist.sendMessage() | ||
373 | 95 | } | ||
374 | 61 | onCommented: pagestack.push(Qt.resolvedUrl("CommentsPage.qml"), {id: tv_id, type: "Show", name: show.name, year: show.year}) | 96 | onCommented: pagestack.push(Qt.resolvedUrl("CommentsPage.qml"), {id: tv_id, type: "Show", name: show.name, year: show.year}) |
375 | 62 | } | 97 | } |
376 | 63 | } | 98 | } |
377 | @@ -80,8 +115,10 @@ | |||
378 | 80 | } | 115 | } |
379 | 81 | onUpdated: { | 116 | onUpdated: { |
380 | 82 | tvCast.json = show.attributes.creditsJson; | 117 | tvCast.json = show.attributes.creditsJson; |
382 | 83 | if(traktLogin.contents.status !== "disabled") | 118 | if(traktLogin.contents.status !== "disabled") { |
383 | 84 | userVote = show.attributes.userVote | 119 | userVote = show.attributes.userVote |
384 | 120 | isShowWatchlisted = show.attributes.in_watchlist | ||
385 | 121 | } | ||
386 | 85 | } | 122 | } |
387 | 86 | } | 123 | } |
388 | 87 | 124 | ||
389 | 88 | 125 | ||
390 | === modified file 'ui/TvTab.qml' | |||
391 | --- ui/TvTab.qml 2014-01-18 20:35:22 +0000 | |||
392 | +++ ui/TvTab.qml 2014-01-20 22:13:50 +0000 | |||
393 | @@ -35,10 +35,17 @@ | |||
394 | 35 | id: airingShowsModel | 35 | id: airingShowsModel |
395 | 36 | username: traktLogin.contents.username | 36 | username: traktLogin.contents.username |
396 | 37 | password: traktLogin.contents.password | 37 | password: traktLogin.contents.password |
397 | 38 | lastUpdated: watchlistActivityDocument.contents.show | ||
398 | 38 | onPasswordChanged: { | 39 | onPasswordChanged: { |
399 | 39 | console.log("[LOG]: Retrieving upcoming shows") | 40 | console.log("[LOG]: Retrieving upcoming shows") |
400 | 40 | fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 7) | 41 | fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 7) |
401 | 41 | } | 42 | } |
402 | 43 | onLastUpdatedChanged: { | ||
403 | 44 | if(username !== "") { | ||
404 | 45 | console.log("[LOG]: Retrieving upcoming shows") | ||
405 | 46 | fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 7) | ||
406 | 47 | } | ||
407 | 48 | } | ||
408 | 42 | } | 49 | } |
409 | 43 | 50 | ||
410 | 44 | LoadingIndicator { | 51 | LoadingIndicator { |