1. import bb.cascades 1.0
  2. import bb.data 1.0
  3. import bb.system 1.0
  4. TabbedPane {
  5. showTabsOnActionBar: true
  6. property variant menu;
  7. Menu.definition: menu
  8. property int size;
  9. property int rand;
  10. property string des;
  11. property string dat;
  12. property string cat;
  13. //*************************************************************************
  14. Tab{
  15. imageSource: "asset:///images/ic_overflow_tab.png"
  16. NavigationPane {
  17. id: nav
  18. Page {
  19. id: recipeListPage
  20. Container {
  21. id:cont
  22. layout: StackLayout {
  23. }
  24. /*
  25. ImageView {
  26. imageSource: "asset:///images/Book_background.amd"
  27. verticalAlignment: VerticalAlignment.Fill
  28. horizontalAlignment: HorizontalAlignment.Fill
  29. }*/
  30. Container {
  31. topPadding: 15
  32. bottomPadding: topPadding
  33. Container{
  34. layout: StackLayout{orientation:LayoutOrientation.LeftToRight}
  35. /*Container {
  36. layout: StackLayout{orientation:LayoutOrientation.LeftToRight}
  37. TextField {
  38. id: bsc
  39. hintText: qsTr("Busque su receta ")
  40. horizontalAlignment: HorizontalAlignment.Left
  41. input.submitKey: SubmitKey.Search*/
  42. /*horizontalAlignment: HorizontalAlignment.Center
  43. verticalAlignment: VerticalAlignment.Center
  44. preferredWidth: 530
  45. preferredHeight: 65
  46. hintText: ""
  47. input {
  48. submitKey: SubmitKey.Search
  49. onSubmitted: root.startSearch()
  50. }*/
  51. // }
  52. /*Button {
  53. text:qsTr("Buscar")
  54. onClicked: {
  55. listview.enabled=false
  56. listview.visible=false
  57. contBus.visible=true
  58. contBus.enabled=true
  59. volver.enabled=true
  60. contBus.text=bsc.text*/
  61. /*if(bsc.length==0){
  62. contBus.text="Debe Colocar algo en la barra de busqueda porfavor"
  63. }else{
  64. contBus.text=bsc.text
  65. }*/
  66. /*}
  67. }*/
  68. Container {
  69. layout:DockLayout{}
  70. /*ImageView {
  71. horizontalAlignment: HorizontalAlignment.Center
  72. verticalAlignment: VerticalAlignment.Center
  73. imageSource: "asset:///images/searcharea.png"
  74. }//Imagen de fondo del input text
  75. */
  76. TextField {
  77. id: zipCodeField
  78. horizontalAlignment: HorizontalAlignment.Center
  79. verticalAlignment: VerticalAlignment.Center
  80. preferredWidth: 530
  81. preferredHeight: 65
  82. hintText: qsTr("Busque su Receta")
  83. input {
  84. submitKey: SubmitKey.Search
  85. onSubmitted: root.startSearch()
  86. }
  87. }//Input text
  88. ImageButton {
  89. horizontalAlignment: HorizontalAlignment.Right
  90. verticalAlignment: VerticalAlignment.Center
  91. translationX: -20
  92. defaultImageSource: "asset:///images/find_button.png"
  93. pressedImageSource: "asset:///images/find_button.png"
  94. //onClicked: root.startSearch()
  95. onClicked: {
  96. listview.enabled=false
  97. listview.visible=false
  98. contBus.visible=true
  99. contBus.enabled=true
  100. volver.enabled=true
  101. //contBus.text=zipCodeField.text
  102. var selectedData = listview.dataModel.data([ zipCodeField.text ])
  103. if(selectedData){
  104. contBus.text=zipCodeField.text
  105. }
  106. }
  107. }//Boton busca
  108. }//Container
  109. Button {
  110. id:volver
  111. text:qsTr("Volver")
  112. /*defaultImageSource: "asset:///images/ic_previous.png"
  113. pressedImageSource: "asset:///images/ic_previous.png"*/
  114. enabled:false
  115. onClicked: {
  116. listview.enabled=true
  117. listview.visible=true
  118. contBus.visible=false
  119. contBus.enabled=false
  120. botV.visible=false
  121. botV.enabled=false
  122. enabled=false
  123. }
  124. }//Boton Volver
  125. Button{
  126. text:qsTr("Azar")
  127. /*defaultImageSource: "asset:///images/ic_view_grid.png"
  128. pressedImageSource: "asset:///images/ic_view_grid.png"*/
  129. onClicked: {
  130. listview.enabled=false
  131. listview.visible=false
  132. contBus.visible=true
  133. contBus.enabled=true
  134. botV.visible=true
  135. botV.enabled=true
  136. volver.enabled=true
  137. var randomnews = Math.floor((Math.random() * groupDataModel.size()) + 1)
  138. var selectedData = listview.dataModel.data([ randomnews ])
  139. contBus.text = selectedData.title
  140. des=selectedData.description
  141. dat=selectedData.pubDate
  142. cat=selectedData.category
  143. //------------------------------------------
  144. /*var pagina = pagina2.createObject();
  145. pagina.nombreIngresado = selectedData.title
  146. pagina.desIngresado = des
  147. pagina.dateIngresado = dat
  148. pagina.catIngresado = cat
  149. nav.push(pagina)*/
  150. //--------------------------------------------
  151. }
  152. }//Boton Random
  153. }//Container
  154. }//Container
  155. /*ListView {
  156. id: contBus
  157. visible: false
  158. enabled: false
  159. listItemComponents: [
  160. ListItemComponent {
  161. type: "item"
  162. Container {
  163. Label {
  164. id:contBus2
  165. }
  166. Divider {
  167. }
  168. }//Container
  169. }]
  170. onTriggered: {
  171. //cont.background = Color.Cyan
  172. var pagina = pagina2.createObject();
  173. var chosenItem = dataModel.data(indexPath)
  174. pagina.nombreIngresado = chosenItem.title
  175. pagina.desIngresado = chosenItem.description
  176. pagina.dateIngresado = chosenItem.pubDate
  177. //pagina.imgIngresado = chosenItem.image
  178. nav.push(pagina)
  179. }
  180. }//Label de busqueda
  181. */
  182. Label {
  183. id:contBus
  184. }
  185. Button {
  186. id:botV
  187. text:qsTr("Ir")
  188. enabled: false
  189. visible: false
  190. onClicked: {
  191. var pagina = pagina2.createObject();
  192. //var chosenItem = dataModel.data(indexPath)
  193. pagina.nombreIngresado = contBus.text
  194. pagina.desIngresado = des
  195. pagina.dateIngresado = dat
  196. pagina.catIngresado = cat
  197. //pagina.desIngresado = chosenItem.description
  198. //pagina.dateIngresado = chosenItem.pubDate
  199. //pagina.imgIngresado = chosenItem.image
  200. nav.push(pagina)
  201. }
  202. }
  203. ListView {
  204. id: listview
  205. dataModel: groupDataModel
  206. listItemComponents: [
  207. ListItemComponent {
  208. type: "item"
  209. /* Container {
  210. layout:DockLayout{}
  211. ImageView {
  212. imageSource: "asset:///images/a.jpg"
  213. }
  214. Label {
  215. text: qsTr(ListItemData.title)
  216. }
  217. Divider {
  218. }
  219. }//Container
  220. */
  221. StandardListItem {
  222. imageSource: "asset:///images/a.jpg"
  223. title: qsTr(ListItemData.title)
  224. description:qsTr("Categoria: "+ListItemData.category)
  225. }
  226. }]
  227. onTriggered: {
  228. //cont.background = Color.Cyan
  229. var pagina = pagina2.createObject();
  230. var chosenItem = dataModel.data(indexPath)
  231. pagina.nombreIngresado = chosenItem.title
  232. pagina.desIngresado = chosenItem.description
  233. pagina.dateIngresado = chosenItem.pubDate
  234. pagina.catIngresado = chosenItem.category
  235. //pagina.imgIngresado = chosenItem.image
  236. nav.push(pagina)
  237. }
  238. } // ListView
  239. }// Container
  240. } // Page
  241. attachedObjects: [
  242. GroupDataModel {
  243. id: groupDataModel
  244. grouping: ItemGrouping.None
  245. sortingKeys: [ "pubDate" ]
  246. sortedAscending: false
  247. },
  248. DataSource {
  249. id: dataSourceYahoo
  250. source: "http://www.universoderecetas.com.ar/feed/"
  251. //source: "http://www.mundosabores.com/feed/"
  252. //source: "http://recetasdeargentina.com.ar/feed/"
  253. //source:"http://www.recetascocina.com.ar/recetas-comidas/feed/"
  254. query: "rss/channel/item"
  255. onDataLoaded: {
  256. groupDataModel.insertList(data)
  257. }
  258. },
  259. ComponentDefinition {
  260. id: pagina2
  261. source: "pagina2.qml"
  262. },
  263. ComponentDefinition {
  264. id: cookbookMenu
  265. source: "CookbookMenu.qml"
  266. }
  267. ]
  268. onCreationCompleted: {
  269. dataSourceYahoo.load()
  270. // We want to only display in portrait-mode in this view.
  271. OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.DisplayPortrait;
  272. // Create the app menu for the cookbook.
  273. menu = cookbookMenu.createObject();
  274. }
  275. }//NavigationPane
  276. //*************************************************************************
  277. }//Tab
  278. //*************************************************************************
  279. Tab {
  280. title: "Home"
  281. imageSource: "asset:///images/ic_select_more.png"
  282. Page {
  283. id: page2
  284. /*actions: [
  285. ActionItem {
  286. title: "New"
  287. },
  288. ActionItem {
  289. title: "Delete"
  290. }
  291. ]*/
  292. }//Page