diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index 08e51c03..a56fd342 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -1405,7 +1405,10 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) } QMap elements = getAdditionalElementToStore(); - QVector dataStorageItems = elements.value("teacherGuide")->save(pageIndex); + QVector dataStorageItems; + + if(elements.value("teacherGuide")) + dataStorageItems = elements.value("teacherGuide")->save(pageIndex); foreach(tIDataStorage* eachItem, dataStorageItems){ if(eachItem->type == eElementType_START){ mXmlWriter.writeStartElement(eachItem->name); diff --git a/src/adaptors/UBThumbnailAdaptor.cpp b/src/adaptors/UBThumbnailAdaptor.cpp index 656a009e..057cf991 100644 --- a/src/adaptors/UBThumbnailAdaptor.cpp +++ b/src/adaptors/UBThumbnailAdaptor.cpp @@ -91,9 +91,22 @@ const QPixmap* UBThumbnailAdaptor::get(UBDocumentProxy* proxy, int pageIndex) return pix; } +void UBThumbnailAdaptor::updateDocumentToHandleZeroPage(UBDocumentProxy* proxy) +{ + if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){ + QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", 0); + QFile file(fileName); + qDebug() << fileName; + if(!file.exists()){ + UBPersistenceManager::persistenceManager()->persistDocumentScene(proxy,new UBGraphicsScene(proxy),0); + } + } +} + void UBThumbnailAdaptor::load(UBDocumentProxy* proxy, QList& list) { - generateMissingThumbnails(proxy); + updateDocumentToHandleZeroPage(proxy); + generateMissingThumbnails(proxy); foreach(const QPixmap* pm, list) delete pm; @@ -102,81 +115,10 @@ void UBThumbnailAdaptor::load(UBDocumentProxy* proxy, QList& lis list.append(get(proxy, i)); } - -/* -QList UBThumbnailAdaptor::load(UBDocumentProxy* proxy) -{ - QList thumbnails; - - qDebug() << "Loadinf thumbnails for " << proxy->name(); - - if (!proxy || proxy->persistencePath().isEmpty()) - return thumbnails; - - //compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails - generateMissingThumbnails(proxy); - - //end compatibility with older format - - bool moreToProcess = true; - int pageCount = UBApplication::boardController->sceneIndexFromPage(0); - - while (moreToProcess) { - pageCount++; - QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageCount); - - QFile file(fileName); - if (file.exists()) { - QPixmap pix; - //Warning. Works only with modified Qt -#ifdef Q_WS_X11 - //pix.load(fileName, 0, Qt::AutoColor); - pix.load(fileName, 0); -#else - pix.load(fileName, 0, Qt::AutoColor, false); -#endif - thumbnails.append(pix); - } else { - moreToProcess = false; - } - } - return thumbnails; -} - -QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index) -{ - qDebug() << "Loadinf thumbnails for " << proxy->name(); - - int existingPageCount = proxy->pageCount(); - - if (!proxy || proxy->persistencePath().size() == 0 || index < 0 || index > existingPageCount) - return QPixmap(); - //compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails - generateMissingThumbnails(proxy); - - //end compatibility with older format - QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", index); - - QFile file(fileName); - if (file.exists()) - { - QPixmap pix; - //Warning. Works only with modified Qt -#ifdef Q_WS_X11 - pix.load(fileName, 0, Qt::AutoColor); -#else - pix.load(fileName, 0, Qt::AutoColor, false); -#endif - return pix; - } - return QPixmap(); -} -*/ - void UBThumbnailAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* pScene, int pageIndex, bool overrideModified) { - qDebug() << "Persiste scene on path " << proxy->persistencePath() << ", index " << pageIndex; + qDebug() << "Persist scene on path " << proxy->persistencePath() << ", index " << pageIndex; QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex); diff --git a/src/adaptors/UBThumbnailAdaptor.h b/src/adaptors/UBThumbnailAdaptor.h index c53f120b..58972ae5 100644 --- a/src/adaptors/UBThumbnailAdaptor.h +++ b/src/adaptors/UBThumbnailAdaptor.h @@ -35,6 +35,7 @@ public: private: static void generateMissingThumbnails(UBDocumentProxy* proxy); + static void updateDocumentToHandleZeroPage(UBDocumentProxy* proxy); UBThumbnailAdaptor() {} }; diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index edbfa923..a64caef9 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -106,18 +106,6 @@ void UBBoardController::init() setupViews(); setupToolbar(); - //connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentWillBeDeleted(UBDocumentProxy*)) - // , this, SLOT(documentWillBeDeleted(UBDocumentProxy*))); - - //connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentSceneCreated(UBDocumentProxy*, int)) - // , this, SLOT(documentSceneChanged(UBDocumentProxy*, int))); - - //connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentSceneDeleted(UBDocumentProxy*, int)) - // , this, SLOT(documentSceneChanged(UBDocumentProxy*, int))); - - //connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentSceneMoved(UBDocumentProxy*, int)) - // , this, SLOT(documentSceneChanged(UBDocumentProxy*, int))); - connect(UBApplication::undoStack, SIGNAL(canUndoChanged(bool)) , this, SLOT(undoRedoStateChange(bool))); @@ -468,7 +456,6 @@ void UBBoardController::addScene() QApplication::restoreOverrideCursor(); } - void UBBoardController::addScene(UBGraphicsScene* scene, bool replaceActiveIfEmpty) { if (scene) diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index 1b349661..5c52ee61 100644 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -150,7 +150,7 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() mLeftPalette->registerWidget(mpPageNavigWidget); mLeftPalette->addTab(mpPageNavigWidget); - if(UBSettings::settings()->teacherGuidePageZeroActivated || UBSettings::settings()->teacherGuideLessonPagesActivated){ + if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool() || UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()){ mpTeacherGuideWidget = new UBDockTeacherGuideWidget(); mLeftPalette->registerWidget(mpTeacherGuideWidget); mLeftPalette->addTab(mpTeacherGuideWidget); diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index a46d8ed7..a279ab4c 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -676,7 +676,7 @@ int UBPersistenceManager::sceneCountInDir(const QString& pPath) } else { - if(UBSettings::settings()->teacherGuidePageZeroActivated && pageIndex == 0){ + if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool() && pageIndex == 0){ // the document has no zero file but doesn't means that it hasn't any file // at all. Just importing a document without the first page using a configuartion // that enables zero page. diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index 46f8cf32..7adbc6fd 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -74,15 +74,9 @@ UBDocumentController::UBDocumentController(UBMainWindow* mainWindow) setupToolbar(); this->selectDocument(UBApplication::boardController->selectedDocument()); connect(this, SIGNAL(exportDone()), mMainWindow, SLOT(onExportDone())); - //connect(mMainWindow->actionNewPage, SIGNAL(triggered()), this, SLOT(reloadThumbs())); connect(this, SIGNAL(documentThumbnailsUpdated(UBDocumentContainer*)), this, SLOT(refreshDocumentThumbnailsView(UBDocumentContainer*))); } -//void UBDocumentController::reloadThumbs() -//{ -// UBThumbnailAdaptor::load(selectedDocumentProxy(), mDocumentThumbs); -//} - UBDocumentController::~UBDocumentController() { if (mDocumentUI) @@ -1654,6 +1648,5 @@ void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*) connect(mDocumentUI->thumbnailWidget->scene(), SIGNAL(selectionChanged()), this, SLOT(pageSelectionChanged())); } - //emit refreshThumbnails(); QApplication::restoreOverrideCursor(); } diff --git a/src/document/UBDocumentController.h b/src/document/UBDocumentController.h index 4d58b87c..29077c4d 100644 --- a/src/document/UBDocumentController.h +++ b/src/document/UBDocumentController.h @@ -57,9 +57,7 @@ class UBDocumentController : public UBDocumentContainer bool pageCanBeDeleted(int page); signals: - //void refreshThumbnails(); void exportDone(); - //void movedToIndex(int index); public slots: void createNewDocument(); @@ -80,7 +78,6 @@ class UBDocumentController : public UBDocumentContainer void copy(); void paste(); void focusChanged(QWidget *old, QWidget *current); - //void reloadThumbs(); protected: virtual void setupViews();