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