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

Method copyDocumentScene

src/core/UBPersistenceManager.cpp:957–988  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

955}
956
957void UBPersistenceManager::copyDocumentScene(std::shared_ptr<UBDocumentProxy> from, int fromIndex, std::shared_ptr<UBDocumentProxy> to, int toIndex)
958{
959 if (from == to && toIndex <= fromIndex) {
960 qDebug() << "operation is not supported" << Q_FUNC_INFO;
961 return;
962 }
963
964 checkIfDocumentRepositoryExists();
965
966 for (int i = to->pageCount(); i > toIndex; i--) {
967 renamePage(to, i - 1, i);
968 mSceneCache.moveScene(to, i - 1, i);
969 }
970
971 UBForeighnObjectsHandler hl;
972 hl.copyPage(QUrl::fromLocalFile(from->persistencePath()), fromIndex,
973 QUrl::fromLocalFile(to->persistencePath()), toIndex);
974
975 to->incPageCount();
976
977 QString thumbTmp(from->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", fromIndex));
978 QString thumbTo(to->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", toIndex));
979
980 QFile::remove(thumbTo);
981 QFile::copy(thumbTmp, thumbTo);
982
983 Q_ASSERT(QFileInfo(thumbTmp).exists());
984 Q_ASSERT(QFileInfo(thumbTo).exists());
985 auto pix = std::make_shared<QPixmap>(thumbTmp);
986 UBDocumentController *ctrl = UBApplication::documentController;
987 ctrl->TreeViewSelectionChanged(ctrl->firstSelectedTreeIndex(), QModelIndex());
988}
989
990
991std::shared_ptr<UBGraphicsScene> UBPersistenceManager::createDocumentSceneAt(std::shared_ptr<UBDocumentProxy> proxy, int index, bool useUndoRedoStack)

Callers 1

copyPageMethod · 0.80

Calls 7

moveSceneMethod · 0.80
persistencePathMethod · 0.80
incPageCountMethod · 0.80
pageCountMethod · 0.45
copyPageMethod · 0.45

Tested by

no test coverage detected