Skip to content
Permalink
Browse files

fix QgsMapLayerAction SIP + do not copy features in identify menu (fo…

…llowup 21c81d6)
  • Loading branch information
3nids committed Sep 17, 2014
1 parent 096d941 commit 2188de608a1c1a3269e64024ad9862af6f80faf3
@@ -7,40 +7,48 @@ class QgsMapLayerAction : QAction
public:
enum Target
{
Layer ,
Layer,
SingleFeature,
MultipleFeatures,
AllActions
};
typedef QFlags<QgsMapLayerAction::Target> Targets;

/**Creates a map layer action which can run on any layer*/
//! Creates a map layer action which can run on any layer
//! @note using AllActions as a target probably does not make a lot of sense. This default action was settled for API compatiblity reasons.
QgsMapLayerAction( QString name, QObject *parent, Targets targets = AllActions );
/**Creates a map layer action which can run only on a specific layer*/

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

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

~QgsMapLayerAction();

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

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

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

/** Triggers the action with the specified layer. This also emits the triggered() slot. */
/** Triggers the action with the specified layer. */
void triggerForLayer( QgsMapLayer* layer );

/** Define the targets of the action */
void setTargets( Targets targets );
/** Return availibity of action */
const Targets& targets() const;

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

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

/** Triggered when action has been run for a specific layer */
void triggeredForLayer( QgsMapLayer* layer );
@@ -56,7 +56,7 @@ QgsMapToolIdentifyAction::QgsMapToolIdentifyAction( QgsMapCanvas * canvas )
mIdentifyMenu->setAllowMultipleReturn( true );

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

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

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

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

QString filter = "$id IN (";
Q_FOREACH ( const QgsFeature* feature, featureList )
Q_FOREACH ( const QgsFeature feature, featureList )

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Sep 17, 2014

Member

better to use const QgsFeature& feature

This comment has been minimized.

Copy link
@3nids

3nids Sep 17, 2014

Author Member

thanks!

{
filter.append( QString( "%1," ).arg( feature->id() ) );
filter.append( QString( "%1," ).arg( feature.id() ) );
}
filter = filter.replace( QRegExp( ",$" ), ")" );

@@ -72,7 +72,8 @@ class APP_EXPORT QgsMapToolIdentifyAction : public QgsMapToolIdentify
void copyToClipboard( QgsFeatureStore & );

private slots:
void showAttributeTable( QgsMapLayer* layer, QList<const QgsFeature*> featureList );
void showAttributeTable( QgsMapLayer* layer, const QList<QgsFeature> featureList );

private:
//! Pointer to the identify results dialog for name/value pairs
QPointer<QgsIdentifyResultsDialog> mResultsDialog;
@@ -413,10 +413,10 @@ void QgsIdentifyMenu::triggerMapLayerAction()
// multiples features
if ( actData.mMapLayerAction->targets().testFlag( QgsMapLayerAction::MultipleFeatures ) )
{
QList<const QgsFeature*> featureList;
QList<QgsFeature> featureList;
Q_FOREACH ( QgsMapToolIdentify::IdentifyResult result, mLayerIdResults[actData.mLayer] )
{
featureList << new QgsFeature( result.mFeature );
featureList << result.mFeature;
}
actData.mMapLayerAction->triggerForFeatures( actData.mLayer, featureList );
}
@@ -72,7 +72,7 @@ bool QgsMapLayerAction::canRunUsingLayer( QgsMapLayer* layer ) const
return false;
}

void QgsMapLayerAction::triggerForFeatures( QgsMapLayer* layer, QList<const QgsFeature*> featureList )
void QgsMapLayerAction::triggerForFeatures( QgsMapLayer* layer, const QList<QgsFeature> featureList )
{
emit triggeredForFeatures( layer, featureList );
}
@@ -47,10 +47,10 @@ class GUI_EXPORT QgsMapLayerAction : public QAction
//! @note using AllActions as a target probably does not make a lot of sense. This default action was settled for API compatiblity reasons.
QgsMapLayerAction( QString name, QObject *parent, Targets targets = AllActions );

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

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

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

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

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

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

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

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

0 comments on commit 2188de6

Please sign in to comment.
You can’t perform that action at this time.