main.qml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import QtQuick 1.0
  2. import "content"
  3. Column{
  4. id: screen
  5. width: 360
  6. height: 360
  7. //spacing: 30
  8. property int frameMargin: 10
  9. property int rowHeight: 60
  10. property int margin: 20
  11. property string brgndColour: "#469e63"
  12. Rectangle {
  13. id: cataloguePane
  14. width: parent.width
  15. height: parent.height - optionbar.height - screen.spacing
  16. color: screen.brgndColour
  17. BusyIndicator {
  18. anchors.verticalCenter: parent.verticalCenter
  19. anchors.horizontalCenter: parent.horizontalCenter
  20. on: listView.model.isApplicationBusy
  21. }
  22. ListView {
  23. id: listView
  24. anchors.fill: parent
  25. anchors.margins: screen.margin
  26. spacing: screen.margin
  27. Component {
  28. id: drmListDelegate
  29. Item {
  30. id: productRow
  31. width: listView.width; height: screen.rowHeight
  32. clip: true
  33. Row {
  34. spacing: screen.frameMargin
  35. Image {
  36. //NOTE image provider caches data, the side effect is updated image is not shown
  37. source: (isActivated === true) ? "image://imagestatusprovider/"+index : //persistent , allow caching
  38. //else disable caching
  39. // workaround for http://bugreports.qt.nokia.com/browse/QTBUG-14900
  40. "image://imagestatusprovider/"+index+
  41. "ignoringpart" + Qt.formatTime(new Date(), "hhmmsszzz")
  42. width: screen.rowHeight
  43. height: screen.rowHeight
  44. MouseArea {
  45. anchors.fill:parent
  46. onClicked: {
  47. console.log("onClicked")
  48. if(isDataKnown === true && isActivated === false){
  49. drmListModel.buy(index)
  50. }
  51. }
  52. }
  53. }
  54. BusyIndicator {
  55. anchors.verticalCenter: parent.verticalCenter
  56. width: screen.rowHeight / 2
  57. height: screen.rowHeight / 2
  58. on: isBusy
  59. }
  60. Text {
  61. anchors.verticalCenter: parent.verticalCenter
  62. text: (isDataKnown === true) ?
  63. (productid + "; " +reqresult + "; " +
  64. tile + "; " +
  65. shortDescr + "; " +
  66. longDescr + "; " +
  67. price)
  68. : productid + "; <UNKNOWN>"
  69. }
  70. }
  71. }
  72. }
  73. model: drmListModel
  74. delegate: drmListDelegate
  75. }
  76. }
  77. Rectangle{
  78. id: optionbar
  79. width: parent.width
  80. height:
  81. ((restoreBtn.width + purgeBtn.width +
  82. userInfoBtn.width + exitBtn.width +
  83. screen.margin * 6) <= width) ? restoreBtn.height + screen.margin :
  84. (restoreBtn.height + screen.margin) * 2
  85. gradient: Gradient {
  86. GradientStop {
  87. position: 0.00;
  88. color: screen.brgndColour;
  89. }
  90. GradientStop {
  91. position: 1.00;
  92. color: "black";
  93. }
  94. }
  95. Flow{
  96. spacing: screen.margin
  97. width: parent.width
  98. Button {
  99. id: restoreBtn
  100. text: "Restore"
  101. onClicked: listView.model.restoreProducts()
  102. }
  103. Button {
  104. id: purgeBtn
  105. text: "Purge"
  106. onClicked: listView.model.purgeProducts()
  107. }
  108. Button {
  109. id: userInfoBtn
  110. text: "User info"
  111. onClicked: listView.model.getUserInfo()
  112. }
  113. Button {
  114. id: exitBtn
  115. text: "Exit"
  116. onClicked: Qt.quit()
  117. }
  118. }
  119. }
  120. }