Commit e5056b7bbbb96a5371de9e1d5632cc8d700d0e0e
1 parent
3df533ac
introduced xmlGallery::skipMissing
Showing
1 changed file
with
8 additions
and
0 deletions
openbr/plugins/gallery/xml.cpp
| ... | ... | @@ -31,7 +31,9 @@ class xmlGallery : public FileGallery |
| 31 | 31 | { |
| 32 | 32 | Q_OBJECT |
| 33 | 33 | Q_PROPERTY(bool ignoreMetadata READ get_ignoreMetadata WRITE set_ignoreMetadata RESET reset_ignoreMetadata STORED false) |
| 34 | + Q_PROPERTY(bool skipMissing READ get_skipMissing WRITE set_skipMissing RESET reset_skipMissing STORED false) | |
| 34 | 35 | BR_PROPERTY(bool, ignoreMetadata, false) |
| 36 | + BR_PROPERTY(bool, skipMissing, false) | |
| 35 | 37 | FileList files; |
| 36 | 38 | |
| 37 | 39 | QXmlStreamReader reader; |
| ... | ... | @@ -116,6 +118,12 @@ class xmlGallery : public FileGallery |
| 116 | 118 | |
| 117 | 119 | // we read another complete template |
| 118 | 120 | count++; |
| 121 | + | |
| 122 | + // optionally remove templates whose files don't exist or are empty | |
| 123 | + if (skipMissing && !QFileInfo(templates.last().file.resolved()).size()) { | |
| 124 | + templates.removeLast(); | |
| 125 | + count--; | |
| 126 | + } | |
| 119 | 127 | } |
| 120 | 128 | } |
| 121 | 129 | } | ... | ... |