Merge lp:~arashbm/cliffhanger/person-movie-backend into lp:~flashback-dev/cliffhanger/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
Reviewer Review Type Date Requested Status
Nekhelesh Ramananthan Approve
Review via email: mp+195487@code.launchpad.net

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
Nekhelesh Ramananthan (nik90) wrote :

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 = {
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_url(ob.poster_path),
214 + 'creditsJson': JSON.stringify(ob.credits || {}),
215 + 'similarMoviesJson': JSON.stringify(ob.similar_movies || {})
216 + };

review: Needs Information
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

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

lgtm!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== removed file 'backend/MovieDetails.js'
--- backend/MovieDetails.js 2013-11-15 09:48:33 +0000
+++ backend/MovieDetails.js 1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
1WorkerScript.onMessage = function(message) {
2
3 var XHR = new XMLHttpRequest();
4 var thumb_url;
5
6 XHR.open("GET", message.movie_url);
7 XHR.setRequestHeader("Accept", "application/json");
8
9 XHR.onreadystatechange = function() {
10 if(XHR.readyState != XHR.DONE)
11 return;
12 if(XHR.status != 200)
13 return;
14
15 var obj = JSON.parse(XHR.responseText);
16
17 WorkerScript.sendMessage({ 'poster': obj.poster_path,
18 "title": obj.original_title,
19 "description": obj.overview,
20 "runtime": obj.runtime,
21 "genre": obj.genres,
22 "theme": obj.tagline,
23 "avg_vote": obj.vote_average,
24 "total_vote": obj.vote_count,
25 "releasedate": obj.release_date})
26 };
27
28 XHR.send();
29}
300
=== removed file 'backend/PersonDetails.js'
--- backend/PersonDetails.js 2013-11-13 21:28:13 +0000
+++ backend/PersonDetails.js 1970-01-01 00:00:00 +0000
@@ -1,58 +0,0 @@
1WorkerScript.onMessage = function(message) {
2
3 var XHR = new XMLHttpRequest();
4 var thumb_url;
5
6 XHR.open("GET", message.person_url);
7 XHR.setRequestHeader("Accept", "application/json");
8
9 XHR.onreadystatechange = function() {
10 if(XHR.readyState != XHR.DONE)
11 return;
12 if(XHR.status != 200)
13 return;
14
15 var obj = JSON.parse(XHR.responseText);
16
17 for(var i=0; i<obj.combined_credits.cast.length; i++) {
18 if (obj.combined_credits.cast[i].poster_path == null)
19 thumb_url = "null"
20 else
21 thumb_url = "http://d3gtl9l2a4fn1j.cloudfront.net/t/p/" + "w185/" + obj.combined_credits.cast[i].poster_path
22
23
24 if(obj.combined_credits.cast[i].media_type == "movie")
25 message.actedModel.append({"title": obj.combined_credits.cast[i].title,
26 "character": obj.combined_credits.cast[i].character,
27 "media_type": obj.combined_credits.cast[i].media_type,
28 "id": obj.combined_credits.cast[i].id,
29 "iconUrl": thumb_url});
30 else if(obj.combined_credits.cast[i].media_type == "tv")
31 message.actedModel.append({"title": obj.combined_credits.cast[i].name,
32 "character": obj.combined_credits.cast[i].media_type,
33 "media_type": obj.combined_credits.cast[i].media_type,
34 "id": obj.combined_credits.cast[i].id,
35 "iconUrl": thumb_url});
36 message.actedModel.sync()
37 }
38
39 for(i=0; i<obj.combined_credits.crew.length; i++) {
40 message.directedModel.append({"title": obj.combined_credits.crew[i].title,
41 "character": obj.combined_credits.crew[i].job,
42 "media_type": obj.combined_credits.cast[i].media_type,
43 "id": obj.combined_credits.crew[i].id,
44 "iconUrl": thumb_url});
45 message.directedModel.sync()
46 }
47
48 WorkerScript.sendMessage({ 'poster': obj.profile_path,
49 "name": obj.name,
50 "biography": obj.biography,
51 "birthday": obj.birthday,
52 "deathday": obj.deathday,
53 "place_of_birth": obj.place_of_birth,
54 "homepage": obj.homepage})
55 };
56
57 XHR.send();
58}
590
=== modified file 'backend/backend.js'
--- backend/backend.js 2013-11-15 22:11:55 +0000
+++ backend/backend.js 2013-11-17 16:42:59 +0000
@@ -16,6 +16,15 @@
16 return credentials.baseUrl + "/movie/upcoming" + "?api_key=" + credentials.apiKey;16 return credentials.baseUrl + "/movie/upcoming" + "?api_key=" + credentials.apiKey;
17}17}
1818
19function movieUrl(movie_id, options) {
20 options = options || {};
21 var base = credentials.baseUrl + "/movie/"+ movie_id + "?api_key=" + credentials.apiKey;
22 if ( options.appendToResponse )
23 return base + "&append_to_response=" + options.appendToResponse.join(',');
24 else
25 return base;
26}
27
19function filterByGenreUrl(genre_id) {28function filterByGenreUrl(genre_id) {
20 return credentials.baseUrl + "/genre/" + genre_id + "/movies" + "?api_key=" + credentials.apiKey;29 return credentials.baseUrl + "/genre/" + genre_id + "/movies" + "?api_key=" + credentials.apiKey;
21}30}
@@ -45,6 +54,15 @@
45 return credentials.baseUrl + "/person/popular" + "?api_key=" + credentials.apiKey;54 return credentials.baseUrl + "/person/popular" + "?api_key=" + credentials.apiKey;
46}55}
4756
57function personUrl(person_id, options) {
58 options = options || {};
59 var base = credentials.baseUrl + "/person/"+ person_id + "?api_key=" + credentials.apiKey;
60 if ( options.appendToResponse )
61 return base + "&append_to_response=" + options.appendToResponse.join(',');
62 else
63 return base;
64}
65
48// Search66// Search
49function searchUrl(type, term) {67function searchUrl(type, term) {
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);
5169
=== modified file 'models/BaseModel.qml'
--- models/BaseModel.qml 2013-11-15 17:02:44 +0000
+++ models/BaseModel.qml 2013-11-17 16:42:59 +0000
@@ -6,8 +6,10 @@
6 property string json: ""6 property string json: ""
7 property int status: XMLHttpRequest.UNSENT7 property int status: XMLHttpRequest.UNSENT
88
9 property ListModel model: ListModel { id: jsonModel }9 property ListModel model: ListModel { id: model }
10 property alias count: jsonModel.count10 property alias count: model.count
11
12 signal updated()
1113
12 onSourceChanged: {14 onSourceChanged: {
13 var xhr = new XMLHttpRequest;15 var xhr = new XMLHttpRequest;
@@ -19,12 +21,18 @@
19 }21 }
20 xhr.send();22 xhr.send();
21 }23 }
22 onJsonChanged: updateJSONModel()24
25 onJsonChanged: {
26 if ( json != "" ) {
27 updateJSONModel();
28 updated();
29 }
30 }
2331
24 function thumbnail_url(thumb_path) {32 function thumbnail_url(thumb_path) {
25 if (thumb_path)33 if (thumb_path)
26 return "http://d3gtl9l2a4fn1j.cloudfront.net/t/p/" + "w185/" + thumb_path;34 return "http://d3gtl9l2a4fn1j.cloudfront.net/t/p/" + "w185/" + thumb_path;
27 else35 else
28 return Qt.resolvedUrl("../graphics/toolbarIcon.png");36 return Qt.resolvedUrl("../graphics/toolbarIcon.png");
29 }37 }
30}38}
3139
=== modified file 'models/Cast.qml'
--- models/Cast.qml 2013-11-15 10:57:48 +0000
+++ models/Cast.qml 2013-11-17 16:42:59 +0000
@@ -6,9 +6,6 @@
6 function updateJSONModel() {6 function updateJSONModel() {
7 model.clear();7 model.clear();
88
9 if ( json === "" )
10 return;
11
12 var objectArray = JSON.parse(json).cast;9 var objectArray = JSON.parse(json).cast;
13 for ( var key in objectArray ) {10 for ( var key in objectArray ) {
14 var jo = objectArray[key];11 var jo = objectArray[key];
1512
=== modified file 'models/Crew.qml'
--- models/Crew.qml 2013-11-15 10:57:48 +0000
+++ models/Crew.qml 2013-11-17 16:42:59 +0000
@@ -5,9 +5,6 @@
5 function updateJSONModel() {5 function updateJSONModel() {
6 model.clear();6 model.clear();
77
8 if ( json === "" )
9 return;
10
11 var objectArray = JSON.parse(json).crew;8 var objectArray = JSON.parse(json).crew;
12 for ( var key in objectArray ) {9 for ( var key in objectArray ) {
13 var jo = objectArray[key];10 var jo = objectArray[key];
1411
=== modified file 'models/Genres.qml'
--- models/Genres.qml 2013-11-15 22:22:17 +0000
+++ models/Genres.qml 2013-11-17 16:42:59 +0000
@@ -5,9 +5,6 @@
5 function updateJSONModel() {5 function updateJSONModel() {
6 model.clear();6 model.clear();
77
8 if ( json === "" )
9 return;
10
11 var objectArray = JSON.parse(json).genres;8 var objectArray = JSON.parse(json).genres;
12 for ( var key in objectArray ) {9 for ( var key in objectArray ) {
13 var jo = objectArray[key];10 var jo = objectArray[key];
1411
=== added file 'models/Movie.qml'
--- models/Movie.qml 1970-01-01 00:00:00 +0000
+++ models/Movie.qml 2013-11-17 16:42:59 +0000
@@ -0,0 +1,37 @@
1import QtQuick 2.0
2
3BaseModel {
4 id: movie
5
6 property variant attributes: {
7 'title': '',
8 'homepage': '',
9 'tagline': '',
10 'overview': '',
11 'releaseDate': '',
12 'runtime': '',
13 'voteAverage': '',
14 'voteCount': '',
15 'genres': [],
16 'thumb_url': ''
17 }
18
19 function updateJSONModel() {
20 var ob = JSON.parse(json);
21 attributes = {
22 'id': ob.id,
23 'title': ob.title,
24 'homepage': ob.homepage,
25 'tagline': ob.tagline,
26 'overview': ob.overview,
27 'releaseDate': ob.release_date,
28 'runtime': ob.runtime,
29 'voteAverage': ob.vote_average,
30 'voteCount': ob.vote_count,
31 'genres': ob.genres,
32 'thumb_url': thumbnail_url(ob.poster_path),
33 'creditsJson': JSON.stringify(ob.credits || {}),
34 'similarMoviesJson': JSON.stringify(ob.similar_movies || {})
35 };
36 }
37}
038
=== modified file 'models/Movies.qml'
--- models/Movies.qml 2013-11-15 10:57:48 +0000
+++ models/Movies.qml 2013-11-17 16:42:59 +0000
@@ -5,8 +5,6 @@
5 5
6 function updateJSONModel() {6 function updateJSONModel() {
7 model.clear();7 model.clear();
8
9 if ( json === "" ) return;
10 8
11 var objectArray = JSON.parse(json).results;9 var objectArray = JSON.parse(json).results;
12 for ( var key in objectArray ) {10 for ( var key in objectArray ) {
1311
=== modified file 'models/People.qml'
--- models/People.qml 2013-11-15 10:57:48 +0000
+++ models/People.qml 2013-11-17 16:42:59 +0000
@@ -5,9 +5,6 @@
5 function updateJSONModel() {5 function updateJSONModel() {
6 model.clear();6 model.clear();
77
8 if ( json === "" )
9 return;
10
11 var objectArray = JSON.parse(json).results;8 var objectArray = JSON.parse(json).results;
12 for ( var key in objectArray ) {9 for ( var key in objectArray ) {
13 var jo = objectArray[key];10 var jo = objectArray[key];
1411
=== added file 'models/Person.qml'
--- models/Person.qml 1970-01-01 00:00:00 +0000
+++ models/Person.qml 2013-11-17 16:42:59 +0000
@@ -0,0 +1,30 @@
1import QtQuick 2.0
2
3BaseModel {
4 id: person
5
6 property variant attributes: {
7 'name': '',
8 'biography': '',
9 'birthday': '',
10 'deathday': '',
11 'homepage': '',
12 'placeOfBirth': '',
13 'thumb_url': ''
14 }
15
16 function updateJSONModel() {
17 var ob = JSON.parse(json);
18 attributes = {
19 'id': ob.id,
20 'name': ob.name,
21 'biography': ob.biography,
22 'birthday': ob.birthday,
23 'deathday': ob.deathday,
24 'homepage': ob.homepage,
25 'placeOfBirth': ob.place_of_birth,
26 'thumb_url': thumbnail_url(ob.profile_path),
27 'combinedCreditsJson': JSON.stringify(ob.combined_credits || {})
28 };
29 }
30}
031
=== added file 'models/PersonCast.qml'
--- models/PersonCast.qml 1970-01-01 00:00:00 +0000
+++ models/PersonCast.qml 2013-11-17 16:42:59 +0000
@@ -0,0 +1,22 @@
1import QtQuick 2.0
2
3BaseModel {
4 id: personCast
5
6 function updateJSONModel() {
7 model.clear();
8
9 var objectArray = JSON.parse(json).cast;
10 for ( var key in objectArray ) {
11 var jo = objectArray[key];
12 model.append({
13 'id': jo.id,
14 'title': jo.title,
15 'character': jo.character,
16 'releaseDate': jo.release_date,
17 'mediaType': jo.media_type,
18 'thumb_url': thumbnail_url(jo.poster_path)
19 });
20 }
21 }
22}
023
=== added file 'models/PersonCrew.qml'
--- models/PersonCrew.qml 1970-01-01 00:00:00 +0000
+++ models/PersonCrew.qml 2013-11-17 16:42:59 +0000
@@ -0,0 +1,21 @@
1import QtQuick 2.0
2
3BaseModel {
4 id: personCrew
5 function updateJSONModel() {
6 model.clear();
7
8 var objectArray = JSON.parse(json).crew;
9 for ( var key in objectArray ) {
10 var jo = objectArray[key];
11 model.append({
12 'id': jo.id,
13 'title': jo.title,
14 'department': jo.department,
15 'releaseDate': jo.release_date,
16 'mediaType': jo.media_type,
17 'thumb_url': thumbnail_url(jo.profile_path)
18 });
19 }
20 }
21}
022
=== modified file 'models/Shows.qml'
--- models/Shows.qml 2013-11-15 10:57:48 +0000
+++ models/Shows.qml 2013-11-17 16:42:59 +0000
@@ -6,9 +6,6 @@
6 function updateJSONModel() {6 function updateJSONModel() {
7 model.clear();7 model.clear();
88
9 if ( json === "" )
10 return;
11
12 var objectArray = JSON.parse(json).results;9 var objectArray = JSON.parse(json).results;
13 for ( var key in objectArray ) {10 for ( var key in objectArray ) {
14 var jo = objectArray[key];11 var jo = objectArray[key];
1512
=== modified file 'ui/MoviePage.qml'
--- ui/MoviePage.qml 2013-11-15 09:48:33 +0000
+++ ui/MoviePage.qml 2013-11-17 16:42:59 +0000
@@ -13,52 +13,30 @@
13 flickable: null13 flickable: null
1414
15 property string movie_id15 property string movie_id
16 property string movie_url: root.baseUrl + "/movie/" + movie_id + root.api_Key + "&append_to_response=credits"
17
18 Component.onCompleted: movieWorker.sendMessage({"movie_url": movie_url})
1916
20 Cast {17 Cast {
21 id: movieCast18 id: movieCast
22 source: Backend.movieCastUrl(movie_id)
23 }19 }
2420
25 Crew {21 Crew {
26 id: movieCrew22 id: movieCrew
27 source: Backend.movieCrewUrl(movie_id)
28 }23 }
2924
30 Movies {25 Movies {
31 id: similarMoviesModel26 id: similarMoviesModel
32 source: Backend.similarMoviesUrl(movie_id)27 }
33 }28
3429 Movie {
35 WorkerScript {30 id: movie
36 id: movieWorker31 source: Backend.movieUrl(movie_id, {appendToResponse: ['credits', 'similar_movies']})
37 source: "../backend/MovieDetails.js"32
38 onMessage: {33 onUpdated: {
39 if(messageObject.poster == null)34 movieCast.json = movie.attributes.creditsJson;
40 thumb.source = Qt.resolvedUrl("../graphics/toolbarIcon.png")35 movieCrew.json = movie.attributes.creditsJson;
41 else36 similarMoviesModel.json = movie.attributes.similarMoviesJson;
42 thumb.source = "http://d3gtl9l2a4fn1j.cloudfront.net/t/p/" + "w185/" + messageObject.poster37 }
4338 }
44 title.text = messageObject.title39
45 description.text = messageObject.description
46 releaseDate.subText = messageObject.releasedate
47 year.text = releaseDate.subText.split("-")[0]
48 runTime.text = messageObject.runtime + " minutes"
49
50 var genreModel = messageObject.genre
51 for (var i=0; i<genreModel.length; i++) {
52 if(genre.subText != "")
53 genre.subText = genre.subText + ", " + genreModel[i].name
54 else
55 genre.subText = genreModel[i].name
56 }
57
58 theme.subText = messageObject.theme
59 rating.text = messageObject.avg_vote + "/10\n" + messageObject.total_vote
60 }
61 }
6240
63 Overlay {41 Overlay {
64 id: summaryOverlay42 id: summaryOverlay
@@ -75,7 +53,7 @@
75 bottomMargin: units.gu(12)53 bottomMargin: units.gu(12)
76 }54 }
7755
78 text: description.text56 text: movie.attributes.overview
79 wrapMode: Text.WordWrap57 wrapMode: Text.WordWrap
80 }58 }
81 }59 }
@@ -153,11 +131,12 @@
153 id: thumb131 id: thumb
154 fillMode: Image.PreserveAspectFit132 fillMode: Image.PreserveAspectFit
155 smooth: true133 smooth: true
134 source: movie.attributes.thumb_url
156 }135 }
157136
158 ActivityIndicator {137 ActivityIndicator {
159 anchors.centerIn: parent138 anchors.centerIn: parent
160 running: thumb.status != Image.Ready ? true : false139 running: thumb.status != Image.Ready
161 }140 }
162 }141 }
163142
@@ -175,6 +154,7 @@
175 spacing: units.gu(2)154 spacing: units.gu(2)
176 Label {155 Label {
177 id: title156 id: title
157 text: movie.attributes.title
178 fontSize: "large"158 fontSize: "large"
179 width: movieColumn.width159 width: movieColumn.width
180 maximumLineCount: 2160 maximumLineCount: 2
@@ -183,7 +163,8 @@
183 }163 }
184164
185 Label {165 Label {
186 id: description166 id: overview
167 text: movie.attributes.overview
187 fontSize: "medium"168 fontSize: "medium"
188 width: movieColumn.width169 width: movieColumn.width
189 height: movieColumn.height/2170 height: movieColumn.height/2
@@ -196,8 +177,15 @@
196 }177 }
197178
198 Column {179 Column {
199 Label { id: year }180 Label {
200 Label { id: runTime }181 id: year
182 text: movie.attributes.releaseDate.split('-')[0]
183 }
184 Label {
185 id: runTime
186 text: movie.attributes.runtime + " minutes"
187 visible: movie.attributes.runtime != '0'
188 }
201 }189 }
202 }190 }
203191
@@ -220,7 +208,10 @@
220 smooth: true208 smooth: true
221 }209 }
222210
223 Label { id: rating }211 Label {
212 id: rating
213 text: movie.attributes.voteAverage+"\n"+movie.attributes.voteCount
214 }
224 }215 }
225216
226 // Movie Details - Release dates, genre, movie theme etc.217 // Movie Details - Release dates, genre, movie theme etc.
@@ -243,19 +234,22 @@
243 Header { text: "Details" }234 Header { text: "Details" }
244235
245 Subtitled {236 Subtitled {
246 id: genre237 id: genres
247 text: "Genre"238 text: "Genres"
239 subText: movie.attributes.genres.map(function(o) { return o.name }).join(', ')
248 }240 }
249241
250 Subtitled {242 Subtitled {
251 id: releaseDate243 id: releaseDate
252 text: "Release Date"244 text: "Release Date"
245 subText: movie.attributes.releaseDate
253 }246 }
254247
255 Subtitled {248 Subtitled {
256 id: theme249 id: theme
257 text: "Movie Theme"250 text: "Tagline"
258 visible: theme.subText == "" ? false : true251 subText: movie.attributes.tagline
252 visible: movie.attributes.tagline
259 }253 }
260254
261 Header { text: "Casts" }255 Header { text: "Casts" }
262256
=== modified file 'ui/PersonPage.qml'
--- ui/PersonPage.qml 2013-11-13 21:28:13 +0000
+++ ui/PersonPage.qml 2013-11-17 16:42:59 +0000
@@ -1,6 +1,8 @@
1import QtQuick 2.01import QtQuick 2.0
2import Ubuntu.Components 0.12import Ubuntu.Components 0.1
3import Ubuntu.Components.ListItems 0.13import Ubuntu.Components.ListItems 0.1
4import '../models'
5import '../backend/backend.js' as Backend
46
5Page {7Page {
6 id: personPage8 id: personPage
@@ -9,29 +11,24 @@
9 flickable: null11 flickable: null
1012
11 property string person_id13 property string person_id
12 property string person_url: root.baseUrl + "/person/" + person_id + root.api_Key + "&append_to_response=combined_credits"14
1315 PersonCast {
14 Component.onCompleted: personWorker.sendMessage({"person_url": person_url, "actedModel": actedModel, "directedModel": directedModel})16 id: personCast
1517 }
16 ListModel { id: actedModel }18
17 ListModel { id: directedModel }19 PersonCrew {
1820 id: personCrew
19 WorkerScript {21 }
20 id: personWorker22
21 source: "../backend/PersonDetails.js"23 Person {
22 onMessage: {24 id: person
23 if(messageObject.poster == null)25
24 thumb.source = Qt.resolvedUrl("../graphics/toolbarIcon.png")26 source: Backend.personUrl(person_id, {appendToResponse: ['combined_credits']})
25 else27
26 thumb.source = "http://d3gtl9l2a4fn1j.cloudfront.net/t/p/" + "w185/" + messageObject.poster28 onUpdated: {
2729 personCast.json = person.attributes.combinedCreditsJson;
28 name.text = messageObject.name30 personCrew.json = person.attributes.combinedCreditsJson;
29 biography.text = messageObject.biography == null ? "Biography not available" : messageObject.biography31 }
30 birthYear.text = messageObject.birthday == null ? "Not Available" : "Born: " + messageObject.birthday
31 deathYear.text = messageObject.deathday == null ? "Not Available" :"Dead: " + messageObject.deathday
32 birthPlace.text = messageObject.place_of_birth == null ? "Birth Place Not Available" : messageObject.place_of_birth
33 contact.text = messageObject.homepage
34 }
35 }32 }
3633
37 Flickable {34 Flickable {
@@ -56,11 +53,12 @@
56 id: thumb53 id: thumb
57 fillMode: Image.PreserveAspectFit54 fillMode: Image.PreserveAspectFit
58 smooth: true55 smooth: true
56 source: person.attributes.thumb_url
59 }57 }
6058
61 ActivityIndicator {59 ActivityIndicator {
62 anchors.centerIn: parent60 anchors.centerIn: parent
63 running: thumb.status != Image.Ready ? true : false61 running: thumb.status != Image.Ready
64 }62 }
65 }63 }
6664
@@ -79,6 +77,7 @@
7977
80 Label {78 Label {
81 id: name79 id: name
80 text: person.attributes.name
82 fontSize: "large"81 fontSize: "large"
83 width: personColumn.width82 width: personColumn.width
84 maximumLineCount: 283 maximumLineCount: 2
@@ -89,6 +88,7 @@
89 Column {88 Column {
90 Label {89 Label {
91 id: birthPlace90 id: birthPlace
91 text: person.attributes.placeOfBirth
92 fontSize: "medium"92 fontSize: "medium"
93 width: personColumn.width93 width: personColumn.width
94 elide: Text.ElideRight94 elide: Text.ElideRight
@@ -97,8 +97,9 @@
9797
98 Label {98 Label {
99 id: birthYear99 id: birthYear
100 text: "Birth: " + person.attributes.birthday.split('-')[0]
100 fontSize: "medium"101 fontSize: "medium"
101 visible: text == "Not Available" ? false: true102 visible: person.attributes.birthday
102 width: personColumn.width103 width: personColumn.width
103 elide: Text.ElideRight104 elide: Text.ElideRight
104 wrapMode: Text.WordWrap105 wrapMode: Text.WordWrap
@@ -106,8 +107,9 @@
106107
107 Label {108 Label {
108 id: deathYear109 id: deathYear
110 text: "Death: " + person.attributes.deathday.split('-')[0]
109 fontSize: "medium"111 fontSize: "medium"
110 visible: text == "Dead: " || text == "Not Available" ? false : true112 visible: person.attributes.deathday
111 width: personColumn.width113 width: personColumn.width
112 elide: Text.ElideRight114 elide: Text.ElideRight
113 wrapMode: Text.WordWrap115 wrapMode: Text.WordWrap
@@ -115,13 +117,14 @@
115117
116 Label {118 Label {
117 id: contact119 id: contact
120 text: person.attributes.homepage
118 fontSize: "medium"121 fontSize: "medium"
119 width: personColumn.width122 width: personColumn.width
120 elide: Text.ElideRight123 elide: Text.ElideRight
121 wrapMode: Text.WordWrap124 wrapMode: Text.WordWrap
122 MouseArea {125 MouseArea {
123 anchors.fill: parent126 anchors.fill: parent
124 enabled: contact.text == "null" ? false : true127 enabled: person.attributes.homepage
125 onClicked: Qt.openUrlExternally(contact.text)128 onClicked: Qt.openUrlExternally(contact.text)
126 }129 }
127 }130 }
@@ -130,6 +133,7 @@
130133
131 Label {134 Label {
132 id: biography135 id: biography
136 text: person.attributes.biography
133 anchors {137 anchors {
134 top: personColumn.bottom138 top: personColumn.bottom
135 left: parent.left139 left: parent.left
@@ -154,10 +158,13 @@
154158
155 Header {159 Header {
156 text: "Acting"160 text: "Acting"
157 visible: actedModel.count !== 0161 visible: personCast.count > 0
158 }162 }
159163
160 ListView {164 ListView {
165 id: personCastView
166 model: personCast.model
167
161 anchors {168 anchors {
162 left: parent.left169 left: parent.left
163 right: parent.right170 right: parent.right
@@ -165,22 +172,23 @@
165172
166 height: units.gu(20)173 height: units.gu(20)
167 clip: true174 clip: true
168
169 model: actedModel
170 delegate: Subtitled {175 delegate: Subtitled {
171 icon: iconUrl == "null" ? Qt.resolvedUrl("../graphics/toolbarIcon.png") : iconUrl176 icon: thumb_url
172 text: title177 text: title
173 subText: character178 subText: character
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")
175 }180 }
176 }181 }
177182
178 Header {183 Header {
179 text: "Production"184 text: "Production"
180 visible: directedModel.count !== 0185 visible: personCrew.count > 0
181 }186 }
182187
183 ListView {188 ListView {
189 id: personCrewView
190 model: personCrew.model
191
184 anchors {192 anchors {
185 left: parent.left193 left: parent.left
186 right: parent.right194 right: parent.right
@@ -188,13 +196,11 @@
188196
189 height: units.gu(20)197 height: units.gu(20)
190 clip: true198 clip: true
191
192 model: directedModel
193 delegate: Subtitled {199 delegate: Subtitled {
194 icon: iconUrl == "null" ? Qt.resolvedUrl("../graphics/toolbarIcon.png") : iconUrl200 icon: thumb_url
195 text: title201 text: title
196 subText: character202 subText: department
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")
198 }204 }
199 }205 }
200 }206 }

Subscribers

People subscribed via source and target branches