-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathMMProjectWizardPage.qml
More file actions
154 lines (116 loc) · 4.08 KB
/
Copy pathMMProjectWizardPage.qml
File metadata and controls
154 lines (116 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
import QtQuick
import QtQuick.Controls
import mm 1.0 as MM
import "./components" as MMProjectComponents
import "../components" as MMComponents
import "../inputs" as MMInputs
MMComponents.MMPage {
id: root
pageHeader.title: qsTr("Create Project")
pageBottomMargin: 0
pageContent: Item {
width: parent.width
height: parent.height
Column {
id: contentLayout
width: parent.width
height: parent.height
spacing: 0
MMComponents.MMListSpacer { height: __style.margin20 }
MMInputs.MMTextInput {
id: projectNameField
title: qsTr("Project name")
width: parent.width
}
MMComponents.MMListSpacer { height: __style.margin20 }
MMComponents.MMText {
id: attributesLabel
width: parent.width
text: qsTr("Fields")
color: __style.nightColor
font: __style.p6
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
MMComponents.MMListView {
id: fieldList
model: fieldsModel
width: parent.width
height: parent.height - __style.margin20 - projectNameField.height - __style.margin20 - attributesLabel.height
clip: true
spacing: __style.margin20
delegate: MMProjectComponents.MMProjectWizardDelegate {
id: fieldDelegate
width: ListView.view.width - ListView.view.scrollSpace
// find current index in the model
comboboxField.comboboxModel: typesmodel
comboboxField.valueRole: "type"
comboboxField.onCurrentIndexChanged: {
WidgetType = typesmodel.get(comboboxField.currentIndex)?.type ?? ""
}
onAttrNameChanged: ( attrname ) => AttributeName = attrname
onRemoveClicked: () => fieldsModel.removeField( index )
Component.onCompleted: {
// assign initial values without binding
attrname = AttributeName
comboboxField.currentIndex = comboboxField.indexFromValue( WidgetType )
}
}
footer: MMComponents.MMButton {
id: addButton
width: ListView.view.width
height: implicitHeight + topPadding
text: qsTr( "Add field" )
type: MMComponents.MMButton.Tertiary
iconSourceRight: __style.addIcon
topPadding: __style.margin20
onClicked: {
fieldsModel.addField("", "TextEdit")
if ( fieldList.visible ) {
fieldList.positionViewAtEnd()
}
}
}
}
}
}
footer: MMComponents.MMToolbar {
id: toolbar
model: ObjectModel {
MMComponents.MMToolbarButton {
text: qsTr("Create project");
iconSource: __style.doneCircleIcon
iconColor: toolbar.color
onClicked: {
if (!projectNameField.text) {
__notificationModel.addWarning( qsTr("Empty project name") )
} else {
__projectWizard.createProject(projectNameField.text, fieldsModel )
}
}
}
}
}
MM.FieldsModel {
id: fieldsModel
onNotifyError: function( message ) {
__notificationModel.addError( message )
}
}
ListModel {
id: typesmodel
ListElement { text: "Text"; type: "TextEdit" }
ListElement { text: "Date&time"; type: "DateTime" }
ListElement { text: "Number"; type: "Range" }
ListElement { text: "Checkbox"; type: "CheckBox" }
ListElement { text: "Photo"; type: "ExternalResource" }
}
}