| 1956 | } |
| 1957 | |
| 1958 | void 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 | |
| 1991 | void UBDocumentController::selectDocument(std::shared_ptr<UBDocumentProxy> proxy, bool setAsCurrentDocument, const bool onImport, const bool editMode) |
| 1992 | { |
nothing calls this directly
no test coverage detected