From cfe25ddaf69fd2ca0da9c1d495ebcf1d2b187c4a Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Thu, 2 May 2019 17:49:20 -0600 Subject: [PATCH] More work --- openbr/core/qtutils.cpp | 16 +++++++++++++--- openbr/openbr_plugin.cpp | 22 ++-------------------- openbr/plugins/gallery/csv.cpp | 70 +++++++++++++++++++++++++++++++--------------------------------------- 3 files changed, 46 insertions(+), 62 deletions(-) diff --git a/openbr/core/qtutils.cpp b/openbr/core/qtutils.cpp index 15bef1f..89a0da1 100644 --- a/openbr/core/qtutils.cpp +++ b/openbr/core/qtutils.cpp @@ -245,10 +245,10 @@ QStringList parse(QString args, char split, bool *ok) QStack subexpressions; for (int i=0; i() || !value.toString().isEmpty()) + f.set(header.key, values[header.indices.first()]); + } + } else if (header.indices.size() == 2) // QPointF + f.appendPoint(QPointF(values[header.indices[header.subKeys.indexOf("X")]].toFloat(), + values[header.indices[header.subKeys.indexOf("Y")]].toFloat())); + else if (header.indices.size() == 4) // QRectF + f.appendRect(QRectF(values[header.indices[header.subKeys.indexOf("X")]].toFloat(), + values[header.indices[header.subKeys.indexOf("Y")]].toFloat(), + values[header.indices[header.subKeys.indexOf("Width")]].toFloat(), + values[header.indices[header.subKeys.indexOf("Height")]].toFloat())); + } } - } TemplateList readBlock(bool *done) { @@ -196,7 +206,10 @@ class csvGallery : public FileGallery QMap combinedFiles; while (!f.atEnd()) { - const QVariantList values = parseLine(f.readLine()); + 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; @@ -207,7 +220,9 @@ class csvGallery : public FileGallery templates.append(in); } else { for (qint64 i = 0; i < this->readBlockSize && !f.atEnd(); i++) { - const QVariantList values = parseLine(f.readLine()); + QVariantList values; + foreach (const QString &value, QtUtils::parse(f.readLine(), ',')) + values.append(QtUtils::fromString(value)); File in; in.name = values.first().toString(); @@ -250,29 +265,6 @@ class csvGallery : public FileGallery } return words.join(","); } - - static QVariantList parseLine(const QByteArray bytes) - { - bool inQuote(false); - QVariantList values; - QString value = QString(); - const QString line = QString::fromLocal8Bit(bytes).trimmed(); - for (int i=0; i