Commit c38b1e31069829815439a2eb53e302778695c384
1 parent
a6d90af6
improved File::resolved()
Showing
3 changed files
with
13 additions
and
14 deletions
openbr/openbr_plugin.cpp
| ... | ... | @@ -112,7 +112,17 @@ QList<File> File::split(const QString &separator) const |
| 112 | 112 | |
| 113 | 113 | QString File::resolved() const |
| 114 | 114 | { |
| 115 | - return exists() ? name : Globals->path + "/" + name; | |
| 115 | + if (exists()) return name; | |
| 116 | + QStringList paths = get<QString>("path").split(";", QString::SkipEmptyParts); | |
| 117 | + foreach (const QString &path, paths) { | |
| 118 | + const File resolved = path + "/" + name; | |
| 119 | + if (resolved.exists()) return resolved; | |
| 120 | + } | |
| 121 | + foreach (const QString &path, paths) { | |
| 122 | + const File resolved = path + "/" + fileName(); | |
| 123 | + if (resolved.exists()) return resolved; | |
| 124 | + } | |
| 125 | + return name; | |
| 116 | 126 | } |
| 117 | 127 | |
| 118 | 128 | bool File::contains(const QString &key) const | ... | ... |
openbr/openbr_plugin.h
| ... | ... | @@ -550,6 +550,7 @@ public: |
| 550 | 550 | |
| 551 | 551 | /*! |
| 552 | 552 | * \brief Path to use when resolving images specified with relative paths. |
| 553 | + * Multiple paths can be specified using a semicolon separator. | |
| 553 | 554 | */ |
| 554 | 555 | Q_PROPERTY(QString path READ get_path WRITE set_path RESET reset_path) |
| 555 | 556 | BR_PROPERTY(QString, path, "") | ... | ... |
openbr/plugins/format.cpp
| ... | ... | @@ -205,19 +205,7 @@ class DefaultFormat : public Format |
| 205 | 205 | t = url->read(); |
| 206 | 206 | } |
| 207 | 207 | } else { |
| 208 | - QString fileName = file.name; | |
| 209 | - if (!QFileInfo(fileName).exists()) { | |
| 210 | - fileName = file.get<QString>("path") + "/" + file.name; | |
| 211 | - if (!QFileInfo(fileName).exists()) { | |
| 212 | - fileName = file.fileName(); | |
| 213 | - if (!QFileInfo(fileName).exists()) { | |
| 214 | - fileName = file.get<QString>("path") + "/" + file.fileName(); | |
| 215 | - if (!QFileInfo(fileName).exists()) return t; | |
| 216 | - } | |
| 217 | - } | |
| 218 | - } | |
| 219 | - | |
| 220 | - Mat m = imread(fileName.toStdString()); | |
| 208 | + Mat m = imread(file.resolved().toStdString()); | |
| 221 | 209 | if (m.data) { |
| 222 | 210 | t.append(m); |
| 223 | 211 | } else { | ... | ... |