From 3e581e6ccace01bc874cab29b5db9af1718db184 Mon Sep 17 00:00:00 2001 From: bhklein Date: Wed, 16 Mar 2022 21:16:32 +0000 Subject: [PATCH] CSV whitespace fixes --- openbr/plugins/gallery/csv.cpp | 203 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------ 1 file changed, 101 insertions(+), 102 deletions(-) diff --git a/openbr/plugins/gallery/csv.cpp b/openbr/plugins/gallery/csv.cpp index efdfcac..0cc0fd9 100644 --- a/openbr/plugins/gallery/csv.cpp +++ b/openbr/plugins/gallery/csv.cpp @@ -23,94 +23,94 @@ namespace br struct CSVHeader { - QList indices; + QList indices; - CSVHeader() - {} + CSVHeader() + {} - CSVHeader(const QString &key) + CSVHeader(const QString &key) : key(key) - {} - - QString key; - QStringList subKeys; + {} + + QString key; + QStringList subKeys; }; - + class CSVHeaderList : public QList { public: - CSVHeaderList() - {} - - CSVHeaderList(const QList &headers) - { - foreach (const CSVHeader &header, headers) - append(header); - } - - CSVHeaderList(const QStringList &keys) - { - foreach (const QString &key, keys) - append(CSVHeader(key)); - } - - void sort() - { - typedef QPair IndexPair; - QList sortedKeys = Common::Sort(keys()); - - CSVHeaderList sortedList; - foreach (const IndexPair sortedKey, sortedKeys) - sortedList.append((*this)[sortedKey.second]); - *this = sortedList; - } - - QStringList keys() const - { - QStringList keys; - for (int i=0; isize(); i++) - keys.append((*this)[i].key); - return keys; - } + CSVHeaderList() + {} + + CSVHeaderList(const QList &headers) + { + foreach (const CSVHeader &header, headers) + append(header); + } + + CSVHeaderList(const QStringList &keys) + { + foreach (const QString &key, keys) + append(CSVHeader(key)); + } + + void sort() + { + typedef QPair IndexPair; + QList sortedKeys = Common::Sort(keys()); + + CSVHeaderList sortedList; + foreach (const IndexPair sortedKey, sortedKeys) + sortedList.append((*this)[sortedKey.second]); + *this = sortedList; + } + + QStringList keys() const + { + QStringList keys; + for (int i=0; isize(); i++) + keys.append((*this)[i].key); + return keys; + } static CSVHeaderList fromHeaders(const QStringList &headers) - { - CSVHeaderList csvHeaders; - QStringList processedKeys; - - for (int i=0; i combinedFiles; - - while (!f.atEnd()) { + if (combineFiles) { + *done = true; + QMap combinedFiles; + + while (!f.atEnd()) { QVariantList values; foreach (const QString &value, QtUtils::parse(f.readLine(), ',')) values.append(QtUtils::fromString(value)); - const QString name = values.first().toString(); - File &in = combinedFiles[name]; - in.name = name; - setValuesFromHeaders(in, headers, values.mid(1)); - } + const QString name = values.first().toString(); + File &in = combinedFiles[name]; + in.name = name; + setValuesFromHeaders(in, headers, values.mid(1)); + } - foreach (const File &in, combinedFiles.values()) - templates.append(in); - } else { - for (qint64 i = 0; i < this->readBlockSize && !f.atEnd(); i++) { + foreach (const File &in, combinedFiles.values()) + templates.append(in); + } else { + for (qint64 i = 0; i < this->readBlockSize && !f.atEnd(); i++) { QVariantList values; foreach (const QString &value, QtUtils::parse(f.readLine(), ',')) values.append(QtUtils::fromString(value)); - File in; - in.name = values.first().toString(); - setValuesFromHeaders(in, headers, values.mid(1)); - in.set("progress", f.pos()); - templates.append(in); - } - *done = f.atEnd(); + File in; + in.name = values.first().toString(); + setValuesFromHeaders(in, headers, values.mid(1)); + in.set("progress", f.pos()); + templates.append(in); + } + *done = f.atEnd(); } - return templates; } @@ -247,7 +246,7 @@ class csvGallery : public FileGallery writeOpen(); if (headers.isEmpty()) { foreach (const QString &key, t.file.localKeys()) - headers.append(CSVHeader(key)); + headers.append(CSVHeader(key)); headers.sort(); const QString header = QString(QStringList(QStringList("File") + headers.keys()).join(",") + "\n"); -- libgit2 0.21.4