MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / createThumbnails

Method createThumbnails

src/gui/UBThumbnailScene.cpp:191–226  ·  view source on GitHub ↗

* @brief Create thumbnails for this scene. * * Thumbnails for the document pages above startIndex are asynchronously * loaded and positioned on the scene. The application remains responsive * even while loading thumbnails. * * It is even possible to interact with the already loaded thumbnails during * the loading process. So the already loaded pages can be moved, copied, * deleted or opene

Source from the content-addressed store, hash-verified

189 * continues in background.
190 */
191void UBThumbnailScene::createThumbnails(int startIndex)
192{
193 // skip already loaded thumbnails
194 while (startIndex < mThumbnailItems.count() && mThumbnailItems.at(startIndex))
195 {
196 ++startIndex;
197 }
198
199 // create the list of all thumbnail paths
200 QList<std::pair<int,QString>> paths;
201
202 for (int index = startIndex; index < mDocument->proxy()->pageCount(); ++index)
203 {
204 paths << std::pair<int,QString>{index, UBThumbnailAdaptor::thumbnailUrl(mDocument->proxy(), index).toLocalFile()};
205 }
206
207 // start background loading of files
208 if (mLoader)
209 {
210 // abort a running loader
211 mLoader->abort();
212 delete mLoader;
213 mLoader = nullptr;
214 }
215
216 if (paths.empty())
217 {
218 return;
219 }
220
221 mLoader = new UBBackgroundLoader{paths, this};
222 mLoader->start();
223
224 // now create all missing thumbnails for document as they arrive from the loader
225 loadNextThumbnail();
226}
227
228/**
229 * @brief Insert a thumbnail.

Callers 2

foreachFunction · 0.80
UBDocumentMethod · 0.80

Calls 5

emptyMethod · 0.80
pageCountMethod · 0.45
proxyMethod · 0.45
abortMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected