QGIS API Documentation 3.99.0-Master (a8f284845db)
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
21#include "ui_qgsattributesformproperties.h"
22
23#include "qgis_gui.h"
24#include "qgsaction.h"
27#include "qgsmessagebar.h"
29#include "qgssettingstree.h"
30#include "qgssettingstreenode.h"
31
32#include <QAction>
33#include <QClipboard>
34#include <QDropEvent>
35#include <QFileDialog>
36#include <QFormLayout>
37#include <QHBoxLayout>
38#include <QMenu>
39#include <QMessageBox>
40#include <QMimeData>
41#include <QPlainTextEdit>
42#include <QPushButton>
43#include <QSpinBox>
44#include <QString>
45#include <QTreeView>
46#include <QWidget>
47
48#define SIP_NO_FILE
49
50using namespace Qt::StringLiterals;
51
52class QgsAttributeFormContainerEdit;
53class QgsAttributeTypeDialog;
54class QgsAttributeWidgetEdit;
59
67class GUI_EXPORT QgsAttributesFormProperties : public QWidget, public QgsExpressionContextGenerator, private Ui_QgsAttributesFormProperties
68{
69 Q_OBJECT
70
71 public:
72 static inline QgsSettingsTreeNode *sTreeAttributesForm = QgsSettingsTree::sTreeApp->createChildNode( u"attributes-form"_s );
74
81 explicit QgsAttributesFormProperties( QgsVectorLayer *layer, QWidget *parent = nullptr, QgsSourceFieldsProperties *sourceFieldsProperties = nullptr );
82
83 void init();
84
88 void apply();
89
94 void store();
95
97
102
106 void initFormLayoutView();
107
108 void initLayoutConfig();
109 void initInitPython();
110 void initSuppressCombo();
111
117 void initAvailableWidgetsActions( const QList< QgsAction > actions );
118
120
121 protected:
123
125
128
129 QgsAttributeWidgetEdit *mAttributeWidgetEdit = nullptr;
130 QgsAttributeTypeDialog *mAttributeTypeDialog = nullptr;
131 QgsAttributeFormContainerEdit *mAttributeContainerEdit = nullptr;
132 QLabel *mInfoTextWidget = nullptr;
133
134 private slots:
135 void addContainer();
136 void removeTabOrGroupButton();
137 void mEditorLayoutComboBox_currentIndexChanged( int index );
138 void pbnSelectEditForm_clicked();
139 void mTbInitCode_clicked();
140 void toggleShowAliases( bool checked );
141
145 void onInvertSelectionButtonClicked( bool checked );
146
147 void loadAttributeSpecificEditor( QgsAttributesFormBaseView *emitter, QgsAttributesFormBaseView *receiver, QModelIndex &deselectedFormLayoutIndex );
148 void onAttributeSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
149 void onFormLayoutSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
150
152 void onContextMenuRequested( QPoint );
153
154 void updatedFields();
155
156 void updateFilteredItems( const QString &filterText );
157
158 void previewForm();
159
160 private:
162 void clearAttributeTypeFrame();
163
164 void loadAttributeWidgetEdit();
165
169 void storeAttributeWidgetEdit();
170
174 void storeAttributeContainerEdit();
175
177 void storeAttributeWidgetEdit( const QModelIndex &index );
178 void storeAttributeContainerEdit( const QModelIndex &index );
179
180 void loadAttributeTypeDialog();
181 void loadAttributeTypeDialogFromConfiguration( const QgsAttributesFormData::FieldConfig &cfg );
182 void storeAttributeTypeDialog();
183
184 void loadAttributeContainerEdit();
185
186 void loadInfoWidget( const QString &infoText );
187
188 void copyWidgetConfiguration();
189 void pasteWidgetConfiguration();
190
191 void setAvailableWidgetsIndicatorProvidersEnabled( bool enabled );
192 void setFormLayoutIndicatorProvidersEnabled( bool enabled );
193
194 void applyToLayer( QgsVectorLayer *layer );
195
196 QgsAttributesAvailableWidgetsModel *mAvailableWidgetsModel = nullptr;
197 QgsAttributesFormLayoutModel *mFormLayoutModel = nullptr;
198 QgsAttributesFormProxyModel *mAvailableWidgetsProxyModel = nullptr;
199 QgsAttributesFormProxyModel *mFormLayoutProxyModel = nullptr;
200
201 QgsMessageBar *mMessageBar = nullptr;
202
204 QString mInitFunction;
205 QString mInitFilePath;
206 QString mInitCode;
207 int mBlockUpdates = 0;
208
210 QMenu *mAvailableWidgetsContextMenu = nullptr;
211 QAction *mActionCopyWidgetConfiguration = nullptr;
212 QAction *mActionPasteWidgetConfiguration = nullptr;
213
215 QgsFieldConstraintIndicatorProvider *mConstraintIndicatorProviderAvailableWidgets = nullptr;
216 QgsFieldDefaultValueIndicatorProvider *mDefaultValueIndicatorProviderAvailableWidgets = nullptr;
217 QgsFieldConstraintIndicatorProvider *mConstraintIndicatorProviderFormLayout = nullptr;
218 QgsFieldDefaultValueIndicatorProvider *mDefaultValueIndicatorProviderFormLayout = nullptr;
219
220 QgsSourceFieldsProperties *mSourceFieldsProperties = nullptr;
221
223};
224
225#endif // QGSATTRIBUTESFORMPROPERTIES_H
AttributeFormPythonInitCodeSource
The Python init code source for attribute forms.
Definition qgis.h:5831
@ NoSource
Do not use Python code at all.
Definition qgis.h:5832
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.