QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
editform
qgsattributeeditoraction.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsattributeeditoraction.cpp - QgsAttributeEditorAction
3
4
---------------------
5
begin : 14.8.2021
6
copyright : (C) 2021 by Alessandro Pasotti
7
email : elpaso at itopen dot it
8
***************************************************************************
9
* *
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
14
* *
15
***************************************************************************/
16
#include "
qgsattributeeditoraction.h
"
17
18
#include "
qgsactionmanager.h
"
19
#include "
qgsvectorlayer.h
"
20
21
#include <QString>
22
23
using namespace
Qt::StringLiterals;
24
25
QgsAttributeEditorAction::QgsAttributeEditorAction
(
const
QgsAction
&
action
,
QgsAttributeEditorElement
*
parent
)
26
:
QgsAttributeEditorElement
(
Qgis
::AttributeEditorType::Action,
action
.id().toString(),
parent
)
27
, mAction(
action
)
28
, mUuid(
action
.id() )
29
{}
30
31
QgsAttributeEditorAction::QgsAttributeEditorAction
(
const
QUuid &uuid,
QgsAttributeEditorElement
*
parent
)
32
:
QgsAttributeEditorAction
(
QgsAction
(),
parent
)
33
{
34
mUuid = uuid;
35
}
36
37
QgsAttributeEditorElement
*
QgsAttributeEditorAction::clone
(
QgsAttributeEditorElement
*
parent
)
const
38
{
39
QgsAttributeEditorAction
*element =
new
QgsAttributeEditorAction
( mAction,
parent
);
40
element->mUuid = mUuid;
41
return
element;
42
}
43
44
const
QgsAction
&
QgsAttributeEditorAction::action
(
const
QgsVectorLayer
*layer )
const
45
{
46
// Lazy loading
47
if
( !mAction.isValid() && !mUuid.isNull() && layer )
48
{
49
mAction = layer->
actions
()->
action
( mUuid );
50
}
51
return
mAction;
52
}
53
54
void
QgsAttributeEditorAction::setAction
(
const
QgsAction
&newAction )
55
{
56
mUuid = newAction.
id
();
57
mAction = newAction;
58
}
59
60
QString QgsAttributeEditorAction::typeIdentifier()
const
61
{
62
return
u
"attributeEditorAction"
_s;
63
}
64
65
void
QgsAttributeEditorAction::saveConfiguration( QDomElement &elem, QDomDocument &doc )
const
66
{
67
Q_UNUSED( doc )
68
elem.setAttribute( u
"ActionUUID"
_s, mUuid.toString() );
69
}
70
71
void
QgsAttributeEditorAction::loadConfiguration(
const
QDomElement &element,
const
QString &layerId,
const
QgsReadWriteContext
&context,
const
QgsFields
&fields )
72
{
73
Q_UNUSED( layerId )
74
Q_UNUSED( context )
75
Q_UNUSED( fields )
76
mUuid = QUuid( element.attribute( u
"ActionUUID"
_s ) );
77
}
Qgis
Provides global constants and enumerations for use throughout the application.
Definition
qgis.h:62
QgsActionManager::action
QgsAction action(QUuid id) const
Gets an action by its id.
Definition
qgsactionmanager.cpp:298
QgsAction
Utility class that encapsulates an action based on vector attributes.
Definition
qgsaction.h:38
QgsAction::id
QUuid id() const
Returns a unique id for this action.
Definition
qgsaction.h:145
QgsAttributeEditorAction::action
const QgsAction & action(const QgsVectorLayer *layer) const
Returns the (possibly lazy loaded) action for the given layer.
Definition
qgsattributeeditoraction.cpp:44
QgsAttributeEditorAction::QgsAttributeEditorAction
QgsAttributeEditorAction(const QgsAction &action, QgsAttributeEditorElement *parent)
Creates a new element which can display a layer action.
Definition
qgsattributeeditoraction.cpp:25
QgsAttributeEditorAction::clone
QgsAttributeEditorElement * clone(QgsAttributeEditorElement *parent) const override
Returns a clone of this element.
Definition
qgsattributeeditoraction.cpp:37
QgsAttributeEditorAction::setAction
void setAction(const QgsAction &newAction)
Set the action to newAction.
Definition
qgsattributeeditoraction.cpp:54
QgsAttributeEditorElement::parent
QgsAttributeEditorElement * parent() const
Gets the parent of this element.
Definition
qgsattributeeditorelement.h:148
QgsAttributeEditorElement::QgsAttributeEditorElement
QgsAttributeEditorElement(Qgis::AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent=nullptr)
Constructor.
Definition
qgsattributeeditorelement.h:113
QgsFields
Container of fields for a vector layer.
Definition
qgsfields.h:45
QgsReadWriteContext
A container for the context for various read/write operations on objects.
Definition
qgsreadwritecontext.h:38
QgsVectorLayer
Represents a vector layer which manages a vector based dataset.
Definition
qgsvectorlayer.h:414
QgsVectorLayer::actions
QgsActionManager * actions()
Returns all layer actions defined on this layer.
Definition
qgsvectorlayer.h:791
qgsactionmanager.h
qgsattributeeditoraction.h
qgsvectorlayer.h
Generated on
for QGIS API Documentation by
1.17.0