Skip to content

Commit

Permalink
Multi-feature selection initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
uclaros committed Feb 21, 2024
1 parent 6359509 commit 0bb61f6
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 2 deletions.
9 changes: 9 additions & 0 deletions app/featuresmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ FeaturesModel::FeaturesModel( QObject *parent )

FeaturesModel::~FeaturesModel() = default;

void FeaturesModel::populateStaticModel( FeatureLayerPairs pairs )
{
beginResetModel();
mFeatures.clear();
mFeatures.append( pairs );
endResetModel();
emit countChanged( rowCount() );
}

void FeaturesModel::populate()
{
if ( mLayer )
Expand Down
8 changes: 8 additions & 0 deletions app/featuresmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ class FeaturesModel : public QAbstractListModel
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
QHash<int, QByteArray> roleNames() const override;

/**
* \brief populateStatic populates a static model using the supplied \a pairs
* \param pairs to populate the model with
* This method allows to use a model that is not tied to a specific layer and
* has a fixed set of FeatureLayerPairs
*/
Q_INVOKABLE void populateStaticModel( FeatureLayerPairs pairs );

/**
* \brief reloadFeatures reloads features from current layer
*/
Expand Down
30 changes: 30 additions & 0 deletions app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ ApplicationWindow {
formsStackManager.openForm( pair, "readOnly", "preview" );
}

onFeaturesIdentified: function( pairs ) {
formsStackManager.closeDrawer()
featurePairSelection.showPairs( pairs );
}

onNothingIdentified: {
formsStackManager.closeDrawer()
}
Expand Down Expand Up @@ -817,6 +822,31 @@ ApplicationWindow {
}
}

MMDropdownDrawer {
id: featurePairSelection

title: qsTr( "Select feature" )
withSearchbar: false
model: InputClass.FeaturesModel {}
valueRole: "FeaturePair"
textRole: "FeatureTitle"

onSelectionFinished: function( pairs ) {
var pair = pairs[0]
featurePairSelection.close()
map.highlightPair( pair )
formsStackManager.openForm( pair, "readOnly", "preview" );
}

function showPairs( pairs ) {
if ( pairs.length > 0 )
{
model.populateStaticModel( pairs )
open()
}
}
}

Connections {
target: __syncManager
enabled: stateManager.state === "map"
Expand Down
13 changes: 11 additions & 2 deletions app/qml/map/MMMapCanvas.qml
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,20 @@ Item {

clickDifferentiatorTimer.restart()
}
else if ( !isDragging )
else if ( !isDragging && !clickDifferentiatorTimer.ignoreNextTrigger )
{
// this is a simple click

clickDifferentiatorTimer.clickedPoint = clickPosition
clickDifferentiatorTimer.ignoreNextTrigger = false // just in case
clickDifferentiatorTimer.start()
}
else
{
// this was a pressAndHold or a drag release

clickDifferentiatorTimer.ignoreNextTrigger = false
}

previousPosition = null
initialPosition = null
Expand All @@ -213,7 +219,10 @@ Item {
}

onPressAndHold: function ( mouse ) {
mapRoot.longPressed( Qt.point( mouse.x, mouse.y ) )
if ( !isDragging ) {
mapRoot.longPressed( Qt.point( mouse.x, mouse.y ) )
}

clickDifferentiatorTimer.ignoreNextTrigger = true
}

Expand Down
17 changes: 17 additions & 0 deletions app/qml/map/MapWrapper.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Item {
property PositionTrackingManager trackingManager: tracking.item?.manager ?? null

signal featureIdentified( var pair )
signal featuresIdentified( var pairs )
signal nothingIdentified()

signal recordingStarted()
Expand Down Expand Up @@ -228,6 +229,22 @@ Item {
{
__positionKit.positionProvider.setPosition( __inputUtils.mapPointToGps( Qt.point( point.x, point.y ), mapCanvas.mapSettings ) )
}

if ( root.state === "view" )
{
let screenPoint = Qt.point( point.x, point.y )
let pairs = identifyKit.identify( screenPoint )

if ( !pairs.isEmpty )
{
root.featuresIdentified( pairs )
}
else
{
root.hideHighlight()
root.nothingIdentified()
}
}
}
}

Expand Down

1 comment on commit 0bb61f6

@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.528611 just submitted!

Please sign in to comment.