From 984602b7a0b6b79cb2c74f1e0b47f9e069945cd4 Mon Sep 17 00:00:00 2001 From: seatedscribe Date: Wed, 8 Mar 2017 22:58:46 +0100 Subject: [PATCH] Enhance FormatStatusText(), other minor cosmetics --- src/gui/csvImport/CsvImportWidget.cpp | 19 ++++++++++--------- src/gui/csvImport/CsvParserModel.cpp | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/gui/csvImport/CsvImportWidget.cpp b/src/gui/csvImport/CsvImportWidget.cpp index 4d64296e..ed00790f 100644 --- a/src/gui/csvImport/CsvImportWidget.cpp +++ b/src/gui/csvImport/CsvImportWidget.cpp @@ -138,14 +138,14 @@ void CsvImportWidget::updatePreview() { int i; QStringList list(tr("Not present in CSV file")); - for (i = 1; i < m_parserModel->getCsvCols(); i++) { + for (i = 1; i < m_parserModel->getCsvCols(); ++i) { QString s = QString(tr("Column ")) + QString::number(i); list << s; } m_comboModel->setStringList(list); i=1; - Q_FOREACH (QComboBox* b, m_combos) { + for (QComboBox* b : m_combos) { if (i < m_parserModel->getCsvCols()) b->setCurrentIndex(i); else @@ -184,20 +184,21 @@ void CsvImportWidget::parse() { QString CsvImportWidget::formatStatusText() const { QString text = m_parserModel->getStatus(); int items = text.count('\n'); - if (items > 2) + if (items > 2) { return text.section('\n', 0, 1) .append("\n[").append(QString::number(items - 2)) .append(tr(" more messages skipped]")); - else - for (int i = 0; i < 2 - items; i++) - text.append(QString("\n")); - return text; + } + if (items == 1) { + text.append(QString("\n")); + } + return text; } void CsvImportWidget::writeDatabase() { setRootGroup(); - for (int r = 0; r < m_parserModel->rowCount(); r++) { + for (int r = 0; r < m_parserModel->rowCount(); ++r) { //use validity of second column as a GO/NOGO for all others fields if (not m_parserModel->data(m_parserModel->index(r, 1)).isValid()) continue; @@ -229,7 +230,7 @@ void CsvImportWidget::setRootGroup() { bool is_empty = false; bool is_label = false; - for (int r = 0; r < m_parserModel->rowCount(); r++) { + for (int r = 0; r < m_parserModel->rowCount(); ++r) { //use validity of second column as a GO/NOGO for all others fields if (not m_parserModel->data(m_parserModel->index(r, 1)).isValid()) continue; diff --git a/src/gui/csvImport/CsvParserModel.cpp b/src/gui/csvImport/CsvParserModel.cpp index d315f1ad..efffda55 100644 --- a/src/gui/csvImport/CsvParserModel.cpp +++ b/src/gui/csvImport/CsvParserModel.cpp @@ -46,7 +46,7 @@ bool CsvParserModel::parse() { QFile csv(m_filename); r = CsvParser::parse(&csv); } - for (int i = 0; i < columnCount(); i++) + for (int i = 0; i < columnCount(); ++i) m_columnMap.insert(i,0); addEmptyColumn(); endResetModel();