QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
qgsidentifymenu.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsidentifymenu.h - menu to be used in identify map tool
3
---------------------
4
begin : August 2014
5
copyright : (C) 2014 by Denis Rouzaud
6
email : denis.rouzaud@gmail.com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#ifndef QGSIDENTIFYMENU_H
17
#define QGSIDENTIFYMENU_H
18
19
#include "qgis_gui.h"
20
#include "
qgis_sip.h
"
21
#include "
qgsexpressioncontext.h
"
22
#include "
qgsmaplayeractionregistry.h
"
23
#include "
qgsmaptoolidentify.h
"
24
25
#include <QMenu>
26
27
#ifndef SIP_RUN
29
class
CustomActionRegistry :
public
QgsMapLayerActionRegistry
30
{
31
Q_OBJECT
32
33
public
:
34
#include "
qgsmaplayeractionregistry.h
"
35
CustomActionRegistry() =
default
;
36
// remove all actions
37
void
clear() { mMapLayerActionList.clear(); }
38
};
40
#endif
41
52
class
GUI_EXPORT
QgsIdentifyMenu
:
public
QMenu
53
{
54
Q_OBJECT
55
56
public
:
57
enum
MenuLevel
58
{
59
LayerLevel
,
60
FeatureLevel
61
};
62
63
struct
ActionData
64
{
65
ActionData
() =
default
;
66
67
ActionData
(
QgsMapLayer
*layer,
QgsMapLayerAction
*mapLayerAction =
nullptr
)
68
:
mIsValid
( true )
69
,
mAllResults
( !layer )
70
,
mIsExternalAction
( nullptr != mapLayerAction )
71
,
mLayer
( layer )
72
,
mMapLayerAction
( mapLayerAction )
73
{}
74
75
ActionData
(
QgsMapLayer
*layer,
QgsFeatureId
fid,
QgsMapLayerAction
*mapLayerAction =
nullptr
)
76
:
mIsValid
( true )
77
,
mIsExternalAction
( nullptr != mapLayerAction )
78
,
mLayer
( layer )
79
,
mFeatureId
( fid )
80
,
mLevel
(
FeatureLevel
)
81
,
mMapLayerAction
( mapLayerAction )
82
{}
83
84
bool
mIsValid
=
false
;
85
bool
mAllResults
=
false
;
86
bool
mIsExternalAction
=
false
;
87
QgsMapLayer
*
mLayer
=
nullptr
;
88
QgsFeatureId
mFeatureId
= 0;
89
QgsIdentifyMenu::MenuLevel
mLevel
=
LayerLevel
;
90
QgsMapLayerAction
*
mMapLayerAction
=
nullptr
;
91
};
92
96
explicit
QgsIdentifyMenu
(
QgsMapCanvas
*canvas );
97
98
~QgsIdentifyMenu
()
override
;
99
100
111
static
QList<QgsMapToolIdentify::IdentifyResult>
findFeaturesOnCanvas
(
QgsMapMouseEvent
*event,
QgsMapCanvas
*canvas,
const
QList<Qgis::GeometryType> &geometryTypes );
112
114
void
setAllowMultipleReturn
(
bool
multipleReturn ) { mAllowMultipleReturn = multipleReturn; }
115
bool
allowMultipleReturn
() {
return
mAllowMultipleReturn; }
116
118
void
setExecWithSingleResult
(
bool
execWithSingleResult
) { mExecWithSingleResult =
execWithSingleResult
; }
119
bool
execWithSingleResult
() {
return
mExecWithSingleResult; }
120
125
void
setExpressionContextScope(
const
QgsExpressionContextScope
&scope );
126
131
QgsExpressionContextScope
expressionContextScope()
const
;
132
139
void
setShowFeatureActions
(
bool
showFeatureActions
) { mShowFeatureActions =
showFeatureActions
; }
140
bool
showFeatureActions
() {
return
mShowFeatureActions; }
141
146
void
setResultsIfExternalAction
(
bool
resultsIfExternalAction
) { mResultsIfExternalAction =
resultsIfExternalAction
; }
147
bool
resultsIfExternalAction
() {
return
mResultsIfExternalAction; }
148
153
void
setMaxLayerDisplay(
int
maxLayerDisplay );
154
int
maxLayerDisplay
() {
return
mMaxLayerDisplay; }
155
160
void
setMaxFeatureDisplay(
int
maxFeatureDisplay );
161
int
maxFeatureDisplay
() {
return
mMaxFeatureDisplay; }
162
164
void
addCustomAction
(
QgsMapLayerAction
*action ) { mCustomActionRegistry.addMapLayerAction( action ); }
165
167
void
removeCustomActions();
168
174
QList<QgsMapToolIdentify::IdentifyResult> exec(
const
QList<QgsMapToolIdentify::IdentifyResult> &idResults, QPoint pos );
175
181
Q_DECL_DEPRECATED
static
void
styleHighlight(
QgsHighlight
*highlight )
SIP_DEPRECATED
;
182
183
signals:
184
191
void
messageEmitted
(
const
QString &message,
Qgis::MessageLevel
level =
Qgis::MessageLevel::Info
);
192
199
void
messageDiscarded
();
200
201
protected
:
202
void
closeEvent
( QCloseEvent *e )
override
;
203
204
private
slots:
205
void
handleMenuHover();
206
void
deleteRubberBands();
207
void
layerDestroyed();
208
void
triggerMapLayerAction();
209
210
private
:
212
void
addRasterLayer(
QgsMapLayer
*layer );
213
218
void
addVectorLayer(
QgsVectorLayer
*layer,
const
QList<QgsMapToolIdentify::IdentifyResult> &results,
bool
singleLayer =
false
);
219
221
QList<QgsMapToolIdentify::IdentifyResult> results( QAction *action,
bool
&externalAction );
222
223
QgsMapCanvas
*mCanvas =
nullptr
;
224
QList<QgsHighlight *> mRubberBands;
225
bool
mAllowMultipleReturn =
true
;
226
bool
mExecWithSingleResult =
false
;
227
bool
mShowFeatureActions =
false
;
228
bool
mResultsIfExternalAction =
false
;
229
int
mMaxLayerDisplay = 10;
230
int
mMaxFeatureDisplay = 10;
231
232
QgsExpressionContextScope
mExpressionContextScope;
233
234
// name of the action to be displayed for feature default action, if other actions are shown
235
QString mDefaultActionName;
236
237
// custom menu actions regirstry
238
CustomActionRegistry mCustomActionRegistry;
239
240
// map layers with their results, this is the odering of the menu
241
QMap<QgsMapLayer *, QList<QgsMapToolIdentify::IdentifyResult>> mLayerIdResults;
242
};
243
244
Q_DECLARE_METATYPE
(
QgsIdentifyMenu::ActionData
)
245
246
#endif
// QGSIDENTIFYMENU_H
Qgis::MessageLevel
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition
qgis.h:160
Qgis::Info
@ Info
Information message.
Definition
qgis.h:161
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext.
Definition
qgsexpressioncontext.h:119
QgsHighlight
Highlights features on the map.
Definition
qgshighlight.h:63
QgsIdentifyMenu::execWithSingleResult
bool execWithSingleResult()
Definition
qgsidentifymenu.h:119
QgsIdentifyMenu::allowMultipleReturn
bool allowMultipleReturn()
Definition
qgsidentifymenu.h:115
QgsIdentifyMenu::setAllowMultipleReturn
void setAllowMultipleReturn(bool multipleReturn)
define if the menu executed can return multiple results (e.g. all results or all identified features ...
Definition
qgsidentifymenu.h:114
QgsIdentifyMenu::setResultsIfExternalAction
void setResultsIfExternalAction(bool resultsIfExternalAction)
setResultsIfExternalAction if set to false (default) the menu will not return any results if an exter...
Definition
qgsidentifymenu.h:146
QgsIdentifyMenu::addCustomAction
void addCustomAction(QgsMapLayerAction *action)
adds a new custom action to the menu
Definition
qgsidentifymenu.h:164
QgsIdentifyMenu::QgsIdentifyMenu
QgsIdentifyMenu(QgsMapCanvas *canvas)
QgsIdentifyMenu is a menu to be used to choose within a list of QgsMapTool::IdentifyReults.
Definition
qgsidentifymenu.cpp:39
QgsIdentifyMenu::setShowFeatureActions
void setShowFeatureActions(bool showFeatureActions)
define if attribute actions(1) and map layer actions(2) can be listed and run from the menu
Definition
qgsidentifymenu.h:139
QgsIdentifyMenu::messageDiscarded
void messageDiscarded()
Emitted when the previous message from the tool should be cleared from the application message bar.
QgsIdentifyMenu::setExecWithSingleResult
void setExecWithSingleResult(bool execWithSingleResult)
define if the menu will be shown with a single identify result
Definition
qgsidentifymenu.h:118
QgsIdentifyMenu::closeEvent
void closeEvent(QCloseEvent *e) override
Definition
qgsidentifymenu.cpp:227
QgsIdentifyMenu::findFeaturesOnCanvas
static QList< QgsMapToolIdentify::IdentifyResult > findFeaturesOnCanvas(QgsMapMouseEvent *event, QgsMapCanvas *canvas, const QList< Qgis::GeometryType > &geometryTypes)
Searches for features on the map canvas, which are located at the specified event point.
Definition
qgsidentifymenu.cpp:50
QgsIdentifyMenu::showFeatureActions
bool showFeatureActions()
Definition
qgsidentifymenu.h:140
QgsIdentifyMenu::MenuLevel
MenuLevel
Definition
qgsidentifymenu.h:58
QgsIdentifyMenu::LayerLevel
@ LayerLevel
Definition
qgsidentifymenu.h:59
QgsIdentifyMenu::FeatureLevel
@ FeatureLevel
Definition
qgsidentifymenu.h:60
QgsIdentifyMenu::maxFeatureDisplay
int maxFeatureDisplay()
Definition
qgsidentifymenu.h:161
QgsIdentifyMenu::maxLayerDisplay
int maxLayerDisplay()
Definition
qgsidentifymenu.h:154
QgsIdentifyMenu::resultsIfExternalAction
bool resultsIfExternalAction()
Definition
qgsidentifymenu.h:147
QgsIdentifyMenu::messageEmitted
void messageEmitted(const QString &message, Qgis::MessageLevel level=Qgis::MessageLevel::Info)
Emitted when a message should be shown to the user in the application message bar.
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition
qgsmapcanvas.h:96
QgsMapLayerActionRegistry
A registry which tracks map layer actions.
Definition
qgsmaplayeractionregistry.h:41
QgsMapLayerAction
An action which can run on map layers.
Definition
qgsmaplayeraction.h:44
QgsMapLayer
Base class for all map layer types.
Definition
qgsmaplayer.h:83
QgsMapMouseEvent
A mouse event which is the result of a user interaction with a QgsMapCanvas.
Definition
qgsmapmouseevent.h:38
QgsVectorLayer
Represents a vector layer which manages a vector based dataset.
Definition
qgsvectorlayer.h:414
qgis_sip.h
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition
qgis_sip.h:113
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
qgsexpressioncontext.h
QgsFeatureId
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition
qgsfeatureid.h:32
qgsmaplayeractionregistry.h
qgsmaptoolidentify.h
QgsIdentifyMenu::ActionData
Definition
qgsidentifymenu.h:64
QgsIdentifyMenu::ActionData::mLevel
QgsIdentifyMenu::MenuLevel mLevel
Definition
qgsidentifymenu.h:89
QgsIdentifyMenu::ActionData::ActionData
ActionData(QgsMapLayer *layer, QgsMapLayerAction *mapLayerAction=nullptr)
Definition
qgsidentifymenu.h:67
QgsIdentifyMenu::ActionData::mIsValid
bool mIsValid
Definition
qgsidentifymenu.h:84
QgsIdentifyMenu::ActionData::mFeatureId
QgsFeatureId mFeatureId
Definition
qgsidentifymenu.h:88
QgsIdentifyMenu::ActionData::mAllResults
bool mAllResults
Definition
qgsidentifymenu.h:85
QgsIdentifyMenu::ActionData::ActionData
ActionData()=default
QgsIdentifyMenu::ActionData::mMapLayerAction
QgsMapLayerAction * mMapLayerAction
Definition
qgsidentifymenu.h:90
QgsIdentifyMenu::ActionData::mLayer
QgsMapLayer * mLayer
Definition
qgsidentifymenu.h:87
QgsIdentifyMenu::ActionData::mIsExternalAction
bool mIsExternalAction
Definition
qgsidentifymenu.h:86
QgsIdentifyMenu::ActionData::ActionData
ActionData(QgsMapLayer *layer, QgsFeatureId fid, QgsMapLayerAction *mapLayerAction=nullptr)
Definition
qgsidentifymenu.h:75
Generated on
for QGIS API Documentation by
1.17.0