Skip to content

Commit cd23621

Browse files
committed
Fix some editor widget config dialogs don't show default settings
1 parent 1671536 commit cd23621

File tree

4 files changed

+28
-62
lines changed

4 files changed

+28
-62
lines changed

src/gui/editorwidgets/qgsdatetimeeditconfig.cpp

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -121,43 +121,29 @@ QgsEditorWidgetConfig QgsDateTimeEditConfig::config()
121121

122122
void QgsDateTimeEditConfig::setConfig( const QgsEditorWidgetConfig &config )
123123
{
124-
if ( config.contains( "field_format" ) )
124+
const QString fieldFormat = config.value( "field_format", QGSDATETIMEEDIT_DATEFORMAT ).toString();
125+
mFieldFormatEdit->setText( fieldFormat );
126+
127+
if ( fieldFormat == QGSDATETIMEEDIT_DATEFORMAT )
128+
mFieldFormatComboBox->setCurrentIndex( 0 );
129+
else if ( fieldFormat == QGSDATETIMEEDIT_TIMEFORMAT )
130+
mFieldFormatComboBox->setCurrentIndex( 1 );
131+
else if ( fieldFormat == QGSDATETIMEEDIT_DATETIMEFORMAT )
132+
mFieldFormatComboBox->setCurrentIndex( 2 );
133+
else
134+
mFieldFormatComboBox->setCurrentIndex( 3 );
135+
136+
QString displayFormat = config.value( "display_format", QGSDATETIMEEDIT_DATEFORMAT ).toString();
137+
mDisplayFormatEdit->setText( displayFormat );
138+
if ( displayFormat == mFieldFormatEdit->text() )
125139
{
126-
const QString fieldFormat = config[ "field_format" ].toString();
127-
mFieldFormatEdit->setText( fieldFormat );
128-
129-
if ( fieldFormat == QGSDATETIMEEDIT_DATEFORMAT )
130-
mFieldFormatComboBox->setCurrentIndex( 0 );
131-
else if ( fieldFormat == QGSDATETIMEEDIT_TIMEFORMAT )
132-
mFieldFormatComboBox->setCurrentIndex( 1 );
133-
else if ( fieldFormat == QGSDATETIMEEDIT_DATETIMEFORMAT )
134-
mFieldFormatComboBox->setCurrentIndex( 2 );
135-
else
136-
mFieldFormatComboBox->setCurrentIndex( 3 );
140+
mDisplayFormatComboBox->setCurrentIndex( 0 );
137141
}
138-
139-
if ( config.contains( "display_format" ) )
140-
{
141-
const QString displayFormat = config[ "display_format" ].toString();
142-
mDisplayFormatEdit->setText( displayFormat );
143-
if ( displayFormat == mFieldFormatEdit->text() )
144-
{
145-
mDisplayFormatComboBox->setCurrentIndex( 0 );
146-
}
147-
else
148-
{
149-
mDisplayFormatComboBox->setCurrentIndex( 1 );
150-
}
151-
}
152-
153-
if ( config.contains( "calendar_popup" ) )
154-
{
155-
mCalendarPopupCheckBox->setChecked( config[ "calendar_popup" ].toBool() );
156-
}
157-
158-
if ( config.contains( "allow_null" ) )
142+
else
159143
{
160-
mAllowNullCheckBox->setChecked( config[ "allow_null" ].toBool() );
144+
mDisplayFormatComboBox->setCurrentIndex( 1 );
161145
}
162146

147+
mCalendarPopupCheckBox->setChecked( config.value( "calendar_popup" , false ).toBool() );
148+
mAllowNullCheckBox->setChecked( config.value( "allow_null", true ).toBool() );
163149
}

src/gui/editorwidgets/qgsdatetimeeditfactory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,4 @@ unsigned int QgsDateTimeEditFactory::fieldScore( const QgsVectorLayer* vl, int f
128128
{
129129
return 5;
130130
}
131-
}
131+
}

src/gui/editorwidgets/qgsrangewidgetwrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void QgsRangeWidgetWrapper::initWidget( QWidget* editor )
7474
mQgsDial = qobject_cast<QgsDial*>( editor );
7575
mQgsSlider = qobject_cast<QgsSlider*>( editor );
7676

77-
bool allowNull = config( "AllowNull" ).toBool();
77+
bool allowNull = config( "AllowNull", true ).toBool();
7878

7979
QVariant min( config( "Min" ) );
8080
QVariant max( config( "Max" ) );

src/gui/editorwidgets/qgsrelationreferenceconfigdlg.cpp

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,39 +56,19 @@ QgsRelationReferenceConfigDlg::QgsRelationReferenceConfigDlg( QgsVectorLayer* vl
5656

5757
void QgsRelationReferenceConfigDlg::setConfig( const QgsEditorWidgetConfig& config )
5858
{
59-
if ( config.contains( "AllowNULL" ) )
60-
{
61-
mCbxAllowNull->setChecked( config.value( "AllowNULL" ).toBool() );
62-
}
63-
64-
if ( config.contains( "OrderByValue" ) )
65-
{
66-
mCbxOrderByValue->setChecked( config.value( "OrderByValue" ).toBool() );
67-
}
68-
69-
if ( config.contains( "ShowForm" ) )
70-
{
71-
mCbxShowForm->setChecked( config.value( "ShowForm" ).toBool() );
72-
}
59+
mCbxAllowNull->setChecked( config.value( "AllowNULL", false ).toBool() );
60+
mCbxOrderByValue->setChecked( config.value( "OrderByValue", false ).toBool() );
61+
mCbxShowForm->setChecked( config.value( "ShowForm", true ).toBool() );
7362

7463
if ( config.contains( "Relation" ) )
7564
{
7665
mComboRelation->setCurrentIndex( mComboRelation->findData( config.value( "Relation" ).toString() ) );
7766
relationChanged( mComboRelation->currentIndex() );
7867
}
7968

80-
if ( config.contains( "MapIdentification" ) )
81-
{
82-
mCbxMapIdentification->setChecked( config.value( "MapIdentification" ).toBool() );
83-
}
84-
85-
if ( config.contains( "AllowAddFeatures" ) )
86-
mCbxAllowAddFeatures->setChecked( config.value( "AllowAddFeatures" ).toBool() );
87-
88-
if ( config.contains( "ReadOnly" ) )
89-
{
90-
mCbxReadOnly->setChecked( config.value( "ReadOnly" ).toBool() );
91-
}
69+
mCbxMapIdentification->setChecked( config.value( "MapIdentification", false ).toBool() );
70+
mCbxAllowAddFeatures->setChecked( config.value( "AllowAddFeatures", false ).toBool() );
71+
mCbxReadOnly->setChecked( config.value( "ReadOnly", false ).toBool() );
9272

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

0 commit comments

Comments
 (0)