From 11129a97dc5cf7ed7f08b5e4ba3215cac9399808 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 21 Sep 2012 14:19:22 +0200 Subject: [PATCH] fixed issue with toque teacher bar --- src/adaptors/UBSvgSubsetAdaptor.cpp | 30 ---------------------------- src/adaptors/UBThumbnailAdaptor.cpp | 13 +++++++++++- src/board/UBBoardController.cpp | 13 ++++++------ src/board/UBBoardController.h | 3 +-- src/core/UBPersistenceManager.cpp | 11 +--------- src/core/UBPersistenceManager.h | 3 --- src/document/UBDocumentContainer.cpp | 2 -- src/document/UBDocumentContainer.h | 4 ++-- src/gui/UBDocumentNavigator.cpp | 22 +------------------- 9 files changed, 23 insertions(+), 78 deletions(-) diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index bcfa5199..03a62143 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -941,18 +941,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() readGroupRoot(); } -// else if (mXmlReader.name() == "teacherBar" || mXmlReader.name() == "teacherGuide"){ -// sTeacherGuideNode.clear(); -// sTeacherGuideNode += ""; -// sTeacherGuideNode += "\n"; -// } -// else if (mXmlReader.name() == "media" || mXmlReader.name() == "link" || mXmlReader.name() == "title" || mXmlReader.name() == "comment" || mXmlReader.name() == "action") -// { -// sTeacherGuideNode += "<" + mXmlReader.name().toString() + " "; -// foreach(QXmlStreamAttribute attribute, mXmlReader.attributes()) -// sTeacherGuideNode += attribute.name().toString() + "=\"" + attribute.value().toString() + "\" "; -// sTeacherGuideNode += " />\n"; -// } else { // NOOP @@ -976,17 +964,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() mGroupDarkBackgroundColor = QColor(); mGroupLightBackgroundColor = QColor(); } -// else if (mXmlReader.name() == "teacherBar" || mXmlReader.name() == "teacherGuide"){ -// sTeacherGuideNode += ""; -// qDebug() << sTeacherGuideNode; -// QMap elements = getAdditionalElementToStore(); -// IDataStorage* storageClass = elements.value("teacherGuide"); -// if(storageClass){ -// storageClass->load(sTeacherGuideNode); -// } -// } - - } } @@ -1147,17 +1124,10 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) QDomElement groupRoot = groupDomDocument.createElement(tGroups); groupDomDocument.appendChild(groupRoot); - - static int i = 0; - qDebug() << "persist call no is " << ++i; - QBuffer buffer; buffer.open(QBuffer::WriteOnly); mXmlWriter.setDevice(&buffer); - //Unused variable - //QTime timer = QTime::currentTime(); - mXmlWriter.setAutoFormatting(true); mXmlWriter.writeStartDocument(); diff --git a/src/adaptors/UBThumbnailAdaptor.cpp b/src/adaptors/UBThumbnailAdaptor.cpp index 1a90f108..a44e6b6b 100644 --- a/src/adaptors/UBThumbnailAdaptor.cpp +++ b/src/adaptors/UBThumbnailAdaptor.cpp @@ -23,7 +23,12 @@ #include "core/UBApplication.h" #include "core/UBSettings.h" + +#include "gui/UBDockTeacherGuideWidget.h" +#include "gui/UBTeacherGuideWidget.h" + #include "board/UBBoardController.h" +#include "board/UBBoardPaletteManager.h" #include "document/UBDocumentProxy.h" @@ -120,7 +125,7 @@ void UBThumbnailAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* p QFile thumbFile(fileName); - if (pScene->isModified() || overrideModified || !thumbFile.exists()) + if (pScene->isModified() || overrideModified || !thumbFile.exists() || UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified()) { qreal nominalWidth = pScene->nominalSize().width(); qreal nominalHeight = pScene->nominalSize().height(); @@ -152,6 +157,12 @@ void UBThumbnailAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* p pScene->render(&painter, imageRect, sceneRect, Qt::KeepAspectRatio); + if(UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified()){ + QPixmap toque(":images/toque.png"); + painter.setOpacity(0.6); + painter.drawPixmap(QPoint(width - toque.width(),0),toque); + } + pScene->setRenderingContext(UBGraphicsScene::Screen); pScene->setRenderingQuality(UBItem::RenderingQualityNormal); diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index ddc30c9e..57d753d7 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -95,6 +95,7 @@ UBBoardController::UBBoardController(UBMainWindow* mainWindow) , mCleanupDone(false) , mCacheWidgetIsEnabled(false) , mDeletingSceneIndex(-1) + , mMovingSceneIndex(-1) , mActionGroupText(tr("Group")) , mActionUngroupText(tr("Ungroup")) { @@ -1450,9 +1451,6 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, { freezeW3CWidgets(true); - if(sceneChange) - emit activeSceneWillChange(); - persistCurrentScene(); ClearUndoStack(); @@ -1500,14 +1498,17 @@ void UBBoardController::moveSceneToIndex(int source, int target) { if (selectedDocument()) { + persistCurrentScene(); UBDocumentContainer::movePageToIndex(source, target); selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); UBMetadataDcSubsetAdaptor::persist(selectedDocument()); - + mMovingSceneIndex = source; setActiveDocumentScene(target); + mMovingSceneIndex = -1; + } } @@ -1807,11 +1808,9 @@ void UBBoardController::persistCurrentScene() { if(UBPersistenceManager::persistenceManager() && selectedDocument() && mActiveScene && mActiveSceneIndex != mDeletingSceneIndex - && (mActiveSceneIndex >= 0) + && (mActiveSceneIndex >= 0) && mActiveSceneIndex != mMovingSceneIndex && (mActiveScene->isModified() || (UBApplication::boardController->paletteManager()->teacherGuideDockWidget() && UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified()))) { - emit activeSceneWillBePersisted(); - UBPersistenceManager::persistenceManager()->persistDocumentScene(selectedDocument(), mActiveScene, mActiveSceneIndex); updatePage(mActiveSceneIndex); } diff --git a/src/board/UBBoardController.h b/src/board/UBBoardController.h index a04c1a25..9d810811 100644 --- a/src/board/UBBoardController.h +++ b/src/board/UBBoardController.h @@ -229,8 +229,6 @@ class UBBoardController : public UBDocumentContainer signals: void newPageAdded(); - void activeSceneWillBePersisted(); - void activeSceneWillChange(); void activeSceneChanged(); void zoomChanged(qreal pZoomFactor); void systemScaleFactorChanged(qreal pSystemScaleFactor); @@ -286,6 +284,7 @@ class UBBoardController : public UBDocumentContainer bool mCacheWidgetIsEnabled; QGraphicsItem* mLastCreatedItem; int mDeletingSceneIndex; + int mMovingSceneIndex; QString mActionGroupText; QString mActionUngroupText; diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 21733038..7224a789 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -463,11 +463,6 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL } } - - foreach(int index, compactedIndexes) - { - emit documentSceneDeleted(proxy, index); - } } @@ -576,8 +571,6 @@ void UBPersistenceManager::moveSceneToIndex(UBDocumentProxy* proxy, int source, thumb.rename(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", target)); mSceneCache.moveScene(proxy, source, target); - - emit documentSceneMoved(proxy, target); } @@ -612,7 +605,7 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy, UBBoardPaletteManager* paletteManager = UBApplication::boardController->paletteManager(); bool teacherGuideModified = false; - if(paletteManager->teacherGuideDockWidget()) + if(UBApplication::app()->boardController->currentPage() == pSceneIndex && paletteManager->teacherGuideDockWidget()) teacherGuideModified = paletteManager->teacherGuideDockWidget()->teacherGuideWidget()->isModified(); if (pDocumentProxy->isModified() || teacherGuideModified) @@ -628,8 +621,6 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy, } mSceneCache.insert(pDocumentProxy, pSceneIndex, pScene); - - emit documentCommitted(pDocumentProxy); } diff --git a/src/core/UBPersistenceManager.h b/src/core/UBPersistenceManager.h index c38e9895..60ce57c2 100644 --- a/src/core/UBPersistenceManager.h +++ b/src/core/UBPersistenceManager.h @@ -117,13 +117,10 @@ class UBPersistenceManager : public QObject void documentCreated(UBDocumentProxy* pDocumentProxy); void documentMetadataChanged(UBDocumentProxy* pDocumentProxy); - void documentCommitted(UBDocumentProxy* pDocumentProxy); void documentWillBeDeleted(UBDocumentProxy* pDocumentProxy); void documentSceneCreated(UBDocumentProxy* pDocumentProxy, int pIndex); - void documentSceneMoved(UBDocumentProxy* pDocumentProxy, int pIndex); void documentSceneWillBeDeleted(UBDocumentProxy* pDocumentProxy, int pIndex); - void documentSceneDeleted(UBDocumentProxy* pDocumentProxy, int pDeletedIndex); private: diff --git a/src/document/UBDocumentContainer.cpp b/src/document/UBDocumentContainer.cpp index ce8549a7..3fe49207 100644 --- a/src/document/UBDocumentContainer.cpp +++ b/src/document/UBDocumentContainer.cpp @@ -94,7 +94,6 @@ void UBDocumentContainer::updatePage(int index) void UBDocumentContainer::deleteThumbPage(int index) { mDocumentThumbs.removeAt(index); - emit documentPageDeleted(index); } void UBDocumentContainer::updateThumbPage(int index) @@ -106,7 +105,6 @@ void UBDocumentContainer::updateThumbPage(int index) void UBDocumentContainer::insertThumbPage(int index) { mDocumentThumbs.insert(index, UBThumbnailAdaptor::get(mCurrentDocument, index)); - emit documentPageAdded(index); } void UBDocumentContainer::reloadThumbnails() diff --git a/src/document/UBDocumentContainer.h b/src/document/UBDocumentContainer.h index b1c2aba1..0fcf2c12 100644 --- a/src/document/UBDocumentContainer.h +++ b/src/document/UBDocumentContainer.h @@ -58,8 +58,8 @@ class UBDocumentContainer : public QObject signals: void documentSet(UBDocumentProxy* document); - void documentPageAdded(int index); - void documentPageDeleted(int index); +// void documentPageAdded(int index); +// void documentPageDeleted(int index); void documentPageUpdated(int index); void documentThumbnailsUpdated(UBDocumentContainer* source); }; diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index 90b45615..4faaa83b 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -89,27 +89,9 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source) { const QPixmap* pix = source->pageAt(i); - QPixmap result(pix->width(),pix->height()); int pageIndex = UBDocumentContainer::pageFromSceneIndex(i); - QPainter composePainter; - composePainter.begin(&result); - composePainter.drawPixmap(QPoint(0,0),*pix); - - if(pageIndex == UBApplication::boardController->currentPage() && - ((pageIndex == 0 && UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) || - (pageIndex && UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool())) - ) { - if(UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified()){ - QPixmap toque(":images/toque.png"); - composePainter.setOpacity(0.6); - composePainter.drawPixmap(QPoint(pix->width() - toque.width(),0),toque); - } - } - - composePainter.end(); - - UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(result, source->selectedDocument(), i); + UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(*pix, source->selectedDocument(), i); QString label = pageIndex == 0 ? tr("Title page") : tr("Page %0").arg(pageIndex); UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(label); @@ -128,7 +110,6 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source) void UBDocumentNavigator::onScrollToSelectedPage(int index) { - qDebug() << "Selection in widget: " << index; int c = 0; foreach(UBImgTextThumbnailElement el, mThumbsWithLabels) { @@ -286,7 +267,6 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event) break; } } - qDebug() << "Selected Scene: " << index; UBApplication::boardController->setActiveDocumentScene(index); } QGraphicsView::mousePressEvent(event);