From ed9de05c66fdee3a1cf1df6379eca8e1da1b97c5 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Sun, 1 Sep 2024 14:38:41 +0330 Subject: [PATCH] Some cleanups. --- src/core/positioning/positioningmodel.cpp | 10 +++++----- src/qml/InformationDrawer.qml | 2 +- src/qml/PositioningInformationView.qml | 22 +++++++++++----------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/core/positioning/positioningmodel.cpp b/src/core/positioning/positioningmodel.cpp index 97f8b3dc19..e60a2e8b5b 100644 --- a/src/core/positioning/positioningmodel.cpp +++ b/src/core/positioning/positioningmodel.cpp @@ -33,11 +33,11 @@ void PositioningModel::refreshData() // updateInfo( key, value ); // } - bool coordinatesIsXY = CoordinateReferenceSystemUtils::defaultCoordinateOrderForCrsIsXY( coordinateDisplayCrs() ); - bool coordinatesIsGeographic = coordinateDisplayCrs().isGeographic(); - QgsPoint coordinates = GeometryUtils::reprojectPoint( positioningSource()->sourcePosition(), CoordinateReferenceSystemUtils::wgs84Crs(), coordinateDisplayCrs() ); - double distanceUnitFactor = QgsUnitTypes::fromUnitToUnitFactor( Qgis::DistanceUnit::Meters, distanceUnits() ); - QString distanceUnitAbbreviation = QgsUnitTypes::toAbbreviatedString( distanceUnits() ); + const bool coordinatesIsXY = CoordinateReferenceSystemUtils::defaultCoordinateOrderForCrsIsXY( coordinateDisplayCrs() ); + const bool coordinatesIsGeographic = coordinateDisplayCrs().isGeographic(); + const QgsPoint coordinates = GeometryUtils::reprojectPoint( positioningSource()->sourcePosition(), CoordinateReferenceSystemUtils::wgs84Crs(), coordinateDisplayCrs() ); + const double distanceUnitFactor = QgsUnitTypes::fromUnitToUnitFactor( Qgis::DistanceUnit::Meters, distanceUnits() ); + const QString distanceUnitAbbreviation = QgsUnitTypes::toAbbreviatedString( distanceUnits() ); QString coord1Label; QString coord2Label; diff --git a/src/qml/InformationDrawer.qml b/src/qml/InformationDrawer.qml index 9a57f63962..929e106d4d 100644 --- a/src/qml/InformationDrawer.qml +++ b/src/qml/InformationDrawer.qml @@ -65,7 +65,7 @@ Item { PositioningInformationView { id: positioningInformationView width: parent.width - height: 200 // contentHeight + height: Math.min(contentHeight, mainWindow.height / 3) visible: positioningInformationViewEnabled positionSource: controller.positionSource antennaHeight: positioningSettings.antennaHeightActivated ? positioningSettings.antennaHeight : -1 diff --git a/src/qml/PositioningInformationView.qml b/src/qml/PositioningInformationView.qml index debd01e034..4c229d3e07 100644 --- a/src/qml/PositioningInformationView.qml +++ b/src/qml/PositioningInformationView.qml @@ -10,6 +10,8 @@ Rectangle { property alias positionSource: positioningModel.positioningSource property alias antennaHeight: positioningModel.antennaHeight + property real contentHeight: grid.contentHeight + property color backgroundColor: "transparent" property color alternateBackgroundColor: Theme.positionBackgroundColor property color textColor: positionSource.currentness ? Theme.mainTextColor : Theme.secondaryTextColor @@ -22,6 +24,14 @@ Rectangle { GridView { id: grid + + readonly property real numberOfColumns: parent.width / cellWidth + + model: PositioningModel { + id: positioningModel + distanceUnits: projectInfo.distanceUnits + coordinateDisplayCrs: projectInfo.coordinateDisplayCrs + } anchors.fill: parent cellHeight: positioningInformationView.cellHeight cellWidth: { @@ -37,24 +47,14 @@ Rectangle { boundsBehavior: Flickable.StopAtBounds ScrollBar.vertical: QfScrollBar { } - model: PositioningModel { - id: positioningModel - - distanceUnits: projectInfo.distanceUnits - coordinateDisplayCrs: projectInfo.coordinateDisplayCrs - } - Component.onCompleted: { positioningModel.setupConnections(); } - - property real numberOfColumns: parent.width / cellWidth - delegate: Rectangle { width: grid.cellWidth height: grid.cellHeight - property real currentRow: parseInt(index / grid.numberOfColumns) + readonly property real currentRow: parseInt(index / grid.numberOfColumns) color: { if (grid.numberOfColumns % 2 == 0) {