@@ -54,6 +54,11 @@ class QgsActionManager
54
54
*/
55
55
void addAction( QgsAction::ActionType type, const QString& name, const QString& action, const QString& icon, bool capture = false );
56
56
57
+ /**
58
+ * Add a new action to this list.
59
+ */
60
+ void addAction( const QgsAction& action );
61
+
57
62
//! Remove an action at given index
58
63
void removeAction( int index );
59
64
@@ -65,6 +70,20 @@ class QgsActionManager
65
70
const QgsFeature &feat,
66
71
int defaultValueIndex = 0 ) /PyName=doActionFeature/;
67
72
73
+ /** Does the action using the expression engine to replace any embedded expressions
74
+ * in the action definition.
75
+ * @param index action index
76
+ * @param feature feature to run action for
77
+ * @param context expression context to evalute expressions under
78
+ * @param substitutionMap deprecated - kept for compatibilty with projects, will be removed for 3.0
79
+ */
80
+ // TODO QGIS 3.0 remove substition map - force use of expression variables
81
+ void doAction( int index,
82
+ const QgsFeature& feature,
83
+ const QgsExpressionContext& context,
84
+ const QMap<QString, QVariant> *substitutionMap = nullptr );
85
+
86
+
68
87
/** Does the action using the expression builder to expand it
69
88
* and getting values from the passed feature attribute map.
70
89
* substitutionMap is used to pass custom substitutions, to replace
@@ -86,8 +105,9 @@ class QgsActionManager
86
105
87
106
/** Expands the given action, replacing all %'s with the value as
88
107
* given.
108
+ * @deprecated use QgsExpression::replaceExpressionText() instead
89
109
*/
90
- QString expandAction( QString action, const QMap<int, QVariant> &attributes, uint defaultValueIndex );
110
+ QString expandAction( QString action, const QMap<int, QVariant> &attributes, uint defaultValueIndex ) /Deprecated/ ;
91
111
92
112
/** Expands the given action using the expression builder
93
113
* This function currently replaces each expression between [% and %]
@@ -96,10 +116,11 @@ class QgsActionManager
96
116
*
97
117
* Additional substitutions can be passed through the substitutionMap
98
118
* parameter
119
+ * @deprecated use QgsExpression::replaceExpressionText() instead
99
120
*/
100
121
QString expandAction( const QString& action,
101
122
QgsFeature &feat,
102
- const QMap<QString, QVariant> *substitutionMap = 0 );
123
+ const QMap<QString, QVariant> *substitutionMap = 0 ) /Deprecated/ ;
103
124
104
125
105
126
//! Writes the actions out in XML format
@@ -112,23 +133,50 @@ class QgsActionManager
112
133
/**
113
134
* Get the action at the specified index.
114
135
*/
115
- QgsAction at( int idx ) const;
136
+ QgsAction at( int idx ) const /Factory/;
137
+ %MethodCode
138
+ if ( a0 < 0 || a0 >= sipCpp->size() )
139
+ {
140
+ PyErr_SetString(PyExc_KeyError, QByteArray::number(a0));
141
+ sipIsErr = 1;
142
+ }
143
+ else
144
+ {
145
+ sipRes = new QgsAction( sipCpp->at( a0 ) );
146
+ }
147
+ %End
148
+
116
149
/**
117
150
* Get the action at the specified index.
118
151
*/
119
152
QgsAction operator[]( int idx ) const;
153
+ %MethodCode
154
+ if ( a0 < 0 || a0 >= sipCpp->size() )
155
+ {
156
+ PyErr_SetString(PyExc_KeyError, QByteArray::number(a0));
157
+ sipIsErr = 1;
158
+ }
159
+ else
160
+ {
161
+ sipRes = new QgsAction( sipCpp->at( a0 ) );
162
+ }
163
+ %End
120
164
121
165
/** @deprecated Initialize QgsPythonRunner instead
122
166
* @note not available in Python bindings
123
167
*/
124
168
// Q_DECL_DEPRECATED static void setPythonExecute( void ( * )( const QString & ) );
125
169
126
170
/**
127
- * Get the index of the default action
171
+ * Returns the index of the default action, or -1 if no default action is available.
172
+ * @see setDefaultAction()
128
173
*/
129
174
int defaultAction() const;
175
+
130
176
/**
131
- * Set the index of the default action
177
+ * Set the index of the default action.
178
+ * @param actionNumber index of action which should be made the default for the layer
179
+ * @see defaultAction()
132
180
*/
133
181
void setDefaultAction( int actionNumber );
134
182
};
0 commit comments