Skip to content

Commit

Permalink
relation reference editor
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed Feb 19, 2024
1 parent 94a8730 commit 2a3364a
Show file tree
Hide file tree
Showing 17 changed files with 186 additions and 151 deletions.
5 changes: 5 additions & 0 deletions app/icons/Link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/icons/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<file>HomeFilled.svg</file>
<file>Info.svg</file>
<file>Layers.svg</file>
<file>Link.svg</file>
<file>Linkedin.svg</file>
<file>LocalChanges.svg</file>
<file>MapThemes.svg</file>
Expand Down
7 changes: 4 additions & 3 deletions app/inpututils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,9 +1117,10 @@ const QUrl InputUtils::getFormEditorType( const QString &widgetNameIn, const QVa
return QUrl( path.arg( QLatin1String( "MMFormRelationEditor" ) ) );
}
}

// TODO == Missing editors:
// - QStringLiteral( "relationreference" )
else if ( widgetName == QStringLiteral( "relationreference" ) )
{
return QUrl( path.arg( QLatin1String( "MMFormRelationReferenceEditor" ) ) );
}

return QUrl( path.arg( QLatin1String( "MMFormTextEditor" ) ) );
}
Expand Down
2 changes: 2 additions & 0 deletions app/mmstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class MMStyle: public QObject
Q_PROPERTY( QColor shadowColor READ shadowColor CONSTANT )

// Icons
Q_PROPERTY( QUrl linkIcon READ linkIcon CONSTANT )
Q_PROPERTY( QUrl closeAccountIcon READ closeAccountIcon CONSTANT )
Q_PROPERTY( QUrl signOutIcon READ signOutIcon CONSTANT )
Q_PROPERTY( QUrl workspacesIcon READ workspacesIcon CONSTANT )
Expand Down Expand Up @@ -262,6 +263,7 @@ class MMStyle: public QObject
QColor errorBgInputColor() {return QColor::fromString( "#FEFAF9" );}
QColor shadowColor() {return QColor::fromString( "#66777777" );}

QUrl linkIcon() {return QUrl( "qrc:/Link.svg" );}
QUrl closeAccountIcon() {return QUrl( "qrc:/CloseAccount.svg" );}
QUrl signOutIcon() {return QUrl( "qrc:/SignOut.svg" );}
QUrl workspacesIcon() {return QUrl( "qrc:/Workspaces.svg" );}
Expand Down
2 changes: 1 addition & 1 deletion app/qml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ set(MM_QML
dialogs/NoPermissionsDialog.qml
dialogs/SplittingFailedDialog.qml
dialogs/SyncFailedDialog.qml
editor/inputrelationreference.qml
inputs/MMBaseInput.qml
inputs/MMPasswordInput.qml
inputs/MMTextInput.qml
Expand All @@ -118,6 +117,7 @@ set(MM_QML
form/editors/MMFormPhotoEditor.qml
form/editors/MMFormPhotoViewer.qml
form/editors/MMFormRelationEditor.qml
form/editors/MMFormRelationReferenceEditor.qml
form/editors/MMFormScannerEditor.qml
form/editors/MMFormSliderEditor.qml
form/editors/MMFormSwitchEditor.qml
Expand Down
6 changes: 4 additions & 2 deletions app/qml/components/MMFeaturesListDrawer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ Drawer {
property alias title: header.title
property alias model: listView.model
property bool withSearch: false
property alias buttonText: primaryButton.text
property alias buttonVisible: primaryButton.visible

padding: 20 * __dp

signal featureClicked( var selectedFeatures )
signal createLinkedFeature()
signal buttonClicked()

width: ApplicationWindow.window.width
height: ApplicationWindow.window.height
Expand Down Expand Up @@ -147,7 +149,7 @@ Drawer {
text: qsTr("Add feature")

onClicked: {
root.createLinkedFeature()
root.buttonClicked()
}
}
}
Expand Down
122 changes: 0 additions & 122 deletions app/qml/editor/inputrelationreference.qml

This file was deleted.

2 changes: 1 addition & 1 deletion app/qml/form/editors/MMFormGalleryEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Item {
anchors.centerIn: parent
source: __style.addImageIcon
color: root.errorMsg.length > 0 ? __style.grapeColor : root.warningMsg.length > 0 ? __style.earthColor : __style.forestColor
size: __style.icon40
size: __style.icon32
}

MouseArea {
Expand Down
15 changes: 4 additions & 11 deletions app/qml/form/editors/MMFormPhotoViewer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,19 @@ MMBaseInput {
onClicked: root.contentClicked()
}

MMCircleIcon {
MMRoundButton {
anchors {
right: parent.right
bottom: parent.bottom
rightMargin: 10 * __dp
bottomMargin: 10 * __dp
}

size: __style.icon40
type: MMCircleIcon.Type.Delete
color: __style.negativeColor
bgndColor: __style.negativeColor
iconSource: __style.deleteIcon
iconColor: __style.grapeColor
visible: true//enabled && ( photo.status === Image.Ready || photo.status === Image.Error )

MouseArea {
anchors.centerIn: parent
width: parent.width + 20 * __dp
height: width
onClicked: root.trashClicked()
}
onClicked: root.trashClicked()
}
}
}
3 changes: 2 additions & 1 deletion app/qml/form/editors/MMFormRelationEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ MMBaseInput {
onFeatureClicked: function(selectedFeatures) {
root.openLinkedFeature( selectedFeatures )
}
onCreateLinkedFeature: root.createLinkedFeature( root._fieldFeatureLayerPair, root._fieldAssociatedRelation )

onButtonClicked: root.createLinkedFeature( root._fieldFeatureLayerPair, root._fieldAssociatedRelation )
}
}

Expand Down
120 changes: 120 additions & 0 deletions app/qml/form/editors/MMFormRelationReferenceEditor.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/***************************************************************************
* *
* 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 lc 1.0

import "../../components"
import "../../inputs"

MMBaseInput {
id: root

property var _fieldValue: parent.fieldValue
property var _fieldConfig: parent.fieldConfig
property var _fieldActiveProject: parent.fieldActiveProject
property bool _fieldValueIsNull: parent.fieldValueIsNull
property bool _fieldIsReadOnly: parent.fieldIsReadOnly
property string _fieldTitle: parent.fieldTitle
property bool _fieldShouldShowTitle: parent.fieldShouldShowTitle

signal openLinkedFeature( /* FeaturePair */ var linkedFeature )
signal editorValueChanged( var newValue, bool isNull )

on_FieldValueChanged: {
console.log("value " + root._fieldValue)
title.text = rModel.attributeFromForeignKey( root._fieldValue, FeaturesModel.FeatureTitle ) || ""
}

title: _fieldShouldShowTitle ? _fieldTitle : ""

RelationReferenceFeaturesModel {
id: rModel

config: root._fieldConfig
project: root._fieldActiveProject

onModelReset: title.text = rModel.attributeFromForeignKey( root._fieldValue, FeaturesModel.FeatureTitle ) || ""
}

content: Text {
id: title

anchors.fill: parent
font: __style.p5
text: root._fieldValue
color: root.enabled ? __style.nightColor : __style.mediumGreenColor
verticalAlignment: Text.AlignVCenter
}

onContentClicked: {
let featurePair = rModel.attributeFromForeignKey( root._fieldValue, FeaturesModel.FeaturePair )

if ( featurePair == null || !featurePair.valid ) return

openLinkedFeature( featurePair )
}

rightAction: MMIcon {
id: rightIcon

anchors.verticalCenter: parent.verticalCenter

size: __style.icon24
source: __style.linkIcon
color: __style.forestColor
}

onRightActionClicked: {
if ( root._fieldIsReadOnly )
return

listLoader.active = true
listLoader.focus = true
}

Loader {
id: listLoader

asynchronous: true
active: false
sourceComponent: listComponent
}

Component {
id: listComponent

MMFeaturesListDrawer {
id: featuresDrawer
focus: true
model: rModel
title: qsTr( "Change link" )
buttonText: qsTr( "Unlink feature" )
buttonVisible: rModel.allowNull
withSearch: false
Component.onCompleted: open()

onClosed: listLoader.active = false

onFeatureClicked: function(selectedFeatures) {
let fk = rModel.foreignKeyFromAttribute( FeaturesModel.FeatureId, selectedFeatures.feature.id )
root.editorValueChanged( fk, false )
featuresDrawer.close()

}

onButtonClicked: {
root.editorValueChanged( undefined, true )
featuresDrawer.close()
}
}
}
}
2 changes: 1 addition & 1 deletion gallery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ set(GALLERY_HDRS
inpututils.h
scalebarkit.h
positionkit.h
relationfeaturesmodel.h
formfeaturesmodel.h
../app/notificationmodel.h
../app/mmstyle.h
../core/merginerrortypes.h
Expand Down
Loading

1 comment on commit 2a3364a

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 24.02.525611 just submitted!

Please sign in to comment.