Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
sipify QgsIdentifyMenu
  • Loading branch information
3nids committed Apr 19, 2017
1 parent e5ab2f6 commit 1341537
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 40 deletions.
1 change: 0 additions & 1 deletion python/auto_sip.blacklist
Expand Up @@ -374,7 +374,6 @@ gui/qgsgroupwmsdatadialog.sip
gui/qgshelp.sip
gui/qgshighlight.sip
gui/qgshistogramwidget.sip
gui/qgsidentifymenu.sip
gui/qgskeyvaluewidget.sip
gui/qgslistwidget.sip
gui/qgslegendfilterbutton.sip
Expand Down
142 changes: 106 additions & 36 deletions python/gui/qgsidentifymenu.sip
@@ -1,9 +1,27 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsidentifymenu.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsIdentifyMenu : QMenu
{
%TypeHeaderCode
#include <qgsidentifymenu.h>
%Docstring
The QgsIdentifyMenu class builds a menu to be used with identify results (\see QgsMapToolIdentify).
It is customizable and can display attribute actions (\see QgsAction) as well as map layer actions (\see QgsMapLayerAction).
It can also embed custom map layer actions, defined for this menu exclusively.
If used in a QgsMapToolIdentify, it is accessible via QgsMapToolIdentify.identifyMenu() and can be customized in the map tool sub-class.
%End

%TypeHeaderCode
#include "qgsidentifymenu.h"
%End
public:
enum MenuLevel
{
Expand All @@ -15,74 +33,126 @@ class QgsIdentifyMenu : QMenu
{
ActionData();

ActionData( QgsMapLayer *layer, QgsMapLayerAction *mapLayerAction = 0 );

ActionData( QgsMapLayer* layer, QgsMapLayerAction* mapLayerAction = 0 );

ActionData( QgsMapLayer* layer, QgsFeatureId fid, QgsMapLayerAction* mapLayerAction = 0 );
ActionData( QgsMapLayer *layer, QgsFeatureId fid, QgsMapLayerAction *mapLayerAction = 0 );

bool mIsValid;
bool mAllResults;
bool mIsExternalAction;
QgsMapLayer* mLayer;
QgsMapLayer *mLayer;
QgsFeatureId mFeatureId;
QgsIdentifyMenu::MenuLevel mLevel;
QgsMapLayerAction* mMapLayerAction;
QgsMapLayerAction *mMapLayerAction;
};

/**
* @brief QgsIdentifyMenu is a menu to be used to choose within a list of QgsMapTool::IdentifyReults
*/
explicit QgsIdentifyMenu( QgsMapCanvas* canvas );
explicit QgsIdentifyMenu( QgsMapCanvas *canvas );
%Docstring
QgsIdentifyMenu is a menu to be used to choose within a list of QgsMapTool.IdentifyReults
%End

~QgsIdentifyMenu();

//! define if the menu executed can return multiple results (e.g. all results or all identified features of a vector layer)
void setAllowMultipleReturn( bool multipleReturn );
%Docstring
define if the menu executed can return multiple results (e.g. all results or all identified features of a vector layer)
%End
bool allowMultipleReturn();
%Docstring
:rtype: bool
%End

//! define if the menu will be shown with a single idetify result
void setExecWithSingleResult( bool execWithSingleResult );
%Docstring
define if the menu will be shown with a single idetify result
%End
bool execWithSingleResult();
%Docstring
:rtype: bool
%End

/**
* @brief define if attribute actions(1) and map layer actions(2) can be listed and run from the menu
* @note custom actions will be shown in any case if they exist.
* @note (1) attribute actions are defined by the user in the layer properties @see QgsActionManager
* @note (2) map layer actions are built-in c++ actions or actions which are defined by a python plugin @see QgsMapLayerActionRegistry
*/
void setShowFeatureActions( bool showFeatureActions );
%Docstring
define if attribute actions(1) and map layer actions(2) can be listed and run from the menu
.. note::

custom actions will be shown in any case if they exist.
.. note::

(1) attribute actions are defined by the user in the layer properties \see QgsAction
.. note::

(2) map layer actions are built-in c++ actions or actions which are defined by a Python plugin \see QgsMapLayerActionRegistry
%End
bool showFeatureActions();
%Docstring
:rtype: bool
%End

/**
* @brief setResultsIfExternalAction if set to false (default) the menu will not return any results if an external action has been triggered
* @note external action can be either custom actions or feature / map layer actions (@see setShowFeatureActions)
*/
void setResultsIfExternalAction( bool resultsIfExternalAction );
%Docstring
setResultsIfExternalAction if set to false (default) the menu will not return any results if an external action has been triggered
.. note::

external action can be either custom actions or feature / map layer actions (\see setShowFeatureActions)
%End
bool resultsIfExternalAction();
%Docstring
:rtype: bool
%End

//! Defines the maximum number of layers displayed in the menu (default is 10).
//! @note 0 is unlimited.
void setMaxLayerDisplay( int maxLayerDisplay );
%Docstring
.. note::

0 is unlimited.

%End
int maxLayerDisplay();
%Docstring
:rtype: int
%End

//! Defines the maximum number of features displayed in the menu for vector layers (default is 10).
//! @note 0 is unlimited.
void setMaxFeatureDisplay( int maxFeatureDisplay );
%Docstring
.. note::

0 is unlimited.

%End
int maxFeatureDisplay();
%Docstring
:rtype: int
%End

//! adds a new custom action to the menu
void addCustomAction( QgsMapLayerAction* action );
void addCustomAction( QgsMapLayerAction *action );
%Docstring
adds a new custom action to the menu
%End

//! remove all custom actions from the menu to be built
void removeCustomActions();
%Docstring
remove all custom actions from the menu to be built
%End

/**
* @brief exec
* @param idResults the list of identify results to choose within
* @param pos the position where the menu will be executed
*/
QList<QgsMapToolIdentify::IdentifyResult> exec( const QList<QgsMapToolIdentify::IdentifyResult>& idResults, QPoint pos );
QList<QgsMapToolIdentify::IdentifyResult> exec( const QList<QgsMapToolIdentify::IdentifyResult> &idResults, QPoint pos );
%Docstring
exec
\param idResults the list of identify results to choose within
\param pos the position where the menu will be executed
:rtype: list of QgsMapToolIdentify.IdentifyResult
%End

protected:
virtual void closeEvent( QCloseEvent *e );

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsidentifymenu.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
9 changes: 6 additions & 3 deletions src/gui/qgsidentifymenu.h
Expand Up @@ -21,8 +21,10 @@
#include "qgsmaplayeractionregistry.h"
#include "qgsmaptoolidentify.h"
#include "qgis_gui.h"
#include "qgis.h"

/// @cond PRIVATE
#ifndef SIP_RUN
/// \cond PRIVATE
class CustomActionRegistry : public QgsMapLayerActionRegistry
{
Q_OBJECT
Expand All @@ -32,7 +34,8 @@ class CustomActionRegistry : public QgsMapLayerActionRegistry
// remove all actions
void clear() { mMapLayerActionList.clear(); }
};
///@endcond
///\endcond
#endif

/** \ingroup gui
* \brief The QgsIdentifyMenu class builds a menu to be used with identify results (\see QgsMapToolIdentify).
Expand Down Expand Up @@ -89,7 +92,7 @@ class GUI_EXPORT QgsIdentifyMenu : public QMenu
bool mIsExternalAction;
QgsMapLayer *mLayer = nullptr;
QgsFeatureId mFeatureId;
MenuLevel mLevel;
QgsIdentifyMenu::MenuLevel mLevel;
QgsMapLayerAction *mMapLayerAction = nullptr;
};

Expand Down

0 comments on commit 1341537

Please sign in to comment.