People.qml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 "../delegates"
  5. import "../parts"
  6. KPage {
  7. property int karmaId
  8. property string currentTitle
  9. property string currentPoints
  10. focus:true
  11. id: listpanel
  12. ListModel {
  13. id: itemModel
  14. }
  15. Rectangle{
  16. id: searchBox
  17. width:parent.width
  18. height: 60
  19. color: "transparent"
  20. anchors.top: titlebar.bottom
  21. Rectangle{
  22. width: parent.width*0.9
  23. height: parent.height*0.8
  24. anchors.centerIn: parent
  25. radius: height/2
  26. color: "transparent"
  27. border.color:"#8f00FF"
  28. TextInput{
  29. id:searchText
  30. width:parent.width - 2*parent.radius
  31. anchors.centerIn: parent
  32. Keys.onReturnPressed: closeSoftwareInputPanel()
  33. Keys.onPressed: console.log("pressed")
  34. onTextChanged: {closeSoftwareInputPanel();listpanel.filter(searchText.text)}
  35. //onCursorPositionChanged: {console.log("key"); accepted()}
  36. }
  37. }
  38. }
  39. Flickable{
  40. id: flicklist
  41. width: parent.width; height: parent.height-titlebar.height
  42. contentWidth: parent.width;
  43. //contentHeight: height+100
  44. anchors.top: searchBox.bottom
  45. anchors.right: parent.right
  46. ListView {
  47. id: view
  48. model: itemModel
  49. anchors.fill: parent
  50. clip:true
  51. delegate: KarmaPeopleDelegate {
  52. image: model.image
  53. name: model.name
  54. points: Core.getGoodKarma()-Core.getBadKarma();
  55. onClicked: {
  56. karmaId=model.id
  57. currentTitle=model.name
  58. currentPoints=Core.getGoodKarma()-Core.getBadKarma();
  59. contexMenu.visible=true;
  60. }
  61. }
  62. }
  63. }
  64. //Page layout is divided in 3
  65. TitleBar{
  66. id:titlebar
  67. KButton{
  68. id:titleButton
  69. text:"+"
  70. anchors.right:parent.right
  71. anchors.top:parent.top
  72. anchors.rightMargin: 10
  73. anchors.topMargin: 5
  74. }
  75. }
  76. // TodoCreateDialog to add new todo to the current box
  77. /*AddKarmaForm {
  78. id: karmaCreateDialog
  79. }*/
  80. KarmaToolBar {
  81. }
  82. KContextMenu {
  83. id: contexMenu
  84. KMenuItem {
  85. text: qsTr("View profile")
  86. onClicked: pageStack.push(Qt.resolvedUrl("PersonPage.qml"))
  87. }
  88. KMenuItem {
  89. text: qsTr("Delete item")
  90. onClicked:{ deleteItem(karmaId)}
  91. }
  92. KMenuItem {
  93. text: qsTr("Edit item")
  94. onClicked:{karmaCreateDialog.open() }
  95. }
  96. }
  97. AboutPage {
  98. id: about
  99. visible:false
  100. }
  101. KarmaMenu {
  102. id: karmaMenu
  103. }
  104. Keys.onMenuPressed: {
  105. karmaMenu.visible=true
  106. }
  107. onVisibleChanged: {
  108. if(visible == true) {
  109. updateUi();
  110. }
  111. }
  112. function updateUi() {
  113. view.model = 0;
  114. Core.readPeopleList(itemModel);
  115. view.model = itemModel;
  116. }
  117. /*function deleteItem(id){
  118. Core.deleteKarma(id);
  119. updateUi();
  120. }*/
  121. /*function update()
  122. {
  123. // read the TodoItem with the provided karmaId
  124. var item = Core.readKarmaItem(karmaId);
  125. // get values from UI fields
  126. item.title = karmaCreateDialog.title;
  127. item.points = karmaCreateDialog.points;
  128. // new Data() will return the current date
  129. item.modified = new Date();
  130. // update the todoItem in Database
  131. Core.updateKarma(item);
  132. }*/
  133. }