mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
ImportCsvDialog: Add options to define custom quote/separator chars
Make it possible to use other quote and separator characters than those predefined in the respective combo boxes when importing a CSV file. See issue #23.
This commit is contained in:
@@ -154,6 +154,10 @@ void ImportCsvDialog::accept()
|
||||
|
||||
void ImportCsvDialog::updatePreview()
|
||||
{
|
||||
// Show/hide custom quote/separator input fields
|
||||
ui->editCustomQuote->setVisible(ui->comboQuote->currentIndex() == ui->comboQuote->count()-1);
|
||||
ui->editCustomSeparator->setVisible(ui->comboSeparator->currentIndex() == ui->comboSeparator->count()-1);
|
||||
|
||||
// Get preview data
|
||||
int numfields;
|
||||
int maxrecs = 20;
|
||||
@@ -206,6 +210,10 @@ void ImportCsvDialog::checkInput()
|
||||
|
||||
char ImportCsvDialog::currentQuoteChar()
|
||||
{
|
||||
// The last item in the combobox is the 'Other' item; if it is selected return the text of the line edit field instead
|
||||
if(ui->comboQuote->currentIndex() == ui->comboQuote->count()-1)
|
||||
return ui->editCustomQuote->text().length() ? ui->editCustomQuote->text().at(0).toLatin1() : 0;
|
||||
|
||||
if(ui->comboQuote->currentText().length())
|
||||
return ui->comboQuote->currentText().at(0).toLatin1();
|
||||
else
|
||||
@@ -214,5 +222,9 @@ char ImportCsvDialog::currentQuoteChar()
|
||||
|
||||
char ImportCsvDialog::currentSeparatorChar()
|
||||
{
|
||||
// The last item in the combobox is the 'Other' item; if it is selected return the text of the line edit field instead
|
||||
if(ui->comboSeparator->currentIndex() == ui->comboSeparator->count()-1)
|
||||
return ui->editCustomSeparator->text().length() ? ui->editCustomSeparator->text().at(0).toLatin1() : 0;
|
||||
|
||||
return ui->comboSeparator->currentText() == tr("Tab") ? '\t' : ui->comboSeparator->currentText().at(0).toLatin1();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelName">
|
||||
<property name="text">
|
||||
@@ -57,28 +60,57 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboSeparator">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>,</string>
|
||||
</property>
|
||||
<widget class="QComboBox" name="comboSeparator">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>,</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>;</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Tab</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>|</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Other</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>;</string>
|
||||
</property>
|
||||
<widget class="QLineEdit" name="editCustomSeparator">
|
||||
<property name="maxLength">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Tab</string>
|
||||
</property>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>|</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelQuote">
|
||||
@@ -91,23 +123,52 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="comboQuote">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>"</string>
|
||||
</property>
|
||||
<widget class="QComboBox" name="comboQuote">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>'</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Other</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>'</string>
|
||||
</property>
|
||||
<widget class="QLineEdit" name="editCustomQuote">
|
||||
<property name="maxLength">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</widget>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@@ -130,7 +191,9 @@
|
||||
<tabstop>editName</tabstop>
|
||||
<tabstop>checkboxHeader</tabstop>
|
||||
<tabstop>comboSeparator</tabstop>
|
||||
<tabstop>editCustomSeparator</tabstop>
|
||||
<tabstop>comboQuote</tabstop>
|
||||
<tabstop>editCustomQuote</tabstop>
|
||||
<tabstop>tablePreview</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
@@ -232,6 +295,38 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>editCustomSeparator</sender>
|
||||
<signal>textChanged(QString)</signal>
|
||||
<receiver>ImportCsvDialog</receiver>
|
||||
<slot>updatePreview()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>325</x>
|
||||
<y>70</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>577</x>
|
||||
<y>76</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>editCustomQuote</sender>
|
||||
<signal>textChanged(QString)</signal>
|
||||
<receiver>ImportCsvDialog</receiver>
|
||||
<slot>updatePreview()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>467</x>
|
||||
<y>101</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>530</x>
|
||||
<y>90</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>updatePreview()</slot>
|
||||
|
||||
Reference in New Issue
Block a user