| 214 | } |
| 215 | |
| 216 | void RSSPhotoFrameSource::requestImageUpdate() |
| 217 | { |
| 218 | // don't start another transfer if one is already in progress |
| 219 | if (ftManager->hasTransfersToHandler(this)) |
| 220 | return; |
| 221 | |
| 222 | // find the next image to load |
| 223 | bool loadCurrent = !_items.empty() && _current.isValid(); |
| 224 | if (_current.isValid()) |
| 225 | { |
| 226 | for (int i = 0; i < _items.size(); ++i) |
| 227 | { |
| 228 | // find the current item |
| 229 | if (_items[i].equals(_current)) |
| 230 | { |
| 231 | // get the next item |
| 232 | for (int j = 1; j < _items.size(); ++j) |
| 233 | { |
| 234 | int nextIndex = (i+j) % _items.size(); |
| 235 | if (_items[nextIndex].isValid()) |
| 236 | { |
| 237 | _current = _items[nextIndex]; |
| 238 | loadCurrent = true; |
| 239 | break; |
| 240 | } |
| 241 | } |
| 242 | break; |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | else if (!_items.empty()) |
| 247 | { |
| 248 | _current = _items[0]; |
| 249 | loadCurrent = _current.isValid(); |
| 250 | } |
| 251 | |
| 252 | if (loadCurrent) |
| 253 | { |
| 254 | if (exists(_current.getTexturePath())) |
| 255 | { |
| 256 | // load the image (so that it will swap) |
| 257 | GLTextureObject obj(Load|Compress|Reload, _textureBufferId, _current.getTexturePath(), SampledImage, IdlePriority); |
| 258 | texMgr->loadTexture(obj); |
| 259 | |
| 260 | // bump up image loaded count |
| 261 | ++_imageUpdateCount; |
| 262 | } |
| 263 | else |
| 264 | { |
| 265 | // download the image to a tmp filename |
| 266 | QString tmpFilename = _current.getTexturePath() + QT_NT(".img_tmp"); |
| 267 | ftManager->addTransfer(FileTransfer(FileTransfer::Download, this) |
| 268 | .setUrl(_current.getResourceId()) |
| 269 | .setUserData(new bool(true)) |
| 270 | .setLocalPath(tmpFilename), false |
| 271 | ); |
| 272 | } |
| 273 | } |
no test coverage detected