mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-02 03:26:14 -04:00
[CSV import GUI] add option to choose dropdown menu field names from CSV
This should also close #458
This commit is contained in:
parent
ad79162061
commit
2e2e37098f
3 changed files with 261 additions and 350 deletions
|
@ -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,16 +132,26 @@ 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 i, 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;
|
||||
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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue