|
|
|
@ -149,32 +149,32 @@ UBDocumentProxy* UBDocumentManager::importFile(const QFile& pFile, const QString |
|
|
|
|
UBPageBasedImportAdaptor* importAdaptor = (UBPageBasedImportAdaptor*)adaptor; |
|
|
|
|
|
|
|
|
|
// Document import procedure.....
|
|
|
|
|
QString documentName = QFileInfo(pFile.fileName()).completeBaseName(); |
|
|
|
|
document = UBPersistenceManager::persistenceManager()->createDocument(pGroup, documentName); |
|
|
|
|
|
|
|
|
|
QUuid uuid = QUuid::createUuid(); |
|
|
|
|
QString filepath = pFile.fileName(); |
|
|
|
|
if (importAdaptor->folderToCopy() != "") |
|
|
|
|
{ |
|
|
|
|
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(document, pFile.fileName(), importAdaptor->folderToCopy() , uuid, filepath); |
|
|
|
|
if (!b) |
|
|
|
|
{ |
|
|
|
|
UBPersistenceManager::persistenceManager()->deleteDocument(document); |
|
|
|
|
UBApplication::setDisabled(false); |
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QList<UBGraphicsItem*> pages = importAdaptor->import(uuid, filepath); |
|
|
|
|
int nPage = 0; |
|
|
|
|
foreach(UBGraphicsItem* page, pages) |
|
|
|
|
{ |
|
|
|
|
UBApplication::showMessage(tr("Inserting page %1 of %2").arg(++nPage).arg(pages.size()), true); |
|
|
|
|
int pageIndex = document->pageCount(); |
|
|
|
|
UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(document, pageIndex); |
|
|
|
|
importAdaptor->placeImportedItemToScene(scene, page); |
|
|
|
|
UBPersistenceManager::persistenceManager()->persistDocumentScene(document, scene, pageIndex); |
|
|
|
|
} |
|
|
|
|
QString documentName = QFileInfo(pFile.fileName()).completeBaseName(); |
|
|
|
|
document = UBPersistenceManager::persistenceManager()->createDocument(pGroup, documentName); |
|
|
|
|
|
|
|
|
|
QUuid uuid = QUuid::createUuid(); |
|
|
|
|
QString filepath = pFile.fileName(); |
|
|
|
|
if (importAdaptor->folderToCopy() != "") |
|
|
|
|
{ |
|
|
|
|
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(document, pFile.fileName(), importAdaptor->folderToCopy() , uuid, filepath); |
|
|
|
|
if (!b) |
|
|
|
|
{ |
|
|
|
|
UBPersistenceManager::persistenceManager()->deleteDocument(document); |
|
|
|
|
UBApplication::setDisabled(false); |
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QList<UBGraphicsItem*> pages = importAdaptor->import(uuid, filepath); |
|
|
|
|
int nPage = 0; |
|
|
|
|
foreach(UBGraphicsItem* page, pages) |
|
|
|
|
{ |
|
|
|
|
UBApplication::showMessage(tr("Inserting page %1 of %2").arg(++nPage).arg(pages.size()), true); |
|
|
|
|
int pageIndex = document->pageCount(); |
|
|
|
|
UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(document, pageIndex); |
|
|
|
|
importAdaptor->placeImportedItemToScene(scene, page); |
|
|
|
|
UBPersistenceManager::persistenceManager()->persistDocumentScene(document, scene, pageIndex); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(document); |
|
|
|
|
UBApplication::showMessage(tr("Import successful.")); |
|
|
|
@ -216,28 +216,28 @@ int UBDocumentManager::addFilesToDocument(UBDocumentProxy* document, QStringList |
|
|
|
|
{ |
|
|
|
|
UBPageBasedImportAdaptor* importAdaptor = (UBPageBasedImportAdaptor*)adaptor; |
|
|
|
|
|
|
|
|
|
QUuid uuid = QUuid::createUuid(); |
|
|
|
|
QString filepath = file.fileName(); |
|
|
|
|
if (importAdaptor->folderToCopy() != "") |
|
|
|
|
{ |
|
|
|
|
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(document, file.fileName(), importAdaptor->folderToCopy() , uuid, filepath); |
|
|
|
|
if (!b) |
|
|
|
|
{ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QList<UBGraphicsItem*> pages = importAdaptor->import(uuid, filepath); |
|
|
|
|
int nPage = 0; |
|
|
|
|
foreach(UBGraphicsItem* page, pages) |
|
|
|
|
{ |
|
|
|
|
UBApplication::showMessage(tr("Inserting page %1 of %2").arg(++nPage).arg(pages.size()), true); |
|
|
|
|
int pageIndex = document->pageCount(); |
|
|
|
|
UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(document, pageIndex); |
|
|
|
|
importAdaptor->placeImportedItemToScene(scene, page); |
|
|
|
|
QUuid uuid = QUuid::createUuid(); |
|
|
|
|
QString filepath = file.fileName(); |
|
|
|
|
if (importAdaptor->folderToCopy() != "") |
|
|
|
|
{ |
|
|
|
|
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(document, file.fileName(), importAdaptor->folderToCopy() , uuid, filepath); |
|
|
|
|
if (!b) |
|
|
|
|
{ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QList<UBGraphicsItem*> pages = importAdaptor->import(uuid, filepath); |
|
|
|
|
int nPage = 0; |
|
|
|
|
foreach(UBGraphicsItem* page, pages) |
|
|
|
|
{ |
|
|
|
|
UBApplication::showMessage(tr("Inserting page %1 of %2").arg(++nPage).arg(pages.size()), true); |
|
|
|
|
int pageIndex = document->pageCount(); |
|
|
|
|
UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(document, pageIndex); |
|
|
|
|
importAdaptor->placeImportedItemToScene(scene, page); |
|
|
|
|
UBPersistenceManager::persistenceManager()->persistDocumentScene(document, scene, pageIndex); |
|
|
|
|
UBApplication::boardController->addEmptyThumbPage(); |
|
|
|
|
} |
|
|
|
|
UBApplication::boardController->addEmptyThumbPage(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(document); |
|
|
|
|
UBApplication::showMessage(tr("Import of file %1 successful.").arg(file.fileName())); |
|
|
|
|