From 142de7bb5f035bdd94e4c2a28ba0ca119b09d01a Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Tue, 15 Apr 2014 13:36:52 -0400 Subject: [PATCH] Revert "cleaned up turkGallery implementation" --- openbr/plugins/turk.cpp | 52 ++++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/openbr/plugins/turk.cpp b/openbr/plugins/turk.cpp index 6f17616..1061237 100644 --- a/openbr/plugins/turk.cpp +++ b/openbr/plugins/turk.cpp @@ -13,45 +13,41 @@ class turkGallery : public Gallery { Q_OBJECT - struct Attribute : public QStringList - { - QString name; - Attribute(const QString &str = QString()) - { - const int i = str.indexOf('['); - name = str.mid(0, i); - if (i != -1) - append(str.mid(i+1, str.length()-i-2).split(",")); - } - }; - TemplateList readBlock(bool *done) { *done = true; TemplateList templates; + if (!file.exists()) return templates; + QStringList lines = QtUtils::readLines(file); - if (lines.empty()) - qFatal(".turk Gallery missing header."); - QList types; - foreach (const QString &header, parse(lines.takeFirst())) - types.append(header); + QRegExp regexp(",(?!(?:\\w+,?)+\\])"); + + QStringList headers; + + if (!lines.isEmpty()) headers = lines.takeFirst().split(regexp); foreach (const QString &line, lines) { - const QStringList words = parse(line); - if (words.size() != types.size()) - qFatal(".turk Gallery incorrect column count."); + QStringList words = line.split(regexp); + if (words.size() != headers.size()) continue; + File f; + f.name = words[0]; + f.set("Label", words[0].mid(0,5)); - File f(words[0], words[0].mid(0,5)); for (int i=1; i categoryMap; - for (int j=0; j