Skip to content

Commit

Permalink
Provider users with visual feedback when initiating a child addition …
Browse files Browse the repository at this point in the history
…process
  • Loading branch information
nirvn committed Jun 27, 2024
1 parent bae0ff0 commit 0b3017f
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 21 deletions.
50 changes: 33 additions & 17 deletions src/qml/editorwidgets/relationeditors/ordered_relation_editor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -92,30 +92,35 @@ EditorWidgetBase {
anchors { top: parent.top; right: parent.right; rightMargin: 10 }
height: parent.height

ToolButton {
QfToolButton {
id: addButton
width: parent.height
height: parent.height
enabled: constraintsHardValid

contentItem: Rectangle {
anchors.fill: parent
color: parent.enabled ? nmRelationId ? 'blue' : 'black' : 'grey'
Image {
anchors.fill: parent
anchors.margins: 8
fillMode: Image.PreserveAspectFit
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: Theme.getThemeIcon( 'ic_add_white_24dp' )
}
}
round: false
iconSource: Theme.getThemeIcon( 'ic_add_white_24dp' )
bgcolor: parent.enabled ? nmRelationId ? 'blue' : 'black' : 'grey'
}
}

MouseArea {
anchors.fill: parent
onClicked: {
BusyIndicator {
id: addingIndicator
anchors { top: parent.top; right: parent.right; rightMargin: 10 }
width: parent.height
height: parent.height
running: false
}

Timer {
id: addingTimer

property string printName: ''

interval: 50
repeat: false

onTriggered: {
if (ProjectUtils.transactionMode(qgisProject) !== Qgis.TransactionMode.Disabled) {
// When a transaction mode is enabled, we must fallback to saving the parent feature to have provider-side issues
if (!save()) {
Expand All @@ -137,6 +142,13 @@ EditorWidgetBase {
}
}
}

MouseArea {
anchors.fill: parent
onClicked: {
addingTimer.restart()
}
}
}
}

Expand Down Expand Up @@ -455,10 +467,14 @@ EditorWidgetBase {
}
}

onFeatureSaved: {
onFeatureSaved: (id) => {
orderedRelationModel.featureFocus = id
orderedRelationModel.reload()
}

onOpened: {
addingIndicator.running = false
}
}

function requestedGeometryReceived(geometry) {
Expand Down
36 changes: 32 additions & 4 deletions src/qml/editorwidgets/relationeditors/relation_editor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,27 @@ EditorWidgetBase {
}
}

MouseArea {
anchors.fill: parent
onClicked: {
BusyIndicator {
id: addingIndicator
anchors { top: parent.top; right: parent.right; rightMargin: 10 }
width: parent.height
height: parent.height
running: false
}

Timer {
id: addingTimer

property string printName: ''

interval: 50
repeat: false

onTriggered: {
if (ProjectUtils.transactionMode(qgisProject) !== Qgis.TransactionMode.Disabled) {
// When a transaction mode is enabled, we must fallback to saving the parent feature to have provider-side issues
if (!save()) {
addingIndicator.running = false
displayToast(qsTr('Cannot add child feature: insure the parent feature meets all constraints and can be saved'), 'warning')
return
}
Expand All @@ -151,10 +166,19 @@ EditorWidgetBase {
}
else
{
addingIndicator.running = false
displayToast(qsTr('Cannot add child feature: attribute value linking parent and children is not set'), 'warning')
}
}
}

MouseArea {
anchors.fill: parent
onClicked: {
addingIndicator.running = true
addingTimer.restart()
}
}
}
}
}
Expand Down Expand Up @@ -345,10 +369,14 @@ EditorWidgetBase {
relationEditorModel.reload()
}

onFeatureSaved: {
onFeatureSaved: (id) => {
relationEditorModel.featureFocus = id
relationEditorModel.reload()
}

onOpened: {
addingIndicator.running = false
}
}

function isButtonEnabled(buttonType) {
Expand Down

0 comments on commit 0b3017f

Please sign in to comment.