QGIS API Documentation 3.41.0-Master (cea29feecf2)
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 "qgis_gui.h"
19#include "qgis_sip.h"
20#include "ui_qgsfielddomainwidgetbase.h"
21#include "ui_qgsrangedomainwidgetbase.h"
22#include "ui_qgsglobdomainwidgetbase.h"
23#include "ui_qgscodedvaluedomainwidgetbase.h"
24#include "qgis.h"
25#include "qgsfielddomain.h"
26#include <QAbstractTableModel>
27#include <QDialog>
28
29class QDialogButtonBox;
30
31#ifndef SIP_RUN
32
42class GUI_EXPORT QgsAbstractFieldDomainWidget : public QWidget
43{
44 Q_OBJECT
45
46 public:
50 QgsAbstractFieldDomainWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
51
53
59 virtual void setFieldDomain( const QgsFieldDomain *domain ) = 0;
60
68 virtual QgsFieldDomain *createFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType ) const = 0 SIP_FACTORY;
69
73 virtual bool isValid() const = 0;
74
75 signals:
76
80 void changed();
81};
82
92class GUI_EXPORT QgsRangeDomainWidget : public QgsAbstractFieldDomainWidget, private Ui_QgsRangeDomainWidgetBase
93{
94 Q_OBJECT
95
96 public:
100 QgsRangeDomainWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
101
102 void setFieldDomain( const QgsFieldDomain *domain ) override;
103 QgsFieldDomain *createFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType ) const override SIP_FACTORY;
104 bool isValid() const override;
105};
106
116class GUI_EXPORT QgsGlobDomainWidget : public QgsAbstractFieldDomainWidget, private Ui_QgsGlobDomainWidgetBase
117{
118 Q_OBJECT
119
120 public:
124 QgsGlobDomainWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
125
126 void setFieldDomain( const QgsFieldDomain *domain ) override;
127 QgsFieldDomain *createFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType ) const override SIP_FACTORY;
128 bool isValid() const override;
129};
130
138class GUI_EXPORT QgsCodedValueTableModel : public QAbstractTableModel
139{
140 Q_OBJECT
141
142 public:
146 QgsCodedValueTableModel( QObject *parent );
147
148 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
149 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
150 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
151 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
152 Qt::ItemFlags flags( const QModelIndex &index ) const override;
153 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
154 bool insertRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
155 bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
156
162 void setValues( const QList<QgsCodedValue> &values );
163
169 QList<QgsCodedValue> values() const { return mValues; }
170
171 private:
172 QList<QgsCodedValue> mValues;
173};
174
175
185class GUI_EXPORT QgsCodedFieldDomainWidget : public QgsAbstractFieldDomainWidget, private Ui_QgsCodedValueDomainWidgetBase
186{
187 Q_OBJECT
188
189 public:
193 QgsCodedFieldDomainWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
194
195 void setFieldDomain( const QgsFieldDomain *domain ) override;
196 QgsFieldDomain *createFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType ) const override SIP_FACTORY;
197 bool isValid() const override;
198
199 private:
200 QgsCodedValueTableModel *mModel = nullptr;
201};
202#endif
203
210class GUI_EXPORT QgsFieldDomainWidget : public QWidget, private Ui_QgsFieldDomainWidgetBase
211{
212 Q_OBJECT
213
214 public:
218 QgsFieldDomainWidget( Qgis::FieldDomainType type, QWidget *parent SIP_TRANSFERTHIS = nullptr );
219
225 void setFieldDomain( const QgsFieldDomain *domain );
226
234 QgsFieldDomain *createFieldDomain() const SIP_FACTORY;
235
241 bool isValid() const;
242
243 signals:
244
250 void validityChanged( bool isValid );
251
252 private:
253 QgsAbstractFieldDomainWidget *mDomainWidget = nullptr;
254};
255
256
263class GUI_EXPORT QgsFieldDomainDialog : public QDialog
264{
265 Q_OBJECT
266
267 public:
271 explicit QgsFieldDomainDialog( Qgis::FieldDomainType type, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
272
278 void setFieldDomain( const QgsFieldDomain *domain );
279
287 QgsFieldDomain *createFieldDomain() const SIP_FACTORY;
288
289 public slots:
290
291 void accept() override;
292
293 private slots:
294
295 void validityChanged( bool isValid );
296
297 private:
298 QgsFieldDomainWidget *mWidget = nullptr;
299 QDialogButtonBox *mButtonBox = nullptr;
300};
301
302
303#endif // QGSFIELDDOMAINWIDGET_H
FieldDomainType
Types of field domain.
Definition qgis.h:3718
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.
virtual bool isValid() const =0
Returns true if the widget currently represents a valid field domain configuration.
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.
A widget for configuration of the extended properties of a QgsCodedFieldDomain.
A table model for representing the values in a QgsCodedValue list.
QList< QgsCodedValue > values() const
Returns the values from the model.
A dialog for configuration of the properties of a QgsFieldDomain.
A widget for configuration of the properties of a QgsFieldDomain.
void validityChanged(bool isValid)
Emitted whenever the validity of the field domain configuration in the widget changes.
Base class for field domains.
A widget for configuration of the extended properties of a QgsGlobFieldDomain.
A widget for configuration of the extended properties of a QgsRangeFieldDomain.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_FACTORY
Definition qgis_sip.h:76