Skip to content

Commit

Permalink
Fix bindings and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Nov 16, 2016
1 parent e7d8b2c commit 08d350c
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 27 deletions.
28 changes: 28 additions & 0 deletions python/core/qgsaction.sip
Expand Up @@ -41,6 +41,20 @@ class QgsAction
//! The short title is used to label user interface elements like buttons
QString shortTitle() const;

/**
* Returns a unique id for this action.
*
* @note Added in QGIS 3.0
*/
QString id() const { return mShortTitle; }

/**
* Returns true if this action was a default constructed one.
*
* @note Added in QGIS 3.0
*/
bool isValid() const { return !mShortTitle.isNull(); }

//! The path to the icon
QString iconPath() const;

Expand All @@ -59,6 +73,20 @@ class QgsAction
//! Checks if the action is runable on the current platform
bool runable() const;

/**
* Run this action.
*
* @note Added in QGIS 3.0
*/
void run( QgsVectorLayer* layer, const QgsFeature& feature, const QgsExpressionContext& expressionContext ) const;

/**
* Run this action.
*
* @note Added in QGIS 3.0
*/
void run( const QgsExpressionContext& expressionContext ) const;

/**
* The action scopes define where an action will be available.
* Action scopes may offer additional variables like the clicked
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsactionmanager.sip
Expand Up @@ -69,7 +69,7 @@ class QgsActionManager

/** Does the action using the expression engine to replace any embedded expressions
* in the action definition.
* @param index action index
* @param actionId action id
* @param feature feature to run action for
* @param context expression context to evalute expressions under
*/
Expand Down
15 changes: 9 additions & 6 deletions python/core/qgsactionscope.sip
Expand Up @@ -25,11 +25,12 @@
* <dl>
* <dt>Canvas</dt>
* <dd>Show for canvas tools. Adds `@clicked_x` and `@clicked_y` in map coordinates.</dd>
* <dt>AttributeTable</dt>
* <dd>Show in attribute table for each row.</dd>
* <dt>FieldSpecific</dt>
* <dd>Show on right click in attribute table. Adds `@field_index` and `@field_name`.</dd>
* <dt>Selection</dt>
* <dt>Feature</dt>
* <dd>Show in feature specific places like the attribute table or feature
* form.</dd>
* <dt>Field</dt>
* <dd>Show in context menus for individual fields (e.g. attribute table). Adds `@field_index`, `@field_name` and `@field_value`.</dd>
* <dt>Layer</dt>
* <dd>Show in attribute table and work on the layer or selection.</dd>
* </dl>
*
Expand All @@ -43,7 +44,9 @@ class QgsActionScope
%End
public:
/**
* Creates a new action scope.
* Creates a new invalid action scope.
*
* @note Added in QGSI 3.0
*/
explicit QgsActionScope();

Expand Down
10 changes: 10 additions & 0 deletions python/core/qgsactionscoperegistry.sip
Expand Up @@ -35,10 +35,20 @@ class QgsActionScopeRegistry : QObject
%End

public:
/**
* Create a new QgsActionScopeRegistry.
* QGIS already creates a central registry. You will normally
* want to use QgsApplication::actionScopeRegistry() to get acess
* to that one instead.
*
* @note Added in QGIS 3.0
*/
explicit QgsActionScopeRegistry( QObject* parent = nullptr );

/**
* Get all registered action scopes.
*
* @note Added in QGIS 3.0
*/
QSet<QgsActionScope> actionScopes() const;

Expand Down
6 changes: 6 additions & 0 deletions python/core/qgsapplication.sip
Expand Up @@ -378,6 +378,12 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
//dummy method to workaround sip generation issue issue
bool x11EventFilter ( XEvent * event );
%End
/**
* Returns the action scope registry.
*
* @Note Added in QGIS 3.0
*/
static QgsActionScopeRegistry* actionScopeRegistry();

public slots:

Expand Down
2 changes: 1 addition & 1 deletion python/gui/attributetable/qgsdualview.sip
Expand Up @@ -229,7 +229,7 @@ class QgsAttributeTableAction : QAction
%End

public:
QgsAttributeTableAction( const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx );
QgsAttributeTableAction( const QString &name, QgsDualView *dualView, const QString& action, const QModelIndex &fieldIdx );

public slots:
void execute();
Expand Down
2 changes: 2 additions & 0 deletions python/gui/qgsactionmenu.sip
Expand Up @@ -35,6 +35,7 @@ class QgsActionMenu : QMenu
* @param feature The feature that this action will be run upon. Make sure that this feature is available
* for the lifetime of this object.
* @param parent The usual QWidget parent.
* @param actionScope The action scope this menu will run in
*/
explicit QgsActionMenu( QgsVectorLayer* layer, const QgsFeature& feature, const QString& actionScope, QWidget *parent /TransferThis/ = nullptr );

Expand All @@ -44,6 +45,7 @@ class QgsActionMenu : QMenu
* @param layer The layer that this action will be run upon.
* @param fid The feature id of the feature for which this action will be run.
* @param parent The usual QWidget parent.
* @param actionScope The action scope this menu will run in
*/
explicit QgsActionMenu( QgsVectorLayer *layer, const QgsFeatureId fid, const QString& actionScope, QWidget *parent /TransferThis/ = nullptr );

Expand Down
18 changes: 16 additions & 2 deletions src/core/qgsaction.h
Expand Up @@ -90,8 +90,18 @@ class CORE_EXPORT QgsAction
//! The short title is used to label user interface elements like buttons
QString shortTitle() const { return mShortTitle; }

/**
* Returns a unique id for this action.
*
* @note Added in QGIS 3.0
*/
QString id() const { return mShortTitle; }

/**
* Returns true if this action was a default constructed one.
*
* @note Added in QGIS 3.0
*/
bool isValid() const { return !mShortTitle.isNull(); }

//! The path to the icon
Expand Down Expand Up @@ -119,12 +129,16 @@ class CORE_EXPORT QgsAction
bool runable() const;

/**
* Run this expression.
* Run this action.
*
* @note Added in QGIS 3.0
*/
void run( QgsVectorLayer* layer, const QgsFeature& feature, const QgsExpressionContext& expressionContext ) const;

/**
* Run this expression.
* Run this action.
*
* @note Added in QGIS 3.0
*/
void run( const QgsExpressionContext& expressionContext ) const;

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsactionmanager.h
Expand Up @@ -84,7 +84,7 @@ class CORE_EXPORT QgsActionManager

/** Does the action using the expression engine to replace any embedded expressions
* in the action definition.
* @param index action index
* @param actionId action id
* @param feature feature to run action for
* @param context expression context to evalute expressions under
*/
Expand Down
13 changes: 8 additions & 5 deletions src/core/qgsactionscope.h
Expand Up @@ -30,15 +30,16 @@
* <dl>
* <dt>Canvas</dt>
* <dd>Show for canvas tools. Adds `@clicked_x` and `@clicked_y` in map coordinates.</dd>
* <dt>AttributeTable</dt>
* <dd>Show in attribute table for each row.</dd>
* <dt>FieldSpecific</dt>
* <dt>Feature</dt>
* <dd>Show in feature specific places like the attribute table or feature
* form.</dd>
* <dt>Field</dt>
* <dd>Show in context menus for individual fields (e.g. attribute table). Adds `@field_index`, `@field_name` and `@field_value`.</dd>
* <dt>Selection</dt>
* <dt>Layer</dt>
* <dd>Show in attribute table and work on the layer or selection.</dd>
* </dl>
*
* \since QGIS 3.0
* @note Added in QGIS 3.0
*/

class CORE_EXPORT QgsActionScope
Expand All @@ -47,6 +48,8 @@ class CORE_EXPORT QgsActionScope

/**
* Creates a new invalid action scope.
*
* @note Added in QGSI 3.0
*/
explicit QgsActionScope();

Expand Down
31 changes: 23 additions & 8 deletions src/core/qgsactionscoperegistry.h
Expand Up @@ -37,21 +37,24 @@
class CORE_EXPORT QgsActionScopeRegistry : public QObject
{
Q_OBJECT
/**
* The action scopes which are currently registered and available.
*
* \read actionScopes()
* \notify actionScopesChanged()
*
* \since QGIS 3.0
*/
Q_PROPERTY( QSet<QgsActionScope> actionScopes READ actionScopes NOTIFY actionScopesChanged )

public:

/**
* Create a new QgsActionScopeRegistry.
* QGIS already creates a central registry. You will normally
* want to use QgsApplication::actionScopeRegistry() to get acess
* to that one instead.
*
* @note Added in QGIS 3.0
*/
explicit QgsActionScopeRegistry( QObject* parent = nullptr );

/**
* Get all registered action scopes.
*
* @note Added in QGIS 3.0
*/
QSet<QgsActionScope> actionScopes() const;

Expand All @@ -69,9 +72,21 @@ class CORE_EXPORT QgsActionScopeRegistry : public QObject
*/
void unregisterActionScope( const QgsActionScope& actionScope );

/**
* Get an action scope by its id.
*
* @note Added in QGIS 3.0
*/
QgsActionScope actionScope( const QString& id );

signals:

/**
* Emitted whenever a new action scope is registered or an action scope
* is unregistered.
*
* @note Added in QGIS 3.0
*/
void actionScopesChanged();

private:
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsapplication.h
Expand Up @@ -376,6 +376,8 @@ class CORE_EXPORT QgsApplication : public QApplication

/**
* Returns the action scope registry.
*
* @Note Added in QGIS 3.0
*/
static QgsActionScopeRegistry* actionScopeRegistry();

Expand Down
8 changes: 5 additions & 3 deletions src/gui/qgsactionmenu.h
Expand Up @@ -62,6 +62,7 @@ class GUI_EXPORT QgsActionMenu : public QMenu
* @param feature The feature that this action will be run upon. Make sure that this feature is available
* for the lifetime of this object.
* @param parent The usual QWidget parent.
* @param actionScope The action scope this menu will run in
*/
explicit QgsActionMenu( QgsVectorLayer* layer, const QgsFeature& feature, const QString& actionScope, QWidget *parent = nullptr );

Expand All @@ -71,6 +72,7 @@ class GUI_EXPORT QgsActionMenu : public QMenu
* @param layer The layer that this action will be run upon.
* @param fid The feature id of the feature for which this action will be run.
* @param parent The usual QWidget parent.
* @param actionScope The action scope this menu will run in
*/
explicit QgsActionMenu( QgsVectorLayer *layer, const QgsFeatureId fid, const QString& actionScope, QWidget *parent = nullptr );

Expand All @@ -87,13 +89,13 @@ class GUI_EXPORT QgsActionMenu : public QMenu
*/
void setFeature( const QgsFeature& feature );

signals:
void reinit();

private slots:
void triggerAction();
void reloadActions();

signals:
void reinit();

private:
void init();
QgsFeature feature();
Expand Down

0 comments on commit 08d350c

Please sign in to comment.