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

Method duplicateDocument

src/core/UBPersistenceManager.cpp:726–760  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

724}
725
726std::shared_ptr<UBDocumentProxy> UBPersistenceManager::duplicateDocument(std::shared_ptr<UBDocumentProxy> pDocumentProxy)
727{
728 checkIfDocumentRepositoryExists();
729
730 std::shared_ptr<UBDocumentProxy> copy = std::make_shared<UBDocumentProxy>();
731
732 generatePathIfNeeded(copy);
733
734 UBFileSystemUtils::copyDir(pDocumentProxy->persistencePath(), copy->persistencePath());
735
736 // regenerate scenes UUIDs
737 for(int i = 0; i < pDocumentProxy->pageCount(); i++)
738 {
739 UBSvgSubsetAdaptor::setSceneUuid(pDocumentProxy, i, QUuid::createUuid());
740 }
741
742 foreach(QString key, pDocumentProxy->metaDatas().keys())
743 {
744 copy->setMetaData(key, pDocumentProxy->metaDatas().value(key));
745 }
746
747 copy->setMetaData(UBSettings::documentName,
748 pDocumentProxy->metaData(UBSettings::documentName).toString() + " " + tr("(copy)"));
749
750 copy->setUuid(QUuid::createUuid());
751
752 persistDocumentMetadata(copy);
753
754 copy->setPageCount(pDocumentProxy->pageCount());
755
756 emit documentCreated(copy);
757
758 return copy;
759
760}
761
762
763void UBPersistenceManager::deleteDocumentScenes(std::shared_ptr<UBDocumentProxy> proxy, const QList<int>& indexes)

Callers 1

copyIndexToNewParentMethod · 0.80

Calls 6

persistencePathMethod · 0.80
setMetaDataMethod · 0.80
metaDataMethod · 0.80
setPageCountMethod · 0.80
pageCountMethod · 0.45
setUuidMethod · 0.45

Tested by

no test coverage detected