| 32 | {} |
| 33 | |
| 34 | void LocalPhotoFrameSource::updateDirectory(QDir dir, vector<PhotoFrameSourceItem>& items) |
| 35 | { |
| 36 | // assume dir exists |
| 37 | if (!empty(dir)) |
| 38 | { |
| 39 | StrList dirListing = fsManager->getDirectoryContents(native(dir)); |
| 40 | for (int i = 0; i < dirListing.size(); ++i) |
| 41 | { |
| 42 | QFileInfo file(dirListing[i]); |
| 43 | |
| 44 | if (file.isSymLink()) { |
| 45 | file = QFile(file.symLinkTarget()); |
| 46 | } |
| 47 | |
| 48 | if (file.isDir()) |
| 49 | // recurse into that directory |
| 50 | updateDirectory(file.absoluteFilePath(), items); |
| 51 | else |
| 52 | { |
| 53 | // XXX: we can do this smarter with watched directories?! |
| 54 | |
| 55 | // check if this is a valid image file |
| 56 | QString filename = file.fileName(); |
| 57 | if (filename.size() > 4) |
| 58 | { |
| 59 | QString ext = fsManager->getFileExtension(filename); |
| 60 | bool isValidImage = !ext.isEmpty() && GLOBAL(supportedExtensions).contains(ext + "."); |
| 61 | if (isValidImage) |
| 62 | { |
| 63 | // check if we already have that item in the list |
| 64 | vector<PhotoFrameSourceItem>::const_iterator itemIter = items.begin(); |
| 65 | vector<PhotoFrameSourceItem>::const_iterator endIter = items.end(); |
| 66 | bool exists = false; |
| 67 | while (itemIter != endIter) |
| 68 | { |
| 69 | if ((*itemIter).getResourceId() == dirListing[i]) |
| 70 | exists = true; |
| 71 | ++itemIter; |
| 72 | } |
| 73 | |
| 74 | // if not, add it to the list |
| 75 | if (!exists) |
| 76 | { |
| 77 | PhotoFrameSourceItem item(dirListing[i]); |
| 78 | item.setTexturePath(dirListing[i]); |
| 79 | items.push_back(item); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | void LocalPhotoFrameSource::requestSourceUpdate() |
| 89 | { |
nothing calls this directly
no test coverage detected