/
FeatureForm.qml
918 lines (776 loc) · 26.9 KB
/
FeatureForm.qml
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Controls.Material 2.14
import QtQuick.Layouts 1.14
import QtQml.Models 2.14
import QtQml 2.14
import QtCharts 2.14 // Not actually used here but added so the android deploy script adds the relevant package
import QtWebView 1.14
import org.qgis 1.0
import org.qfield 1.0
import Theme 1.0
import QFieldControls 1.0
Page {
id: form
signal confirmed
signal cancelled
signal temporaryStored
signal valueChanged(var field, var oldValue, var newValue)
signal aboutToSave
signal requestGeometry(var item, var layer)
signal requestBarcode(var item)
property DigitizingToolbar digitizingToolbar
property CodeReader codeReader
property AttributeFormModel model
property alias currentTab: swipeView.currentIndex
property alias toolbarVisible: toolbar.visible
//! if embedded form called by RelationEditor or RelationReferenceWidget
property bool embedded: false
property int embeddedLevel: 0
//setupOnly means data would be neither saved nor cleared (feature creation is handled elsewhere like e.g. in the tracking)
property bool setupOnly: false
property bool featureCreated: false
property double topMargin: 0.0
property double bottomMargin: 0.0
function requestCancel() {
if (!qfieldSettings.autoSave) {
cancelDialog.open();
} else {
cancel()
}
}
clip: true
states: [
State {
name: 'ReadOnly'
},
State {
name: 'Edit'
},
State {
name: 'Add'
}
]
/**
* This is a relay to forward private signals to internal components.
*/
QtObject {
id: master
/**
* When set to true, changed value signals are ignored to avoid double feature creation / save when in fast editing mode
*/
property bool ignoreChanges: false
}
ColumnLayout {
id: container
anchors.fill: parent
Flickable {
id: flickable
Layout.fillWidth: true
Layout.preferredHeight: tabRow.height
flickableDirection: Flickable.HorizontalFlick
contentWidth: tabRow.width
// Tabs
TabBar {
id: tabRow
visible: model.hasTabs
height: form.model.hasTabs ? 48 : 0
Connections {
target: swipeView
function onCurrentIndexChanged(currentIndex) {
tabRow.currentIndex = swipeView.currentIndex
}
}
Repeater {
model: form.model.hasTabs ? form.model : 0
TabButton {
id: tabButton
property bool isCurrentIndex: index == tabRow.currentIndex
text: Name
topPadding: 0
bottomPadding: 0
leftPadding: !ConstraintHardValid || !ConstraintSoftValid ? 22 : 8
rightPadding: 8
width: contentItem.width + leftPadding + rightPadding
height: 48
background: Rectangle {
implicitWidth: parent.width
implicitHeight: parent.height
color: "transparent"
Rectangle {
anchors.left: parent.left
anchors.leftMargin: 8
anchors.verticalCenter: parent.verticalCenter
width: 10
height: 10
radius: 5
color: !ConstraintHardValid ? Theme.errorColor : Theme.warningColor
visible: !ConstraintHardValid || !ConstraintSoftValid
}
}
contentItem: Text {
// Make sure the width is derived from the text so we can get wider
// than the parent item and the Flickable is useful
width: paintedWidth
height: parent.height
text: tabButton.text
color: !tabButton.enabled ? Theme.darkGray : tabButton.down ? Qt.darker(Theme.mainColor,1.5) : Theme.mainColor
font.pointSize: Theme.tipFont.pointSize
font.weight: isCurrentIndex ? Font.DemiBold : Font.Normal
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
}
}
}
/**
* The main form content area
*/
SwipeView {
id: swipeView
Layout.fillWidth: true
Layout.fillHeight: true
currentIndex: tabRow.currentIndex
Repeater {
// One page per tab in tabbed forms, 1 page in auto forms
model: form.model.hasTabs ? form.model : 1
Flickable {
id: contentView
property int contentIndex: index
width: form.width
contentWidth: content.width
contentHeight: content.height
bottomMargin: form.bottomMargin
clip: true
ScrollBar.vertical: ScrollBar {
policy: content.height > contentView.height ? ScrollBar.AsNeeded : ScrollBar.AlwaysOff
width: 6
contentItem: Rectangle {
implicitWidth: 6
implicitHeight: 25
color: Theme.mainColor
}
}
Rectangle {
anchors.fill: parent
color: Theme.mainBackgroundColor
}
Flow {
id: content
width: form.width
SubModel {
id: contentModel
model: form.model
rootIndex: form.model.index(form.model.hasTabs ? contentIndex : -1, 0)
}
Repeater {
// Note: digitizing a child geometry will temporarily hide the feature form,
// we need to preserve items so signal connections are kept alive
model: form.model.hasTabs
? contentModel
: form.model
delegate: fieldItem
}
}
}
}
}
}
Component {
id: textContainer
Item {
height: childrenRect.height
anchors {
left: parent.left
right: parent.right
leftMargin: 12
}
Label {
id: textLabel
width: parent.width
text: containerName
wrapMode: Text.WordWrap
font.pointSize: Theme.tinyFont.pointSize
font.bold: true
topPadding: 10
bottomPadding: 5
opacity: form.state === 'ReadOnly' || embedded && EditorWidget === 'RelationEditor'
? 0.45
: 1
color: labelOverrideColor !== undefined && labelOverrideColor ? labelColor : Theme.mainTextColor
}
Text {
id: textContent
width: parent.width
text: containerCode
wrapMode: Text.WordWrap
font: Theme.defaultFont
anchors {
left: parent.left
right: parent.right
top: textLabel.bottom
}
opacity: textLabel.opacity
color: Theme.mainTextColor
linkColor: Theme.mainColor
onLinkActivated: Qt.openUrlExternally(link)
}
}
}
Component {
id: qmlContainer
Item {
height: childrenRect.height
anchors {
left: parent.left
right: parent.right
leftMargin: 12
}
Label {
id: qmlLabel
width: parent.width
text: containerName
wrapMode: Text.WordWrap
font.pointSize: Theme.tinyFont.pointSize
font.bold: true
topPadding: 10
bottomPadding: 5
opacity: form.state === 'ReadOnly' || embedded && EditorWidget === 'RelationEditor'
? 0.45
: 1
color: labelOverrideColor !== undefined && labelOverrideColor ? labelColor : Theme.mainTextColor
}
Item {
id: qmlItem
property string code: containerCode
onCodeChanged: {
var obj = Qt.createQmlObject(code,qmlItem,'qmlContent');
}
height: childrenRect.height
anchors {
left: parent.left
rightMargin: 12
right: parent.right
top: qmlLabel.bottom
}
}
}
}
Component {
id: htmlContainer
Item {
property string htmlCode: containerCode
property var htmlItem: undefined
height: childrenRect.height
anchors {
left: parent.left
right: parent.right
leftMargin: 12
}
Label {
id: htmlLabel
width: parent.width
text: containerName
wrapMode: Text.WordWrap
font.pointSize: Theme.tinyFont.pointSize
font.bold: true
topPadding: 10
bottomPadding: 5
opacity: form.state === 'ReadOnly' || embedded && EditorWidget === 'RelationEditor'
? 0.45
: 1
color: labelOverrideColor !== undefined && labelOverrideColor ? labelColor : Theme.mainTextColor
}
Item {
id: htmlContent
height: childrenRect.height
anchors {
left: parent.left
right: parent.right
top: htmlLabel.bottom
}
}
Component.onCompleted: {
if (visible) {
if (htmlItem === undefined) {
// avoid cost of WevView creation until needed
htmlItem = Qt.createQmlObject('import QtWebView 1.14;
WebView {
id: htmlItem;
height: 0;
opacity: 0;
anchors { top: parent.top; left: parent.left; right: parent.right; }
onLoadingChanged: { if (!loading) { runJavaScript("document.body.offsetHeight", function(result) { anchors.left = parent.left; width = parent.width; height = (result + 18); opacity = 1.0; } ) } }
}'
, htmlContent);
}
htmlItem.loadHtml(htmlCode)
}
}
onHtmlCodeChanged: {
if (visible && htmlItem) {
htmlItem.loadHtml(htmlCode);
}
}
}
}
Component {
id: innerContainer
Item {
height: childrenRect.height
anchors {
left: parent.left
right: parent.right
}
Flow {
id: innerContainerContent
anchors {
left: parent.left
right: parent.right
}
Repeater {
model: SubModel {
id: innerSubModel
model: form.model
rootIndex: form.model.mapFromSource(containerGroupIndex)
}
delegate: fieldItem
}
Connections {
target: form.model
function onModelReset() {
if (containerGroupIndex !== undefined && innerContainer.visible) {
innerSubModel.rootIndex = form.model.mapFromSource(containerGroupIndex)
}
}
}
}
}
}
Component {
id: dummyContainer
Item {}
}
/**
* A field editor
*/
Component {
id: fieldItem
Item {
width: parent && parent.width > 0
? parent.width / ColumnCount > 200
? parent.width / ColumnCount
: parent.width
: form.width
height: fieldGroupTitle.height + fieldContent.childrenRect.height
Rectangle {
id: fieldGroupBackground
anchors.fill: parent
visible: GroupColor ? true : false
color: GroupColor ? Qt.hsla(GroupColor.hslHue, GroupColor.hslSaturation, GroupColor.hslLightness, 0.05) : "transparent"
}
Rectangle {
id: fieldGroupTitle
width: parent.width
height: GroupName !== '' ? childrenRect.height : 0
color: GroupColor ? Qt.hsla(GroupColor.hslHue, GroupColor.hslSaturation, GroupColor.hslLightness, 0.5) : Theme.controlBorderColor
Rectangle {
width: 5
height: parent.height
anchors.top: parent.top
anchors.left: parent.left
color: GroupColor ? GroupColor : "transparent"
}
Text {
leftPadding: 10
rightPadding: 10
topPadding: 5
bottomPadding: 5
width: parent.width
font.pointSize: Theme.tipFont.pointSize
font.bold: true
color: Theme.mainTextColor
text: GroupName || ''
wrapMode: Text.WordWrap
}
}
Item {
id: fieldContent
anchors {
top: fieldGroupTitle.bottom
left: parent.left
right: parent.right
}
Loader {
property string containerName: Name || ''
property string containerCode: EditorWidgetCode || ''
property var containerGroupIndex: GroupIndex
property var labelOverrideColor: LabelOverrideColor
property var labelColor: LabelColor
active: (Type === 'container' && GroupIndex !== undefined && GroupIndex.valid) ||
((Type === 'text' || Type === 'html' || Type === 'qml') && form.model.featureModel.modelMode != FeatureModel.MultiFeatureModel)
height: active ? item.childrenRect.height : 0
anchors {
left: parent.left
right: parent.right
}
sourceComponent: Type === 'container' && GroupIndex !== undefined && GroupIndex.valid
? innerContainer
: Type === 'qml'
? qmlContainer
: Type === 'html'
? htmlContainer
: Type === 'text'
? textContainer
: dummyContainer
}
Item {
id: fieldContainer
property bool isVisible: Type === 'field' || Type === 'relation'
visible: isVisible
height: isVisible ? childrenRect.height : 0
anchors {
left: parent.left
right: parent.right
leftMargin: 12
}
Label {
id: fieldLabel
width: parent.width
text: Name || ''
wrapMode: Text.WordWrap
font.family: LabelOverrideFont ? LabelFont.family : Theme.tinyFont.family
font.pointSize: Theme.tinyFont.pointSize
font.bold: LabelOverrideFont ? LabelFont.bold : true
font.italic: LabelOverrideFont ? LabelFont.italic : false
font.underline: LabelOverrideFont ? LabelFont.underline : false
font.strikeout: LabelOverrideFont ? LabelFont.strikeout : false
topPadding: 10
bottomPadding: 5
opacity: (form.state === 'ReadOnly' || !AttributeEditable) || embedded && EditorWidget === 'RelationEditor'
? 0.45
: 1
color: LabelOverrideColor ? LabelColor : Theme.mainTextColor
}
Label {
id: constraintDescriptionLabel
anchors {
left: parent.left
right: parent.right
top: fieldLabel.bottom
}
font.pointSize: fieldLabel.font.pointSize/3*2
text: {
if ( ConstraintHardValid && ConstraintSoftValid )
return '';
return ConstraintDescription || '';
}
height: !ConstraintHardValid || !ConstraintSoftValid ? undefined : 0
visible: !ConstraintHardValid || !ConstraintSoftValid
opacity: fieldLabel.opacity
color: !ConstraintHardValid ? Theme.errorColor : Theme.warningColor
}
Item {
id: placeholder
height: attributeEditorLoader.childrenRect.height
anchors { left: parent.left; right: menuButton.left; top: constraintDescriptionLabel.bottom; }
Loader {
id: attributeEditorLoader
anchors { left: parent.left; right: parent.right }
//disable widget if it's:
// - not activated in multi edit mode
// - not set to editable in the widget configuration
// - not in edit mode (ReadOnly)
// - a relation in multi edit mode
property bool isAdding: form.state === 'Add'
property bool isEditing: form.state === 'Edit'
property bool isEnabled: !!AttributeEditable
&& form.state !== 'ReadOnly'
&& !( Type === 'relation' && form.model.featureModel.modelMode == FeatureModel.MultiFeatureModel )
property var value: AttributeValue
property var config: ( EditorWidgetConfig || {} )
property var widget: EditorWidget
property var relationEditorWidget: RelationEditorWidget
property var relationEditorWidgetConfig: RelationEditorWidgetConfig
property var field: Field
property var fieldLabel: Name
property var relationId: RelationId
property var nmRelationId: NmRelationId
property var constraintHardValid: ConstraintHardValid
property var constraintSoftValid: ConstraintSoftValid
property bool constraintsHardValid: form.model.constraintsHardValid
property bool constraintsSoftValid: form.model.constraintsSoftValid
property var currentFeature: form.model.featureModel.feature
property var currentLayer: form.model.featureModel.currentLayer
property bool autoSave: qfieldSettings.autoSave
// TODO investigate why StringUtils are not available in ./editorwidget/*.qml files
property var stringUtilities: StringUtils
active: widget !== 'Hidden'
source: {
if ( widget === 'RelationEditor' ) {
return 'editorwidgets/relationeditors/' + ( RelationEditorWidget || 'relation_editor' ) + '.qml'
}
return 'editorwidgets/' + ( widget || 'TextEdit' ) + '.qml'
}
onLoaded: {
item.isLoaded = true;
}
onStatusChanged: {
if ( attributeEditorLoader.status === Loader.Error ) {
source = ( widget === 'RelationEditor' )
? 'editorwidgets/relationeditors/relation_editor.qml'
: 'editorwidgets/TextEdit.qml'
}
}
}
Connections {
target: form
function onAboutToSave() {
// it may not be implemented
if ( attributeEditorLoader.item.pushChanges ) {
attributeEditorLoader.item.pushChanges( form.model.featureModel.feature )
}
}
function onValueChanged(field, oldValue, newValue) {
// it may not be implemented
if ( attributeEditorLoader.item.siblingValueChanged ) {
attributeEditorLoader.item.siblingValueChanged( field, form.model.featureModel.feature )
}
}
}
Connections {
target: attributeEditorLoader.item
function onValueChangeRequested(value, isNull) {
//do not compare AttributeValue and value with strict comparison operators
if( ( AttributeValue != value || ( AttributeValue !== undefined && isNull ) ) && !( AttributeValue === undefined && isNull ) )
{
var oldValue = AttributeValue
AttributeValue = isNull ? undefined : value
valueChanged(Field, oldValue, AttributeValue)
if ( !AttributeAllowEdit && form.model.featureModel.modelMode == FeatureModel.MultiFeatureModel ) {
AttributeAllowEdit = true;
}
if ( qfieldSettings.autoSave && !setupOnly && !master.ignoreChanges ) {
// indirect action, no need to check for success and display a toast, the log is enough
save()
}
}
}
function onRequestGeometry(item, layer) {
form.digitizingToolbar.geometryRequested = true
form.digitizingToolbar.geometryRequestedItem = item
form.digitizingToolbar.geometryRequestedLayer = layer
}
function onRequestBarcode(item) {
form.codeReader.barcodeRequestedItem = item
form.codeReader.open()
}
}
}
QfToolButton {
id: menuButton
anchors { right: rememberCheckbox.left; top: constraintDescriptionLabel.bottom; rightMargin: 10; }
visible: attributeEditorLoader.isEnabled && attributeEditorLoader.item.hasMenu
enabled: visible
width: visible ? 48 : 0
iconSource: Theme.getThemeIcon("ic_dot_menu_gray_24dp")
iconColor: Theme.mainTextColor
bgcolor: "transparent"
onClicked: {
attributeEditorLoader.item.menu.popup(menuButton.x, menuButton.y)
}
}
CheckBox {
id: rememberCheckbox
checked: RememberValue ? true : false
visible: form.state === "Add" && EditorWidget !== "Hidden" && EditorWidget !== 'RelationEditor'
width: visible ? undefined : 0
anchors { right: parent.right; top: constraintDescriptionLabel.bottom; verticalCenter: menuButton.verticalCenter }
onCheckedChanged: {
RememberValue = checked
}
indicator.height: 16
indicator.width: 16
icon.height: 16
icon.width: 16
}
Label {
id: multiEditAttributeLabel
text: (AttributeAllowEdit ? qsTr( "Value applied" ) : qsTr( "Value skipped" ) ) + qsTr( " (click to toggle)" )
visible: form.model.featureModel.modelMode == FeatureModel.MultiFeatureModel && Type !== 'relation'
height: form.model.featureModel.modelMode == FeatureModel.MultiFeatureModel ? undefined : 0
bottomPadding: form.model.featureModel.modelMode == FeatureModel.MultiFeatureModel ? 15 : 0
anchors { left: parent.left; top: placeholder.bottom; rightMargin: 10; }
font: Theme.tipFont
color: AttributeAllowEdit ? Theme.mainColor : Theme.secondaryTextColor
MouseArea {
anchors.fill: parent
onClicked: {
AttributeAllowEdit = !AttributeAllowEdit
}
}
}
}
}
}
}
function confirm() {
//if this is not handled before (e.g. when this is called because the drawer is closed by tipping on the map)
if ( !model.constraintsHardValid )
{
displayToast( qsTr( 'Constraints not valid'), 'warning' )
cancel()
return
}
else if ( !model.constraintsSoftValid )
{
displayToast( qsTr( 'Note: soft constraints were not met') )
}
parent.focus = true
if( setupOnly ) {
temporaryStored()
return
}
if ( !save() ) {
displayToast( qsTr( 'Unable to save changes'), 'error' )
featureCreated = false
return
}
state = 'Edit'
featureCreated = false
confirmed()
}
function save() {
if( !model.constraintsHardValid ) {
return false
}
aboutToSave()
master.ignoreChanges = true;
var isSuccess = false;
if( form.state === 'Add' && !featureCreated ) {
isSuccess = model.create()
featureCreated = isSuccess
} else {
isSuccess = model.save()
}
master.ignoreChanges = false;
return isSuccess
}
function cancel() {
if( form.state === 'Add' && featureCreated ) {
// indirect action, no need to check for success and display a toast, the log is enough
model.deleteFeature()
}
cancelled()
featureCreated = false
}
Connections {
target: Qt.inputMethod
function onVisibleChanged() {
Qt.inputMethod.commit()
}
}
/** The title toolbar **/
header: ToolBar {
id: toolbar
height: visible ? form.topMargin + 48 : 0
visible: form.state === 'Add'
anchors {
top: parent.top
topMargin: -1 // fix scene rounding issue leading to a white line
}
background: Rectangle {
color: !model.constraintsHardValid ? Theme.errorColor : !model.constraintsSoftValid ? Theme.warningColor : Theme.mainColor
}
RowLayout {
anchors.fill: parent
anchors.topMargin: form.topMargin
Layout.margins: 0
QfToolButton {
id: saveButton
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
visible: ( form.state === 'Add' || form.state === 'Edit' )
width: 48
height: 48
clip: true
iconSource: Theme.getThemeIcon( "ic_check_white_48dp" )
opacity: typeof featureFormList !== "undefined" ? featureFormList.model.constraintsHardValid ? 1.0 : 0.3 : 1.0
onClicked: {
if( model.constraintsHardValid ) {
if ( !model.constraintsSoftValid ) {
displayToast( qsTr('Note: soft constraints were not met') )
}
confirm()
} else {
displayToast( qsTr('Constraints not valid'), 'warning' )
}
}
}
Text {
id: titleLabel
Layout.fillWidth: true
Layout.preferredHeight: parent.height
font: Theme.strongFont
color: Theme.light
text:
{
var currentLayer = model.featureModel.currentLayer
var layerName = 'N/A'
if (currentLayer != null)
layerName = currentLayer.name
if ( form.state === 'Add' )
qsTr( 'Add feature on %1' ).arg(layerName )
else if ( form.state === 'Edit' )
qsTr( 'Edit feature on %1' ).arg(layerName)
else
qsTr( 'View feature on %1' ).arg(layerName)
}
fontSizeMode: Text.Fit
wrapMode: Text.Wrap
elide: Label.ElideRight
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
}
QfToolButton {
id: closeButton
Layout.alignment: Qt.AlignTop | Qt.AlignRight
width: 49
height: 48
clip: true
visible: !setupOnly
iconSource: form.state === 'Add' ? Theme.getThemeIcon( 'ic_delete_forever_white_24dp' ) : Theme.getThemeIcon( 'ic_close_white_24dp' )
onClicked: {
Qt.inputMethod.hide()
if ((form.state === 'Add' || form.state === 'Edit')) {
form.requestCancel()
} else {
cancel();
}
}
}
}
}
Dialog {
id: cancelDialog
parent: mainWindow.contentItem
visible: false
modal: true
font: Theme.defaultFont
z: 10000 // 1000s are embedded feature forms, user a higher value to insure the dialog will always show above embedded feature forms
x: ( mainWindow.width - width ) / 2
y: ( mainWindow.height - height ) / 2
title: qsTr( "Cancel editing" )
Label {
width: parent.width
wrapMode: Text.WordWrap
text: form.state === 'Add'
? qsTr( "You are about to dismiss the new feature, proceed?" )
: qsTr( "You are about to leave editing state, any changes will be lost. Proceed?" )
}
standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: {
form.cancel()
}
}
}