Commit ddbf56c63beb295078876aa69efce0e18926f53c
1 parent
f1129f62
Bug fixes
Showing
1 changed file
with
3 additions
and
7 deletions
openbr/plugins/gallery/csv.cpp
| @@ -93,10 +93,10 @@ public: | @@ -93,10 +93,10 @@ public: | ||
| 93 | header.indices.append(i); | 93 | header.indices.append(i); |
| 94 | 94 | ||
| 95 | // Look for other subheaders with the same key | 95 | // Look for other subheaders with the same key |
| 96 | - for (int j=i; j<headers.size(); j++) | 96 | + for (int j=i+1; j<headers.size(); j++) |
| 97 | if (headers[j].contains("_")) { | 97 | if (headers[j].contains("_")) { |
| 98 | const QStringList subKeys = headers[j].split("_"); | 98 | const QStringList subKeys = headers[j].split("_"); |
| 99 | - if (subKeys.first() == header.key) { | 99 | + if (subKeys.first() == header.key && !header.subKeys.contains(subKeys.last()) /* Check for ill-formed csvs */) { |
| 100 | header.indices.append(j); | 100 | header.indices.append(j); |
| 101 | header.subKeys.append(subKeys.last()); | 101 | header.subKeys.append(subKeys.last()); |
| 102 | } | 102 | } |
| @@ -159,10 +159,7 @@ class csvGallery : public FileGallery | @@ -159,10 +159,7 @@ class csvGallery : public FileGallery | ||
| 159 | 159 | ||
| 160 | void setValuesFromHeaders(File &f, const CSVHeaderList &headers, const QVariantList &values) | 160 | void setValuesFromHeaders(File &f, const CSVHeaderList &headers, const QVariantList &values) |
| 161 | { | 161 | { |
| 162 | - qDebug() << headers.keys(); | ||
| 163 | - | ||
| 164 | foreach (const CSVHeader &header, headers) { | 162 | foreach (const CSVHeader &header, headers) { |
| 165 | - qDebug() << header.key; | ||
| 166 | if (header.indices.size() == 1) | 163 | if (header.indices.size() == 1) |
| 167 | f.set(header.key, values[header.indices.first()]); | 164 | f.set(header.key, values[header.indices.first()]); |
| 168 | else if (header.indices.size() == 2) // QPointF | 165 | else if (header.indices.size() == 2) // QPointF |
| @@ -198,7 +195,7 @@ class csvGallery : public FileGallery | @@ -198,7 +195,7 @@ class csvGallery : public FileGallery | ||
| 198 | *done = true; | 195 | *done = true; |
| 199 | QMap<QString, File> combinedFiles; | 196 | QMap<QString, File> combinedFiles; |
| 200 | 197 | ||
| 201 | - for (qint64 i = 0; i < !f.atEnd(); i++) { | 198 | + while (!f.atEnd()) { |
| 202 | const QVariantList values = parseLine(f.readLine()); | 199 | const QVariantList values = parseLine(f.readLine()); |
| 203 | const QString name = values.first().toString(); | 200 | const QString name = values.first().toString(); |
| 204 | File &in = combinedFiles[name]; | 201 | File &in = combinedFiles[name]; |
| @@ -206,7 +203,6 @@ class csvGallery : public FileGallery | @@ -206,7 +203,6 @@ class csvGallery : public FileGallery | ||
| 206 | setValuesFromHeaders(in, headers, values.mid(1)); | 203 | setValuesFromHeaders(in, headers, values.mid(1)); |
| 207 | } | 204 | } |
| 208 | 205 | ||
| 209 | - qDebug() << combinedFiles.values(); | ||
| 210 | foreach (const File &in, combinedFiles.values()) | 206 | foreach (const File &in, combinedFiles.values()) |
| 211 | templates.append(in); | 207 | templates.append(in); |
| 212 | } else { | 208 | } else { |