Skip to content

Commit 2b2066a

Browse files
committedSep 17, 2014
[SIP] add QgsIdentifyMenu
1 parent c5d3be5 commit 2b2066a

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed
 

‎python/gui/gui.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
%Include qgsformannotationitem.sip
5959
%Include qgsgenericprojectionselector.sip
6060
%Include qgshtmlannotationitem.sip
61+
%Include qgsidentifymenu.sip
6162
%Include qgslegendinterface.sip
6263
%Include qgspluginmanagerinterface.sip
6364
%Include qgslonglongvalidator.sip

‎python/gui/qgsidentifymenu.sip

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
class QgsIdentifyMenu : QMenu
2+
{
3+
%TypeHeaderCode
4+
#include <qgsidentifymenu.h>
5+
%End
6+
7+
public:
8+
enum MenuLevel
9+
{
10+
LayerLevel,
11+
FeatureLevel
12+
};
13+
14+
struct ActionData
15+
{
16+
ActionData();
17+
18+
19+
ActionData( QgsMapLayer* layer, QgsMapLayerAction* mapLayerAction = 0 );
20+
21+
ActionData( QgsMapLayer* layer, QgsFeatureId fid, QgsMapLayerAction* mapLayerAction = 0 );
22+
23+
bool mIsValid;
24+
bool mAllResults;
25+
bool mIsExternalAction;
26+
QgsMapLayer* mLayer;
27+
QgsFeatureId mFeatureId;
28+
MenuLevel mLevel;
29+
QgsMapLayerAction* mMapLayerAction;
30+
};
31+
32+
/**
33+
* @brief QgsIdentifyMenu is a menu to be used to choose within a list of QgsMapTool::IdentifyReults
34+
*/
35+
explicit QgsIdentifyMenu( QgsMapCanvas* canvas );
36+
37+
~QgsIdentifyMenu();
38+
39+
//! define if the menu executed can return multiple results (e.g. all results or all identified features of a vector layer)
40+
void setAllowMultipleReturn( bool multipleReturn );
41+
bool allowMultipleReturn();
42+
43+
//! define if the menu will be shown with a single idetify result
44+
void setExecWithSingleResult( bool execWithSingleResult );
45+
bool execWithSingleResult();
46+
47+
/**
48+
* @brief define if attribute actions(1) and map layer actions(2) can be listed and run from the menu
49+
* @note custom actions will be shown in any case if they exist.
50+
* @note (1) attribute actions are defined by the user in the layer properties @see QgsAttributeAction
51+
* @note (2) map layer actions are built-in c++ actions or actions which are defined by a python plugin @see QgsMapLayerActionRegistry
52+
*/
53+
void setShowFeatureActions( bool showFeatureActions );
54+
bool showFeatureActions();
55+
56+
/**
57+
* @brief setResultsIfExternalAction if set to false (default) the menu will not return any results if an external action has been triggered
58+
* @note external action can be either custom actions or feature / map layer actions (@see setShowFeatureActions)
59+
*/
60+
void setResultsIfExternalAction( bool resultsIfExternalAction );
61+
bool resultsIfExternalAction();
62+
63+
//! Defines the maximimum number of layers displayed in the menu (default is 10).
64+
//! @note 0 is unlimited.
65+
void setMaxLayerDisplay( int maxLayerDisplay );
66+
int maxLayerDisplay();
67+
68+
//! Defines the maximimum number of features displayed in the menu for vector layers (default is 10).
69+
//! @note 0 is unlimited.
70+
void setMaxFeatureDisplay( int maxFeatureDisplay );
71+
int maxFeatureDisplay();
72+
73+
//! adds a new custom action to the menu
74+
void addCustomAction( QgsMapLayerAction* action );
75+
76+
//! remove all custom actions from the menu to be built
77+
void removeCustomActions();
78+
79+
/**
80+
* @brief exec
81+
* @param idResults the list of identify results to choose within
82+
* @param pos the position where the menu will be executed
83+
* @param selectedAction if specified, this will allow to know which action has been triggered
84+
*/
85+
QList<QgsMapToolIdentify::IdentifyResult> exec( const QList<QgsMapToolIdentify::IdentifyResult> idResults, QPoint pos );
86+
};

0 commit comments

Comments
 (0)
Please sign in to comment.