20#include <QDialogButtonBox> 
   46  mMinSpinBox->setMinimum( std::numeric_limits<double>::lowest() );
 
   47  mMinSpinBox->setMaximum( std::numeric_limits<double>::max() );
 
   48  mMinSpinBox->setValue( 0 );
 
   49  mMinSpinBox->setDecimals( 6 );
 
   51  mMaxSpinBox->setMinimum( std::numeric_limits<double>::lowest() );
 
   52  mMaxSpinBox->setMaximum( std::numeric_limits<double>::max() );
 
   54  mMaxSpinBox->setValue( 100 );
 
   55  mMaxSpinBox->setDecimals( 6 );
 
   57  mMinInclusiveCheckBox->setChecked( 
true );
 
   58  mMaxInclusiveCheckBox->setChecked( 
true );
 
 
   73  mMinSpinBox->setValue( rangeDomain->
minimum().toDouble() );
 
   74  mMaxSpinBox->setValue( rangeDomain->
maximum().toDouble() );
 
 
   83                                  mMinSpinBox->value(), mMinInclusiveCheckBox->isChecked(),
 
   84                                  mMaxSpinBox->value(), mMaxInclusiveCheckBox->isChecked() );
 
 
   89  return mMinSpinBox->value() <= mMaxSpinBox->value();
 
 
  110  mEditGlob->setText( globDomain->
glob() );
 
 
  120  return !mEditGlob->text().trimmed().isEmpty();
 
 
  133  mValuesTable->setModel( mModel );
 
  135  connect( mButtonAddRow, &QToolButton::clicked, 
this, [ = ]
 
  137    mModel->insertRow( mModel->
rowCount() );
 
  139  connect( mButtonRemoveRow, &QToolButton::clicked, 
this, [ = ]
 
  141    QItemSelectionModel *selectionModel = mValuesTable->selectionModel();
 
  142    const QModelIndexList selectedRows = selectionModel->selectedIndexes();
 
  143    if ( !selectedRows.empty() )
 
  145      mModel->removeRow( selectedRows.first().row() );
 
 
  179  : QAbstractTableModel( parent )
 
 
  186  return mValues.count();
 
 
  196  if ( index.row() < 0 || index.row() >= mValues.count()
 
  197       || index.column() < 0 || index.column() >= 2 )
 
  203    case Qt::DisplayRole:
 
  205    case Qt::ToolTipRole:
 
  207      switch ( index.column() )
 
  212          return value.
value();
 
 
  225  if ( index.row() < 0 || index.row() >= mValues.count()
 
  226       || index.column() < 0 || index.column() >= 2 )
 
  234      switch ( index.column() )
 
  239          mValues.replace( index.row(), newValue );
 
  240          emit dataChanged( index, index );
 
  247          mValues.replace( index.row(), newValue );
 
  248          emit dataChanged( index, index );
 
 
  264       || index.row() >= mValues.size()
 
  265       || index.column() < 0
 
  267    return QAbstractTableModel::flags( index );
 
  269  return Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable | Qt::ItemFlag::ItemIsEditable;
 
 
  274  switch ( orientation )
 
  279        case Qt::DisplayRole:
 
  280        case Qt::ToolTipRole:
 
  287              return tr( 
"Value" );
 
 
  306  if ( parent.isValid() )
 
  309  beginInsertRows( QModelIndex(), row, row + count - 1 );
 
  310  for ( 
int i = row; i < row + count; ++i )
 
 
  320  if ( row < 0 || row >= mValues.count() )
 
  323  if ( parent.isValid() )
 
  326  for ( 
int i = row + count - 1; i >= row; --i )
 
  328    beginRemoveRows( parent, i, i );
 
  329    mValues.removeAt( i );
 
 
  374      mFieldTypeCombo->setCurrentIndex( mFieldTypeCombo->findData( 
static_cast< int >( QMetaType::Type::QString ) ) );
 
  379      mFieldTypeCombo->setCurrentIndex( mFieldTypeCombo->findData( 
static_cast< int >( QMetaType::Type::Double ) ) );
 
  384      mFieldTypeCombo->setCurrentIndex( mFieldTypeCombo->findData( 
static_cast< int >( QMetaType::Type::QString ) ) );
 
  388  mStackedWidget->addWidget( mDomainWidget );
 
  389  mStackedWidget->setCurrentWidget( mDomainWidget );
 
  391  connect( mNameEdit, &QLineEdit::textChanged, 
this, [ = ]
 
 
  407  mNameEdit->setText( domain->
name() );
 
  408  mDescriptionEdit->setText( domain->
description() );
 
  409  mComboMergePolicy->setCurrentIndex( mComboMergePolicy->findData( 
static_cast< int >( domain->
mergePolicy() ) ) );
 
  410  mComboSplitPolicy->setCurrentIndex( mComboSplitPolicy->findData( 
static_cast< int >( domain->
splitPolicy() ) ) );
 
  411  mFieldTypeCombo->setCurrentIndex( mFieldTypeCombo->findData( 
static_cast< int >( domain->
fieldType() ) ) );
 
 
  419  if ( !mDomainWidget )
 
  422  std::unique_ptr< QgsFieldDomain > res( mDomainWidget->
createFieldDomain( mNameEdit->text(),
 
  423                                         mDescriptionEdit->text(),
 
  424                                         static_cast< QMetaType::Type 
>( mFieldTypeCombo->currentData().toInt() ) ) );
 
  428  return res.release();
 
 
  433  if ( mNameEdit->text().trimmed().isEmpty() )
 
  436  return mDomainWidget && mDomainWidget->
isValid();
 
 
  444  : QDialog( parent, flags )
 
  446  setObjectName( QStringLiteral( 
"QgsFieldDomainDialog" ) );
 
  448  QVBoxLayout *vLayout = 
new QVBoxLayout();
 
  450  vLayout->addWidget( mWidget, 1 );
 
  452  mButtonBox = 
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
 
  453  connect( mButtonBox, &QDialogButtonBox::accepted, 
this, &QDialog::accept );
 
  454  connect( mButtonBox, &QDialogButtonBox::rejected, 
this, &QDialog::reject );
 
  455  vLayout->addWidget( mButtonBox );
 
  457  setLayout( vLayout );
 
  459  validityChanged( mWidget->
isValid() );
 
 
  482void QgsFieldDomainDialog::validityChanged( 
bool isValid )
 
  484  mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( isValid );
 
FieldDomainMergePolicy
Merge policy for field domains.
 
@ GeometryWeighted
New values are computed as the weighted average of the source values.
 
@ DefaultValue
Use default field value.
 
FieldDomainSplitPolicy
Split policy for field domains.
 
@ GeometryRatio
New values are computed by the ratio of their area/length compared to the area/length of the original...
 
@ DefaultValue
Use default field value.
 
@ Duplicate
Duplicate original value.
 
FieldDomainType
Types of field domain.
 
@ Coded
Coded field domain.
 
@ Range
Numeric range field domain (min/max)
 
@ Glob
Glob string pattern field domain.
 
Abstract base class for widgets which configure the extended properties of a QgsFieldDomain subclass.
 
virtual ~QgsAbstractFieldDomainWidget()
 
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.
 
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.
 
A widget for configuration of the extended properties of a QgsCodedFieldDomain.
 
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.
 
Definition of a coded / enumerated field domain.
 
QList< QgsCodedValue > values() const
Returns the enumeration as QgsCodedValue values.
 
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
 
Associates a code and a value.
 
QVariant code() const
Returns the associated code, which is the underlying value stored in fields.
 
QString value() const
Returns the associated value, which is the user-friendly string representation.
 
void setFieldDomain(const QgsFieldDomain *domain)
Sets the current field domain to show properties for in the dialog.
 
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 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.
 
Qgis::FieldDomainMergePolicy mergePolicy() const
Returns the merge policy.
 
Qgis::FieldDomainSplitPolicy splitPolicy() const
Returns the split policy.
 
QMetaType::Type fieldType() const
Returns the associated field type.
 
QString name() const
Returns the name of the field domain.
 
QString description() const
Returns the description of the field domain.
 
A widget for configuration of the extended properties of a QgsGlobFieldDomain.
 
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.
 
Definition of a field domain for field content validated by a glob.
 
QString glob() const
Returns the glob expression.
 
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
 
A widget for configuration of the extended properties of a QgsRangeFieldDomain.
 
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.
 
Definition of a numeric field domain with a range of validity for values.
 
QVariant minimum() const
Returns the minimum value.
 
bool maximumIsInclusive() const
Returns true if the maximum value is inclusive.
 
bool minimumIsInclusive() const
Returns true if the minimum value is inclusive.
 
QVariant maximum() const
Returns the maximum value.
 
static QString typeToDisplayString(QMetaType::Type type, QMetaType::Type subType=QMetaType::Type::UnknownType)
Returns a user-friendly translated string representing a QVariant type.