Using the typedef ModelItemValues for "QHash<int, QVariant>".
This commit is contained in:
@ -9,15 +9,15 @@
|
||||
|
||||
using namespace rapidcsv;
|
||||
|
||||
QList<QHash<int, QVariant>> CsvParser::getItemsFromCSVFile(const QString& fileName) {
|
||||
QList<ModelItemValues> CsvParser::getItemsFromCSVFile(const QString& fileName) {
|
||||
Document doc(fileName.toStdString());
|
||||
|
||||
const bool isCompatible = isCsvCompatible(doc);
|
||||
if (isCompatible) {
|
||||
const QList<QHash<int, QVariant>> result = createListItemsFromCsvEntries(doc);
|
||||
const QList<ModelItemValues> result = createListItemsFromCsvEntries(doc);
|
||||
return result;
|
||||
} else {
|
||||
return QList<QHash<int, QVariant>>();
|
||||
return QList<ModelItemValues>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,9 +47,8 @@ bool CsvParser::isCsvCompatible(const rapidcsv::Document& doc) {
|
||||
return true;
|
||||
}
|
||||
|
||||
QList<QHash<int, QVariant>> CsvParser::createListItemsFromCsvEntries(
|
||||
const rapidcsv::Document& doc) {
|
||||
QList<QHash<int, QVariant>> result;
|
||||
QList<ModelItemValues> CsvParser::createListItemsFromCsvEntries(const rapidcsv::Document& doc) {
|
||||
QList<ModelItemValues> result;
|
||||
const int rowCount = doc.GetRowCount();
|
||||
const QList<QString> headerNames = GET_HEADER_NAMES();
|
||||
|
||||
@ -58,7 +57,7 @@ QList<QHash<int, QVariant>> CsvParser::createListItemsFromCsvEntries(
|
||||
|
||||
/// get item values for each row
|
||||
for (int row = 0; row < rowCount; ++row) {
|
||||
const QHash<int, QVariant> itemValues = getItemValuesForRow(headerNames, columnValueMap, row);
|
||||
const ModelItemValues itemValues = getItemValuesForRow(headerNames, columnValueMap, row);
|
||||
result.append(itemValues);
|
||||
}
|
||||
return result;
|
||||
@ -85,11 +84,11 @@ QHash<QString, std::vector<std::string>> CsvParser::extractColumnValues(
|
||||
return columnValueMap;
|
||||
}
|
||||
|
||||
QHash<int, QVariant> CsvParser::getItemValuesForRow(
|
||||
ModelItemValues CsvParser::getItemValuesForRow(
|
||||
const QList<QString>& headerNames,
|
||||
const QHash<QString, std::vector<std::string>>& columnValueMap,
|
||||
const int row) {
|
||||
QHash<int, QVariant> result;
|
||||
ModelItemValues result;
|
||||
for (const QString& columnName : headerNames) {
|
||||
if (!columnValueMap.contains(columnName)) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user