AddKarmaForm.qml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
  2. import QtQuick 1.1
  3. import "../js/core.js" as Core
  4. import "../parts/"
  5. KPage {
  6. id: root
  7. property alias title: karmaTitle.text;
  8. property alias description: karmaDesc.text;
  9. property int points: 0 //: pointsSelection.text;
  10. property int karmaId: 0// listpanel.karmaId
  11. property variant indexmap: { "10": 0, '5': 1, '3': 2, '2': 3, '1': 4, '0': 5, '-1': 6, '-2': 7, '-3': 8, '-5': 9, '-10': 10 }
  12. Rectangle{
  13. anchors.fill: parent
  14. color: "#e1ecef"
  15. }
  16. anchors.fill:parent
  17. Flickable{
  18. id: flick
  19. width: parent.width; height: parent.height-titlebar.height
  20. contentWidth: parent.width;
  21. contentHeight: 700
  22. anchors.top: titlebar.bottom
  23. anchors.bottom: toolbar.top
  24. Column {
  25. id: grid1
  26. spacing: 20
  27. anchors{
  28. top:parent.top
  29. left: parent.left
  30. right: parent.right
  31. margins: 10
  32. }
  33. KLabel{id:intro; text:qsTr("You are goint to add a karma fact for:"); }
  34. Row{
  35. Image {
  36. id: selectImage
  37. width: 128
  38. height: 128
  39. source: "qrc:/violet/face"
  40. MouseArea{
  41. anchors.fill: parent;
  42. onClicked: pageStack.push(Qt.resolvedUrl("ImageSelectionDialog.qml"))
  43. }
  44. }
  45. KLabel{
  46. id:name;
  47. text:qsTr("Person name");
  48. anchors.verticalCenter: parent.verticalCenter
  49. }
  50. }
  51. KLabel{id:title; text:qsTr("Title"); }
  52. KTextInput{
  53. id:karmaTitle;
  54. width: parent.width
  55. focus: true
  56. }
  57. KLabel{text:qsTr("Points");}
  58. KButton {
  59. id: pointsSelection
  60. text: selectionDialog.model.get(indexmap[points]).modelData
  61. width:parent.width
  62. onClicked: {
  63. selectionDialog.visible=true
  64. }
  65. }
  66. /* TextEdit{
  67. id: pointsSelection s
  68. text: selectionDialog.model.get(indexmap[points]).modelData
  69. readOnly: true
  70. MouseArea{
  71. anchors.fill: parent;
  72. onClicked: selectionDialog.visible=true;
  73. }
  74. KarmaSelectionDialog {
  75. id: selectionDialog
  76. onAccepted :{
  77. pointsSelection.text = model.get(selectedIndex).modelData;
  78. points = model.get(selectedIndex).value;
  79. pointsSelection.cursorPosition= 0
  80. }
  81. }
  82. MouseArea{
  83. anchors.fill: parent;
  84. onClicked: selectionDialog.visible=true;
  85. }
  86. }*/
  87. KLabel{id:desc; text:qsTr("Description"); }
  88. KTextArea{
  89. id:karmaDesc;
  90. width: parent.width
  91. }
  92. }
  93. }
  94. //Page layout is divided in 3
  95. TitleBar{
  96. id: titlebar
  97. }
  98. KToolBar{
  99. id: toolbar
  100. KButton{
  101. text:qsTr("Cancel")
  102. onClicked: pageStack.pop();
  103. }
  104. KButton{
  105. text:qsTr("Ok")
  106. onClicked: {
  107. if (karmaId==0){
  108. var item = Core.defaultItem();
  109. item.points = points;
  110. item.title = root.title;
  111. item.description = description;
  112. Core.createKarma(item);
  113. //updateUi();
  114. }
  115. else{
  116. update();
  117. updateUi();
  118. }
  119. pageStack.pop();
  120. }
  121. }
  122. }
  123. KarmaSelectionDialog{
  124. id: selectionDialog
  125. onAccepted: points=selectionDialog.currentValue
  126. }
  127. }