Commit bf4e9fbc authored by Alexander Semke's avatar Alexander Semke

[ascii import] instead of asking the user to provide the locale, ask

explictely for the decimal separator (point or comma).
parent 708a25d0
......@@ -47,20 +47,19 @@ AsciiOptionsWidget::AsciiOptionsWidget(QWidget* parent) : QWidget(parent) {
ui.cbSeparatingCharacter->addItems(AsciiFilter::separatorCharacters());
ui.cbCommentCharacter->addItems(AsciiFilter::commentCharacters());
ui.cbNumberFormat->addItems(AbstractFileFilter::numberFormats());
ui.cbDecimalSeparator->addItem(i18n("Point '.'"));
ui.cbDecimalSeparator->addItem(i18n("Comma ','"));
ui.cbDateTimeFormat->addItems(AbstractColumn::dateTimeFormats());
const QString textNumberFormatShort = i18n("This option determines how the imported strings have to be converted to numbers.");
const QString textNumberFormat = textNumberFormatShort + "<br><br>" + i18n(
"For 'C Format', a period is used for the decimal point character and comma is used for the thousands group separator. "
"Valid number representations are:"
"When point character is used for the decimal separator, the valid number representations are:"
"<ul>"
"<li>1234.56</li>"
"<li>1,234.56</li>"
"<li>etc.</li>"
"</ul>"
"When using 'System locale', the system settings will be used. "
"E.g., for the German local the valid number representations are:"
"For comma as the decimal separator, the valid number representations are:"
"<ul>"
"<li>1234,56</li>"
"<li>1.234,56</li>"
......@@ -68,10 +67,10 @@ AsciiOptionsWidget::AsciiOptionsWidget(QWidget* parent) : QWidget(parent) {
"</ul>"
);
ui.lNumberFormat->setToolTip(textNumberFormatShort);
ui.lNumberFormat->setWhatsThis(textNumberFormat);
ui.cbNumberFormat->setToolTip(textNumberFormatShort);
ui.cbNumberFormat->setWhatsThis(textNumberFormat);
ui.lDecimalSeparator->setToolTip(textNumberFormatShort);
ui.lDecimalSeparator->setWhatsThis(textNumberFormat);
ui.cbDecimalSeparator->setToolTip(textNumberFormatShort);
ui.cbDecimalSeparator->setWhatsThis(textNumberFormat);
const QString textDateTimeFormatShort = i18n("This option determines how the imported strings have to be converted to calendar date, i.e. year, month, and day numbers in the Gregorian calendar and to time.");
const QString textDateTimeFormat = textDateTimeFormatShort + "<br><br>" + i18n(
......@@ -148,7 +147,13 @@ void AsciiOptionsWidget::applyFilterSettings(AsciiFilter* filter) const {
Q_ASSERT(filter);
filter->setCommentCharacter( ui.cbCommentCharacter->currentText() );
filter->setSeparatingCharacter( ui.cbSeparatingCharacter->currentText() );
filter->setNumberFormat( QLocale::Language(ui.cbNumberFormat->currentIndex()) );
QLocale::Language lang;
if (ui.cbDecimalSeparator->currentIndex() == 0)
lang = QLocale::Language::C;
else
lang = QLocale::Language::German;
filter->setNumberFormat(lang);
filter->setDateTimeFormat(ui.cbDateTimeFormat->currentText());
filter->setCreateIndexEnabled( ui.chbCreateIndex->isChecked() );
filter->setCreateTimestampEnabled( ui.chbCreateTimestamp->isChecked() );
......@@ -169,7 +174,11 @@ void AsciiOptionsWidget::loadSettings() const {
ui.cbCommentCharacter->setCurrentText(conf.readEntry("CommentCharacter", "#"));
ui.cbSeparatingCharacter->setCurrentItem(conf.readEntry("SeparatingCharacter", "auto"));
ui.cbNumberFormat->setCurrentIndex(conf.readEntry("NumberFormat", (int)QLocale::AnyLanguage));
const QChar decimalSeparator = QLocale().decimalPoint();
int index = (decimalSeparator == '.') ? 0 : 1;
ui.cbDecimalSeparator->setCurrentIndex(conf.readEntry("DecimalSeparator", index));
ui.cbDateTimeFormat->setCurrentItem(conf.readEntry("DateTimeFormat", "yyyy-MM-dd hh:mm:ss.zzz"));
ui.chbCreateIndex->setChecked(conf.readEntry("CreateIndex", false));
ui.chbCreateTimestamp->setChecked(conf.readEntry("CreateTimestamp", true));
......@@ -186,7 +195,7 @@ void AsciiOptionsWidget::saveSettings() {
conf.writeEntry("CommentCharacter", ui.cbCommentCharacter->currentText());
conf.writeEntry("SeparatingCharacter", ui.cbSeparatingCharacter->currentText());
conf.writeEntry("NumberFormat", ui.cbNumberFormat->currentIndex());
conf.writeEntry("DecimalSeparator", ui.cbDecimalSeparator->currentIndex());
conf.writeEntry("DateTimeFormat", ui.cbDateTimeFormat->currentText());
conf.writeEntry("CreateIndex", ui.chbCreateIndex->isChecked());
conf.writeEntry("CreateTimestamp", ui.chbCreateTimestamp->isChecked());
......
......@@ -20,7 +20,7 @@
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Comment character:</string>
<string>Comment Character:</string>
</property>
</widget>
</item>
......@@ -53,7 +53,7 @@
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="lSeparatingCharacter">
<property name="text">
<string>Separating string:</string>
<string>Column Separator</string>
</property>
</widget>
</item>
......@@ -65,19 +65,19 @@
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="lNumberFormat">
<widget class="QLabel" name="lDecimalSeparator">
<property name="text">
<string>Number format:</string>
<string>Decimal Separator:</string>
</property>
</widget>
</item>
<item row="2" column="2" colspan="3">
<widget class="QComboBox" name="cbNumberFormat"/>
<widget class="QComboBox" name="cbDecimalSeparator"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="lDateTimeFormat">
<property name="text">
<string>DateTime format:</string>
<string>DateTime Format:</string>
</property>
</widget>
</item>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment