* @brief Insert a thumbnail. * * Insert a thumbnail at the given index. This function assumes that the thumbnail pixmap files * are already moved to provide the necessary space. The pixmap for the new thumbnail can either * be provided in the corresponding pixmap file or it will be created from the scene. * * @param pageIndex Page index of the scene. * @param pageScene Optional scene. If th
| 237 | * created from the scene. Otherwise it is assumed that the pixmap file already exists. |
| 238 | */ |
| 239 | void UBThumbnailScene::insertThumbnail(int pageIndex, std::shared_ptr<UBGraphicsScene> pageScene) |
| 240 | { |
| 241 | if (pageScene) |
| 242 | { |
| 243 | UBThumbnailAdaptor::persistScene(mDocument->proxy(), pageScene, pageIndex); |
| 244 | } |
| 245 | |
| 246 | if (pageIndex <= mThumbnailItems.size()) |
| 247 | { |
| 248 | if (mThumbnailItems.size() == 1) |
| 249 | { |
| 250 | thumbnailAt(0)->setDeletable(true); |
| 251 | } |
| 252 | |
| 253 | auto thumbnailItem = new UBThumbnail; |
| 254 | |
| 255 | thumbnailItem->setPixmap(UBThumbnailAdaptor::get(mDocument->proxy(), pageIndex)); |
| 256 | thumbnailItem->setSceneIndex(pageIndex); |
| 257 | |
| 258 | mThumbnailItems.insert(pageIndex, thumbnailItem); |
| 259 | addItem(thumbnailItem); |
| 260 | |
| 261 | renumberThumbnails(pageIndex); |
| 262 | arrangeThumbnails(pageIndex); |
| 263 | } |
| 264 | |
| 265 | if (mLoader) |
| 266 | { |
| 267 | // restart loading remaining thumbnails |
| 268 | createThumbnails(pageIndex); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | void UBThumbnailScene::deleteThumbnail(int pageIndex, bool rearrange) |
| 273 | { |
no test coverage detected