Merge lp:~arashbm/cliffhanger/person-movie-backend into lp:~flashback-dev/cliffhanger/trunk
- person-movie-backend
- Merge into trunk
Proposed by
Arash Badie Modiri
Status: | Merged |
---|---|
Merged at revision: | 10 |
Proposed branch: | lp:~arashbm/cliffhanger/person-movie-backend |
Merge into: | lp:~flashback-dev/cliffhanger/trunk |
Diff against target: |
750 lines (+224/-192) 16 files modified
backend/MovieDetails.js (+0/-29) backend/PersonDetails.js (+0/-58) backend/backend.js (+18/-0) models/BaseModel.qml (+13/-5) models/Cast.qml (+0/-3) models/Crew.qml (+0/-3) models/Genres.qml (+0/-3) models/Movie.qml (+37/-0) models/Movies.qml (+0/-2) models/People.qml (+0/-3) models/Person.qml (+30/-0) models/PersonCast.qml (+22/-0) models/PersonCrew.qml (+21/-0) models/Shows.qml (+0/-3) ui/MoviePage.qml (+39/-45) ui/PersonPage.qml (+44/-38) |
To merge this branch: | bzr merge lp:~arashbm/cliffhanger/person-movie-backend |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nekhelesh Ramananthan | Approve | ||
Review via email: mp+195487@code.launchpad.net |
Commit message
Description of the change
* Added models for Movie and Person, PersonCast, PersonCrew
* Removed `PersonDetails.js` and `MovieDetails,js`
* Optimized MoviePage (and PersonPage) to do one request only
To post a comment you must log in.
Revision history for this message
Arash Badie Modiri (arashbm) wrote : | # |
oops! I thought I had removed them. I'll fix it in a moment.
- 17. By Arash Badie Modiri
-
* refactoring json === ''
* removing unused defaultAttributes property
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed file 'backend/MovieDetails.js' | |||
2 | --- backend/MovieDetails.js 2013-11-15 09:48:33 +0000 | |||
3 | +++ backend/MovieDetails.js 1970-01-01 00:00:00 +0000 | |||
4 | @@ -1,29 +0,0 @@ | |||
5 | 1 | WorkerScript.onMessage = function(message) { | ||
6 | 2 | |||
7 | 3 | var XHR = new XMLHttpRequest(); | ||
8 | 4 | var thumb_url; | ||
9 | 5 | |||
10 | 6 | XHR.open("GET", message.movie_url); | ||
11 | 7 | XHR.setRequestHeader("Accept", "application/json"); | ||
12 | 8 | |||
13 | 9 | XHR.onreadystatechange = function() { | ||
14 | 10 | if(XHR.readyState != XHR.DONE) | ||
15 | 11 | return; | ||
16 | 12 | if(XHR.status != 200) | ||
17 | 13 | return; | ||
18 | 14 | |||
19 | 15 | var obj = JSON.parse(XHR.responseText); | ||
20 | 16 | |||
21 | 17 | WorkerScript.sendMessage({ 'poster': obj.poster_path, | ||
22 | 18 | "title": obj.original_title, | ||
23 | 19 | "description": obj.overview, | ||
24 | 20 | "runtime": obj.runtime, | ||
25 | 21 | "genre": obj.genres, | ||
26 | 22 | "theme": obj.tagline, | ||
27 | 23 | "avg_vote": obj.vote_average, | ||
28 | 24 | "total_vote": obj.vote_count, | ||
29 | 25 | "releasedate": obj.release_date}) | ||
30 | 26 | }; | ||
31 | 27 | |||
32 | 28 | XHR.send(); | ||
33 | 29 | } | ||
34 | 30 | 0 | ||
35 | === removed file 'backend/PersonDetails.js' | |||
36 | --- backend/PersonDetails.js 2013-11-13 21:28:13 +0000 | |||
37 | +++ backend/PersonDetails.js 1970-01-01 00:00:00 +0000 | |||
38 | @@ -1,58 +0,0 @@ | |||
39 | 1 | WorkerScript.onMessage = function(message) { | ||
40 | 2 | |||
41 | 3 | var XHR = new XMLHttpRequest(); | ||
42 | 4 | var thumb_url; | ||
43 | 5 | |||
44 | 6 | XHR.open("GET", message.person_url); | ||
45 | 7 | XHR.setRequestHeader("Accept", "application/json"); | ||
46 | 8 | |||
47 | 9 | XHR.onreadystatechange = function() { | ||
48 | 10 | if(XHR.readyState != XHR.DONE) | ||
49 | 11 | return; | ||
50 | 12 | if(XHR.status != 200) | ||
51 | 13 | return; | ||
52 | 14 | |||
53 | 15 | var obj = JSON.parse(XHR.responseText); | ||
54 | 16 | |||
55 | 17 | for(var i=0; i<obj.combined_credits.cast.length; i++) { | ||
56 | 18 | if (obj.combined_credits.cast[i].poster_path == null) | ||
57 | 19 | thumb_url = "null" | ||
58 | 20 | else | ||
59 | 21 | thumb_url = "http://d3gtl9l2a4fn1j.cloudfront.net/t/p/" + "w185/" + obj.combined_credits.cast[i].poster_path | ||
60 | 22 | |||
61 | 23 | |||
62 | 24 | if(obj.combined_credits.cast[i].media_type == "movie") | ||
63 | 25 | message.actedModel.append({"title": obj.combined_credits.cast[i].title, | ||
64 | 26 | "character": obj.combined_credits.cast[i].character, | ||
65 | 27 | "media_type": obj.combined_credits.cast[i].media_type, | ||
66 | 28 | "id": obj.combined_credits.cast[i].id, | ||
67 | 29 | "iconUrl": thumb_url}); | ||
68 | 30 | else if(obj.combined_credits.cast[i].media_type == "tv") | ||
69 | 31 | message.actedModel.append({"title": obj.combined_credits.cast[i].name, | ||
70 | 32 | "character": obj.combined_credits.cast[i].media_type, | ||
71 | 33 | "media_type": obj.combined_credits.cast[i].media_type, | ||
72 | 34 | "id": obj.combined_credits.cast[i].id, | ||
73 | 35 | "iconUrl": thumb_url}); | ||
74 | 36 | message.actedModel.sync() | ||
75 | 37 | } | ||
76 | 38 | |||
77 | 39 | for(i=0; i<obj.combined_credits.crew.length; i++) { | ||
78 | 40 | message.directedModel.append({"title": obj.combined_credits.crew[i].title, | ||
79 | 41 | "character": obj.combined_credits.crew[i].job, | ||
80 | 42 | "media_type": obj.combined_credits.cast[i].media_type, | ||
81 | 43 | "id": obj.combined_credits.crew[i].id, | ||
82 | 44 | "iconUrl": thumb_url}); | ||
83 | 45 | message.directedModel.sync() | ||
84 | 46 | } | ||
85 | 47 | |||
86 | 48 | WorkerScript.sendMessage({ 'poster': obj.profile_path, | ||
87 | 49 | "name": obj.name, | ||
88 | 50 | "biography": obj.biography, | ||
89 | 51 | "birthday": obj.birthday, | ||
90 | 52 | "deathday": obj.deathday, | ||
91 | 53 | "place_of_birth": obj.place_of_birth, | ||
92 | 54 | "homepage": obj.homepage}) | ||
93 | 55 | }; | ||
94 | 56 | |||
95 | 57 | XHR.send(); | ||
96 | 58 | } | ||
97 | 59 | 0 | ||
98 | === modified file 'backend/backend.js' | |||
99 | --- backend/backend.js 2013-11-15 22:11:55 +0000 | |||
100 | +++ backend/backend.js 2013-11-17 16:42:59 +0000 | |||
101 | @@ -16,6 +16,15 @@ | |||
102 | 16 | return credentials.baseUrl + "/movie/upcoming" + "?api_key=" + credentials.apiKey; | 16 | return credentials.baseUrl + "/movie/upcoming" + "?api_key=" + credentials.apiKey; |
103 | 17 | } | 17 | } |
104 | 18 | 18 | ||
105 | 19 | function movieUrl(movie_id, options) { | ||
106 | 20 | options = options || {}; | ||
107 | 21 | var base = credentials.baseUrl + "/movie/"+ movie_id + "?api_key=" + credentials.apiKey; | ||
108 | 22 | if ( options.appendToResponse ) | ||
109 | 23 | return base + "&append_to_response=" + options.appendToResponse.join(','); | ||
110 | 24 | else | ||
111 | 25 | return base; | ||
112 | 26 | } | ||
113 | 27 | |||
114 | 19 | function filterByGenreUrl(genre_id) { | 28 | function filterByGenreUrl(genre_id) { |
115 | 20 | return credentials.baseUrl + "/genre/" + genre_id + "/movies" + "?api_key=" + credentials.apiKey; | 29 | return credentials.baseUrl + "/genre/" + genre_id + "/movies" + "?api_key=" + credentials.apiKey; |
116 | 21 | } | 30 | } |
117 | @@ -45,6 +54,15 @@ | |||
118 | 45 | return credentials.baseUrl + "/person/popular" + "?api_key=" + credentials.apiKey; | 54 | return credentials.baseUrl + "/person/popular" + "?api_key=" + credentials.apiKey; |
119 | 46 | } | 55 | } |
120 | 47 | 56 | ||
121 | 57 | function personUrl(person_id, options) { | ||
122 | 58 | options = options || {}; | ||
123 | 59 | var base = credentials.baseUrl + "/person/"+ person_id + "?api_key=" + credentials.apiKey; | ||
124 | 60 | if ( options.appendToResponse ) | ||
125 | 61 | return base + "&append_to_response=" + options.appendToResponse.join(','); | ||
126 | 62 | else | ||
127 | 63 | return base; | ||
128 | 64 | } | ||
129 | 65 | |||
130 | 48 | // Search | 66 | // Search |
131 | 49 | function searchUrl(type, term) { | 67 | function searchUrl(type, term) { |
132 | 50 | return credentials.baseUrl + "/search/"+ type + "?api_key=" + credentials.apiKey + "&query=" + encodeURIComponent(term); | 68 | return credentials.baseUrl + "/search/"+ type + "?api_key=" + credentials.apiKey + "&query=" + encodeURIComponent(term); |
133 | 51 | 69 | ||
134 | === modified file 'models/BaseModel.qml' | |||
135 | --- models/BaseModel.qml 2013-11-15 17:02:44 +0000 | |||
136 | +++ models/BaseModel.qml 2013-11-17 16:42:59 +0000 | |||
137 | @@ -6,8 +6,10 @@ | |||
138 | 6 | property string json: "" | 6 | property string json: "" |
139 | 7 | property int status: XMLHttpRequest.UNSENT | 7 | property int status: XMLHttpRequest.UNSENT |
140 | 8 | 8 | ||
143 | 9 | property ListModel model: ListModel { id: jsonModel } | 9 | property ListModel model: ListModel { id: model } |
144 | 10 | property alias count: jsonModel.count | 10 | property alias count: model.count |
145 | 11 | |||
146 | 12 | signal updated() | ||
147 | 11 | 13 | ||
148 | 12 | onSourceChanged: { | 14 | onSourceChanged: { |
149 | 13 | var xhr = new XMLHttpRequest; | 15 | var xhr = new XMLHttpRequest; |
150 | @@ -19,12 +21,18 @@ | |||
151 | 19 | } | 21 | } |
152 | 20 | xhr.send(); | 22 | xhr.send(); |
153 | 21 | } | 23 | } |
155 | 22 | onJsonChanged: updateJSONModel() | 24 | |
156 | 25 | onJsonChanged: { | ||
157 | 26 | if ( json != "" ) { | ||
158 | 27 | updateJSONModel(); | ||
159 | 28 | updated(); | ||
160 | 29 | } | ||
161 | 30 | } | ||
162 | 23 | 31 | ||
163 | 24 | function thumbnail_url(thumb_path) { | 32 | function thumbnail_url(thumb_path) { |
164 | 25 | if (thumb_path) | 33 | if (thumb_path) |
166 | 26 | return "http://d3gtl9l2a4fn1j.cloudfront.net/t/p/" + "w185/" + thumb_path; | 34 | return "http://d3gtl9l2a4fn1j.cloudfront.net/t/p/" + "w185/" + thumb_path; |
167 | 27 | else | 35 | else |
169 | 28 | return Qt.resolvedUrl("../graphics/toolbarIcon.png"); | 36 | return Qt.resolvedUrl("../graphics/toolbarIcon.png"); |
170 | 29 | } | 37 | } |
171 | 30 | } | 38 | } |
172 | 31 | 39 | ||
173 | === modified file 'models/Cast.qml' | |||
174 | --- models/Cast.qml 2013-11-15 10:57:48 +0000 | |||
175 | +++ models/Cast.qml 2013-11-17 16:42:59 +0000 | |||
176 | @@ -6,9 +6,6 @@ | |||
177 | 6 | function updateJSONModel() { | 6 | function updateJSONModel() { |
178 | 7 | model.clear(); | 7 | model.clear(); |
179 | 8 | 8 | ||
180 | 9 | if ( json === "" ) | ||
181 | 10 | return; | ||
182 | 11 | |||
183 | 12 | var objectArray = JSON.parse(json).cast; | 9 | var objectArray = JSON.parse(json).cast; |
184 | 13 | for ( var key in objectArray ) { | 10 | for ( var key in objectArray ) { |
185 | 14 | var jo = objectArray[key]; | 11 | var jo = objectArray[key]; |
186 | 15 | 12 | ||
187 | === modified file 'models/Crew.qml' | |||
188 | --- models/Crew.qml 2013-11-15 10:57:48 +0000 | |||
189 | +++ models/Crew.qml 2013-11-17 16:42:59 +0000 | |||
190 | @@ -5,9 +5,6 @@ | |||
191 | 5 | function updateJSONModel() { | 5 | function updateJSONModel() { |
192 | 6 | model.clear(); | 6 | model.clear(); |
193 | 7 | 7 | ||
194 | 8 | if ( json === "" ) | ||
195 | 9 | return; | ||
196 | 10 | |||
197 | 11 | var objectArray = JSON.parse(json).crew; | 8 | var objectArray = JSON.parse(json).crew; |
198 | 12 | for ( var key in objectArray ) { | 9 | for ( var key in objectArray ) { |
199 | 13 | var jo = objectArray[key]; | 10 | var jo = objectArray[key]; |
200 | 14 | 11 | ||
201 | === modified file 'models/Genres.qml' | |||
202 | --- models/Genres.qml 2013-11-15 22:22:17 +0000 | |||
203 | +++ models/Genres.qml 2013-11-17 16:42:59 +0000 | |||
204 | @@ -5,9 +5,6 @@ | |||
205 | 5 | function updateJSONModel() { | 5 | function updateJSONModel() { |
206 | 6 | model.clear(); | 6 | model.clear(); |
207 | 7 | 7 | ||
208 | 8 | if ( json === "" ) | ||
209 | 9 | return; | ||
210 | 10 | |||
211 | 11 | var objectArray = JSON.parse(json).genres; | 8 | var objectArray = JSON.parse(json).genres; |
212 | 12 | for ( var key in objectArray ) { | 9 | for ( var key in objectArray ) { |
213 | 13 | var jo = objectArray[key]; | 10 | var jo = objectArray[key]; |
214 | 14 | 11 | ||
215 | === added file 'models/Movie.qml' | |||
216 | --- models/Movie.qml 1970-01-01 00:00:00 +0000 | |||
217 | +++ models/Movie.qml 2013-11-17 16:42:59 +0000 | |||
218 | @@ -0,0 +1,37 @@ | |||
219 | 1 | import QtQuick 2.0 | ||
220 | 2 | |||
221 | 3 | BaseModel { | ||
222 | 4 | id: movie | ||
223 | 5 | |||
224 | 6 | property variant attributes: { | ||
225 | 7 | 'title': '', | ||
226 | 8 | 'homepage': '', | ||
227 | 9 | 'tagline': '', | ||
228 | 10 | 'overview': '', | ||
229 | 11 | 'releaseDate': '', | ||
230 | 12 | 'runtime': '', | ||
231 | 13 | 'voteAverage': '', | ||
232 | 14 | 'voteCount': '', | ||
233 | 15 | 'genres': [], | ||
234 | 16 | 'thumb_url': '' | ||
235 | 17 | } | ||
236 | 18 | |||
237 | 19 | function updateJSONModel() { | ||
238 | 20 | var ob = JSON.parse(json); | ||
239 | 21 | attributes = { | ||
240 | 22 | 'id': ob.id, | ||
241 | 23 | 'title': ob.title, | ||
242 | 24 | 'homepage': ob.homepage, | ||
243 | 25 | 'tagline': ob.tagline, | ||
244 | 26 | 'overview': ob.overview, | ||
245 | 27 | 'releaseDate': ob.release_date, | ||
246 | 28 | 'runtime': ob.runtime, | ||
247 | 29 | 'voteAverage': ob.vote_average, | ||
248 | 30 | 'voteCount': ob.vote_count, | ||
249 | 31 | 'genres': ob.genres, | ||
250 | 32 | 'thumb_url': thumbnail_url(ob.poster_path), | ||
251 | 33 | 'creditsJson': JSON.stringify(ob.credits || {}), | ||
252 | 34 | 'similarMoviesJson': JSON.stringify(ob.similar_movies || {}) | ||
253 | 35 | }; | ||
254 | 36 | } | ||
255 | 37 | } | ||
256 | 0 | 38 | ||
257 | === modified file 'models/Movies.qml' | |||
258 | --- models/Movies.qml 2013-11-15 10:57:48 +0000 | |||
259 | +++ models/Movies.qml 2013-11-17 16:42:59 +0000 | |||
260 | @@ -5,8 +5,6 @@ | |||
261 | 5 | 5 | ||
262 | 6 | function updateJSONModel() { | 6 | function updateJSONModel() { |
263 | 7 | model.clear(); | 7 | model.clear(); |
264 | 8 | |||
265 | 9 | if ( json === "" ) return; | ||
266 | 10 | 8 | ||
267 | 11 | var objectArray = JSON.parse(json).results; | 9 | var objectArray = JSON.parse(json).results; |
268 | 12 | for ( var key in objectArray ) { | 10 | for ( var key in objectArray ) { |
269 | 13 | 11 | ||
270 | === modified file 'models/People.qml' | |||
271 | --- models/People.qml 2013-11-15 10:57:48 +0000 | |||
272 | +++ models/People.qml 2013-11-17 16:42:59 +0000 | |||
273 | @@ -5,9 +5,6 @@ | |||
274 | 5 | function updateJSONModel() { | 5 | function updateJSONModel() { |
275 | 6 | model.clear(); | 6 | model.clear(); |
276 | 7 | 7 | ||
277 | 8 | if ( json === "" ) | ||
278 | 9 | return; | ||
279 | 10 | |||
280 | 11 | var objectArray = JSON.parse(json).results; | 8 | var objectArray = JSON.parse(json).results; |
281 | 12 | for ( var key in objectArray ) { | 9 | for ( var key in objectArray ) { |
282 | 13 | var jo = objectArray[key]; | 10 | var jo = objectArray[key]; |
283 | 14 | 11 | ||
284 | === added file 'models/Person.qml' | |||
285 | --- models/Person.qml 1970-01-01 00:00:00 +0000 | |||
286 | +++ models/Person.qml 2013-11-17 16:42:59 +0000 | |||
287 | @@ -0,0 +1,30 @@ | |||
288 | 1 | import QtQuick 2.0 | ||
289 | 2 | |||
290 | 3 | BaseModel { | ||
291 | 4 | id: person | ||
292 | 5 | |||
293 | 6 | property variant attributes: { | ||
294 | 7 | 'name': '', | ||
295 | 8 | 'biography': '', | ||
296 | 9 | 'birthday': '', | ||
297 | 10 | 'deathday': '', | ||
298 | 11 | 'homepage': '', | ||
299 | 12 | 'placeOfBirth': '', | ||
300 | 13 | 'thumb_url': '' | ||
301 | 14 | } | ||
302 | 15 | |||
303 | 16 | function updateJSONModel() { | ||
304 | 17 | var ob = JSON.parse(json); | ||
305 | 18 | attributes = { | ||
306 | 19 | 'id': ob.id, | ||
307 | 20 | 'name': ob.name, | ||
308 | 21 | 'biography': ob.biography, | ||
309 | 22 | 'birthday': ob.birthday, | ||
310 | 23 | 'deathday': ob.deathday, | ||
311 | 24 | 'homepage': ob.homepage, | ||
312 | 25 | 'placeOfBirth': ob.place_of_birth, | ||
313 | 26 | 'thumb_url': thumbnail_url(ob.profile_path), | ||
314 | 27 | 'combinedCreditsJson': JSON.stringify(ob.combined_credits || {}) | ||
315 | 28 | }; | ||
316 | 29 | } | ||
317 | 30 | } | ||
318 | 0 | 31 | ||
319 | === added file 'models/PersonCast.qml' | |||
320 | --- models/PersonCast.qml 1970-01-01 00:00:00 +0000 | |||
321 | +++ models/PersonCast.qml 2013-11-17 16:42:59 +0000 | |||
322 | @@ -0,0 +1,22 @@ | |||
323 | 1 | import QtQuick 2.0 | ||
324 | 2 | |||
325 | 3 | BaseModel { | ||
326 | 4 | id: personCast | ||
327 | 5 | |||
328 | 6 | function updateJSONModel() { | ||
329 | 7 | model.clear(); | ||
330 | 8 | |||
331 | 9 | var objectArray = JSON.parse(json).cast; | ||
332 | 10 | for ( var key in objectArray ) { | ||
333 | 11 | var jo = objectArray[key]; | ||
334 | 12 | model.append({ | ||
335 | 13 | 'id': jo.id, | ||
336 | 14 | 'title': jo.title, | ||
337 | 15 | 'character': jo.character, | ||
338 | 16 | 'releaseDate': jo.release_date, | ||
339 | 17 | 'mediaType': jo.media_type, | ||
340 | 18 | 'thumb_url': thumbnail_url(jo.poster_path) | ||
341 | 19 | }); | ||
342 | 20 | } | ||
343 | 21 | } | ||
344 | 22 | } | ||
345 | 0 | 23 | ||
346 | === added file 'models/PersonCrew.qml' | |||
347 | --- models/PersonCrew.qml 1970-01-01 00:00:00 +0000 | |||
348 | +++ models/PersonCrew.qml 2013-11-17 16:42:59 +0000 | |||
349 | @@ -0,0 +1,21 @@ | |||
350 | 1 | import QtQuick 2.0 | ||
351 | 2 | |||
352 | 3 | BaseModel { | ||
353 | 4 | id: personCrew | ||
354 | 5 | function updateJSONModel() { | ||
355 | 6 | model.clear(); | ||
356 | 7 | |||
357 | 8 | var objectArray = JSON.parse(json).crew; | ||
358 | 9 | for ( var key in objectArray ) { | ||
359 | 10 | var jo = objectArray[key]; | ||
360 | 11 | model.append({ | ||
361 | 12 | 'id': jo.id, | ||
362 | 13 | 'title': jo.title, | ||
363 | 14 | 'department': jo.department, | ||
364 | 15 | 'releaseDate': jo.release_date, | ||
365 | 16 | 'mediaType': jo.media_type, | ||
366 | 17 | 'thumb_url': thumbnail_url(jo.profile_path) | ||
367 | 18 | }); | ||
368 | 19 | } | ||
369 | 20 | } | ||
370 | 21 | } | ||
371 | 0 | 22 | ||
372 | === modified file 'models/Shows.qml' | |||
373 | --- models/Shows.qml 2013-11-15 10:57:48 +0000 | |||
374 | +++ models/Shows.qml 2013-11-17 16:42:59 +0000 | |||
375 | @@ -6,9 +6,6 @@ | |||
376 | 6 | function updateJSONModel() { | 6 | function updateJSONModel() { |
377 | 7 | model.clear(); | 7 | model.clear(); |
378 | 8 | 8 | ||
379 | 9 | if ( json === "" ) | ||
380 | 10 | return; | ||
381 | 11 | |||
382 | 12 | var objectArray = JSON.parse(json).results; | 9 | var objectArray = JSON.parse(json).results; |
383 | 13 | for ( var key in objectArray ) { | 10 | for ( var key in objectArray ) { |
384 | 14 | var jo = objectArray[key]; | 11 | var jo = objectArray[key]; |
385 | 15 | 12 | ||
386 | === modified file 'ui/MoviePage.qml' | |||
387 | --- ui/MoviePage.qml 2013-11-15 09:48:33 +0000 | |||
388 | +++ ui/MoviePage.qml 2013-11-17 16:42:59 +0000 | |||
389 | @@ -13,52 +13,30 @@ | |||
390 | 13 | flickable: null | 13 | flickable: null |
391 | 14 | 14 | ||
392 | 15 | property string movie_id | 15 | property string movie_id |
393 | 16 | property string movie_url: root.baseUrl + "/movie/" + movie_id + root.api_Key + "&append_to_response=credits" | ||
394 | 17 | |||
395 | 18 | Component.onCompleted: movieWorker.sendMessage({"movie_url": movie_url}) | ||
396 | 19 | 16 | ||
397 | 20 | Cast { | 17 | Cast { |
398 | 21 | id: movieCast | 18 | id: movieCast |
399 | 22 | source: Backend.movieCastUrl(movie_id) | ||
400 | 23 | } | 19 | } |
401 | 24 | 20 | ||
402 | 25 | Crew { | 21 | Crew { |
403 | 26 | id: movieCrew | 22 | id: movieCrew |
404 | 27 | source: Backend.movieCrewUrl(movie_id) | ||
405 | 28 | } | 23 | } |
406 | 29 | 24 | ||
407 | 30 | Movies { | 25 | Movies { |
408 | 31 | id: similarMoviesModel | 26 | id: similarMoviesModel |
439 | 32 | source: Backend.similarMoviesUrl(movie_id) | 27 | } |
440 | 33 | } | 28 | |
441 | 34 | 29 | Movie { | |
442 | 35 | WorkerScript { | 30 | id: movie |
443 | 36 | id: movieWorker | 31 | source: Backend.movieUrl(movie_id, {appendToResponse: ['credits', 'similar_movies']}) |
444 | 37 | source: "../backend/MovieDetails.js" | 32 | |
445 | 38 | onMessage: { | 33 | onUpdated: { |
446 | 39 | if(messageObject.poster == null) | 34 | movieCast.json = movie.attributes.creditsJson; |
447 | 40 | thumb.source = Qt.resolvedUrl("../graphics/toolbarIcon.png") | 35 | movieCrew.json = movie.attributes.creditsJson; |
448 | 41 | else | 36 | similarMoviesModel.json = movie.attributes.similarMoviesJson; |
449 | 42 | thumb.source = "http://d3gtl9l2a4fn1j.cloudfront.net/t/p/" + "w185/" + messageObject.poster | 37 | } |
450 | 43 | 38 | } | |
451 | 44 | title.text = messageObject.title | 39 | |
422 | 45 | description.text = messageObject.description | ||
423 | 46 | releaseDate.subText = messageObject.releasedate | ||
424 | 47 | year.text = releaseDate.subText.split("-")[0] | ||
425 | 48 | runTime.text = messageObject.runtime + " minutes" | ||
426 | 49 | |||
427 | 50 | var genreModel = messageObject.genre | ||
428 | 51 | for (var i=0; i<genreModel.length; i++) { | ||
429 | 52 | if(genre.subText != "") | ||
430 | 53 | genre.subText = genre.subText + ", " + genreModel[i].name | ||
431 | 54 | else | ||
432 | 55 | genre.subText = genreModel[i].name | ||
433 | 56 | } | ||
434 | 57 | |||
435 | 58 | theme.subText = messageObject.theme | ||
436 | 59 | rating.text = messageObject.avg_vote + "/10\n" + messageObject.total_vote | ||
437 | 60 | } | ||
438 | 61 | } | ||
452 | 62 | 40 | ||
453 | 63 | Overlay { | 41 | Overlay { |
454 | 64 | id: summaryOverlay | 42 | id: summaryOverlay |
455 | @@ -75,7 +53,7 @@ | |||
456 | 75 | bottomMargin: units.gu(12) | 53 | bottomMargin: units.gu(12) |
457 | 76 | } | 54 | } |
458 | 77 | 55 | ||
460 | 78 | text: description.text | 56 | text: movie.attributes.overview |
461 | 79 | wrapMode: Text.WordWrap | 57 | wrapMode: Text.WordWrap |
462 | 80 | } | 58 | } |
463 | 81 | } | 59 | } |
464 | @@ -153,11 +131,12 @@ | |||
465 | 153 | id: thumb | 131 | id: thumb |
466 | 154 | fillMode: Image.PreserveAspectFit | 132 | fillMode: Image.PreserveAspectFit |
467 | 155 | smooth: true | 133 | smooth: true |
468 | 134 | source: movie.attributes.thumb_url | ||
469 | 156 | } | 135 | } |
470 | 157 | 136 | ||
471 | 158 | ActivityIndicator { | 137 | ActivityIndicator { |
472 | 159 | anchors.centerIn: parent | 138 | anchors.centerIn: parent |
474 | 160 | running: thumb.status != Image.Ready ? true : false | 139 | running: thumb.status != Image.Ready |
475 | 161 | } | 140 | } |
476 | 162 | } | 141 | } |
477 | 163 | 142 | ||
478 | @@ -175,6 +154,7 @@ | |||
479 | 175 | spacing: units.gu(2) | 154 | spacing: units.gu(2) |
480 | 176 | Label { | 155 | Label { |
481 | 177 | id: title | 156 | id: title |
482 | 157 | text: movie.attributes.title | ||
483 | 178 | fontSize: "large" | 158 | fontSize: "large" |
484 | 179 | width: movieColumn.width | 159 | width: movieColumn.width |
485 | 180 | maximumLineCount: 2 | 160 | maximumLineCount: 2 |
486 | @@ -183,7 +163,8 @@ | |||
487 | 183 | } | 163 | } |
488 | 184 | 164 | ||
489 | 185 | Label { | 165 | Label { |
491 | 186 | id: description | 166 | id: overview |
492 | 167 | text: movie.attributes.overview | ||
493 | 187 | fontSize: "medium" | 168 | fontSize: "medium" |
494 | 188 | width: movieColumn.width | 169 | width: movieColumn.width |
495 | 189 | height: movieColumn.height/2 | 170 | height: movieColumn.height/2 |
496 | @@ -196,8 +177,15 @@ | |||
497 | 196 | } | 177 | } |
498 | 197 | 178 | ||
499 | 198 | Column { | 179 | Column { |
502 | 199 | Label { id: year } | 180 | Label { |
503 | 200 | Label { id: runTime } | 181 | id: year |
504 | 182 | text: movie.attributes.releaseDate.split('-')[0] | ||
505 | 183 | } | ||
506 | 184 | Label { | ||
507 | 185 | id: runTime | ||
508 | 186 | text: movie.attributes.runtime + " minutes" | ||
509 | 187 | visible: movie.attributes.runtime != '0' | ||
510 | 188 | } | ||
511 | 201 | } | 189 | } |
512 | 202 | } | 190 | } |
513 | 203 | 191 | ||
514 | @@ -220,7 +208,10 @@ | |||
515 | 220 | smooth: true | 208 | smooth: true |
516 | 221 | } | 209 | } |
517 | 222 | 210 | ||
519 | 223 | Label { id: rating } | 211 | Label { |
520 | 212 | id: rating | ||
521 | 213 | text: movie.attributes.voteAverage+"\n"+movie.attributes.voteCount | ||
522 | 214 | } | ||
523 | 224 | } | 215 | } |
524 | 225 | 216 | ||
525 | 226 | // Movie Details - Release dates, genre, movie theme etc. | 217 | // Movie Details - Release dates, genre, movie theme etc. |
526 | @@ -243,19 +234,22 @@ | |||
527 | 243 | Header { text: "Details" } | 234 | Header { text: "Details" } |
528 | 244 | 235 | ||
529 | 245 | Subtitled { | 236 | Subtitled { |
532 | 246 | id: genre | 237 | id: genres |
533 | 247 | text: "Genre" | 238 | text: "Genres" |
534 | 239 | subText: movie.attributes.genres.map(function(o) { return o.name }).join(', ') | ||
535 | 248 | } | 240 | } |
536 | 249 | 241 | ||
537 | 250 | Subtitled { | 242 | Subtitled { |
538 | 251 | id: releaseDate | 243 | id: releaseDate |
539 | 252 | text: "Release Date" | 244 | text: "Release Date" |
540 | 245 | subText: movie.attributes.releaseDate | ||
541 | 253 | } | 246 | } |
542 | 254 | 247 | ||
543 | 255 | Subtitled { | 248 | Subtitled { |
544 | 256 | id: theme | 249 | id: theme |
547 | 257 | text: "Movie Theme" | 250 | text: "Tagline" |
548 | 258 | visible: theme.subText == "" ? false : true | 251 | subText: movie.attributes.tagline |
549 | 252 | visible: movie.attributes.tagline | ||
550 | 259 | } | 253 | } |
551 | 260 | 254 | ||
552 | 261 | Header { text: "Casts" } | 255 | Header { text: "Casts" } |
553 | 262 | 256 | ||
554 | === modified file 'ui/PersonPage.qml' | |||
555 | --- ui/PersonPage.qml 2013-11-13 21:28:13 +0000 | |||
556 | +++ ui/PersonPage.qml 2013-11-17 16:42:59 +0000 | |||
557 | @@ -1,6 +1,8 @@ | |||
558 | 1 | import QtQuick 2.0 | 1 | import QtQuick 2.0 |
559 | 2 | import Ubuntu.Components 0.1 | 2 | import Ubuntu.Components 0.1 |
560 | 3 | import Ubuntu.Components.ListItems 0.1 | 3 | import Ubuntu.Components.ListItems 0.1 |
561 | 4 | import '../models' | ||
562 | 5 | import '../backend/backend.js' as Backend | ||
563 | 4 | 6 | ||
564 | 5 | Page { | 7 | Page { |
565 | 6 | id: personPage | 8 | id: personPage |
566 | @@ -9,29 +11,24 @@ | |||
567 | 9 | flickable: null | 11 | flickable: null |
568 | 10 | 12 | ||
569 | 11 | property string person_id | 13 | property string person_id |
593 | 12 | property string person_url: root.baseUrl + "/person/" + person_id + root.api_Key + "&append_to_response=combined_credits" | 14 | |
594 | 13 | 15 | PersonCast { | |
595 | 14 | Component.onCompleted: personWorker.sendMessage({"person_url": person_url, "actedModel": actedModel, "directedModel": directedModel}) | 16 | id: personCast |
596 | 15 | 17 | } | |
597 | 16 | ListModel { id: actedModel } | 18 | |
598 | 17 | ListModel { id: directedModel } | 19 | PersonCrew { |
599 | 18 | 20 | id: personCrew | |
600 | 19 | WorkerScript { | 21 | } |
601 | 20 | id: personWorker | 22 | |
602 | 21 | source: "../backend/PersonDetails.js" | 23 | Person { |
603 | 22 | onMessage: { | 24 | id: person |
604 | 23 | if(messageObject.poster == null) | 25 | |
605 | 24 | thumb.source = Qt.resolvedUrl("../graphics/toolbarIcon.png") | 26 | source: Backend.personUrl(person_id, {appendToResponse: ['combined_credits']}) |
606 | 25 | else | 27 | |
607 | 26 | thumb.source = "http://d3gtl9l2a4fn1j.cloudfront.net/t/p/" + "w185/" + messageObject.poster | 28 | onUpdated: { |
608 | 27 | 29 | personCast.json = person.attributes.combinedCreditsJson; | |
609 | 28 | name.text = messageObject.name | 30 | personCrew.json = person.attributes.combinedCreditsJson; |
610 | 29 | biography.text = messageObject.biography == null ? "Biography not available" : messageObject.biography | 31 | } |
588 | 30 | birthYear.text = messageObject.birthday == null ? "Not Available" : "Born: " + messageObject.birthday | ||
589 | 31 | deathYear.text = messageObject.deathday == null ? "Not Available" :"Dead: " + messageObject.deathday | ||
590 | 32 | birthPlace.text = messageObject.place_of_birth == null ? "Birth Place Not Available" : messageObject.place_of_birth | ||
591 | 33 | contact.text = messageObject.homepage | ||
592 | 34 | } | ||
611 | 35 | } | 32 | } |
612 | 36 | 33 | ||
613 | 37 | Flickable { | 34 | Flickable { |
614 | @@ -56,11 +53,12 @@ | |||
615 | 56 | id: thumb | 53 | id: thumb |
616 | 57 | fillMode: Image.PreserveAspectFit | 54 | fillMode: Image.PreserveAspectFit |
617 | 58 | smooth: true | 55 | smooth: true |
618 | 56 | source: person.attributes.thumb_url | ||
619 | 59 | } | 57 | } |
620 | 60 | 58 | ||
621 | 61 | ActivityIndicator { | 59 | ActivityIndicator { |
622 | 62 | anchors.centerIn: parent | 60 | anchors.centerIn: parent |
624 | 63 | running: thumb.status != Image.Ready ? true : false | 61 | running: thumb.status != Image.Ready |
625 | 64 | } | 62 | } |
626 | 65 | } | 63 | } |
627 | 66 | 64 | ||
628 | @@ -79,6 +77,7 @@ | |||
629 | 79 | 77 | ||
630 | 80 | Label { | 78 | Label { |
631 | 81 | id: name | 79 | id: name |
632 | 80 | text: person.attributes.name | ||
633 | 82 | fontSize: "large" | 81 | fontSize: "large" |
634 | 83 | width: personColumn.width | 82 | width: personColumn.width |
635 | 84 | maximumLineCount: 2 | 83 | maximumLineCount: 2 |
636 | @@ -89,6 +88,7 @@ | |||
637 | 89 | Column { | 88 | Column { |
638 | 90 | Label { | 89 | Label { |
639 | 91 | id: birthPlace | 90 | id: birthPlace |
640 | 91 | text: person.attributes.placeOfBirth | ||
641 | 92 | fontSize: "medium" | 92 | fontSize: "medium" |
642 | 93 | width: personColumn.width | 93 | width: personColumn.width |
643 | 94 | elide: Text.ElideRight | 94 | elide: Text.ElideRight |
644 | @@ -97,8 +97,9 @@ | |||
645 | 97 | 97 | ||
646 | 98 | Label { | 98 | Label { |
647 | 99 | id: birthYear | 99 | id: birthYear |
648 | 100 | text: "Birth: " + person.attributes.birthday.split('-')[0] | ||
649 | 100 | fontSize: "medium" | 101 | fontSize: "medium" |
651 | 101 | visible: text == "Not Available" ? false: true | 102 | visible: person.attributes.birthday |
652 | 102 | width: personColumn.width | 103 | width: personColumn.width |
653 | 103 | elide: Text.ElideRight | 104 | elide: Text.ElideRight |
654 | 104 | wrapMode: Text.WordWrap | 105 | wrapMode: Text.WordWrap |
655 | @@ -106,8 +107,9 @@ | |||
656 | 106 | 107 | ||
657 | 107 | Label { | 108 | Label { |
658 | 108 | id: deathYear | 109 | id: deathYear |
659 | 110 | text: "Death: " + person.attributes.deathday.split('-')[0] | ||
660 | 109 | fontSize: "medium" | 111 | fontSize: "medium" |
662 | 110 | visible: text == "Dead: " || text == "Not Available" ? false : true | 112 | visible: person.attributes.deathday |
663 | 111 | width: personColumn.width | 113 | width: personColumn.width |
664 | 112 | elide: Text.ElideRight | 114 | elide: Text.ElideRight |
665 | 113 | wrapMode: Text.WordWrap | 115 | wrapMode: Text.WordWrap |
666 | @@ -115,13 +117,14 @@ | |||
667 | 115 | 117 | ||
668 | 116 | Label { | 118 | Label { |
669 | 117 | id: contact | 119 | id: contact |
670 | 120 | text: person.attributes.homepage | ||
671 | 118 | fontSize: "medium" | 121 | fontSize: "medium" |
672 | 119 | width: personColumn.width | 122 | width: personColumn.width |
673 | 120 | elide: Text.ElideRight | 123 | elide: Text.ElideRight |
674 | 121 | wrapMode: Text.WordWrap | 124 | wrapMode: Text.WordWrap |
675 | 122 | MouseArea { | 125 | MouseArea { |
676 | 123 | anchors.fill: parent | 126 | anchors.fill: parent |
678 | 124 | enabled: contact.text == "null" ? false : true | 127 | enabled: person.attributes.homepage |
679 | 125 | onClicked: Qt.openUrlExternally(contact.text) | 128 | onClicked: Qt.openUrlExternally(contact.text) |
680 | 126 | } | 129 | } |
681 | 127 | } | 130 | } |
682 | @@ -130,6 +133,7 @@ | |||
683 | 130 | 133 | ||
684 | 131 | Label { | 134 | Label { |
685 | 132 | id: biography | 135 | id: biography |
686 | 136 | text: person.attributes.biography | ||
687 | 133 | anchors { | 137 | anchors { |
688 | 134 | top: personColumn.bottom | 138 | top: personColumn.bottom |
689 | 135 | left: parent.left | 139 | left: parent.left |
690 | @@ -154,10 +158,13 @@ | |||
691 | 154 | 158 | ||
692 | 155 | Header { | 159 | Header { |
693 | 156 | text: "Acting" | 160 | text: "Acting" |
695 | 157 | visible: actedModel.count !== 0 | 161 | visible: personCast.count > 0 |
696 | 158 | } | 162 | } |
697 | 159 | 163 | ||
698 | 160 | ListView { | 164 | ListView { |
699 | 165 | id: personCastView | ||
700 | 166 | model: personCast.model | ||
701 | 167 | |||
702 | 161 | anchors { | 168 | anchors { |
703 | 162 | left: parent.left | 169 | left: parent.left |
704 | 163 | right: parent.right | 170 | right: parent.right |
705 | @@ -165,22 +172,23 @@ | |||
706 | 165 | 172 | ||
707 | 166 | height: units.gu(20) | 173 | height: units.gu(20) |
708 | 167 | clip: true | 174 | clip: true |
709 | 168 | |||
710 | 169 | model: actedModel | ||
711 | 170 | delegate: Subtitled { | 175 | delegate: Subtitled { |
713 | 171 | icon: iconUrl == "null" ? Qt.resolvedUrl("../graphics/toolbarIcon.png") : iconUrl | 176 | icon: thumb_url |
714 | 172 | text: title | 177 | text: title |
715 | 173 | subText: character | 178 | subText: character |
717 | 174 | onClicked: media_type == "movie" ? pageStack.push(Qt.resolvedUrl("MoviePage.qml"), {"movie_id": id}) : console.log("Not a movie") | 179 | onClicked: mediaType == "movie" ? pageStack.push(Qt.resolvedUrl("MoviePage.qml"), {"movie_id": id}) : console.log("Not a movie") |
718 | 175 | } | 180 | } |
719 | 176 | } | 181 | } |
720 | 177 | 182 | ||
721 | 178 | Header { | 183 | Header { |
722 | 179 | text: "Production" | 184 | text: "Production" |
724 | 180 | visible: directedModel.count !== 0 | 185 | visible: personCrew.count > 0 |
725 | 181 | } | 186 | } |
726 | 182 | 187 | ||
727 | 183 | ListView { | 188 | ListView { |
728 | 189 | id: personCrewView | ||
729 | 190 | model: personCrew.model | ||
730 | 191 | |||
731 | 184 | anchors { | 192 | anchors { |
732 | 185 | left: parent.left | 193 | left: parent.left |
733 | 186 | right: parent.right | 194 | right: parent.right |
734 | @@ -188,13 +196,11 @@ | |||
735 | 188 | 196 | ||
736 | 189 | height: units.gu(20) | 197 | height: units.gu(20) |
737 | 190 | clip: true | 198 | clip: true |
738 | 191 | |||
739 | 192 | model: directedModel | ||
740 | 193 | delegate: Subtitled { | 199 | delegate: Subtitled { |
742 | 194 | icon: iconUrl == "null" ? Qt.resolvedUrl("../graphics/toolbarIcon.png") : iconUrl | 200 | icon: thumb_url |
743 | 195 | text: title | 201 | text: title |
746 | 196 | subText: character | 202 | subText: department |
747 | 197 | onClicked: media_type == "movie" ? pageStack.push(Qt.resolvedUrl("MoviePage.qml"), {"movie_id": id}) : console.log("Not a movie") | 203 | onClicked: mediaType == "movie" ? pageStack.push(Qt.resolvedUrl("MoviePage.qml"), {"movie_id": id}) : console.log("Not a movie") |
748 | 198 | } | 204 | } |
749 | 199 | } | 205 | } |
750 | 200 | } | 206 | } |
As usual great work! I have one question regarding the Movie.qml and Person.qml Models. In their model definition why do you define default_attributes if you are anyway going to add additional items to the attribute variable? I feel like the defaultAttributes variables is just unnecessary. Thoughts?
180 + property variant defaultAttributes: {
181 + 'title': '',
182 + 'homepage': '',
183 + 'tagline': '',
184 + 'overview': '',
185 + 'releaseDate': '',
186 + 'runtime': '',
187 + 'voteAverage': '',
188 + 'voteCount': '',
189 + 'genres': [],
190 + 'thumb_url': ''
191 + }
202 + attributes = { url(ob. poster_ path), ob.credits || {}), son': JSON.stringify( ob.similar_ movies || {})
203 + 'id': ob.id,
204 + 'title': ob.title,
205 + 'homepage': ob.homepage,
206 + 'tagline': ob.tagline,
207 + 'overview': ob.overview,
208 + 'releaseDate': ob.release_date,
209 + 'runtime': ob.runtime,
210 + 'voteAverage': ob.vote_average,
211 + 'voteCount': ob.vote_count,
212 + 'genres': ob.genres,
213 + 'thumb_url': thumbnail_
214 + 'creditsJson': JSON.stringify(
215 + 'similarMoviesJ
216 + };