From 46b33afae3609e4672ab736c00874fa5d6b96d7a Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 7 May 2012 11:07:29 +0200 Subject: [PATCH] added page on save call --- src/adaptors/UBSvgSubsetAdaptor.cpp | 10 +++++++--- src/adaptors/UBSvgSubsetAdaptor.h | 2 +- src/gui/UBTeacherGuideWidget.cpp | 22 +++++++++++++--------- src/gui/UBTeacherGuideWidget.h | 2 +- src/interfaces/IDataStorage.h | 2 +- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index b7c94c18..5fc372fe 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -333,6 +333,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() UBGraphicsStrokesGroup* strokesGroup = 0; UBDrawingController* dc = UBDrawingController::drawingController(); + sTeacherGuideNode = ""; + + while (!mXmlReader.atEnd()) { mXmlReader.readNext(); @@ -915,7 +918,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() void UBSvgSubsetAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* pScene, const int pageIndex) { UBSvgSubsetWriter writer(proxy, pScene, pageIndex); - writer.persistScene(); + writer.persistScene(pageIndex); } @@ -963,8 +966,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::writeSvgElement() mXmlWriter.writeEndElement(); } -bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() +bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) { + sTeacherGuideNode = ""; if (mScene->isModified()) { QBuffer buffer; @@ -1189,7 +1193,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() } QMap elements = getAdditionalElementToStore(); - QVector dataStorageItems = elements.value("teacherGuide")->save(); + QVector dataStorageItems = elements.value("teacherGuide")->save(pageIndex); foreach(tIDataStorage* eachItem, dataStorageItems){ if(eachItem->type == eElementType_START){ mXmlWriter.writeStartElement(eachItem->name); diff --git a/src/adaptors/UBSvgSubsetAdaptor.h b/src/adaptors/UBSvgSubsetAdaptor.h index 37eacb07..8edb3389 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.h +++ b/src/adaptors/UBSvgSubsetAdaptor.h @@ -164,7 +164,7 @@ class UBSvgSubsetAdaptor UBSvgSubsetWriter(UBDocumentProxy* proxy, UBGraphicsScene* pScene, const int pageIndex); - bool persistScene(); + bool persistScene(int pageIndex); virtual ~UBSvgSubsetWriter(){} diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index e0389b44..b51b9232 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -189,10 +189,11 @@ void UBTeacherGuideEditionWidget::load(QString element) -QVector UBTeacherGuideEditionWidget::save() +QVector UBTeacherGuideEditionWidget::save(int pageIndex) { QVector result; - QMap attributes; + if(pageIndex != UBApplication::boardController->currentPage()) + return result; tIDataStorage* data = new tIDataStorage(); data->name = "teacherGuide"; data->type = eElementType_START; @@ -239,7 +240,7 @@ void UBTeacherGuideEditionWidget::onActiveSceneChanged() int currentPage = UBApplication::boardController->currentPage(); if(currentPage > 0){ cleanData(); - qDebug() << UBSvgSubsetAdaptor::sTeacherGuideNode; + qDebug() << "active scene changed current page " << currentPage << " " << UBSvgSubsetAdaptor::sTeacherGuideNode; load(UBSvgSubsetAdaptor::sTeacherGuideNode); mpPageNumberLabel->setText(tr("Page: %0").arg(currentPage)); UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); @@ -936,14 +937,18 @@ void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode) mpModePushButton->hide(); mpSessionTitle->setReadOnly(false); mpSessionTitle->setStyleSheet(inputStyleSheet); + mpSessionTitle->setTextColor(QColor(Qt::lightGray)); QFont titleFont(QApplication::font().family(),11,-1); mpSessionTitle->document()->setDefaultFont(titleFont); mpAuthors->setReadOnly(false); mpAuthors->setStyleSheet(inputStyleSheet); + mpAuthors->setTextColor(QColor(Qt::lightGray)); mpGoals->setReadOnly(false); mpGoals->setStyleSheet(inputStyleSheet); + mpGoals->setTextColor(QColor(Qt::lightGray)); mpKeywords->setReadOnly(false); mpKeywords->setStyleSheet(inputStyleSheet); + mpKeywords->setTextColor(QColor(Qt::lightGray)); mpSchoolLevelValueLabel->hide(); mpSchoolLevelBox->show(); mpSchoolBranchValueLabel->hide(); @@ -957,21 +962,20 @@ void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode) else{ QString inputStyleSheet("QTextEdit { background: transparent; border: none;}"); mpModePushButton->show(); - mpSessionTitle->setReadOnly(true); - updateSceneTitle(); + mpSessionTitle->showText(mpSessionTitle->text()); mpSessionTitle->setStyleSheet(inputStyleSheet); - mpSessionTitle->setTextColor(QColor(Qt::black)); + updateSceneTitle(); QFont titleFont(QApplication::font().family(),14,1); mpSessionTitle->document()->setDefaultFont(titleFont); - mpAuthors->setReadOnly(true); mpAuthors->setStyleSheet(inputStyleSheet); mpAuthors->setTextColor(QColor(Qt::black)); - mpGoals->setReadOnly(true); + mpAuthors->showText(mpAuthors->text()); mpGoals->setStyleSheet(inputStyleSheet); mpGoals->setTextColor(QColor(Qt::black)); - mpKeywords->setReadOnly(true); + mpGoals->showText(mpGoals->text()); mpKeywords->setStyleSheet(inputStyleSheet); mpKeywords->setTextColor(QColor(Qt::black)); + mpKeywords->showText(mpKeywords->text()); mpSchoolLevelValueLabel->setText(mpSchoolLevelBox->currentText()); mpSchoolLevelValueLabel->show(); mpSchoolLevelBox->hide(); diff --git a/src/gui/UBTeacherGuideWidget.h b/src/gui/UBTeacherGuideWidget.h index 387a7a64..3f9834c4 100644 --- a/src/gui/UBTeacherGuideWidget.h +++ b/src/gui/UBTeacherGuideWidget.h @@ -48,7 +48,7 @@ public: QVector getData(); void load(QString element); - QVector save(); + QVector save(int pageIndex); public slots: void onAddItemClicked(QTreeWidgetItem* widget, int column, QDomElement* element = 0); diff --git a/src/interfaces/IDataStorage.h b/src/interfaces/IDataStorage.h index a703227d..10e69c93 100644 --- a/src/interfaces/IDataStorage.h +++ b/src/interfaces/IDataStorage.h @@ -37,6 +37,6 @@ class IDataStorage { public: virtual void load(QString element) = 0; - virtual QVectorsave() = 0 ; + virtual QVectorsave(int pageIndex) = 0 ; }; #endif // IDATASTORAGE_H