-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqgsfeatureaction.h
72 lines (58 loc) · 2.52 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
/***************************************************************************
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 "qgis_app.h"
class QgsIdentifyResultsDialog;
class QgsVectorLayer;
class QgsHighlight;
class QgsAttributeDialog;
class APP_EXPORT QgsFeatureAction : public QAction
{
Q_OBJECT
public:
QgsFeatureAction( const QString &name, QgsFeature &f, QgsVectorLayer *vl, const QUuid &actionId = QString(), int defaultAttr = -1, QObject *parent = nullptr );
public slots:
void execute();
bool viewFeatureForm( QgsHighlight *h = nullptr );
bool editFeature( bool showModal = true );
/**
* 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.
*
* @return true if feature was added if showModal is true. If showModal is false, returns true in every case
*/
bool addFeature( const QgsAttributeMap &defaultAttributes = QgsAttributeMap(), bool showModal = true );
private slots:
void onFeatureSaved( const QgsFeature &feature );
private:
QgsAttributeDialog *newDialog( bool cloneFeature );
QgsVectorLayer *mLayer = nullptr;
QgsFeature *mFeature = nullptr;
QUuid mActionId;
int mIdx;
bool mFeatureSaved;
static QHash<QgsVectorLayer *, QgsAttributeMap> sLastUsedValues;
};
#endif