~pkunal-parmar/ubuntu-calendar-app/Minor-Performance

« back to all changes in this revision

Viewing changes to CalendarChoicePopup.qml

  • Committer: Kunal Parmar
  • Date: 2014-01-18 03:11:01 UTC
  • mto: This revision was merged to the branch mainline in revision 186.
  • Revision ID: pkunal.parmar@gmail.com-20140118031101-cif3k2wdidy9us8s
Print statement removed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2013-2014 Canonical Ltd
3
 
 *
4
 
 * This file is part of Ubuntu Calendar App
5
 
 *
6
 
 * Ubuntu Calendar App is free software: you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License version 3 as
8
 
 * published by the Free Software Foundation.
9
 
 *
10
 
 * Ubuntu Calendar App is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 
 */
18
 
import QtQuick 2.3
19
 
import Ubuntu.Components 1.1
20
 
import Ubuntu.Components.Popups 1.0
21
 
import Ubuntu.Components.ListItems 1.0 as ListItem
22
 
import QtOrganizer 5.0
23
 
 
24
 
Page {
25
 
    id: root
26
 
 
27
 
    property var model;
28
 
 
29
 
    signal collectionUpdated();
30
 
 
31
 
    visible: false
32
 
    title: i18n.tr("Calendars")
33
 
 
34
 
    head {
35
 
        backAction: Action {
36
 
            text: i18n.tr("Back")
37
 
            iconName: "back"
38
 
            onTriggered: {
39
 
                root.collectionUpdated();
40
 
                pop();
41
 
            }
42
 
        }
43
 
    }
44
 
 
45
 
    head.actions:  Action {
46
 
        iconName: "contact-group"
47
 
        objectName: "contactGroup"
48
 
        text: i18n.tr("Accounts")
49
 
        onTriggered: {
50
 
            Qt.openUrlExternally("settings:///online-accounts")
51
 
        }
52
 
    }
53
 
 
54
 
    ListView {
55
 
        id: calendarsList
56
 
 
57
 
        anchors.fill: parent
58
 
 
59
 
        model : root.model.getCollections();
60
 
        delegate: ListItem.Standard {
61
 
            id: delegateComp
62
 
 
63
 
            UbuntuShape {
64
 
                id: calendarColorCode
65
 
 
66
 
                width: parent.height
67
 
                height: width - units.gu(2)
68
 
 
69
 
                anchors {
70
 
                    left: parent.left
71
 
                    leftMargin: units.gu(2)
72
 
                    verticalCenter: parent.verticalCenter
73
 
                }
74
 
 
75
 
                color: modelData.color
76
 
                opacity: checkBox.checked ? 1.0 : 0.8
77
 
 
78
 
                MouseArea{
79
 
                    anchors.fill: parent
80
 
                    onClicked: {
81
 
                        //popup dialog
82
 
                        var dialog = PopupUtils.open(Qt.resolvedUrl("ColorPickerDialog.qml"),root);
83
 
                        dialog.accepted.connect(function(color) {
84
 
                            var collection = root.model.collection(modelData.collectionId);
85
 
                            collection.color = color;
86
 
                            root.model.saveCollection(collection);
87
 
                        })
88
 
                    }
89
 
                }
90
 
            }
91
 
 
92
 
            Label{
93
 
                text: modelData.name
94
 
                elide: Text.ElideRight
95
 
                opacity: checkBox.checked ? 1.0 : 0.8
96
 
                color: UbuntuColors.midAubergine
97
 
                width: parent.width - calendarColorCode.width - checkBox.width - units.gu(6) /*margins*/
98
 
                anchors {
99
 
                    left: calendarColorCode.right
100
 
                    margins: units.gu(2)
101
 
                    verticalCenter: parent.verticalCenter
102
 
                }
103
 
            }
104
 
 
105
 
            control: CheckBox {
106
 
                id: checkBox
107
 
                checked: modelData.extendedMetaData("collection-selected")
108
 
                enabled:  !root.isInEditMode
109
 
                onCheckedChanged: {
110
 
                    modelData.setExtendedMetaData("collection-selected",checkBox.checked)
111
 
                    var collection = root.model.collection(modelData.collectionId);
112
 
                    root.model.saveCollection(collection);
113
 
                }
114
 
            }
115
 
        }
116
 
    }
117
 
}
118