~rpadovani/reminders-app/1382730

« back to all changes in this revision

Viewing changes to src/app/qml/components/TagsDelegate.qml

  • Committer: Tarmac
  • Author(s): Michael Zanetti
  • Date: 2014-10-11 16:31:17 UTC
  • mfrom: (266.2.6 reminders-app-tags)
  • Revision ID: tarmac-20141011163117-k34jgx6jk5zizxpw
Add support for tags. Fixes: https://bugs.launchpad.net/bugs/1379747.

Approved by Riccardo Padovani, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright: 2013 Canonical, Ltd
 
3
 *
 
4
 * This file is part of reminders
 
5
 *
 
6
 * reminders is free software: you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; version 3.
 
9
 *
 
10
 * reminders 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
 
 
19
import QtQuick 2.3
 
20
import QtQuick.Layouts 1.0
 
21
import Ubuntu.Components 1.1
 
22
import Ubuntu.Components.ListItems 1.0
 
23
import Evernote 0.1
 
24
 
 
25
Empty {
 
26
    id: root
 
27
    height: units.gu(10)
 
28
 
 
29
    Rectangle {
 
30
        anchors.fill: parent
 
31
        color: "#f9f9f9"
 
32
        anchors.bottomMargin: units.dp(1)
 
33
    }
 
34
 
 
35
    Base {
 
36
        anchors.fill: parent
 
37
        progression: true
 
38
 
 
39
        onClicked: root.clicked()
 
40
 
 
41
        RowLayout {
 
42
            anchors { fill: parent; topMargin: units.gu(1); bottomMargin: units.gu(1) }
 
43
 
 
44
            Item {
 
45
                anchors { top: parent.top; bottom: parent.bottom }
 
46
                width: units.gu(1)
 
47
                Rectangle {
 
48
                    anchors { top: parent.top; bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; margins: units.gu(1.5) }
 
49
                    width: units.gu(.5)
 
50
                    color: "black"
 
51
                    radius: width / 2
 
52
                }
 
53
            }
 
54
 
 
55
            ColumnLayout {
 
56
                height: parent.height
 
57
                Layout.fillWidth: true
 
58
 
 
59
                Label {
 
60
                    id: tagTitleLabel
 
61
                    objectName: 'tagTitleLabel'
 
62
                    text: model.name
 
63
                    fontSize: "large"
 
64
 
 
65
                    MouseArea {
 
66
                        onPressAndHold: {
 
67
                            tagTitleLabel.visible = false;
 
68
                            tagTitleTextField.forceActiveFocus();
 
69
                        }
 
70
                        anchors.fill: parent
 
71
                        propagateComposedEvents: true
 
72
                    }
 
73
                }
 
74
 
 
75
                TextField {
 
76
                    id: tagTitleTextField
 
77
                    text: model.name
 
78
                    visible: !tagTitleLabel.visible
 
79
 
 
80
                    InverseMouseArea {
 
81
                        onClicked: {
 
82
                            if (tagTitleTextField.text) {
 
83
                                tags.tag(index).name = tagTitleTextField.text;
 
84
                                NotesStore.saveTag(tags.tag(index).guid);
 
85
                                tagTitleLabel.visible = true;
 
86
                            }
 
87
                        }
 
88
                        anchors.fill: parent
 
89
                    }
 
90
                }
 
91
            }
 
92
 
 
93
            Label {
 
94
                objectName: 'tagNoteCountLabel'
 
95
                Layout.fillHeight: true
 
96
                verticalAlignment: Text.AlignVCenter
 
97
                text: "(" + model.noteCount + ")"
 
98
                color: "#b3b3b3"
 
99
            }
 
100
        }
 
101
    }
 
102
}