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

Method createDocument

src/core/UBPersistenceManager.cpp:566–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

564
565
566std::shared_ptr<UBDocumentProxy> UBPersistenceManager::createDocument(const QString& pGroupName
567 , const QString& pName
568 , bool withEmptyPage
569 , QString directory
570 , int pageCount
571 , bool promptDialogIfExists)
572{
573 std::shared_ptr<UBDocumentProxy> doc;
574 if(directory.length() != 0 )
575 {
576 doc = std::make_shared<UBDocumentProxy>(directory);
577 doc->setPageCount(pageCount);
578 }
579 else{
580 checkIfDocumentRepositoryExists();
581 doc = std::make_shared<UBDocumentProxy>();
582 }
583
584 if (pGroupName.length() > 0)
585 {
586 doc->setMetaData(UBSettings::documentGroupName, pGroupName);
587 }
588
589 if (pName.length() > 0)
590 {
591 doc->setMetaData(UBSettings::documentName, pName);
592 }
593
594 doc->setMetaData(UBSettings::documentVersion, UBSettings::currentFileVersion);
595 QString currentDate = UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime());
596 doc->setMetaData(UBSettings::documentUpdatedAt,currentDate);
597 doc->setMetaData(UBSettings::documentDate,currentDate);
598
599 if (withEmptyPage)
600 {
601 createDocumentSceneAt(doc, 0);
602 }
603 else
604 {
605 generatePathIfNeeded(doc);
606 QDir dir(doc->persistencePath());
607 if (!dir.mkpath(doc->persistencePath()))
608 {
609 return nullptr; // if we can't create the path, abort function.
610 }
611 }
612
613 bool documentAdded = false;
614 if (!promptDialogIfExists)
615 {
616 documentAdded = true;
617 mDocumentTreeStructureModel->addDocument(doc);
618 }
619 else if (processInteractiveReplacementDialog(doc) == QDialog::Accepted)
620 {
621 documentAdded = true;
622 }
623

Callers 5

OpenLayers.jsFile · 0.80
foreachFunction · 0.80
importDirMethod · 0.80
createNewDocumentMethod · 0.80

Calls 5

setPageCountMethod · 0.80
setMetaDataMethod · 0.80
persistencePathMethod · 0.80
addDocumentMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected