Skip to content

Commit

Permalink
Rename the legend's current layer to active layer for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jul 16, 2023
1 parent 1772714 commit 51833b4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions src/qml/DashBoard.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Drawer {
signal showCloudMenu

property alias allowLayerChange: legend.enabled
property alias currentLayer: legend.currentLayer
property alias activeLayer: legend.activeLayer
property alias layerTree: legend.model
property MapSettings mapSettings

Expand All @@ -41,9 +41,9 @@ Drawer {
onShowMenu: mainMenu.popup(settingsButton.x + 2, mainWindow.sceneTopMargin + settingsButton.y + 2)
onShowCloudMenu: cloudPopup.show()

onCurrentLayerChanged: {
if ( currentLayer && currentLayer.readOnly && stateMachine.state == "digitize" )
displayToast( qsTr( "The layer %1 is read only." ).arg( currentLayer.name ) )
onActiveLayerChanged: {
if (activeLayer && activeLayer.readOnly && stateMachine.state == "digitize")
displayToast(qsTr("The layer %1 is read only.").arg(activeLayer.name))
}

Connections {
Expand Down
10 changes: 5 additions & 5 deletions src/qml/Legend.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ListView {
id: legend

property bool isVisible: false
property VectorLayer currentLayer
property VectorLayer activeLayer

model: flatLayerTree
flickableDirection: Flickable.VerticalFlick
Expand All @@ -28,7 +28,7 @@ ListView {
property int itemPadding: 5 + ( 5 + 24 ) * TreeLevel
property string itemType: Type
property string layerType: LayerType
property bool isSelectedLayer: ( itemType === "layer" && vectorLayer != null && vectorLayer == currentLayer )
property bool isSelectedLayer: ( itemType === "layer" && vectorLayer != null && vectorLayer == activeLayer )
property bool isPressed: false

id: rectangle
Expand Down Expand Up @@ -141,7 +141,7 @@ ListView {
text: Name
horizontalAlignment: Text.AlignLeft
font.pointSize: Theme.tipFont.pointSize
font.bold: itemType === "group" || (itemType === "layer" && vectorLayer != null && vectorLayer == currentLayer) ? true : false
font.bold: itemType === "group" || (itemType === "layer" && vectorLayer != null && vectorLayer == activeLayer) ? true : false
color: {
if ( isSelectedLayer )
return Theme.light;
Expand Down Expand Up @@ -233,8 +233,8 @@ ListView {

if (item) {
if (item.vectorLayer && item.vectorLayer.isValid) {
currentLayer = item.vectorLayer
projectInfo.saveActiveLayer(currentLayer)
activeLayer = item.vectorLayer
projectInfo.saveActiveLayer(activeLayer)
}
}
}
Expand Down
56 changes: 28 additions & 28 deletions src/qml/qgismobileapp.qml
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ ApplicationWindow {
case 'digitize':
projectInfo.saveStateMode(mode)
dashBoard.ensureEditableLayerSelected();
if (dashBoard.currentLayer)
if (dashBoard.activeLayer)
{
displayToast( qsTr( 'You are now in digitize mode on layer %1' ).arg( dashBoard.currentLayer.name ) );
displayToast( qsTr( 'You are now in digitize mode on layer %1' ).arg( dashBoard.activeLayer.name ) );
}
else
{
Expand Down Expand Up @@ -506,7 +506,7 @@ ApplicationWindow {
// for instance, the vertex editor will select a vertex if possible
return
}
if ( stateMachine.state === "digitize" && dashBoard.currentLayer ) { // the sourceLocation test checks if a (stylus) hover is active
if ( stateMachine.state === "digitize" && dashBoard.activeLayer ) { // the sourceLocation test checks if a (stylus) hover is active
if ( ( Number( currentRubberband.model.geometryType ) === Qgis.GeometryType.Line && currentRubberband.model.vertexCount >= 2 )
|| ( Number( currentRubberband.model.geometryType ) === Qgis.GeometryType.Polygon && currentRubberband.model.vertexCount >= 2 ) ) {
digitizingToolbar.addVertex();
Expand Down Expand Up @@ -620,7 +620,7 @@ ApplicationWindow {
return Number.NaN;
}
}
vectorLayer: digitizingToolbar.geometryRequested ? digitizingToolbar.geometryRequestedLayer : dashBoard.currentLayer
vectorLayer: digitizingToolbar.geometryRequested ? digitizingToolbar.geometryRequestedLayer : dashBoard.activeLayer
crs: mapCanvas.mapSettings.destinationCrs
}

Expand Down Expand Up @@ -685,7 +685,7 @@ ApplicationWindow {
visible: stateMachine.state === "digitize" || stateMachine.state === 'measure'
highlightColor: digitizingToolbar.isDigitizing ? currentRubberband.color : "#CFD8DC"
mapSettings: mapCanvas.mapSettings
currentLayer: dashBoard.currentLayer
currentLayer: dashBoard.activeLayer
positionInformation: positionSource.positionInformation
positionLocked: positionSource.active && positioningSettings.positioningCoordinateLock
averagedPosition: positionSource.averagedPosition
Expand Down Expand Up @@ -889,7 +889,7 @@ ApplicationWindow {
DistanceArea {
id: digitizingGeometryMeasure

property VectorLayer currentLayer: dashBoard.currentLayer
property VectorLayer currentLayer: dashBoard.activeLayer

rubberbandModel: currentRubberband ? currentRubberband.model : null
project: qgisProject
Expand Down Expand Up @@ -1146,7 +1146,7 @@ ApplicationWindow {

function ensureEditableLayerSelected() {
var firstEditableLayer = null;
var currentLayerLocked = false;
var activeLayerLocked = false;
for (var i = 0; i < layerTree.rowCount(); i++)
{
var index = layerTree.index(i, 0)
Expand All @@ -1160,14 +1160,14 @@ ApplicationWindow {
firstEditableLayer = layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer);
}
}
if (currentLayer != null && currentLayer === layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer))
if (activeLayer != null && activeLayer === layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer))
{
if (
layerTree.data(index, FlatLayerTreeModel.ReadOnly) === true
|| layerTree.data(index, FlatLayerTreeModel.GeometryLocked) === true
)
{
currentLayerLocked = true;
activeLayerLocked = true;
}
else
{
Expand All @@ -1176,10 +1176,10 @@ ApplicationWindow {
}
if (
firstEditableLayer !== null
&& (currentLayer == null || currentLayerLocked === true)
&& (activeLayer == null || activeLayerLocked === true)
)
{
currentLayer = firstEditableLayer;
activeLayer = firstEditableLayer;
break;
}
}
Expand Down Expand Up @@ -1243,12 +1243,12 @@ ApplicationWindow {
id: topologyButton
round: true
visible: stateMachine.state === "digitize"
&& dashBoard.currentLayer
&& dashBoard.currentLayer.isValid
&& dashBoard.activeLayer
&& dashBoard.activeLayer.isValid
&& (
dashBoard.currentLayer.geometryType() === Qgis.GeometryType.Polygon
|| dashBoard.currentLayer.geometryType() === Qgis.GeometryType.Line
|| dashBoard.currentLayer.geometryType() === Qgis.GeometryType.Point
dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Polygon
|| dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Line
|| dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Point
)
state: qgisProject && qgisProject.topologicalEditing ? "On" : "Off"
iconSource: Theme.getThemeIcon( "ic_topology_white_24dp" )
Expand Down Expand Up @@ -1289,9 +1289,9 @@ ApplicationWindow {
&& ((digitizingToolbar.geometryRequested && digitizingToolbar.geometryRequestedLayer && digitizingToolbar.geometryRequestedLayer.isValid &&
(digitizingToolbar.geometryRequestedLayer.geometryType() === Qgis.GeometryType.Polygon
|| digitizingToolbar.geometryRequestedLayer.geometryType() === Qgis.GeometryType.Line))
|| (!digitizingToolbar.geometryRequested && dashBoard.currentLayer && dashBoard.currentLayer.isValid &&
(dashBoard.currentLayer.geometryType() === Qgis.GeometryType.Polygon
|| dashBoard.currentLayer.geometryType() === Qgis.GeometryType.Line)))
|| (!digitizingToolbar.geometryRequested && dashBoard.activeLayer && dashBoard.activeLayer.isValid &&
(dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Polygon
|| dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Line)))
iconSource: Theme.getThemeIcon( "ic_freehand_white_24dp" )

bgcolor: Theme.darkGray
Expand Down Expand Up @@ -1697,10 +1697,10 @@ ApplicationWindow {

stateVisible: !screenLocker.enabled &&
((stateMachine.state === "digitize"
&& dashBoard.currentLayer
&& !dashBoard.currentLayer.readOnly
&& dashBoard.activeLayer
&& !dashBoard.activeLayer.readOnly
// unfortunately there is no way to call QVariant::toBool in QML so the value is a string
&& dashBoard.currentLayer.customProperty( 'QFieldSync/is_geometry_locked' ) !== 'true'
&& dashBoard.activeLayer.customProperty( 'QFieldSync/is_geometry_locked' ) !== 'true'
&& !geometryEditorsToolbar.stateVisible
&& !moveFeaturesToolbar.stateVisible
&& (projectInfo.editRights || projectInfo.insertRights))
Expand All @@ -1716,15 +1716,15 @@ ApplicationWindow {
FeatureModel {
id: digitizingFeature
project: qgisProject
currentLayer: digitizingToolbar.geometryRequested ? digitizingToolbar.geometryRequestedLayer : dashBoard.currentLayer
currentLayer: digitizingToolbar.geometryRequested ? digitizingToolbar.geometryRequestedLayer : dashBoard.activeLayer
positionInformation: positionSource.positionInformation
topSnappingResult: coordinateLocator.topSnappingResult
positionLocked: positionSource.active && positioningSettings.positioningCoordinateLock
cloudUserInformation: cloudConnection.userInformation
geometry: Geometry {
id: digitizingGeometry
rubberbandModel: digitizingRubberband.model
vectorLayer: digitizingToolbar.geometryRequested ? digitizingToolbar.geometryRequestedLayer : dashBoard.currentLayer
vectorLayer: digitizingToolbar.geometryRequested ? digitizingToolbar.geometryRequestedLayer : dashBoard.activeLayer
}
}

Expand Down Expand Up @@ -2884,8 +2884,8 @@ ApplicationWindow {
onEditGeometry: {
// Set overall selected (i.e. current) layer to that of the feature geometry being edited,
// important for snapping settings to make sense when set to current layer
if ( dashBoard.currentLayer != featureForm.selection.focusedLayer ) {
dashBoard.currentLayer = featureForm.selection.focusedLayer
if ( dashBoard.activeLayer != featureForm.selection.focusedLayer ) {
dashBoard.activeLayer = featureForm.selection.focusedLayer
displayToast( qsTr( "Current layer switched to the one holding the selected geometry." ) );
}
geometryEditingFeature.vertexModel.geometry = featureForm.selection.focusedGeometry
Expand Down Expand Up @@ -2926,7 +2926,7 @@ ApplicationWindow {
id: overlayFeatureFormDrawer
digitizingToolbar: digitizingToolbar
barcodeReader: barcodeReader
featureModel.currentLayer: dashBoard.currentLayer
featureModel.currentLayer: dashBoard.activeLayer
}

function displayToast( message, type ) {
Expand Down Expand Up @@ -2993,7 +2993,7 @@ ApplicationWindow {

projectInfo.filePath = path
stateMachine.state = projectInfo.getSavedStateMode()
dashBoard.currentLayer = projectInfo.getSavedActiveLayer()
dashBoard.activeLayer = projectInfo.getSavedActiveLayer()

mapCanvasBackground.color = mapCanvas.mapSettings.backgroundColor

Expand Down

0 comments on commit 51833b4

Please sign in to comment.