56 changes: 56 additions & 0 deletions src/app/qgsmaptoolfeatureaction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/***************************************************************************
qgsmaptoolfeatureaction.h - map tool for running feature actions
---------------------
begin : January 2012
copyright : (C) 2012 by Giuseppe Sucameli
email : brush.tyler at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSMAPTOOLFEATUREACTION_H
#define QGSMAPTOOLFEATUREACTION_H

#include "qgis.h"
#include "qgsmaptool.h"

#include <QObject>
#include <QPointer>

class QgsVectorLayer;

/**
\brief Map tool for running feature actions on the current layer
*/
class QgsMapToolFeatureAction : public QgsMapTool
{
Q_OBJECT

public:
QgsMapToolFeatureAction( QgsMapCanvas* canvas );

~QgsMapToolFeatureAction();

//! Overridden mouse move event
virtual void canvasMoveEvent( QMouseEvent * e );

//! Overridden mouse press event
virtual void canvasPressEvent( QMouseEvent * e );

//! Overridden mouse release event
virtual void canvasReleaseEvent( QMouseEvent * e );

virtual void activate();

virtual void deactivate();

private:
bool doAction( QgsVectorLayer *layer, int x, int y );
};

#endif
6 changes: 6 additions & 0 deletions src/core/qgsattributeaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,19 @@ class CORE_EXPORT QgsAttributeAction
//! @deprecated Initialize QgsPythonRunner instead
static void setPythonExecute( void ( * )( const QString & ) );

//! Whether the action is the default action
int defaultAction() const { return mDefaultAction < 0 || mDefaultAction >= size() ? 0 : mDefaultAction; }
void setDefaultAction( int actionNumber ) { mDefaultAction = actionNumber ; }

private:
QList<QgsAction> mActions;
QgsVectorLayer *mLayer;
static void ( *smPythonExecute )( const QString & );

void runAction( const QgsAction &action,
void ( *executePython )( const QString & ) = 0 );

int mDefaultAction;
};

#endif
17 changes: 16 additions & 1 deletion src/ui/qgisapp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<x>0</x>
<y>0</y>
<width>1052</width>
<height>23</height>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="mEditMenu">
Expand Down Expand Up @@ -1542,6 +1542,21 @@
<string>Add WFS Layer</string>
</property>
</action>
<action name="mActionFeatureAction">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mAction.png</normaloff>:/images/themes/default/mAction.png</iconset>
</property>
<property name="text">
<string>Feature Action</string>
</property>
<property name="toolTip">
<string>Run feature action</string>
</property>
</action>
</widget>
<resources>
<include location="../../images/images.qrc"/>
Expand Down