Skip to content

Commit 1e9a40f

Browse files
committedMay 11, 2016
Fix python bindings for QgsAttributeAction
1 parent d088fe0 commit 1e9a40f

File tree

1 file changed

+108
-2
lines changed

1 file changed

+108
-2
lines changed
 

‎python/core/qgsattributeaction.sip

Lines changed: 108 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,114 @@
1818
* *
1919
***************************************************************************/
2020

21-
/**
21+
/** \class QgsAttributeAction
2222
* QgsAttributeAction is deprecated and has been replaced with
2323
* QgsActionManager. This legacy typedef will be removed with QGIS 3.
2424
*/
25-
typedef QgsActionManager QgsAttributeAction;
25+
26+
class QgsAttributeAction
27+
{
28+
%TypeHeaderCode
29+
#include <qgsattributeaction.h>
30+
%End
31+
public:
32+
//! Constructor
33+
QgsAttributeAction( QgsVectorLayer *layer );
34+
35+
//! Destructor
36+
virtual ~QgsAttributeAction();
37+
38+
/** Add an action with the given name and action details.
39+
* Will happily have duplicate names and actions. If
40+
* capture is true, when running the action using doAction(),
41+
* any stdout from the process will be captured and displayed in a
42+
* dialog box.
43+
*/
44+
void addAction( QgsAction::ActionType type, const QString& name, const QString& action, bool capture = false );
45+
46+
/** Add an action with the given name and action details.
47+
* Will happily have duplicate names and actions. If
48+
* capture is true, when running the action using doAction(),
49+
* any stdout from the process will be captured and displayed in a
50+
* dialog box.
51+
*/
52+
void addAction( QgsAction::ActionType type, const QString& name, const QString& action, const QString& icon, bool capture = false );
53+
54+
//! Remove an action at given index
55+
void removeAction( int index );
56+
57+
/** Does the given values. defaultValueIndex is the index of the
58+
* field to be used if the action has a $currfield placeholder.
59+
* @note available in python bindings as doActionFeature
60+
*/
61+
void doAction( int index,
62+
const QgsFeature &feat,
63+
int defaultValueIndex = 0 ) /PyName=doActionFeature/;
64+
65+
/** Does the action using the expression builder to expand it
66+
* and getting values from the passed feature attribute map.
67+
* substitutionMap is used to pass custom substitutions, to replace
68+
* each key in the map with the associated value
69+
* @note available in python bindings as doActionFeatureWithSubstitution
70+
*/
71+
void doAction( int index,
72+
const QgsFeature &feat,
73+
const QMap<QString, QVariant> *substitutionMap ) /PyName=doActionFeatureWithSubstitution/;
74+
75+
//! Removes all actions
76+
void clearActions();
77+
78+
//! List all actions
79+
QList<QgsAction> listActions() const;
80+
81+
//! Return the layer
82+
QgsVectorLayer* layer() const;
83+
84+
/** Expands the given action, replacing all %'s with the value as
85+
* given.
86+
*/
87+
QString expandAction( QString action, const QMap<int, QVariant> &attributes, uint defaultValueIndex );
88+
89+
/** Expands the given action using the expression builder
90+
* This function currently replaces each expression between [% and %]
91+
* placeholders in the action with the result of its evaluation on
92+
* the feature passed as argument.
93+
*
94+
* Additional substitutions can be passed through the substitutionMap
95+
* parameter
96+
*/
97+
QString expandAction( const QString& action,
98+
QgsFeature &feat,
99+
const QMap<QString, QVariant> *substitutionMap = 0 );
100+
101+
102+
//! Writes the actions out in XML format
103+
bool writeXML( QDomNode& layer_node, QDomDocument& doc ) const;
104+
105+
//! Reads the actions in in XML format
106+
bool readXML( const QDomNode& layer_node );
107+
108+
int size() const;
109+
/**
110+
* Get the action at the specified index.
111+
*/
112+
QgsAction at( int idx ) const;
113+
/**
114+
* Get the action at the specified index.
115+
*/
116+
QgsAction operator[]( int idx ) const;
117+
118+
/** @deprecated Initialize QgsPythonRunner instead
119+
* @note not available in Python bindings
120+
*/
121+
// Q_DECL_DEPRECATED static void setPythonExecute( void ( * )( const QString & ) );
122+
123+
/**
124+
* Get the index of the default action
125+
*/
126+
int defaultAction() const;
127+
/**
128+
* Set the index of the default action
129+
*/
130+
void setDefaultAction( int actionNumber );
131+
};

0 commit comments

Comments
 (0)
Please sign in to comment.