QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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:
52 QgsAbstractFieldDomainWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
53
55
61 virtual void setFieldDomain( const QgsFieldDomain *domain ) = 0;
62
70 virtual QgsFieldDomain *createFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType ) const = 0 SIP_FACTORY;
71
75 virtual bool isValid() const = 0;
76
77 signals:
78
82 void changed();
83};
84
94class GUI_EXPORT QgsRangeDomainWidget : public QgsAbstractFieldDomainWidget, private Ui_QgsRangeDomainWidgetBase
95{
96 Q_OBJECT
97
98 public:
102 QgsRangeDomainWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
103
104 void setFieldDomain( const QgsFieldDomain *domain ) override;
105 QgsFieldDomain *createFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType ) const override SIP_FACTORY;
106 bool isValid() const override;
107};
108
118class GUI_EXPORT QgsGlobDomainWidget : public QgsAbstractFieldDomainWidget, private Ui_QgsGlobDomainWidgetBase
119{
120 Q_OBJECT
121
122 public:
126 QgsGlobDomainWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
127
128 void setFieldDomain( const QgsFieldDomain *domain ) override;
129 QgsFieldDomain *createFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType ) const override SIP_FACTORY;
130 bool isValid() const override;
131};
132
140class GUI_EXPORT QgsCodedValueTableModel : public QAbstractTableModel
141{
142 Q_OBJECT
143
144 public:
148 QgsCodedValueTableModel( QObject *parent );
149
150 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
151 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
152 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
153 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
154 Qt::ItemFlags flags( const QModelIndex &index ) const override;
155 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
156 bool insertRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
157 bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
158
164 void setValues( const QList<QgsCodedValue> &values );
165
171 QList<QgsCodedValue> values() const { return mValues; }
172
173 private:
174 QList<QgsCodedValue> mValues;
175};
176
177
187class GUI_EXPORT QgsCodedFieldDomainWidget : public QgsAbstractFieldDomainWidget, private Ui_QgsCodedValueDomainWidgetBase
188{
189 Q_OBJECT
190
191 public:
195 QgsCodedFieldDomainWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
196
197 void setFieldDomain( const QgsFieldDomain *domain ) override;
198 QgsFieldDomain *createFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType ) const override SIP_FACTORY;
199 bool isValid() const override;
200
201 private:
202 QgsCodedValueTableModel *mModel = nullptr;
203};
204#endif
205
212class GUI_EXPORT QgsFieldDomainWidget : public QWidget, private Ui_QgsFieldDomainWidgetBase
213{
214 Q_OBJECT
215
216 public:
220 QgsFieldDomainWidget( Qgis::FieldDomainType type, QWidget *parent SIP_TRANSFERTHIS = nullptr );
221
227 void setFieldDomain( const QgsFieldDomain *domain );
228
237
243 bool isValid() const;
244
250 void setNameEditable( bool editable );
251
252 signals:
253
260
261 private:
262 QgsAbstractFieldDomainWidget *mDomainWidget = nullptr;
263};
264
265
272class GUI_EXPORT QgsFieldDomainDialog : public QDialog
273{
274 Q_OBJECT
275
276 public:
280 explicit QgsFieldDomainDialog( Qgis::FieldDomainType type, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
281
287 void setFieldDomain( const QgsFieldDomain *domain );
288
297
303 void setNameEditable( bool editable );
304
305 public slots:
306
307 void accept() override;
308
309 private slots:
310
311 void validityChanged( bool isValid );
312
313 private:
314 QgsFieldDomainWidget *mWidget = nullptr;
315 QDialogButtonBox *mButtonBox = nullptr;
316};
317
318
319#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