-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqgsfeatureaction.h
117 lines (97 loc) · 4.1 KB
/
qgsfeatureaction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/***************************************************************************
qgsfeatureaction.h - description
------------------
begin : 2010-09-20
copyright : (C) 2010 by Jürgen E. Fischer
email : jef at norbit dot de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSFEATUREACTION_H
#define QGSFEATUREACTION_H
#include "qgsfeature.h"
#include <QList>
#include <QPair>
#include <QAction>
#include <QUuid>
#include <QPointer>
#include "qgis_app.h"
#include "qgshighlight.h"
class QgsIdentifyResultsDialog;
class QgsVectorLayer;
class QgsAttributeDialog;
class QgsExpressionContextScope;
class APP_EXPORT QgsFeatureAction : public QAction
{
Q_OBJECT
public:
QgsFeatureAction( const QString &name, QgsFeature &f, QgsVectorLayer *vl, QUuid actionId = QUuid(), int defaultAttr = -1, QObject *parent = nullptr );
enum class AddFeatureResult
{
Success = 0,
LayerStateError = 1,
Canceled = 2,
Pending = 3,
FeatureError = 4
};
/**
* Add a new feature to the layer.
* Will set the default values to recently used or provider defaults based on settings
* and override with values in defaultAttributes if provided.
*
* \param defaultAttributes Provide some default attributes here if desired.
* \param scope Scope of the expression
* \param showModal If the used dialog should be modal or not
* \param hideParent If the parent widget should be hidden, when the used dialog is opened
* \param highlight Optional canvas highlight for feature
*
* \returns result if feature was added if showModal is true. If showModal is FALSE, returns Pending in every case
*/
AddFeatureResult addFeature( const QgsAttributeMap &defaultAttributes = QgsAttributeMap(),
bool showModal = true,
std::unique_ptr<QgsExpressionContextScope >scope = std::unique_ptr< QgsExpressionContextScope >(),
bool hideParent = false,
std::unique_ptr<QgsHighlight> highlight = std::unique_ptr<QgsHighlight>() );
public slots:
void execute();
bool viewFeatureForm( QgsHighlight *h = nullptr );
bool editFeature( bool showModal = true );
/**
* Sets whether to force suppression of the attribute form popup after creating a new feature.
* If \a force is TRUE, then regardless of any user settings, form settings, etc, the attribute
* form will ALWAYS be suppressed.
*/
void setForceSuppressFormPopup( bool force );
/**
* Returns the added feature or invalid feature in case addFeature() was not successful.
*/
QgsFeature feature() const;
signals:
/**
* This signal is emitted when the add feature process is finished.
* Either during the call to addFeature() already or when the dialog is eventually
* closed (accepted or canceled).
*
* \since QGIS 3.8
*/
void addFeatureFinished();
private slots:
void onFeatureSaved( const QgsFeature &feature );
void unhideParentWidget();
void hideParentWidget();
private:
QgsAttributeDialog *newDialog( bool cloneFeature );
QgsVectorLayer *mLayer = nullptr;
QgsFeature *mFeature = nullptr;
QUuid mActionId;
int mIdx;
bool mFeatureSaved;
bool mForceSuppressFormPopup = false;
};
#endif