diff --git a/src/gui/csvImport/CsvImportWidget.cpp b/src/gui/csvImport/CsvImportWidget.cpp
index ed00790f5..93cba84c0 100644
--- a/src/gui/csvImport/CsvImportWidget.cpp
+++ b/src/gui/csvImport/CsvImportWidget.cpp
@@ -92,6 +92,7 @@ CsvImportWidget::CsvImportWidget(QWidget *parent)
connect(m_ui->comboBoxComment, SIGNAL(currentIndexChanged(int)), SLOT(parse()));
connect(m_ui->comboBoxFieldSeparator, SIGNAL(currentIndexChanged(int)), SLOT(parse()));
connect(m_ui->checkBoxBackslash, SIGNAL(toggled(bool)), SLOT(parse()));
+ connect(m_ui->checkBoxFieldNames, SIGNAL(toggled(bool)), SLOT(updatePreview()));
connect(m_comboMapper, SIGNAL(mapped(int)), this, SLOT(comboChanged(int)));
connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(writeDatabase()));
@@ -131,26 +132,36 @@ void CsvImportWidget::updateTableview() {
void CsvImportWidget::updatePreview() {
+ int minSkip = 0;
+ if (m_ui->checkBoxFieldNames->isChecked())
+ minSkip = 1;
m_ui->labelSizeRowsCols->setText(m_parserModel->getFileInfo());
- m_ui->spinBoxSkip->setValue(0);
- m_ui->spinBoxSkip->setMaximum(qMax(0, m_parserModel->rowCount() - 1));
+ m_ui->spinBoxSkip->setRange(minSkip, qMax(minSkip, m_parserModel->rowCount() - 1));
+ m_ui->spinBoxSkip->setValue(minSkip);
- int i;
+ int emptyId = 0;
+ QString columnName;
QStringList list(tr("Not present in CSV file"));
- for (i = 1; i < m_parserModel->getCsvCols(); ++i) {
- QString s = QString(tr("Column ")) + QString::number(i);
- list << s;
+ for (int i = 1; i < m_parserModel->getCsvCols(); ++i) {
+ if (m_ui->checkBoxFieldNames->isChecked()) {
+ columnName = m_parserModel->getCsvTable().at(0).at(i);
+ if (columnName.isEmpty())
+ columnName = "<" + tr("Empty fieldname ") + QString::number(++emptyId) + ">";
+ list << columnName;
+ } else {
+ list << QString(tr("column ")) + QString::number(i);
+ }
}
m_comboModel->setStringList(list);
- i=1;
+ int j=1;
for (QComboBox* b : m_combos) {
- if (i < m_parserModel->getCsvCols())
- b->setCurrentIndex(i);
+ if (j < m_parserModel->getCsvCols())
+ b->setCurrentIndex(j);
else
b->setCurrentIndex(0);
- ++i;
+ ++j;
}
}
diff --git a/src/gui/csvImport/CsvImportWidget.h b/src/gui/csvImport/CsvImportWidget.h
index aa463c08b..9215fd368 100644
--- a/src/gui/csvImport/CsvImportWidget.h
+++ b/src/gui/csvImport/CsvImportWidget.h
@@ -53,6 +53,7 @@ private slots:
void comboChanged(int comboId);
void skippedChanged(int rows);
void writeDatabase();
+ void updatePreview();
void setRootGroup();
void reject();
@@ -68,7 +69,6 @@ private:
KeePass2Writer m_writer;
static const QStringList m_columnHeader;
void configParser();
- void updatePreview();
void updateTableview();
Group* splitGroups(QString label);
Group* hasChildren(Group* current, QString groupName);
diff --git a/src/gui/csvImport/CsvImportWidget.ui b/src/gui/csvImport/CsvImportWidget.ui
index 1b4bed729..df0af79f1 100644
--- a/src/gui/csvImport/CsvImportWidget.ui
+++ b/src/gui/csvImport/CsvImportWidget.ui
@@ -6,15 +6,15 @@
0
0
- 779
- 691
+ 892
+ 525
- -
+
-
-
@@ -67,7 +67,23 @@
- -
+
-
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Fixed
+
+
+
+ 758
+ 24
+
+
+
+
+ -
@@ -91,48 +107,6 @@
Encoding
-
-
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Preferred
-
-
-
- 114
- 20
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 114
- 20
-
-
-
-
- -
-
-
-
- 50
- false
-
-
-
- Consider '\' an escape character
-
-
-
-
@@ -149,167 +123,7 @@
- -
-
-
-
- 50
- false
- true
-
-
-
-
-
-
-
- -
-
-
-
- 50
- false
-
-
-
- Fields are separated by
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
- 0
-
-
-
-
- 50
- false
-
-
-
- false
-
-
-
- -
-
-
-
- 50
- false
-
-
-
- Comments start with
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Expanding
-
-
-
- 114
- 20
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
- 0
-
-
-
-
- 50
- false
-
-
-
- false
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Expanding
-
-
-
- 114
- 20
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Expanding
-
-
-
- 114
- 20
-
-
-
-
- -
-
-
-
- 50
- false
-
-
-
- Text is qualified by
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
+
-
@@ -334,79 +148,105 @@
- -
-
-
- Qt::Horizontal
+
-
+
+
+
+ 50
+ false
+
-
- QSizePolicy::Expanding
+
+ Text is qualified by
-
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
- 114
- 20
+ 0
+ 0
-
+
+
+ 50
+ false
+
+
+
+ false
+
+
+
+ -
+
+
+
+ 50
+ false
+
+
+
+ Fields are separated by
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 50
+ false
+
+
+
+ false
+
+
-
-
-
-
-
-
-
- 50
- false
-
-
-
- Skip first
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
-
- 50
- false
-
-
-
-
- -
-
-
-
- 50
- false
-
-
-
- rows
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
+
+
+
+ 50
+ false
+
+
+
+ Comments start with
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
- -
+
-
@@ -431,96 +271,112 @@
- -
+
-
+
+
+
+ 50
+ false
+
+
+
+ First record has field names
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+ 50
+ false
+
+
+
+ Number of headers line to discard
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 50
+ false
+
+
+
+
+
+
+ -
Qt::Horizontal
- 114
+ 122
20
- -
-
-
- Qt::Horizontal
+
-
+
+
+
+ 0
+ 0
+
-
-
- 114
- 20
-
+
+
+ 50
+ false
+
-
+
+ Consider '\' an escape character
+
+
+
+ -
+
+
+
+ 50
+ false
+ true
+
+
+
+
+
+
-
-
-
-
- 0
- 0
-
-
-
-
- 75
- true
-
-
-
- Column layout
-
-
-
-
-
-
- 6
-
-
- 6
-
-
- 0
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Fixed
-
-
-
- 758
- 24
-
-
-
-
- -
-
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
- false
-
-
-
- -
@@ -569,6 +425,50 @@
+ -
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+ false
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 75
+ true
+
+
+
+ Column layout
+
+
+
-
+
+
+ 6
+
+
+ 6
+
+
+ 0
+
+
+
+
+
+