QString QgsDateTimeEditFactory::representValue( QgsVectorLayer* vl, int fieldIdx, const QgsEditorWidgetConfig& config, const QVariant& cache, const QVariant& value ) const { Q_UNUSED( vl ) Q_UNUSED( fieldIdx ) Q_UNUSED( cache ) QString result; if ( value.isNull() ) { QSettings settings; return settings.value( "qgis/nullValue", "NULL" ).toString(); } const QString displayFormat = config.value( "display_format", QGSDATETIMEEDIT_DATEFORMAT ).toString(); const QString fieldFormat = config.value( "field_format", QGSDATETIMEEDIT_DATEFORMAT ).toString(); QDateTime date = QDateTime::fromString( value.toString(), fieldFormat ); if ( date.isValid() ) { result = date.toString( displayFormat ); } else { result = value.toString(); } return result; }
QString QgsDateTimeEditFactory::representValue( QgsVectorLayer* vl, int fieldIdx, const QgsEditorWidgetConfig& config, const QVariant& cache, const QVariant& value ) const { Q_UNUSED( vl ) Q_UNUSED( fieldIdx ) Q_UNUSED( cache ) QString result; if ( value.isNull() ) { QSettings settings; return settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString(); } const QgsField field = vl->fields().at( fieldIdx ); const QString displayFormat = config.value( QStringLiteral( "display_format" ), QgsDateTimeEditConfig::defaultFormat( field.type() ) ).toString(); const QString fieldFormat = config.value( QStringLiteral( "field_format" ), QgsDateTimeEditConfig::defaultFormat( field.type() ) ).toString(); QDateTime date = QDateTime::fromString( value.toString(), fieldFormat ); if ( date.isValid() ) { result = date.toString( displayFormat ); } else { result = value.toString(); } return result; }
void QgsPhotoWidgetFactory::writeConfig( const QgsEditorWidgetConfig& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) { Q_UNUSED( doc ) Q_UNUSED( layer ) Q_UNUSED( fieldIdx ) configElement.setAttribute( "Height", config.value( "Height", 0 ).toString() ); configElement.setAttribute( "Width", config.value( "Width", 0 ).toString() ); }
void QgsCheckboxWidgetFactory::writeConfig( const QgsEditorWidgetConfig& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) { Q_UNUSED( doc ) Q_UNUSED( layer ) Q_UNUSED( fieldIdx ) configElement.setAttribute( QStringLiteral( "CheckedState" ), config.value( QStringLiteral( "CheckedState" ), "1" ).toString() ); configElement.setAttribute( QStringLiteral( "UncheckedState" ), config.value( QStringLiteral( "UncheckedState" ), "0" ).toString() ); }
void QgsTextEditWidgetFactory::writeConfig( const QgsEditorWidgetConfig& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) { Q_UNUSED( doc ) Q_UNUSED( layer ) Q_UNUSED( fieldIdx ) configElement.setAttribute( QStringLiteral( "IsMultiline" ), config.value( QStringLiteral( "IsMultiline" ), false ).toBool() ); configElement.setAttribute( QStringLiteral( "UseHtml" ), config.value( QStringLiteral( "UseHtml" ), false ).toBool() ); }
void QgsExternalResourceWidgetFactory::writeConfig( const QgsEditorWidgetConfig& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) { Q_UNUSED( doc ) Q_UNUSED( layer ) Q_UNUSED( fieldIdx ) configElement.setAttribute( "FileWidget", config.value( "FileWidget", true ).toBool() ); configElement.setAttribute( "FileWidgetButton", config.value( "FileWidgetButton", true ).toBool() ); // Non mandatory options are not saved into project file (to save some space). if ( config.contains( "UseLink" ) ) configElement.setAttribute( "UseLink", config.value( "UseLink" ).toBool() ); if ( config.contains( "FullUrl" ) ) configElement.setAttribute( "FullUrl", config.value( "FullUrl" ).toBool() ); if ( config.contains( "DefaultRoot" ) ) configElement.setAttribute( "DefaultRoot", config.value( "DefaultRoot" ).toString() ); if ( config.contains( "RelativeStorage" ) ) configElement.setAttribute( "RelativeStorage" , config.value( "RelativeStorage" ).toString() ); if ( config.contains( "DocumentViewer" ) ) configElement.setAttribute( "DocumentViewer", config.value( "DocumentViewer" ).toInt() ); if ( config.contains( "FileWidgetFilter" ) ) configElement.setAttribute( "FileWidgetFilter", config.value( "FileWidgetFilter" ).toString() ); configElement.setAttribute( "StorageMode", config.value( "StorageMode" ).toString() ); }
QString QgsValueRelationWidgetFactory::representValue( QgsVectorLayer* vl, int fieldIdx, const QgsEditorWidgetConfig& config, const QVariant& cache, const QVariant& value ) const { Q_UNUSED( vl ) Q_UNUSED( fieldIdx ) QgsValueRelationWidgetWrapper::ValueRelationCache vrCache; if ( cache.isValid() ) { vrCache = cache.value<QgsValueRelationWidgetWrapper::ValueRelationCache>(); } else { vrCache = QgsValueRelationWidgetWrapper::createCache( config ); } if ( config.value( "AllowMulti" ).toBool() ) { QStringList keyList = value.toString().remove( QChar( '{' ) ).remove( QChar( '}' ) ).split( "," ); QStringList valueList; Q_FOREACH ( const QgsValueRelationWidgetWrapper::ValueRelationItem& item, vrCache ) { if ( keyList.contains( item.first.toString() ) ) { valueList << item.second; } } return valueList.join( ", " ).prepend( '{' ).append( '}' ); }
void QgsUniqueValueWidgetFactory::writeConfig( const QgsEditorWidgetConfig& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) { Q_UNUSED( doc ) Q_UNUSED( layer ) Q_UNUSED( fieldIdx ) configElement.setAttribute( "Editable", config.value( "Editable", false ).toBool() ); }
void QgsRelationReferenceConfigDlg::setConfig( const QgsEditorWidgetConfig& config ) { if ( config.contains( "AllowNULL" ) ) { mCbxAllowNull->setChecked( config.value( "AllowNULL" ).toBool() ); } if ( config.contains( "OrderByValue" ) ) { mCbxOrderByValue->setChecked( config.value( "OrderByValue" ).toBool() ); } if ( config.contains( "ShowForm" ) ) { mCbxShowForm->setChecked( config.value( "ShowForm" ).toBool() ); } if ( config.contains( "Relation" ) ) { mComboRelation->setCurrentIndex( mComboRelation->findData( config.value( "Relation" ).toString() ) ); relationChanged( mComboRelation->currentIndex() ); } if ( config.contains( "MapIdentification" ) ) { mCbxMapIdentification->setChecked( config.value( "MapIdentification" ).toBool() ); } if ( config.contains( "AllowAddFeatures" ) ) mCbxAllowAddFeatures->setChecked( config.value( "AllowAddFeatures" ).toBool() ); if ( config.contains( "ReadOnly" ) ) { mCbxReadOnly->setChecked( config.value( "ReadOnly" ).toBool() ); } if ( config.contains( "FilterFields" ) ) { mFilterGroupBox->setChecked( true ); Q_FOREACH ( const QString& fld, config.value( "FilterFields" ).toStringList() ) { addFilterField( fld ); } mCbxChainFilters->setChecked( config.value( "ChainFilters" ).toBool() ); }
void QgsValueRelationWidgetFactory::writeConfig( const QgsEditorWidgetConfig& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) { Q_UNUSED( doc ) Q_UNUSED( layer ) Q_UNUSED( fieldIdx ) configElement.setAttribute( "Layer", config.value( "Layer" ).toString() ); configElement.setAttribute( "Key", config.value( "Key" ).toString() ); configElement.setAttribute( "Value", config.value( "Value" ).toString() ); configElement.setAttribute( "FilterExpression", config.value( "FilterExpression" ).toString() ); configElement.setAttribute( "OrderByValue", config.value( "OrderByValue" ).toBool() ); configElement.setAttribute( "AllowMulti", config.value( "AllowMulti" ).toBool() ); configElement.setAttribute( "AllowNull", config.value( "AllowNull" ).toBool() ); configElement.setAttribute( "UseCompleter", config.value( "UseCompleter" ).toBool() ); }
void QgsValueRelationConfigDlg::setConfig( const QgsEditorWidgetConfig& config ) { QgsVectorLayer* lyr = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( config.value( QStringLiteral( "Layer" ) ).toString() ) ); mLayerName->setLayer( lyr ); mKeyColumn->setField( config.value( QStringLiteral( "Key" ) ).toString() ); mValueColumn->setField( config.value( QStringLiteral( "Value" ) ).toString() ); mAllowMulti->setChecked( config.value( QStringLiteral( "AllowMulti" ) ).toBool() ); mAllowNull->setChecked( config.value( QStringLiteral( "AllowNull" ) ).toBool() ); mOrderByValue->setChecked( config.value( QStringLiteral( "OrderByValue" ) ).toBool() ); mFilterExpression->setPlainText( config.value( QStringLiteral( "FilterExpression" ) ).toString() ); mUseCompleter->setChecked( config.value( QStringLiteral( "UseCompleter" ) ).toBool() ); }
void QgsRangeConfigDlg::setConfig( const QgsEditorWidgetConfig& config ) { minimumDoubleSpinBox->setValue( config.value( "Min", 0.0 ).toDouble() ); maximumDoubleSpinBox->setValue( config.value( "Max", 5.0 ).toDouble() ); stepDoubleSpinBox->setValue( config.value( "Step", 1.0 ).toDouble() ); minimumSpinBox->setValue( config.value( "Min", 0 ).toInt() ); maximumSpinBox->setValue( config.value( "Max", 5 ).toInt() ); stepSpinBox->setValue( config.value( "Step", 1 ).toInt() ); rangeWidget->setCurrentIndex( rangeWidget->findData( config.value( "Style", "SpinBox" ) ) ); suffixLineEdit->setText( config.value( "Suffix" ).toString() ); allowNullCheckBox->setChecked( config.value( "AllowNull", true ).toBool() ); }
void QgsTextEditConfigDlg::setConfig( const QgsEditorWidgetConfig& config ) { mIsMultiline->setChecked( config.value( "IsMultiline" ).toBool() ); mUseHtml->setChecked( config.value( "UseHtml" ).toBool() ); }
QgsVectorLayer::EditType QgsLegacyHelpers::convertEditType( const QString& editType, const QgsEditorWidgetConfig& cfg, QgsVectorLayer* vl, const QString& name ) { int idx = vl->fieldNameIndex( name ); if ( !vl->fieldEditable( idx ) ) { return QgsVectorLayer::Immutable; } if ( editType == "Hidden" ) { return QgsVectorLayer::Hidden; } if ( editType == "ValueMap" ) { return QgsVectorLayer::ValueMap; } if ( editType == "TextEdit" ) { if ( cfg.value( "IsMultiline" ).toBool() ) { return QgsVectorLayer::TextEdit; } else { return QgsVectorLayer::LineEdit; } } if ( editType == "Range" ) { if ( cfg.value( "Style" ).toString() == "SliderRange" ) { return QgsVectorLayer::SliderRange; } else if ( cfg.value( "Style" ).toString() == "DialRange" ) { return QgsVectorLayer::DialRange; } else { return QgsVectorLayer::EditRange; } } if ( editType == "UuidGenerator" ) { return QgsVectorLayer::UuidGenerator; } if ( editType == "UniqueValues" ) { if ( cfg.value( "Editable" ).toBool() ) { return QgsVectorLayer::UniqueValuesEditable; } else { return QgsVectorLayer::UniqueValues; } } if ( editType == "Classification" ) { return QgsVectorLayer::Classification; } if ( editType == "CheckBox" ) { return QgsVectorLayer::CheckBox; } if ( editType == "DateTime" ) { return QgsVectorLayer::Calendar; } if ( editType == "FileName" ) { return QgsVectorLayer::FileName; } if ( editType == "WebView" ) { return QgsVectorLayer::WebView; } if ( editType == "Photo" ) { return QgsVectorLayer::Photo; } if ( editType == "Color" ) { return QgsVectorLayer::Color; } if ( editType == "Enumeration" ) { return QgsVectorLayer::Enumeration; } return QgsVectorLayer::EditorWidgetV2; }
void QgsExternalResourceConfigDlg::setConfig( const QgsEditorWidgetConfig& config ) { if ( config.contains( "FileWidget" ) ) { mFileWidgetGroupBox->setChecked( config.value( "FileWidget" ).toBool() ); } if ( config.contains( "FileWidget" ) ) { mFileWidgetButtonGroupBox->setChecked( config.value( "FileWidgetButton" ).toBool() ); } if ( config.contains( "FileWidgetFilter" ) ) { mFileWidgetFilterLineEdit->setText( config.value( "Filter" ).toString() ); } if ( config.contains( "UseLink" ) ) { mUseLink->setChecked( config.value( "UseLink" ).toBool() ); if ( config.contains( "FullUrl" ) ) mFullUrl->setChecked( true ); } if ( config.contains( "DefaultRoot" ) ) { mRootPath->setText( config.value( "DefaultRoot" ).toString() ); } // relative storage if ( config.contains( "RelativeStorage" ) ) { int relative = config.value( "RelativeStorage" ).toInt(); if (( QgsFileWidget::RelativeStorage )relative == QgsFileWidget::Absolute ) { mRelativeGroupBox->setChecked( false ); } else { mRelativeGroupBox->setChecked( true ); mRelativeButtonGroup->button( relative )->setChecked( true ); } } // set storage mode if ( config.contains( "StorageMode" ) ) { int mode = config.value( "StorageMode" ).toInt(); mStorageButtonGroup->button( mode )->setChecked( true ); } // Document viewer if ( config.contains( "DocumentViewer" ) ) { QgsExternalResourceWidget::DocumentViewerContent content = ( QgsExternalResourceWidget::DocumentViewerContent )config.value( "DocumentViewer" ).toInt(); mDocumentViewerGroupBox->setChecked( content != QgsExternalResourceWidget::NoContent ); mDocumentViewerContentComboBox->setCurrentIndex( mDocumentViewerContentComboBox->findData( content ) ); if ( config.contains( "DocumentViewerHeight" ) ) { mDocumentViewerHeight->setValue( config.value( "DocumentViewerHeight" ).toInt() ); } if ( config.contains( "DocumentViewerWidth" ) ) { mDocumentViewerWidth->setValue( config.value( "DocumentViewerWidth" ).toInt() ); } } }
void QgsPhotoConfigDlg::setConfig( const QgsEditorWidgetConfig& config ) { sbWidgetHeight->setValue( config.value( "Height", 0 ).toInt() ); sbWidgetWidth->setValue( config.value( "Width", 0 ).toInt() ); }
void QgsUniqueValuesConfigDlg::setConfig( const QgsEditorWidgetConfig& config ) { editableUniqueValues->setChecked( config.value( "Editable", false ).toBool() ); }