From 6ef17ec05badbc08fea270dc854a6fb2dd221888 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 9 Nov 2020 13:16:50 +0200 Subject: [PATCH] Fix mapping csv columns. --- .../dialogs/dialogmeasurementscsvcolumns.cpp | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp b/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp index 7d7ba78c4..80345637f 100644 --- a/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp +++ b/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp @@ -497,7 +497,7 @@ void DialogMeasurementsCSVColumns::InitColumnsMap() QSharedPointer csv = DialogMeasurementsCSVColumns::CSVModel(); m_columnsMap.clear(); - auto InitColumn = [this, csv](int column, bool forceSkip=false) + auto InitColumn = [this, csv](int column, int &index, bool forceSkip=false) { if (forceSkip) { @@ -505,13 +505,14 @@ void DialogMeasurementsCSVColumns::InitColumnsMap() } else { + ++index; if (ColumnMandatory(column)) { - m_columnsMap[column] = column; + m_columnsMap[column] = index; } else { - m_columnsMap[column] = csv->columnCount() >= column ? column : -1; + m_columnsMap[column] = csv->columnCount() >= index ? index : -1; } } }; @@ -519,23 +520,25 @@ void DialogMeasurementsCSVColumns::InitColumnsMap() if (m_type == MeasurementsType::Individual) { m_columnsMap.resize(static_cast(IndividualMeasurementsColumns::LAST_DO_NOT_USE)); + int index = -1; for(int column = 0; column < static_cast(IndividualMeasurementsColumns::LAST_DO_NOT_USE); ++column) { - InitColumn(column); + InitColumn(column, index); } } else { m_columnsMap.resize(static_cast(MultisizeMeasurementsColumns::LAST_DO_NOT_USE)); + int index = -1; - InitColumn(static_cast(MultisizeMeasurementsColumns::Name)); - InitColumn(static_cast(MultisizeMeasurementsColumns::BaseValue)); - InitColumn(static_cast(MultisizeMeasurementsColumns::ShiftA)); - InitColumn(static_cast(MultisizeMeasurementsColumns::ShiftB), m_dimensions.size() < 2); - InitColumn(static_cast(MultisizeMeasurementsColumns::ShiftC), m_dimensions.size() < 3); - InitColumn(static_cast(MultisizeMeasurementsColumns::FullName)); - InitColumn(static_cast(MultisizeMeasurementsColumns::Description)); + InitColumn(static_cast(MultisizeMeasurementsColumns::Name), index); + InitColumn(static_cast(MultisizeMeasurementsColumns::BaseValue), index); + InitColumn(static_cast(MultisizeMeasurementsColumns::ShiftA), index); + InitColumn(static_cast(MultisizeMeasurementsColumns::ShiftB), index, m_dimensions.size() < 2); + InitColumn(static_cast(MultisizeMeasurementsColumns::ShiftC), index, m_dimensions.size() < 3); + InitColumn(static_cast(MultisizeMeasurementsColumns::FullName), index); + InitColumn(static_cast(MultisizeMeasurementsColumns::Description), index); } }