Introduced styles - first version of Widgets
[opentodolist:opentodolist.git] / OpenTodoList / qml / OpenTodoList / styles / widget / views / TodoListsView.qml
1 /*
2  *  OpenTodoList - A todo and task manager
3  *  Copyright (C) 2013  Martin Höher <martin@rpdev.net>
4  *
5  *  This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program 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.0
20 import QtQuick.Controls 1.0
21 import QtQuick.Layouts 1.0
22 import QtQuick.Window 2.0
23
24 GroupBox {
25     id: view
26
27     title: qsTr( "Todo Lists" )
28
29     property QtObject todoList: null
30
31     ExclusiveGroup {
32         id: todoListsGroup
33     }
34
35     ScrollView {
36         anchors.fill: parent
37
38         Column {
39             width: parent.parent.width
40
41             Repeater {
42                 model: library.todoLists
43                 delegate: Item {
44                     width: parent.width
45                     height: childrenRect.height
46                     RowLayout {
47                         width: parent.width
48
49                         RadioButton {
50                             id: radioButton
51                             exclusiveGroup: todoListsGroup
52                             text: object.name
53                             Layout.fillWidth: true
54
55                             onCheckedChanged: {
56                                 if ( checked ) {
57                                     view.todoList = object;
58                                 }
59                             }
60                         }
61                         Item {
62                             width: childrenRect.width
63                             height: childrenRect.height
64                             visible: radioButton.checked
65                             Text {
66                                 id: editLabel
67                                 text: "Edit"
68                             }
69                             MouseArea {
70                                 anchors.fill: editLabel
71                                 onClicked: {
72                                     var component = Qt.createComponent( "../dialogs/TodoListEditDialog.qml" );
73                                     var editDialog = component.createObject( window );
74                                     editDialog.edit( object );
75                                 }
76                             }
77                         }
78                     }
79                 }
80             }
81         }
82     }
83 }