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