diff --git a/openbr/plugins/turk.cpp b/openbr/plugins/turk.cpp index 1061237..6f17616 100644 --- a/openbr/plugins/turk.cpp +++ b/openbr/plugins/turk.cpp @@ -13,41 +13,45 @@ 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); - QRegExp regexp(",(?!(?:\\w+,?)+\\])"); - - QStringList headers; - - if (!lines.isEmpty()) headers = lines.takeFirst().split(regexp); + if (lines.empty()) + qFatal(".turk Gallery missing header."); + QList types; + foreach (const QString &header, parse(lines.takeFirst())) + types.append(header); foreach (const QString &line, lines) { - 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)); + const QStringList words = parse(line); + if (words.size() != types.size()) + qFatal(".turk Gallery incorrect column count."); + File f(words[0], words[0].mid(0,5)); for (int i=1; i categoryMap; - for (int j=0; j