QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
qgsfielddomainwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsfielddomainwidget.h
3 ------------------
4 Date : February 2022
5 Copyright : (C) 2022 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
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#ifndef QGSFIELDDOMAINWIDGET_H
16#define QGSFIELDDOMAINWIDGET_H
17
18#include "ui_qgscodedvaluedomainwidgetbase.h"
19#include "ui_qgsfielddomainwidgetbase.h"
20#include "ui_qgsglobdomainwidgetbase.h"
21#include "ui_qgsrangedomainwidgetbase.h"
22
23#include "qgis.h"
24#include "qgis_gui.h"
25#include "qgis_sip.h"
26#include "qgsfielddomain.h"
27
28#include <QAbstractTableModel>
29#include <QDialog>
30
31class QDialogButtonBox;
32
33#ifndef SIP_RUN
34
44class GUI_EXPORT QgsAbstractFieldDomainWidget : public QWidget
45{
46 Q_OBJECT
47
48 public:
49
53 QgsAbstractFieldDomainWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
54
56
62 virtual void setFieldDomain( const QgsFieldDomain *domain ) = 0;
63
71 virtual QgsFieldDomain *createFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType ) const = 0 SIP_FACTORY;
72
76 virtual bool isValid() const = 0;
77
78 signals:
79
83 void changed();
84};
85
95class GUI_EXPORT QgsRangeDomainWidget : public QgsAbstractFieldDomainWidget, private Ui_QgsRangeDomainWidgetBase
96{
97 Q_OBJECT
98
99 public:
100
104 QgsRangeDomainWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
105
106 void setFieldDomain( const QgsFieldDomain *domain ) override;
107 QgsFieldDomain *createFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType ) const override SIP_FACTORY;
108 bool isValid() const override;
109};
110
120class GUI_EXPORT QgsGlobDomainWidget : public QgsAbstractFieldDomainWidget, private Ui_QgsGlobDomainWidgetBase
121{
122 Q_OBJECT
123
124 public:
125
129 QgsGlobDomainWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
130
131 void setFieldDomain( const QgsFieldDomain *domain ) override;
132 QgsFieldDomain *createFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType ) const override SIP_FACTORY;
133 bool isValid() const override;
134};
135
143class GUI_EXPORT QgsCodedValueTableModel : public QAbstractTableModel
144{
145 Q_OBJECT
146
147 public:
148
152 QgsCodedValueTableModel( QObject *parent );
153
154 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
155 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
156 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
157 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
158 Qt::ItemFlags flags( const QModelIndex &index ) const override;
159 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
160 bool insertRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
161 bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
162
168 void setValues( const QList<QgsCodedValue> &values );
169
175 QList<QgsCodedValue> values() const { return mValues; }
176
177 private:
178 QList<QgsCodedValue> mValues;
179};
180
181
191class GUI_EXPORT QgsCodedFieldDomainWidget : public QgsAbstractFieldDomainWidget, private Ui_QgsCodedValueDomainWidgetBase
192{
193 Q_OBJECT
194
195 public:
196
200 QgsCodedFieldDomainWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
201
202 void setFieldDomain( const QgsFieldDomain *domain ) override;
203 QgsFieldDomain *createFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType ) const override SIP_FACTORY;
204 bool isValid() const override;
205
206 private:
207 QgsCodedValueTableModel *mModel = nullptr;
208};
209#endif
210
217class GUI_EXPORT QgsFieldDomainWidget : public QWidget, private Ui_QgsFieldDomainWidgetBase
218{
219 Q_OBJECT
220
221 public:
222
226 QgsFieldDomainWidget( Qgis::FieldDomainType type, QWidget *parent SIP_TRANSFERTHIS = nullptr );
227
233 void setFieldDomain( const QgsFieldDomain *domain );
234
243
249 bool isValid() const;
250
256 void setNameEditable( bool editable );
257
258 signals:
259
266
267 private:
268 QgsAbstractFieldDomainWidget *mDomainWidget = nullptr;
269};
270
271
278class GUI_EXPORT QgsFieldDomainDialog : public QDialog
279{
280 Q_OBJECT
281
282 public:
283
287 explicit QgsFieldDomainDialog( Qgis::FieldDomainType type, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
288
294 void setFieldDomain( const QgsFieldDomain *domain );
295
304
310 void setNameEditable( bool editable );
311
312 public slots:
313
314 void accept() override;
315
316 private slots:
317
318 void validityChanged( bool isValid );
319
320 private:
321 QgsFieldDomainWidget *mWidget = nullptr;
322 QDialogButtonBox *mButtonBox = nullptr;
323};
324
325
326#endif // QGSFIELDDOMAINWIDGET_H
FieldDomainType
Types of field domain.
Definition qgis.h:3956
Abstract base class for widgets which configure the extended properties of a QgsFieldDomain subclass.
void changed()
Emitted whenever the field domain configuration in the widget changes.
~QgsAbstractFieldDomainWidget() override
virtual bool isValid() const =0
Returns true if the widget currently represents a valid field domain configuration.
QgsAbstractFieldDomainWidget(QWidget *parent=nullptr)
Constructor for QgsAbstractFieldDomainWidget, with the specified parent widget.
virtual QgsFieldDomain * createFieldDomain(const QString &name, const QString &description, QMetaType::Type fieldType) const =0
Creates a new field domain using the properties from the widget.
virtual void setFieldDomain(const QgsFieldDomain *domain)=0
Sets the current field domain to show properties for in the widget.
QgsFieldDomain * createFieldDomain(const QString &name, const QString &description, QMetaType::Type fieldType) const override
Creates a new field domain using the properties from the widget.
void setFieldDomain(const QgsFieldDomain *domain) override
Sets the current field domain to show properties for in the widget.
QgsCodedFieldDomainWidget(QWidget *parent=nullptr)
Constructor for QgsCodedFieldDomainWidget, with the specified parent widget.
bool isValid() const override
Returns true if the widget currently represents a valid field domain configuration.
A table model for representing the values in a QgsCodedValue list.
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QgsCodedValueTableModel(QObject *parent)
Constructor for QgsCodedValueTableModel, with the specified parent object.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
Qt::ItemFlags flags(const QModelIndex &index) const override
void setValues(const QList< QgsCodedValue > &values)
Sets the values to show in the model.
QList< QgsCodedValue > values() const
Returns the values from the model.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void setFieldDomain(const QgsFieldDomain *domain)
Sets the current field domain to show properties for in the dialog.
void setNameEditable(bool editable)
Sets if name of the field domain is editable.
QgsFieldDomain * createFieldDomain() const
Creates a new field domain using the properties from the dialog.
QgsFieldDomainDialog(Qgis::FieldDomainType type, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
Constructor for QgsFieldDomainDialog for the given domain type, with the specified parent widget and ...
A widget for configuration of the properties of a QgsFieldDomain.
QgsFieldDomainWidget(Qgis::FieldDomainType type, QWidget *parent=nullptr)
Constructor for QgsFieldDomainWidget for the given domain type, with the specified parent widget.
QgsFieldDomain * createFieldDomain() const
Creates a new field domain using the properties from the widget.
void setNameEditable(bool editable)
Sets if name of the field domain is editable.
void setFieldDomain(const QgsFieldDomain *domain)
Sets the current field domain to show properties for in the widget.
bool isValid() const
Returns true if the widget currently represents a valid field domain configuration.
void validityChanged(bool isValid)
Emitted whenever the validity of the field domain configuration in the widget changes.
Base class for field domains.
QgsGlobDomainWidget(QWidget *parent=nullptr)
Constructor for QgsGlobDomainWidget, with the specified parent widget.
void setFieldDomain(const QgsFieldDomain *domain) override
Sets the current field domain to show properties for in the widget.
QgsFieldDomain * createFieldDomain(const QString &name, const QString &description, QMetaType::Type fieldType) const override
Creates a new field domain using the properties from the widget.
bool isValid() const override
Returns true if the widget currently represents a valid field domain configuration.
void setFieldDomain(const QgsFieldDomain *domain) override
Sets the current field domain to show properties for in the widget.
bool isValid() const override
Returns true if the widget currently represents a valid field domain configuration.
QgsRangeDomainWidget(QWidget *parent=nullptr)
Constructor for QgsRangeDomainWidget, with the specified parent widget.
QgsFieldDomain * createFieldDomain(const QString &name, const QString &description, QMetaType::Type fieldType) const override
Creates a new field domain using the properties from the widget.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_FACTORY
Definition qgis_sip.h:84