diff --git a/src/adaptors/UBImportDocument.cpp b/src/adaptors/UBImportDocument.cpp index 7d43feee..27ba6673 100644 --- a/src/adaptors/UBImportDocument.cpp +++ b/src/adaptors/UBImportDocument.cpp @@ -191,7 +191,7 @@ UBDocumentProxy* UBImportDocument::importFile(const QFile& pFile, const QString& return 0; } else{ - UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocumentFromDir(documentRootFolder); + UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocumentFromDir(documentRootFolder, pGroup); UBApplication::showMessage(tr("Import successful.")); return newDocument; } diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 23b5e3c3..8d0e1952 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -254,13 +254,23 @@ UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName, return doc; } - -UBDocumentProxy* UBPersistenceManager::createDocumentFromDir(const QString& pDocumentDirectory) +UBDocumentProxy* UBPersistenceManager::createDocumentFromDir(const QString& pDocumentDirectory, const QString& pGroupName, const QString& pName, bool withEmptyPage) { checkIfDocumentRepositoryExists(); UBDocumentProxy* doc = new UBDocumentProxy(pDocumentDirectory); // deleted in UBPersistenceManager::destructor + if (pGroupName.length() > 0) + { + doc->setMetaData(UBSettings::documentGroupName, pGroupName); + } + + if (pName.length() > 0) + { + doc->setMetaData(UBSettings::documentName, pName); + } + if (withEmptyPage) createDocumentSceneAt(doc, 0); + QMap metadatas = UBMetadataDcSubsetAdaptor::load(pDocumentDirectory); foreach(QString key, metadatas.keys()) diff --git a/src/core/UBPersistenceManager.h b/src/core/UBPersistenceManager.h index 7a7bdd87..b9c53579 100644 --- a/src/core/UBPersistenceManager.h +++ b/src/core/UBPersistenceManager.h @@ -46,7 +46,7 @@ class UBPersistenceManager : public QObject static void destroy(); virtual UBDocumentProxy* createDocument(const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = true); - virtual UBDocumentProxy* createDocumentFromDir(const QString& pDocumentDirectory); + virtual UBDocumentProxy* createDocumentFromDir(const QString& pDocumentDirectory, const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = false); virtual UBDocumentProxy* persistDocumentMetadata(UBDocumentProxy* pDocumentProxy);