24 mDemoDateTimeEdit->setDateTime( QDateTime::currentDateTime() );
26 connect( mDisplayFormatEdit, SIGNAL( textChanged( QString ) ),
this, SLOT( updateDemoWidget() ) );
27 connect( mCalendarPopupCheckBox, SIGNAL( toggled(
bool ) ),
this, SLOT( updateDemoWidget() ) );
29 connect( mFieldFormatComboBox, SIGNAL( currentIndexChanged(
int ) ),
this, SLOT( updateFieldFormat(
int ) ) );
30 connect( mFieldFormatEdit, SIGNAL( textChanged( QString ) ),
this, SLOT( updateDisplayFormat( QString ) ) );
31 connect( mDisplayFormatComboBox, SIGNAL( currentIndexChanged(
int ) ),
this, SLOT( displayFormatChanged(
int ) ) );
33 connect( mFieldHelpToolButton, SIGNAL( clicked(
bool ) ),
this, SLOT( showHelp(
bool ) ) );
34 connect( mDisplayHelpToolButton, SIGNAL( clicked(
bool ) ),
this, SLOT( showHelp(
bool ) ) );
37 updateFieldFormat( mFieldFormatComboBox->currentIndex() );
38 displayFormatChanged( mDisplayFormatComboBox->currentIndex() );
42 void QgsDateTimeEditConfig::updateDemoWidget()
44 mDemoDateTimeEdit->setDisplayFormat( mDisplayFormatEdit->text() );
45 mDemoDateTimeEdit->setCalendarPopup( mCalendarPopupCheckBox->isChecked() );
49 void QgsDateTimeEditConfig::updateFieldFormat(
int idx )
64 mFieldFormatEdit->setVisible( idx == 3 );
65 mFieldHelpToolButton->setVisible( idx == 3 );
66 if ( mFieldHelpToolButton->isHidden() && mDisplayHelpToolButton->isHidden() )
68 mHelpScrollArea->setVisible(
false );
73 void QgsDateTimeEditConfig::updateDisplayFormat( QString fieldFormat )
75 if ( mDisplayFormatComboBox->currentIndex() == 0 )
77 mDisplayFormatEdit->setText( fieldFormat );
82 void QgsDateTimeEditConfig::displayFormatChanged(
int idx )
84 mDisplayFormatEdit->setEnabled( idx == 1 );
85 mDisplayHelpToolButton->setVisible( idx == 1 );
86 if ( mFieldHelpToolButton->isHidden() && mDisplayHelpToolButton->isHidden() )
88 mHelpScrollArea->setVisible(
false );
92 mDisplayFormatEdit->setText( mFieldFormatEdit->text() );
96 void QgsDateTimeEditConfig::showHelp(
bool buttonChecked )
98 mFieldHelpToolButton->setChecked( buttonChecked );
99 mDisplayHelpToolButton->setChecked( buttonChecked );
100 mHelpScrollArea->setVisible( buttonChecked );
108 myConfig.insert(
"field_format", mFieldFormatEdit->text() );
109 myConfig.insert(
"display_format", mDisplayFormatEdit->text() );
110 myConfig.insert(
"calendar_popup", mCalendarPopupCheckBox->isChecked() );
111 myConfig.insert(
"allow_null", mAllowNullCheckBox->isChecked() );
119 if ( config.contains(
"field_format" ) )
121 const QString fieldFormat = config[
"field_format" ].toString();
122 mFieldFormatEdit->setText( fieldFormat );
125 mFieldFormatComboBox->setCurrentIndex( 0 );
127 mFieldFormatComboBox->setCurrentIndex( 1 );
129 mFieldFormatComboBox->setCurrentIndex( 2 );
131 mFieldFormatComboBox->setCurrentIndex( 3 );
134 if ( config.contains(
"display_format" ) )
136 const QString displayFormat = config[
"display_format" ].toString();
137 mDisplayFormatEdit->setText( displayFormat );
138 if ( displayFormat == mFieldFormatEdit->text() )
140 mDisplayFormatComboBox->setCurrentIndex( 0 );
144 mDisplayFormatComboBox->setCurrentIndex( 1 );
148 if ( config.contains(
"calendar_popup" ) )
150 mCalendarPopupCheckBox->setChecked( config[
"calendar_popup" ].toBool() );
153 if ( config.contains(
"allow_null" ) )
155 mAllowNullCheckBox->setChecked( config[
"allow_null" ].toBool() );