123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
- import QtQuick 1.1
- import "../js/core.js" as Core
- import "../delegates"
- import "../parts"
- KPage {
- property int karmaId
- property string personName
- property string currentTitle
- property string currentPoints
- property int filter: 0
- id: listpanel
- ListModel {
- id: itemModel
- }
- KButton{
- id: filterSelector
- anchors.top:titlebar.bottom
- width: parent.width
- text: selectionDialog.model.get(filter).modelData
- onClicked: {
- selectionDialog.visible=true
- }
- }
- Flickable{
- id: flicklist
- width: parent.width; height: parent.height-titlebar.height - filterSelector.height
- contentWidth: parent.width;
- //contentHeight: height+100
- anchors.top: filterSelector.bottom
- anchors.right: parent.right
- ListView {
- id: view
- model: itemModel
- anchors.fill: parent
- clip:true
- delegate: KarmaItemDelegate {
- title: model.title
- points: model.points
- onPressAndHold: {
- karmaId=model.id
- currentTitle=model.title
- currentPoints=model.points
- contexMenu.open();
- }
- onClicked:pageStack.push(Qt.resolvedUrl("KarmaFact.qml"), {karmaId: model.id, karmaName: personName, karmaTitle: model.title, karmaPoints: model.points, karmaDescription: model.description})
- }
- }
- }
- //Page layout is divided in 3
- TitleBar{
- id:titlebar
- KButton{
- id:titleButton
- text:"+"
- anchors.right:parent.right
- anchors.top:parent.top
- anchors.rightMargin: 10
- anchors.topMargin: 5
- onClicked: pageStack.push(Qt.resolvedUrl("AddKarmaForm.qml"))
- }
- }
- KToolBar {
- id: listTools
- KButton{
- text:qsTr("Back")
- onClicked: pageStack.pop()
- }
- }
- KContextMenu {
- id: contexMenu
- KMenuItem {
- text: "Delete item"
- onClicked:{ deleteItem(karmaId)}
- }
- KMenuItem {
- text: "Edit item"
- onClicked:{karmaCreateDialog.open() }
- }
- }
- KarmaFactFilterDialog{
- id: selectionDialog
- onAccepted: filter=selectionDialog.currentValue
- }
- onVisibleChanged: {
- if(visible == true) {
- updateUi();
- }
- }
- function updateUi() {
- view.model = 0;
- Core.readKarmaList(itemModel);
- view.model = itemModel;
- }
- function deleteItem(id){
- Core.deleteKarma(id);
- updateUi();
- }
- function update()
- {
- // read the TodoItem with the provided karmaId
- var item = Core.readKarmaItem(karmaId);
- // get values from UI fields
- item.title = karmaCreateDialog.title;
- item.points = karmaCreateDialog.points;
- item.description = karmaCreateDialog.description;
- // new Data() will return the current date
- item.modified = new Date();
- // update the todoItem in Database
- Core.updateKarma(item);
- }
- }
|