QuiaMainView.qml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. import Qt 4.7
  2. Rectangle {
  3. id: mainView
  4. width: 800
  5. height: 480
  6. color: "#979595"
  7. property string heiaRssFeed
  8. property string currentIcon
  9. property string currentTitle
  10. property string currentDescription
  11. state: "noImages"
  12. Rectangle {
  13. id: rectangleEntryList
  14. x: 0
  15. y: 0
  16. width: 284
  17. height: 424
  18. color: "#949595"
  19. }
  20. Rectangle {
  21. id: rectangleLogoutButton
  22. x: 0
  23. y: 422
  24. width: 284
  25. height: 58
  26. color: "#949595"
  27. z: 4
  28. Button { id: logoutButton; text: "Logout"
  29. width: parent.width -20
  30. height: parent.height -10
  31. anchors.fill: parent
  32. onClicked: { flipable.flipped = !flipable.flipped; }
  33. z: 6
  34. }
  35. }
  36. Rectangle {
  37. id: rectangleEntryDetailed
  38. x: 284
  39. y: 0
  40. width: 516
  41. height: 346
  42. color: "#949595"
  43. QuiaEntryDetailed {
  44. id: detailedView
  45. title: xmlModelHeia.get(entryList.currentIndex).heiaTitle
  46. description: xmlModelHeia.get(entryList.currentIndex).heiaDescription
  47. icon: mapSportIcon(title)
  48. }
  49. }
  50. Rectangle {
  51. id: rectangleFlickrMini
  52. x: 284
  53. y: 346
  54. width: 516
  55. height: 134
  56. color: "#949595"
  57. QuiaMiniFlickr {
  58. id: miniFlickrList
  59. width: parent.width
  60. height: parent.height
  61. //entryDescription: xmlModelHeia.get(entryList.currentIndex).heiaDescription
  62. }
  63. /*MouseArea {
  64. anchors.fill: parent
  65. onClicked: { mainView.state = "photoView"; }
  66. }*/
  67. }
  68. Rectangle {
  69. id: flickrBigView
  70. x: 800
  71. y: 480
  72. color: "darkgrey"
  73. /*QuiaFlickrBigView {
  74. id: mainFlickrView
  75. width: parent.width
  76. height: parent.height
  77. }*/
  78. }
  79. ListView {
  80. id: entryList
  81. width: 284
  82. height: 424
  83. z: 2
  84. anchors.left: rectangleEntryList.right
  85. anchors.leftMargin: -284
  86. anchors.top: rectangleEntryList.bottom
  87. anchors.topMargin: -424
  88. model: xmlModelHeia
  89. delegate: QuiaEntryDelegate {
  90. entryTitle: heiaTitle
  91. entryDate: heiaDate
  92. iconSource: mapSportIcon(heiaTitle)
  93. MouseArea {
  94. anchors.fill: parent
  95. onClicked: {
  96. entryList.currentIndex = index
  97. entryList.currentItem
  98. parseFlickr(xmlModelHeia.get(entryList.currentIndex).heiaDescription)
  99. }
  100. }
  101. }
  102. highlight: Rectangle {
  103. color: "#210bad"
  104. radius: 7
  105. gradient: Gradient {
  106. GradientStop {
  107. position: 0.00;
  108. color: "#ffd500";
  109. }
  110. GradientStop {
  111. position: 1.00;
  112. color: "#ffffff";
  113. }
  114. }
  115. opacity: 0.4
  116. z:2
  117. }
  118. highlightMoveSpeed: 300
  119. }
  120. //Here we parse the title and map it to the
  121. //correct sport icon
  122. //..or set a default one if no match
  123. function mapSportIcon(title) {
  124. var sportName=title.slice(0, title.indexOf(" "));
  125. if(sportName=="Ashtanga") {
  126. return "sports_icons/ashtanga.png";
  127. }
  128. else if(sportName=="Walking") {
  129. return "sports_icons/walking.png";
  130. }
  131. else if(sportName=="Skydiving") {
  132. return "sports_icons/skydiving.png";
  133. }
  134. else if(sportName=="Meditation") {
  135. return "sports_icons/ashtanga.png"
  136. }
  137. else {
  138. return "sports_icons/sport1.png";
  139. }
  140. }
  141. ScrollBar {
  142. scrollArea: entryList; height: entryList.height; width: 8
  143. anchors.right: entryList.right
  144. z:6
  145. }
  146. XmlListModel {
  147. id: xmlModelHeia
  148. //source: "http://www.heiaheia.com/users/33370921/feed.xml"
  149. source: "http://www.heiaheia.com/users/"+heiaRssFeed+"/feed.xml"
  150. query: "/rss/channel/item"
  151. XmlRole { name: "heiaTitle"; query: "title/string()" }
  152. XmlRole { name: "heiaDescription"; query: "description/string()" }
  153. XmlRole { name: "heiaAuthor"; query: "author/string()" }
  154. XmlRole { name: "heiaDate"; query: "pubDate/string()" }
  155. XmlRole { name: "heiaLink"; query: "link/string()" }
  156. onStatusChanged: {
  157. if(xmlModelHeia.status == XmlListModel.Ready) {
  158. parseFlickr(xmlModelHeia.get(entryList.currentIndex).heiaDescription);
  159. }
  160. }
  161. }
  162. function parseFlickr(description) {
  163. if(description.indexOf("flickr")!=-1)
  164. {
  165. //we got potential flickr url
  166. // now let's parse it
  167. var flickrUsername = description.slice(description.indexOf("/photos/")+8, description.indexOf("/sets/"));
  168. //assuming that Flickr set ID is always 17 characters long (so far it is so)
  169. var flickrSetId = description.slice(description.indexOf("/sets/")+6, description.indexOf("/sets/")+23);
  170. miniFlickrList.setId = flickrSetId;
  171. //mainFlickrView.setId = flickrSetId;
  172. //text1.text = flickrSetId;
  173. //mainView.flickrSetId = flickrSetId;
  174. flickrApiModel.source = "http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=c8ade722748871f7792dd7c8b765fda9&photoset_id=" + flickrSetId;
  175. flickrApiModel.query= "/rsp/photoset";
  176. flickrApiModel.reload();
  177. mainView.state = "";
  178. }
  179. else {
  180. mainView.state = "noImages"
  181. }
  182. }
  183. XmlListModel {
  184. id: flickrApiModel
  185. XmlRole { name: "owner"; query: "@owner/string()" }
  186. onStatusChanged: {
  187. if (flickrApiModel.status == XmlListModel.Ready) {
  188. //outputTextOwner.text = flickrApiModel.get(0).owner;
  189. //var ownerId=flickrApiModel.get(0).owner;
  190. //var setId=outputText.text;
  191. //flickrRssModel.reload();
  192. miniFlickrList.ownerId = flickrApiModel.get(0).owner;
  193. miniFlickrList.reloadFlickrModel();
  194. /*mainFlickrView.ownerId = flickrApiModel.get(0).owner;
  195. mainFlickrView.reloadFlickrModel();*/
  196. //QuiaMiniFlickr.setId =
  197. }
  198. else if( flickrApiModel.status == XmlListModel.Error){
  199. //outputTextOwner.text = flickrApiModel.errorString();
  200. }
  201. else if( flickrApiModel.status == XmlListModel.Loading){
  202. //outputTextOwner.text = "Loading";
  203. }
  204. }
  205. }
  206. states: [
  207. State {
  208. name: "noImages"
  209. PropertyChanges {
  210. target: rectangleFlickrMini
  211. y: 470
  212. }
  213. PropertyChanges {
  214. target: rectangleEntryDetailed
  215. height: 470
  216. }
  217. PropertyChanges {
  218. target: detailedView
  219. height: 470
  220. }
  221. },
  222. State {
  223. name: "photoView"
  224. PropertyChanges {
  225. target: rectangleLogoutButton
  226. x: -284
  227. y: 422
  228. }
  229. PropertyChanges {
  230. target: rectangleEntryDetailed
  231. x: -92
  232. y: -388
  233. }
  234. PropertyChanges {
  235. target: rectangleFlickrMini
  236. x: 0
  237. y: 0
  238. }
  239. PropertyChanges {
  240. target: entryList
  241. x: -306
  242. y: -282
  243. anchors.topMargin: -706
  244. anchors.leftMargin: -590
  245. }
  246. PropertyChanges {
  247. target: rectangleEntryList
  248. x: -298
  249. y: -282
  250. }
  251. PropertyChanges {
  252. target: flickrBigView
  253. x: 0
  254. y: 0
  255. }
  256. }
  257. ]
  258. transitions: [
  259. Transition {
  260. from: ""; to: "noImages"
  261. NumberAnimation {
  262. properties: "y, height"
  263. easing.type: Easing.OutBounce
  264. duration: 1000
  265. }
  266. reversible: true
  267. },
  268. Transition {
  269. from: ""; to: "photoView"
  270. NumberAnimation {
  271. properties: "x, y"
  272. easing.type: Easing.InOutQuad
  273. duration: 800
  274. }
  275. reversible: true
  276. }
  277. ]
  278. function changeStateToPhotoView() {
  279. mainView.state = "photoView"
  280. }
  281. function changeStateToBasicView() {
  282. mainView.state=""
  283. }
  284. }