From 147e7acd3ea1066bdc7fa4ab2b14737710cf4b97 Mon Sep 17 00:00:00 2001 From: VitorVieiraZ Date: Thu, 2 Jan 2025 14:31:03 -0300 Subject: [PATCH] solving first problem: hiding tracking layer when recording --- app/inpututils.cpp | 10 ++++++++++ app/inpututils.h | 5 +++++ app/qml/components/MMListDelegate.qml | 18 +++++++++++++++--- app/qml/map/MMMapController.qml | 2 ++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/inpututils.cpp b/app/inpututils.cpp index 218c024e1..c117fbb86 100644 --- a/app/inpututils.cpp +++ b/app/inpututils.cpp @@ -2222,3 +2222,13 @@ double InputUtils::pixelDistanceBetween( const QPointF &p1, const QPointF &p2 ) { return std::hypot( p1.x() - p2.x(), p1.y() - p2.y() ); } + +bool InputUtils::isPositionTrackingLayerId( const QString &layerId, QgsProject *project ) +{ + if ( layerId.isEmpty() || !project ) + return false; + + QString trackingLayerId = project->readEntry( QStringLiteral( "Mergin" ), QStringLiteral( "PositionTracking/TrackingLayer" ), QString() ); + + return layerId == trackingLayerId; +} diff --git a/app/inpututils.h b/app/inpututils.h index 83be81f39..9eb7341dd 100644 --- a/app/inpututils.h +++ b/app/inpututils.h @@ -589,6 +589,11 @@ class InputUtils: public QObject */ static double pixelDistanceBetween( const QPointF &p1, const QPointF &p2 ); + /** + * Returns true if the layerId corresponds to position tracking layer id + */ + Q_INVOKABLE bool isPositionTrackingLayerId( const QString &layerId, QgsProject *project ); + public slots: void onQgsLogMessageReceived( const QString &message, const QString &tag, Qgis::MessageLevel level ); diff --git a/app/qml/components/MMListDelegate.qml b/app/qml/components/MMListDelegate.qml index 9662f7584..2eb48d612 100644 --- a/app/qml/components/MMListDelegate.qml +++ b/app/qml/components/MMListDelegate.qml @@ -28,14 +28,26 @@ Item { property alias rightContent: rightContentGroup.children property bool hasLine: { - // calculate automatically when this item is a delegate in list + if ( !visible ) + return false; + + // calculate automatically when this item is a delegate in list if ( typeof index != "undefined" ) { if ( ListView?.view ?? false ) { - return index < ListView.view.count - 1 + // hide line if this is the last item + if ( index >= ListView.view.count - 1 ) + return false; + + // hide line if next item is invisible + var nextItem = ListView.view.itemAtIndex( index + 1 ); + if ( nextItem && !nextItem.visible ) + return false; + + return true; } } - return true + return true; } property real verticalSpacing: root.secondaryText ? __style.margin8 : __style.margin20 diff --git a/app/qml/map/MMMapController.qml b/app/qml/map/MMMapController.qml index 43f76d8af..473cb3ded 100644 --- a/app/qml/map/MMMapController.qml +++ b/app/qml/map/MMMapController.qml @@ -808,6 +808,8 @@ Item { // TODO: why we need to set hight here? height: __style.menuDrawerHeight + visible: !__inputUtils.isPositionTrackingLayerId( model.layerId, __activeProject.qgsProject ) + leftContent: MMIcon { source: model.iconSource }