From f973c8b2d2511294318a4eeb7594ede4ff0d0684 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 5 Aug 2013 13:08:51 +0200 Subject: [PATCH 1/3] importing pdf doesn't add a blanc page anymore. Issue 81 --- src/core/UBDocumentManager.cpp | 2 +- src/core/UBPersistenceManager.cpp | 10 +++++----- src/document/UBDocumentController.cpp | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/core/UBDocumentManager.cpp b/src/core/UBDocumentManager.cpp index 17c2c9f5..cedc1bef 100644 --- a/src/core/UBDocumentManager.cpp +++ b/src/core/UBDocumentManager.cpp @@ -150,7 +150,7 @@ UBDocumentProxy* UBDocumentManager::importFile(const QFile& pFile, const QString // Document import procedure..... QString documentName = QFileInfo(pFile.fileName()).completeBaseName(); - document = UBPersistenceManager::persistenceManager()->createDocument(pGroup, documentName); + document = UBPersistenceManager::persistenceManager()->createDocument(pGroup, documentName,false); QUuid uuid = QUuid::createUuid(); QString filepath = pFile.fileName(); diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index ab267208..a97cc87e 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -264,7 +264,10 @@ UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName, doc->setMetaData(UBSettings::documentUpdatedAt,currentDate); doc->setMetaData(UBSettings::documentDate,currentDate); - if (withEmptyPage) createDocumentSceneAt(doc, 0); + if (withEmptyPage) + createDocumentSceneAt(doc, 0); + else + generatePathIfNeeded(doc); documentProxies.insert(0, QPointer(doc)); @@ -887,16 +890,13 @@ bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy, if (data == NULL && !fi.exists()) return false; - qDebug() << fi.suffix(); - QString fileName = subdir + "/" + objectUuid.toString() + "." + fi.suffix(); - destinationPath = pDocumentProxy->persistencePath() + "/" + fileName; if (!QFile::exists(destinationPath)) { QDir dir; - dir.mkdir(pDocumentProxy->persistencePath() + "/" + subdir); + dir.mkpath(pDocumentProxy->persistencePath() + "/" + subdir); if (!QFile::exists(pDocumentProxy->persistencePath() + "/" + subdir)) return false; diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index a0fe8304..01b8d8ab 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -1052,7 +1052,6 @@ bool UBDocumentController::addFileToDocument(UBDocumentProxy* document) if (filePath.length() > 0) { QApplication::processEvents(); // NOTE: We performed this just a few lines before. Is it really necessary to do it again here?? - QFile selectedFile(filePath); showMessage(tr("Importing file %1...").arg(fileInfo.baseName()), true); From 4e3f45d9508a50114d74ae5554d37c1eb9ee23bc Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 5 Aug 2013 14:00:38 +0200 Subject: [PATCH 2/3] long click on add page permits to add pdf but on tumblr generation an error eccours --- src/gui/UBDocumentNavigator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index 4f489ad6..c586d37f 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -101,7 +101,7 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source) { //claudio This is a very bad hack and shows a architectural problem // source->selectedDocument()->pageCount() != source->pageCount() - if(i>=source->pageCount()) + if(i>=source->pageCount() || source->pageAt(i)->isNull()) source->insertThumbPage(i); const QPixmap* pix = source->pageAt(i); From c80e93d4142bc0e972b0a57755e28c3e0e5f5465 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 5 Aug 2013 14:00:38 +0200 Subject: [PATCH 3/3] long click on add page permits to add pdf but on thumbnail generation an error eccours --- src/gui/UBDocumentNavigator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index 4f489ad6..c586d37f 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -101,7 +101,7 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source) { //claudio This is a very bad hack and shows a architectural problem // source->selectedDocument()->pageCount() != source->pageCount() - if(i>=source->pageCount()) + if(i>=source->pageCount() || source->pageAt(i)->isNull()) source->insertThumbPage(i); const QPixmap* pix = source->pageAt(i);