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

Method addToDocument

src/document/UBDocumentController.cpp:3456–3499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3454}
3455
3456void UBDocumentController::addToDocument()
3457{
3458 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3459
3460 QList<QGraphicsItem*> selectedItems = mDocumentUI->thumbnailWidget->selectedItems();
3461
3462 if (selectedItems.count() > 0)
3463 {
3464 int oldActiveSceneIndex = mBoardController->activeSceneIndex();
3465
3466 QList<QPair<std::shared_ptr<UBDocumentProxy>, int>> pageInfoList;
3467
3468 foreach (QGraphicsItem* item, selectedItems)
3469 {
3470 UBThumbnail* thumb = dynamic_cast<UBThumbnail*> (item);
3471
3472 auto proxy = mDocumentUI->thumbnailWidget->document()->proxy();
3473
3474 if (thumb && proxy)
3475 {
3476 QPair<std::shared_ptr<UBDocumentProxy>, int> pageInfo(proxy, thumb->sceneIndex());
3477 pageInfoList << pageInfo;
3478 }
3479 }
3480
3481 for (int i = 0; i < pageInfoList.length(); i++)
3482 {
3483 mBoardController->addScene(pageInfoList.at(i).first, pageInfoList.at(i).second, false);
3484 }
3485
3486 selectDocument(mBoardController->selectedDocument());
3487 int newActiveSceneIndex = selectedItems.count() == mBoardController->selectedDocument()->pageCount() ? 0 : oldActiveSceneIndex + 1;
3488 mDocumentUI->thumbnailWidget->selectItemAt(newActiveSceneIndex, false);
3489 QDateTime now = QDateTime::currentDateTime();
3490 mBoardController->selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(now));
3491 UBMetadataDcSubsetAdaptor::persist(mBoardController->selectedDocument());
3492
3493 UBApplication::applicationController->showBoard();
3494
3495 mBoardController->setActiveDocumentScene(newActiveSceneIndex);
3496 }
3497
3498 QApplication::restoreOverrideCursor();
3499}
3500
3501void UBDocumentController::renameSelectedItem()
3502{

Callers

nothing calls this directly

Calls 10

selectedItemsMethod · 0.80
activeSceneIndexMethod · 0.80
addSceneMethod · 0.80
selectedDocumentMethod · 0.80
selectItemAtMethod · 0.80
setMetaDataMethod · 0.80
lengthMethod · 0.45
pageCountMethod · 0.45
showBoardMethod · 0.45

Tested by

no test coverage detected