Skip to content

Commit 2188de6

Browse files
committed
fix QgsMapLayerAction SIP + do not copy features in identify menu (followup 21c81d6)
1 parent 096d941 commit 2188de6

File tree

6 files changed

+30
-21
lines changed

6 files changed

+30
-21
lines changed

python/gui/qgsmaplayeractionregistry.sip

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,48 @@ class QgsMapLayerAction : QAction
77
public:
88
enum Target
99
{
10-
Layer ,
10+
Layer,
1111
SingleFeature,
1212
MultipleFeatures,
1313
AllActions
1414
};
1515
typedef QFlags<QgsMapLayerAction::Target> Targets;
1616

17-
/**Creates a map layer action which can run on any layer*/
17+
//! Creates a map layer action which can run on any layer
18+
//! @note using AllActions as a target probably does not make a lot of sense. This default action was settled for API compatiblity reasons.
1819
QgsMapLayerAction( QString name, QObject *parent, Targets targets = AllActions );
19-
/**Creates a map layer action which can run only on a specific layer*/
20+
21+
//! Creates a map layer action which can run only on a specific layer
2022
QgsMapLayerAction( QString name, QObject *parent, QgsMapLayer* layer, Targets targets = AllActions );
21-
/**Creates a map layer action which can run on a specific type of layer*/
23+
24+
//! Creates a map layer action which can run on a specific type of layer
2225
QgsMapLayerAction( QString name, QObject *parent, QgsMapLayer::LayerType layerType, Targets targets = AllActions );
26+
2327
~QgsMapLayerAction();
2428

2529
/** True if action can run using the specified layer */
2630
bool canRunUsingLayer( QgsMapLayer* layer ) const;
2731

2832
/** Triggers the action with the specified layer and list of feature. */
29-
void triggerForFeatures( QgsMapLayer* layer, QList<const QgsFeature*> featureList );
33+
void triggerForFeatures( QgsMapLayer* layer, const QList<QgsFeature> featureList );
34+
35+
/** Triggers the action with the specified layer and feature. */
36+
void triggerForFeature( QgsMapLayer* layer, const QgsFeature* feature );
3037

31-
/** Triggers the action with the specified layer. This also emits the triggered() slot. */
38+
/** Triggers the action with the specified layer. */
3239
void triggerForLayer( QgsMapLayer* layer );
3340

3441
/** Define the targets of the action */
3542
void setTargets( Targets targets );
43+
/** Return availibity of action */
3644
const Targets& targets() const;
3745

3846
signals:
3947
/** Triggered when action has been run for a specific list of features */
40-
void triggeredForFeatures( QgsMapLayer* layer, QList<const QgsFeature*> featureList );
48+
void triggeredForFeatures( QgsMapLayer* layer, const QList<QgsFeature> featureList );
4149

4250
/** Triggered when action has been run for a specific feature */
43-
void triggeredForFeature( QgsMapLayer* layer, const QgsFeature* feature );
51+
void triggeredForFeature( QgsMapLayer* layer, const QgsFeature& feature );
4452

4553
/** Triggered when action has been run for a specific layer */
4654
void triggeredForLayer( QgsMapLayer* layer );

src/app/qgsmaptoolidentifyaction.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ QgsMapToolIdentifyAction::QgsMapToolIdentifyAction( QgsMapCanvas * canvas )
5656
mIdentifyMenu->setAllowMultipleReturn( true );
5757

5858
QgsMapLayerAction* attrTableAction = new QgsMapLayerAction( tr( "Show attribute table" ), mIdentifyMenu, QgsMapLayer::VectorLayer, QgsMapLayerAction::MultipleFeatures );
59-
connect( attrTableAction, SIGNAL( triggeredForFeatures( QgsMapLayer*, QList<const QgsFeature*> ) ), this, SLOT( showAttributeTable( QgsMapLayer*, QList<const QgsFeature*> ) ) );
59+
connect( attrTableAction, SIGNAL( triggeredForFeatures( QgsMapLayer*, const QList<QgsFeature> ) ), this, SLOT( showAttributeTable( QgsMapLayer*, const QList<QgsFeature> ) ) );
6060
identifyMenu()->addCustomAction( attrTableAction );
6161
}
6262

@@ -81,7 +81,7 @@ QgsIdentifyResultsDialog *QgsMapToolIdentifyAction::resultsDialog()
8181
return mResultsDialog;
8282
}
8383

84-
void QgsMapToolIdentifyAction::showAttributeTable( QgsMapLayer* layer, QList<const QgsFeature*> featureList )
84+
void QgsMapToolIdentifyAction::showAttributeTable( QgsMapLayer* layer, const QList<QgsFeature> featureList )
8585
{
8686
resultsDialog()->clear();
8787

@@ -90,9 +90,9 @@ void QgsMapToolIdentifyAction::showAttributeTable( QgsMapLayer* layer, QList<con
9090
return;
9191

9292
QString filter = "$id IN (";
93-
Q_FOREACH ( const QgsFeature* feature, featureList )
93+
Q_FOREACH ( const QgsFeature feature, featureList )
9494
{
95-
filter.append( QString( "%1," ).arg( feature->id() ) );
95+
filter.append( QString( "%1," ).arg( feature.id() ) );
9696
}
9797
filter = filter.replace( QRegExp( ",$" ), ")" );
9898

src/app/qgsmaptoolidentifyaction.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ class APP_EXPORT QgsMapToolIdentifyAction : public QgsMapToolIdentify
7272
void copyToClipboard( QgsFeatureStore & );
7373

7474
private slots:
75-
void showAttributeTable( QgsMapLayer* layer, QList<const QgsFeature*> featureList );
75+
void showAttributeTable( QgsMapLayer* layer, const QList<QgsFeature> featureList );
76+
7677
private:
7778
//! Pointer to the identify results dialog for name/value pairs
7879
QPointer<QgsIdentifyResultsDialog> mResultsDialog;

src/gui/qgsidentifymenu.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,10 @@ void QgsIdentifyMenu::triggerMapLayerAction()
413413
// multiples features
414414
if ( actData.mMapLayerAction->targets().testFlag( QgsMapLayerAction::MultipleFeatures ) )
415415
{
416-
QList<const QgsFeature*> featureList;
416+
QList<QgsFeature> featureList;
417417
Q_FOREACH ( QgsMapToolIdentify::IdentifyResult result, mLayerIdResults[actData.mLayer] )
418418
{
419-
featureList << new QgsFeature( result.mFeature );
419+
featureList << result.mFeature;
420420
}
421421
actData.mMapLayerAction->triggerForFeatures( actData.mLayer, featureList );
422422
}

src/gui/qgsmaplayeractionregistry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ bool QgsMapLayerAction::canRunUsingLayer( QgsMapLayer* layer ) const
7272
return false;
7373
}
7474

75-
void QgsMapLayerAction::triggerForFeatures( QgsMapLayer* layer, QList<const QgsFeature*> featureList )
75+
void QgsMapLayerAction::triggerForFeatures( QgsMapLayer* layer, const QList<QgsFeature> featureList )
7676
{
7777
emit triggeredForFeatures( layer, featureList );
7878
}

src/gui/qgsmaplayeractionregistry.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class GUI_EXPORT QgsMapLayerAction : public QAction
4747
//! @note using AllActions as a target probably does not make a lot of sense. This default action was settled for API compatiblity reasons.
4848
QgsMapLayerAction( QString name, QObject *parent, Targets targets = AllActions );
4949

50-
/**Creates a map layer action which can run only on a specific layer*/
50+
//! Creates a map layer action which can run only on a specific layer
5151
QgsMapLayerAction( QString name, QObject *parent, QgsMapLayer* layer, Targets targets = AllActions );
5252

53-
/**Creates a map layer action which can run on a specific type of layer*/
53+
//! Creates a map layer action which can run on a specific type of layer
5454
QgsMapLayerAction( QString name, QObject *parent, QgsMapLayer::LayerType layerType, Targets targets = AllActions );
5555

5656
~QgsMapLayerAction();
@@ -59,9 +59,9 @@ class GUI_EXPORT QgsMapLayerAction : public QAction
5959
bool canRunUsingLayer( QgsMapLayer* layer ) const;
6060

6161
/** Triggers the action with the specified layer and list of feature. */
62-
void triggerForFeatures( QgsMapLayer* layer, QList<const QgsFeature*> featureList );
62+
void triggerForFeatures( QgsMapLayer* layer, const QList<QgsFeature> featureList );
6363

64-
/** Triggers the action with the specified layer and feature. */
64+
/** Triggers the action with the specified layer and feature. */
6565
void triggerForFeature( QgsMapLayer* layer, const QgsFeature* feature );
6666

6767
/** Triggers the action with the specified layer. */
@@ -74,7 +74,7 @@ class GUI_EXPORT QgsMapLayerAction : public QAction
7474

7575
signals:
7676
/** Triggered when action has been run for a specific list of features */
77-
void triggeredForFeatures( QgsMapLayer* layer, QList<const QgsFeature*> featureList );
77+
void triggeredForFeatures( QgsMapLayer* layer, const QList<QgsFeature> featureList );
7878

7979
/** Triggered when action has been run for a specific feature */
8080
void triggeredForFeature( QgsMapLayer* layer, const QgsFeature& feature );

0 commit comments

Comments
 (0)