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

Method createNewDocument

src/document/UBDocumentController.cpp:1958–1989  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1956}
1957
1958void UBDocumentController::createNewDocument()
1959{
1960 UBPersistenceManager *pManager = UBPersistenceManager::persistenceManager();
1961 UBDocumentTreeModel *docModel = pManager->mDocumentTreeStructureModel;
1962 QModelIndex selectedIndex = firstSelectedTreeIndex();
1963
1964 if (!selectedIndex.isValid())
1965 selectedIndex = docModel->myDocumentsIndex();
1966
1967 QString groupName = docModel->isCatalog(selectedIndex)
1968 ? docModel->virtualPathForIndex(selectedIndex)
1969 : docModel->virtualDirForIndex(selectedIndex);
1970
1971
1972 QDateTime now = QDateTime::currentDateTime();
1973 QString documentName = "";
1974 if (docModel->isCatalog(selectedIndex))
1975 {
1976 documentName = docModel->adjustNameForParentIndex(QLocale::system().toString(now, QLocale::ShortFormat), selectedIndex);
1977 }
1978 else
1979 {
1980 documentName = docModel->adjustNameForParentIndex(QLocale::system().toString(now, QLocale::ShortFormat), selectedIndex.parent());
1981 }
1982
1983
1984 std::shared_ptr<UBDocumentProxy> document = pManager->createDocument(groupName, documentName);
1985
1986 selectDocument(document, true, false, true);
1987
1988 pageSelectionChanged();
1989}
1990
1991void UBDocumentController::selectDocument(std::shared_ptr<UBDocumentProxy> proxy, bool setAsCurrentDocument, const bool onImport, const bool editMode)
1992{

Callers

nothing calls this directly

Calls 8

myDocumentsIndexMethod · 0.80
isCatalogMethod · 0.80
virtualPathForIndexMethod · 0.80
virtualDirForIndexMethod · 0.80
createDocumentMethod · 0.80
isValidMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected