Skip to content
Permalink
Browse files

Fix some editor widget config dialogs don't show default settings

  • Loading branch information
nyalldawson committed Sep 5, 2016
1 parent 1671536 commit cd236218e06b99da5da769cf5ff5a11ccada6828
@@ -121,43 +121,29 @@ QgsEditorWidgetConfig QgsDateTimeEditConfig::config()

void QgsDateTimeEditConfig::setConfig( const QgsEditorWidgetConfig &config )
{
if ( config.contains( "field_format" ) )
const QString fieldFormat = config.value( "field_format", QGSDATETIMEEDIT_DATEFORMAT ).toString();
mFieldFormatEdit->setText( fieldFormat );

if ( fieldFormat == QGSDATETIMEEDIT_DATEFORMAT )
mFieldFormatComboBox->setCurrentIndex( 0 );
else if ( fieldFormat == QGSDATETIMEEDIT_TIMEFORMAT )
mFieldFormatComboBox->setCurrentIndex( 1 );
else if ( fieldFormat == QGSDATETIMEEDIT_DATETIMEFORMAT )
mFieldFormatComboBox->setCurrentIndex( 2 );
else
mFieldFormatComboBox->setCurrentIndex( 3 );

QString displayFormat = config.value( "display_format", QGSDATETIMEEDIT_DATEFORMAT ).toString();
mDisplayFormatEdit->setText( displayFormat );
if ( displayFormat == mFieldFormatEdit->text() )
{
const QString fieldFormat = config[ "field_format" ].toString();
mFieldFormatEdit->setText( fieldFormat );

if ( fieldFormat == QGSDATETIMEEDIT_DATEFORMAT )
mFieldFormatComboBox->setCurrentIndex( 0 );
else if ( fieldFormat == QGSDATETIMEEDIT_TIMEFORMAT )
mFieldFormatComboBox->setCurrentIndex( 1 );
else if ( fieldFormat == QGSDATETIMEEDIT_DATETIMEFORMAT )
mFieldFormatComboBox->setCurrentIndex( 2 );
else
mFieldFormatComboBox->setCurrentIndex( 3 );
mDisplayFormatComboBox->setCurrentIndex( 0 );
}

if ( config.contains( "display_format" ) )
{
const QString displayFormat = config[ "display_format" ].toString();
mDisplayFormatEdit->setText( displayFormat );
if ( displayFormat == mFieldFormatEdit->text() )
{
mDisplayFormatComboBox->setCurrentIndex( 0 );
}
else
{
mDisplayFormatComboBox->setCurrentIndex( 1 );
}
}

if ( config.contains( "calendar_popup" ) )
{
mCalendarPopupCheckBox->setChecked( config[ "calendar_popup" ].toBool() );
}

if ( config.contains( "allow_null" ) )
else
{
mAllowNullCheckBox->setChecked( config[ "allow_null" ].toBool() );
mDisplayFormatComboBox->setCurrentIndex( 1 );
}

mCalendarPopupCheckBox->setChecked( config.value( "calendar_popup" , false ).toBool() );
mAllowNullCheckBox->setChecked( config.value( "allow_null", true ).toBool() );
}
@@ -128,4 +128,4 @@ unsigned int QgsDateTimeEditFactory::fieldScore( const QgsVectorLayer* vl, int f
{
return 5;
}
}
}
@@ -74,7 +74,7 @@ void QgsRangeWidgetWrapper::initWidget( QWidget* editor )
mQgsDial = qobject_cast<QgsDial*>( editor );
mQgsSlider = qobject_cast<QgsSlider*>( editor );

bool allowNull = config( "AllowNull" ).toBool();
bool allowNull = config( "AllowNull", true ).toBool();

QVariant min( config( "Min" ) );
QVariant max( config( "Max" ) );
@@ -56,39 +56,19 @@ QgsRelationReferenceConfigDlg::QgsRelationReferenceConfigDlg( QgsVectorLayer* vl

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() );
}
mCbxAllowNull->setChecked( config.value( "AllowNULL", false ).toBool() );
mCbxOrderByValue->setChecked( config.value( "OrderByValue", false ).toBool() );
mCbxShowForm->setChecked( config.value( "ShowForm", true ).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() );
}
mCbxMapIdentification->setChecked( config.value( "MapIdentification", false ).toBool() );
mCbxAllowAddFeatures->setChecked( config.value( "AllowAddFeatures", false ).toBool() );
mCbxReadOnly->setChecked( config.value( "ReadOnly", false ).toBool() );

if ( config.contains( "FilterFields" ) )
{

0 comments on commit cd23621

Please sign in to comment.
You can’t perform that action at this time.