24 mFieldFormatComboBox->clear();
29 mFieldFormatComboBox->addItem(
tr(
"Custom" ),
QString() );
33 connect( mDisplayFormatEdit, SIGNAL( textChanged(
QString ) ),
this, SLOT( updateDemoWidget() ) );
34 connect( mCalendarPopupCheckBox, SIGNAL( toggled(
bool ) ),
this, SLOT( updateDemoWidget() ) );
36 connect( mFieldFormatComboBox, SIGNAL( currentIndexChanged(
int ) ),
this, SLOT( updateFieldFormat(
int ) ) );
37 connect( mFieldFormatEdit, SIGNAL( textChanged(
QString ) ),
this, SLOT( updateDisplayFormat(
QString ) ) );
38 connect( mDisplayFormatComboBox, SIGNAL( currentIndexChanged(
int ) ),
this, SLOT( displayFormatChanged(
int ) ) );
40 connect( mFieldHelpToolButton, SIGNAL( clicked(
bool ) ),
this, SLOT( showHelp(
bool ) ) );
41 connect( mDisplayHelpToolButton, SIGNAL( clicked(
bool ) ),
this, SLOT( showHelp(
bool ) ) );
45 connect( mCalendarPopupCheckBox, SIGNAL( toggled(
bool ) ),
this, SIGNAL(
changed() ) );
46 connect( mAllowNullCheckBox, SIGNAL( toggled(
bool ) ),
this, SIGNAL(
changed() ) );
49 updateFieldFormat( mFieldFormatComboBox->currentIndex() );
50 displayFormatChanged( mDisplayFormatComboBox->currentIndex() );
54 void QgsDateTimeEditConfig::updateDemoWidget()
56 mDemoDateTimeEdit->setDisplayFormat( mDisplayFormatEdit->text() );
57 mDemoDateTimeEdit->setCalendarPopup( mCalendarPopupCheckBox->isChecked() );
61 void QgsDateTimeEditConfig::updateFieldFormat(
int idx )
63 const QString format = mFieldFormatComboBox->itemData( idx ).toString();
67 mFieldFormatEdit->setText( format );
70 mFieldFormatEdit->setEnabled( custom );
71 mFieldHelpToolButton->setVisible( custom );
72 if ( mFieldHelpToolButton->isHidden() && mDisplayHelpToolButton->isHidden() )
74 mHelpScrollArea->setVisible(
false );
80 void QgsDateTimeEditConfig::updateDisplayFormat(
const QString& fieldFormat )
82 if ( mDisplayFormatComboBox->currentIndex() == 0 )
91 mDisplayFormatEdit->setText( fieldFormat );
97 void QgsDateTimeEditConfig::displayFormatChanged(
int idx )
99 const bool custom = idx == 1;
100 mDisplayFormatEdit->setEnabled( custom );
101 mDisplayHelpToolButton->setVisible( custom );
102 if ( mFieldHelpToolButton->isHidden() && mDisplayHelpToolButton->isHidden() )
104 mHelpScrollArea->setVisible(
false );
108 mDisplayFormatEdit->setText( mFieldFormatEdit->text() );
112 void QgsDateTimeEditConfig::showHelp(
bool buttonChecked )
114 mFieldHelpToolButton->setChecked( buttonChecked );
115 mDisplayHelpToolButton->setChecked( buttonChecked );
116 mHelpScrollArea->setVisible( buttonChecked );
125 myConfig.insert(
"field_format", mFieldFormatEdit->text() );
126 myConfig.insert(
"display_format", mDisplayFormatEdit->text() );
127 myConfig.insert(
"calendar_popup", mCalendarPopupCheckBox->isChecked() );
128 myConfig.insert(
"allow_null", mAllowNullCheckBox->isChecked() );
136 if ( config.contains(
"field_format" ) )
138 const QString fieldFormat = config[
"field_format" ].toString();
139 mFieldFormatEdit->setText( fieldFormat );
141 const int idx = mFieldFormatComboBox->findData( fieldFormat );
144 mFieldFormatComboBox->setCurrentIndex( idx );
148 mFieldFormatComboBox->setCurrentIndex( 4 );
152 if ( config.contains(
"display_format" ) )
154 const QString displayFormat = config[
"display_format" ].toString();
155 mDisplayFormatEdit->setText( displayFormat );
156 if ( displayFormat == mFieldFormatEdit->text() )
158 mDisplayFormatComboBox->setCurrentIndex( 0 );
162 mDisplayFormatComboBox->setCurrentIndex( 1 );
166 if ( config.contains(
"calendar_popup" ) )
168 mCalendarPopupCheckBox->setChecked( config[
"calendar_popup" ].toBool() );
171 if ( config.contains(
"allow_null" ) )
173 mAllowNullCheckBox->setChecked( config[
"allow_null" ].toBool() );
#define QGSDATETIMEEDIT_DATEFORMAT
#define QGSDATETIMEEDIT_ISODATETIMEFORMAT
QgsDateTimeEditConfig(QgsVectorLayer *vl, int fieldIdx, QWidget *parent=nullptr)
void setConfig(const QgsEditorWidgetConfig &config) override
Update the configuration widget to represent the given configuration.
QString tr(const char *sourceText, const char *disambiguation, int n)
QVariantMap QgsEditorWidgetConfig
Holds a set of configuration parameters for a editor widget wrapper.
#define QGSDATETIMEEDIT_TIMEFORMAT
QDateTime currentDateTime()
QgsEditorWidgetConfig config() override
Create a configuration from the current GUI state.
#define QGSDATETIMEEDIT_ISODISPLAYFORMAT
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
#define QGSDATETIMEEDIT_DATETIMEFORMAT