Ver código fonte

add modified files

kunickyd 3 anos atrás
pai
commit
ffac4817bc

+ 2 - 0
src/core/CMakeLists.txt

@@ -21,6 +21,7 @@ set(QFIELD_CORE_SRCS
     appinterface.cpp
     attributeformmodel.cpp
     attributeformmodelbase.cpp
+    attributetrackingmodel.cpp
     badlayerhandler.cpp
     bluetoothdevicemodel.cpp
     bluetoothreceiver.cpp
@@ -108,6 +109,7 @@ set(QFIELD_CORE_HDRS
     appinterface.h
     attributeformmodel.h
     attributeformmodelbase.h
+    attributetrackingmodel.h
     badlayerhandler.h
     bluetoothdevicemodel.h
     bluetoothreceiver.h

+ 6 - 0
src/core/qgismobileapp.cpp

@@ -46,6 +46,7 @@
 
 #include "appinterface.h"
 #include "attributeformmodel.h"
+#include "attributetrackingmodel.h"
 #include "badlayerhandler.h"
 #include "bluetoothdevicemodel.h"
 #include "bluetoothreceiver.h"
@@ -219,6 +220,7 @@ QgisMobileapp::QgisMobileapp( QgsApplication *app, QObject *parent )
   mFlatLayerTree = new FlatLayerTreeModel( mProject->layerTreeRoot(), mProject, this );
   mLegendImageProvider = new LegendImageProvider( mFlatLayerTree->layerTreeModel() );
   mTrackingModel = new TrackingModel;
+  mAttributeTrackingModel = new AttributeTrackingModel;
 
   // Transition from 1.8 to 1.8.1+
   const QString deviceAddress = settings.value( QStringLiteral( "positioningDevice" ), QString() ).toString();
@@ -464,6 +466,8 @@ void QgisMobileapp::initDeclarative()
   qmlRegisterUncreatableType<QgsGpkgFlusher>( "org.qfield", 1, 0, "QgsGpkgFlusher", "The gpkgFlusher is available as context property `gpkgFlusher`" );
   qmlRegisterUncreatableType<LayerObserver>( "org.qfield", 1, 0, "LayerObserver", "" );
   qmlRegisterUncreatableType<DeltaFileWrapper>( "org.qfield", 1, 0, "DeltaFileWrapper", "" );
+  qmlRegisterUncreatableType<FieldItem>("org.qfield", 1, 0, "FieldItem", "");
+
 
   qRegisterMetaType<SnappingResult>( "SnappingResult" );
 
@@ -492,8 +496,10 @@ void QgisMobileapp::initDeclarative()
   rootContext()->setContextProperty( "qfieldAuthRequestHandler", mAuthRequestHandler );
 
   rootContext()->setContextProperty( "trackingModel", mTrackingModel );
+  rootContext()->setContextProperty( "attributeTrackingModel", mAttributeTrackingModel );
 
   addImageProvider( QLatin1String( "legend" ), mLegendImageProvider );
+  addImageProvider( QLatin1String( "attributeTracking" ), mAttributeTrackingModel );
 }
 
 void QgisMobileapp::loadProjectQuirks()

+ 2 - 0
src/core/qgismobileapp.h

@@ -39,6 +39,7 @@
 #include "screendimmer.h"
 #include "settings.h"
 
+class AttributeTrackingModel;
 class AppInterface;
 class AppMissingGridHandler;
 class QgsOfflineEditing;
@@ -189,6 +190,7 @@ class QFIELD_CORE_EXPORT QgisMobileapp : public QQmlApplicationEngine
     QgsExifTools mExifTools;
 
     TrackingModel *mTrackingModel = nullptr;
+    AttributeTrackingModel *mAttributeTrackingModel = nullptr;
 
     AppMissingGridHandler *mAppMissingGridHandler = nullptr;
 

+ 36 - 0
src/qml/LayerTreeItemProperties.qml

@@ -21,6 +21,10 @@ Popup {
   property bool trackingButtonVisible: false
   property var trackingButtonText
 
+  property var attributeTrackingButtonText
+  property bool attributeTrackingButtonVisible: false
+
+
   width: Math.min( childrenRect.width, mainWindow.width - 20 )
   x: (parent.width - width) / 2
   y: (parent.height - height) / 2
@@ -43,6 +47,11 @@ Popup {
     trackingButtonText = trackingModel.layerInTracking( layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer) )
         ? qsTr('Stop tracking')
         : qsTr('Setup tracking')
+
+    attributeTrackingButtonVisible = isAttributeTrackingButtonVisible();
+    attributeTrackingButtonText = attributeTrackingModel.tracking()
+        ? qsTr('Stop attribute tracking')
+        : qsTr('Setup attribute tracking')
   }
 
   Page {
@@ -214,6 +223,26 @@ Popup {
         }
       }
 
+      QfButton {
+          id: setupAttributeTracking
+          Layout.fillWidth: true
+          Layout.topMargin: 5
+          text: attributeTrackingButtonText
+          visible: attributeTrackingButtonVisible
+          onClicked: {
+              if(attributeTrackingModel.tracking()){
+                  attributeTrackingModel.stopTracker();
+                  dashBoard.visible = false;
+              }else{
+                  attributeSettingsDialog.currentLayer = layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer);
+                  attributeSettingsDialog.index = index;
+                  attributeSettingsDialog.open();
+              }
+              close();
+
+          }
+      }
+
       Text {
         id: lockText
         property var padlockIcon: Theme.getThemeIcon('ic_lock_black_24dp')
@@ -306,4 +335,11 @@ Popup {
     return layerTree.data( index, FlatLayerTreeModel.IsValid )
         && layerTree.data( index, FlatLayerTreeModel.LayerType ) === 'vectorlayer'
   }
+
+  function isAttributeTrackingButtonVisible(){
+      //TODO: find out which layer types are supported
+      return layerTree.data( index, FlatLayerTreeModel.Type ) === 'layer'
+              && layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer).geometryType() === QgsWkbTypes.PolygonGeometry
+              && positionSource.active;
+  }
 }

+ 10 - 0
src/qml/qgismobileapp.qml

@@ -823,6 +823,16 @@ ApplicationWindow {
     }
   }
 
+  AttributeTrackingSettings{
+      id: attributeSettingsDialog
+  }
+
+  AttributeTracker{
+      id: attributeTracker
+      location: positionSource.projectedPosition
+      settings: mapCanvas.mapSettings
+  }
+
   /* The main menu */
   Row {
     id: mainMenuBar

+ 2 - 0
src/qml/qml.qrc

@@ -72,5 +72,7 @@
         <file>QFieldCloudPopup.qml</file>
         <file>QFieldCloudDeltaHistory.qml</file>
         <file>QFieldCloudExportLayersFeedback.qml</file>
+        <file>AttributeTrackingSettings.qml</file>
+        <file>AttributeTracker.qml</file>
     </qresource>
 </RCC>