18#include "moc_qgsrelationreferencewidgetwrapper.cpp" 
   28  , mMessageBar( messageBar )
 
   29  , mIndeterminateState( false )
 
 
   57  const bool showForm = 
config( QStringLiteral( 
"ShowForm" ), 
false ).toBool();
 
   58  const bool mapIdent = 
config( QStringLiteral( 
"MapIdentification" ), 
false ).toBool();
 
   59  const bool readOnlyWidget = 
config( QStringLiteral( 
"ReadOnly" ), 
false ).toBool();
 
   60  const bool showOpenFormButton = 
config( QStringLiteral( 
"ShowOpenFormButton" ), 
true ).toBool();
 
   67  const bool fetchLimitActive = 
config( QStringLiteral( 
"FetchLimitActive" ), 
QgsSettings().
value( QStringLiteral( 
"maxEntriesRelationWidget" ), 100, 
QgsSettings::Gui ).toInt() > 0 ).toBool();
 
   68  if ( fetchLimitActive )
 
   73  if ( 
config( QStringLiteral( 
"FilterFields" ), QVariant() ).isValid() )
 
   78  if ( !
config( QStringLiteral( 
"FilterExpression" ) ).toString().isEmpty() )
 
   86  const QVariant relationName = 
config( QStringLiteral( 
"Relation" ) );
 
   95  if ( relationName.isValid() )
 
  117  if ( !
config( QStringLiteral( 
"AllowNULL" ) ).isValid() )
 
  123    mWidget->
setRelation( relation, 
config( QStringLiteral( 
"AllowNULL" ) ).toBool() );
 
 
  129void QgsRelationReferenceWidgetWrapper::aboutToSave()
 
  142  if ( fkeys.isEmpty() )
 
  149    Q_ASSERT( fieldPairs.count() == fkeys.count() );
 
  150    for ( 
int i = 0; i < fieldPairs.count(); i++ )
 
  152      if ( fieldPairs.at( i ).referencingField() == 
field().name() )
 
  153        return fkeys.at( i );
 
 
  170  mIndeterminateState = 
true;
 
 
  181    for ( 
int i = 0; i < mWidget->
relation().fieldPairs().count(); i++ )
 
  183      values << QVariant();
 
  191    const int fieldCount = std::min( fieldPairs.count(), values.count() );
 
  192    for ( 
int i = 0; i < fieldCount; i++ )
 
  194      if ( fieldPairs.at( i ).referencingField() == 
field().name() )
 
  196        values.removeAt( i );
 
 
  207    return QStringList();
 
  211  for ( 
int i = 0; i < fieldPairs.count(); i++ )
 
  213    if ( fieldPairs.at( i ).referencingField() == 
field().name() )
 
  216    fields << fieldPairs.at( i ).referencingField();
 
 
  221void QgsRelationReferenceWidgetWrapper::updateValues( 
const QVariant &val, 
const QVariantList &additionalValues )
 
  226  mIndeterminateState = 
false;
 
  228  QVariantList values = additionalValues;
 
  230  for ( 
int i = 0; i < fieldPairs.count(); i++ )
 
  232    if ( fieldPairs.at( i ).referencingField() == 
field().name() )
 
  234      values.insert( i, val );
 
  238  Q_ASSERT( values.count() == fieldPairs.count() );
 
  254void QgsRelationReferenceWidgetWrapper::foreignKeysChanged( 
const QVariantList &values )
 
  256  if ( mBlockChanges != 0 ) 
 
  270  QVariantList additionalValues = values;
 
  272  for ( 
int i = 0; i < fieldPairs.count(); i++ )
 
  274    if ( fieldPairs.at( i ).referencingField() == 
field().name() )
 
  275      mainValue = additionalValues.takeAt( i ); 
 
  277  Q_ASSERT( additionalValues.count() == values.count() - 1 );
 
  291      widget()->setStyleSheet( QString() );
 
  298          mWidget->setStyleSheet( QString() );
 
  302          mWidget->setStyleSheet( QStringLiteral( 
".QComboBox { background-color: #dd7777; }" ) );
 
  306          mWidget->setStyleSheet( QStringLiteral( 
".QComboBox { background-color: #ffd85d; }" ) );
 
 
  319  ctx.setParentFormFeature( feature );
 
 
  332  if ( attributeChanged )
 
 
Contains context information for attribute editor widgets.
 
QgsFeature parentFormFeature() const
Returns the feature of the currently edited parent form in its actual state.
 
const QgsAttributeEditorContext * parentContext() const
 
const QgsRelation & relation() const
Returns the attribute relation.
 
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
 
Q_INVOKABLE bool setAttribute(int field, const QVariant &attr)
Sets an attribute's value by field index.
 
Map canvas is a class for displaying all GIS data types on a canvas.
 
A bar for displaying non-blocking messages to the user.
 
QgsRelationManager * relationManager
 
static QgsProject * instance()
Returns the QgsProject singleton instance.
 
Q_INVOKABLE QgsRelation relation(const QString &id) const
Gets access to a relation by its id.
 
Represents a relationship between two vector layers.
 
QList< QgsRelation::FieldPair > fieldPairs() const
Returns the field pairs which form this relation The first element of each pair are the field names o...
 
bool referencingFieldsAllowNull() const
Returns true if none of the referencing fields has a NOT NULL constraint.
 
Stores settings for use within QGIS.
 
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
 
static QVariant createNullVariant(QMetaType::Type metaType)
Helper method to properly create a null QVariant from a metaType Returns the created QVariant.
 
Represents a vector layer which manages a vector based dataset.
 
QList< QgsRelation > referencingRelations(int idx) const
Returns the layer's relations, where the foreign key is on this layer.
 
#define Q_NOWARN_DEPRECATED_POP
 
#define Q_NOWARN_DEPRECATED_PUSH