QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgsattributesformproperties.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsattributesformproperties.h
3 ---------------------
4 begin : August 2017
5 copyright : (C) 2017 by David Signer
6 email : david at opengis dot ch
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 QGSATTRIBUTESFORMPROPERTIES_H
17#define QGSATTRIBUTESFORMPROPERTIES_H
18
19// We don't want to expose this in the public API
20#define SIP_NO_FILE
21
22#include "ui_qgsattributesformproperties.h"
23
24#include "qgis_gui.h"
25#include "qgsaction.h"
28#include "qgsmessagebar.h"
30#include "qgssettingstree.h"
31#include "qgssettingstreenode.h"
32
33#include <QAction>
34#include <QClipboard>
35#include <QDropEvent>
36#include <QFileDialog>
37#include <QFormLayout>
38#include <QHBoxLayout>
39#include <QMenu>
40#include <QMessageBox>
41#include <QMimeData>
42#include <QPlainTextEdit>
43#include <QPushButton>
44#include <QSpinBox>
45#include <QString>
46#include <QTreeView>
47#include <QWidget>
48
49using namespace Qt::StringLiterals;
50
51class QgsAttributeFormContainerEdit;
52class QgsAttributeTypeDialog;
53class QgsAttributeWidgetEdit;
58
66class GUI_EXPORT QgsAttributesFormProperties : public QWidget, public QgsExpressionContextGenerator, private Ui_QgsAttributesFormProperties
67{
68 Q_OBJECT
69
70 public:
71 static inline QgsSettingsTreeNode *sTreeAttributesForm = QgsSettingsTree::sTreeApp->createChildNode( u"attributes-form"_s );
73
80 explicit QgsAttributesFormProperties( QgsVectorLayer *layer, QWidget *parent = nullptr, QgsSourceFieldsProperties *sourceFieldsProperties = nullptr );
81
82 void init();
83
87 void apply();
88
93 void store();
94
96
101
105 void initFormLayoutView();
106
107 void initLayoutConfig();
108 void initInitPython();
109 void initSuppressCombo();
110
116 void initAvailableWidgetsActions( const QList< QgsAction > actions );
117
119
120 protected:
122
124
127
128 QgsAttributeWidgetEdit *mAttributeWidgetEdit = nullptr;
129 QgsAttributeTypeDialog *mAttributeTypeDialog = nullptr;
130 QgsAttributeFormContainerEdit *mAttributeContainerEdit = nullptr;
131 QLabel *mInfoTextWidget = nullptr;
132
133 private slots:
134 void addContainer();
135 void removeTabOrGroupButton();
136 void mEditorLayoutComboBox_currentIndexChanged( int index );
137 void pbnSelectEditForm_clicked();
138 void mTbInitCode_clicked();
139 void toggleShowAliases( bool checked );
140
144 void onInvertSelectionButtonClicked( bool checked );
145
146 void loadAttributeSpecificEditor( QgsAttributesFormBaseView *emitter, QgsAttributesFormBaseView *receiver, QModelIndex &deselectedFormLayoutIndex );
147 void onAttributeSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
148 void onFormLayoutSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
149
151 void onContextMenuRequested( QPoint );
152
153 void updatedFields();
154
155 void updateFilteredItems( const QString &filterText );
156
157 void previewForm();
158
159 private:
161 void clearAttributeTypeFrame();
162
163 void loadAttributeWidgetEdit();
164
168 void storeAttributeWidgetEdit();
169
173 void storeAttributeContainerEdit();
174
176 void storeAttributeWidgetEdit( const QModelIndex &index );
177 void storeAttributeContainerEdit( const QModelIndex &index );
178
179 void loadAttributeTypeDialog();
180 void loadAttributeTypeDialogFromConfiguration( const QgsAttributesFormData::FieldConfig &cfg );
181 void storeAttributeTypeDialog();
182
183 void loadAttributeContainerEdit();
184
185 void loadInfoWidget( const QString &infoText );
186
187 void copyWidgetConfiguration();
188 void pasteWidgetConfiguration();
189
190 void setAvailableWidgetsIndicatorProvidersEnabled( bool enabled );
191 void setFormLayoutIndicatorProvidersEnabled( bool enabled );
192
193 void applyToLayer( QgsVectorLayer *layer );
194
195 QgsAttributesAvailableWidgetsModel *mAvailableWidgetsModel = nullptr;
196 QgsAttributesFormLayoutModel *mFormLayoutModel = nullptr;
197 QgsAttributesFormProxyModel *mAvailableWidgetsProxyModel = nullptr;
198 QgsAttributesFormProxyModel *mFormLayoutProxyModel = nullptr;
199
200 QgsMessageBar *mMessageBar = nullptr;
201
203 QString mInitFunction;
204 QString mInitFilePath;
205 QString mInitCode;
206 int mBlockUpdates = 0;
207
209 QMenu *mAvailableWidgetsContextMenu = nullptr;
210 QAction *mActionCopyWidgetConfiguration = nullptr;
211 QAction *mActionPasteWidgetConfiguration = nullptr;
212
214 QgsFieldConstraintIndicatorProvider *mConstraintIndicatorProviderAvailableWidgets = nullptr;
215 QgsFieldDefaultValueIndicatorProvider *mDefaultValueIndicatorProviderAvailableWidgets = nullptr;
216 QgsFieldConstraintIndicatorProvider *mConstraintIndicatorProviderFormLayout = nullptr;
217 QgsFieldDefaultValueIndicatorProvider *mDefaultValueIndicatorProviderFormLayout = nullptr;
218
219 QgsSourceFieldsProperties *mSourceFieldsProperties = nullptr;
220
222};
223
224#endif // QGSATTRIBUTESFORMPROPERTIES_H
AttributeFormPythonInitCodeSource
The Python init code source for attribute forms.
Definition qgis.h:5781
@ NoSource
Do not use Python code at all.
Definition qgis.h:5782
Manages available widgets when configuring attributes forms.
Graphical representation for the attribute drag and drop editor.
Manages form layouts when configuring attributes forms via drag and drop designer.
QgsAttributesFormBaseView * mFormLayoutView
void initAvailableWidgetsActions(const QList< QgsAction > actions)
Refresh layer actions in the Available Widgets view.
QgsAttributeFormContainerEdit * mAttributeContainerEdit
static const QgsSettingsEntryBool * settingShowAliases
static QgsSettingsTreeNode * sTreeAttributesForm
QgsAttributesFormBaseView * mAvailableWidgetsView
QgsAttributeTypeDialog * mAttributeTypeDialog
void store()
Stores currently opened widget configuration.
QgsAttributesFormProperties(QgsVectorLayer *layer, QWidget *parent=nullptr, QgsSourceFieldsProperties *sourceFieldsProperties=nullptr)
The QgsAttributesFormProperties constructor.
QgsAttributeWidgetEdit * mAttributeWidgetEdit
void apply()
Applies the attribute from properties to the vector layer.
void initFormLayoutView()
Initializes the form layout tree view, repopulating the underlying model.
void initAvailableWidgetsView()
Initializes the available widgets tree view, repopulating the underlying model.
Proxy model to filter items in the tree views of the drag and drop designer.
Abstract interface for generating an expression context.
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Provides field constraint indicators for attribute form views.
Provides default value indicators for attribute form views.
A bar for displaying non-blocking messages to the user.
A boolean settings entry.
A tree node for the settings tree to help organizing and introspecting the tree.
static QgsSettingsTreeNode * sTreeApp
A widget which displays information about vector layer fields, and allows some configuration of them.
Represents a vector layer which manages a vector based dataset.
Holds the configuration for a field.