| 86 | } |
| 87 | |
| 88 | void LocalPhotoFrameSource::requestSourceUpdate() |
| 89 | { |
| 90 | // assume dir exists |
| 91 | vector<PhotoFrameSourceItem> items; |
| 92 | |
| 93 | if(!QFileInfo(_localPath.absolutePath()).isDir()) { |
| 94 | // check if this is a valid image file |
| 95 | QString filename = _localPath.absolutePath(); |
| 96 | if (filename.size() > 4) |
| 97 | { |
| 98 | QString ext = fsManager->getFileExtension(filename); |
| 99 | bool isValidImage = !ext.isEmpty() && GLOBAL(supportedExtensions).contains(ext + "."); |
| 100 | if (isValidImage) |
| 101 | { |
| 102 | PhotoFrameSourceItem newItem(filename); |
| 103 | newItem.setTexturePath(filename); |
| 104 | items.push_back(newItem); |
| 105 | } else { |
| 106 | MessageClearPolicy clearPolicy; |
| 107 | clearPolicy.setTimeout(4); |
| 108 | scnManager->messages()->addMessage(new Message("PhotoFrameActor::resolveSourceFromString", QT_TR_NOOP("Invalid photo frame source given!"), Message::Warning, clearPolicy)); |
| 109 | } |
| 110 | } |
| 111 | } else { |
| 112 | updateDirectory(_localPath, items); |
| 113 | |
| 114 | // randomize the items |
| 115 | PhotoFrameSourceItem tmp; |
| 116 | int n = items.size(); |
| 117 | srand(time(NULL)); |
| 118 | for (int i = 0; i < n; ++i) |
| 119 | { |
| 120 | int j = (rand() + rand()) % n; |
| 121 | if (i != j) |
| 122 | { |
| 123 | tmp = items[i]; |
| 124 | items[i] = items[j]; |
| 125 | items[j] = tmp; |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | if (!items.empty()) |
| 131 | { |
| 132 | // set the items |
| 133 | _items = items; |
| 134 | ++_sourceUpdateCount; |
| 135 | |
| 136 | // check if the current item is still valid |
| 137 | bool found = false; |
| 138 | for (int i = 0; i < _items.size(); ++i) |
| 139 | { |
| 140 | if (_items[i].equals(_current)) |
| 141 | { |
| 142 | found = true; |
| 143 | } |
| 144 | } |
| 145 | if (!found) |
nothing calls this directly
no test coverage detected