From 6e81d74d41f3cda36a47797e3877a9d07b19dfb4 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Mon, 23 Jan 2012 15:50:12 +0100 Subject: [PATCH] Added some logic for the Document description datas in the teacherbar --- src/core/UBPersistenceManager.cpp | 2 -- src/core/UBPersistenceManager.h | 3 +-- src/gui/UBTBDocumentEditWidget.cpp | 22 +++++++++++++++++-- src/gui/UBTBDocumentEditWidget.h | 3 +++ src/gui/UBTBPageEditWidget.cpp | 1 - src/gui/UBTeacherBarDataMgr.cpp | 27 ++++++++++++++++++------ src/gui/UBTeacherBarDataMgr.h | 2 +- src/gui/UBTeacherBarWidget.cpp | 34 +++++++++++++++++++++--------- src/gui/UBTeacherBarWidget.h | 4 +++- 9 files changed, 73 insertions(+), 25 deletions(-) diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index d3389c19..f0502955 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -1086,7 +1086,6 @@ void UBPersistenceManager::persistTeacherBar(UBDocumentProxy* pDocumentProxy, in // Set the element values QDomElement teacherBarElem = teacherBarNode.toElement(); teacherBarElem.setAttribute("title", infos.title); - teacherBarElem.setAttribute("duration", QString("%0").arg(infos.Duration)); QString qsAct; for(int i=0; isetSessionTitle(mpTitle->text()); + emit valueChanged(); +} +void UBTBDocumentEditWidget::onSessionTargetChanged() +{ + mpDataMgr->setSessionTarget(mpTarget->document()->toPlainText()); + emit valueChanged(); } -void UBTBDocumentEditWidget::clearFields() +void UBTBDocumentEditWidget::updateFields() { + mpTitle->setText(mpDataMgr->sessionTitle()); + mpTarget->setPlainText(mpDataMgr->sessionTarget()); +} +void UBTBDocumentEditWidget::clearFields() +{ + mpTitle->setText(""); + mpTarget->setPlainText(""); } + + diff --git a/src/gui/UBTBDocumentEditWidget.h b/src/gui/UBTBDocumentEditWidget.h index 705adcfe..147e5404 100644 --- a/src/gui/UBTBDocumentEditWidget.h +++ b/src/gui/UBTBDocumentEditWidget.h @@ -20,10 +20,13 @@ public: signals: void changeTBState(eTeacherBarState state); + void valueChanged(); private slots: void onPageView(); void onPreview(); + void onSessionTitleChanged(); + void onSessionTargetChanged(); private: QVBoxLayout mLayout; diff --git a/src/gui/UBTBPageEditWidget.cpp b/src/gui/UBTBPageEditWidget.cpp index 5e512d52..c93a5332 100644 --- a/src/gui/UBTBPageEditWidget.cpp +++ b/src/gui/UBTBPageEditWidget.cpp @@ -42,7 +42,6 @@ UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *p mpTitleLabel = new QLabel(tr("Title"), mpContainer); mpTitle = new QLineEdit(mpContainer); mpTitle->setObjectName("DockPaletteWidgetLineEdit"); - connect(mpTitle, SIGNAL(textChanged(const QString&)), this, SLOT(onTitleTextChanged(const QString&))); mContainerLayout.addWidget(mpTitleLabel, 0); mContainerLayout.addWidget(mpTitle, 0); diff --git a/src/gui/UBTeacherBarDataMgr.cpp b/src/gui/UBTeacherBarDataMgr.cpp index 8ee86c8c..857898d0 100644 --- a/src/gui/UBTeacherBarDataMgr.cpp +++ b/src/gui/UBTeacherBarDataMgr.cpp @@ -20,6 +20,7 @@ void UBTeacherBarDataMgr::clearLists() mActionList.clear(); mUrlList.clear(); mMediaList.clear(); + mMediaUrls.clear(); } void UBTeacherBarDataMgr::saveContent() @@ -27,40 +28,49 @@ void UBTeacherBarDataMgr::saveContent() // Store the page information in the UBZ sTeacherBarInfos infos; + // Page Title infos.title = mPageTitle; - // Actions foreach(sAction action, mActionList){ infos.actions << QString("%0;%1").arg(action.type).arg(action.content); } - // Media foreach(QString media, mMediaUrls){ infos.medias << media; } - // Links foreach(sLink link, mUrlList){ if("" != link.title && "" != link.link){ infos.urls << QString("%0;%1").arg(link.title).arg(link.link); } } - // Comments infos.comments = mComments; UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos); // TODO: Store the document metadata somewhere + // Session Title + //... = mSessionTitle; + // Session Target + //... = mSessionTarget; } -void UBTeacherBarDataMgr::loadContent() +void UBTeacherBarDataMgr::loadContent(bool docChanged) { clearLists(); sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); + if(docChanged){ + // TODO: Read these information from the metadata file + + // Session Title + //mSessionTitle = ...; + // Session Target + //mSessionTarget = ...; + } // Page Title mPageTitle = nextInfos.title; // Actions @@ -74,7 +84,12 @@ void UBTeacherBarDataMgr::loadContent() } } // Media URL - mMediaUrls = nextInfos.medias; + if((nextInfos.medias.size() == 1) && (nextInfos.medias.at(0) == "")){ + // Do not retrieve it + } + else{ + mMediaUrls = nextInfos.medias; + } // Links foreach(QString eachUrl, nextInfos.urls){ diff --git a/src/gui/UBTeacherBarDataMgr.h b/src/gui/UBTeacherBarDataMgr.h index 2c299474..3ac888be 100644 --- a/src/gui/UBTeacherBarDataMgr.h +++ b/src/gui/UBTeacherBarDataMgr.h @@ -68,7 +68,7 @@ public: // Others void clearLists(); void saveContent(); - void loadContent(); + void loadContent(bool docChanged = false); private: QString mSessionTitle; diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index d0bbc85b..7d8ab771 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -52,14 +52,16 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpStackWidget->addWidget(mpDocEditWidget); connect(UBApplication::boardController, SIGNAL(activeSceneWillChange()), this, SLOT(saveContent())); - connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContent())); connect(UBApplication::mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(saveContent())); + connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContentInfos())); + connect(UBApplication::boardController, SIGNAL(activeDocumentChanged()), this, SLOT(onActiveDocumentChanged())); connect(mpPreview, SIGNAL(showEditMode()), this, SLOT(onShowEditMode())); connect(mpDocPreviewWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); connect(mpDocEditWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); connect(mpPageEditWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); connect(mpPageEditWidget, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); + connect(mpDocEditWidget, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); } UBTeacherBarWidget::~UBTeacherBarWidget() @@ -71,6 +73,11 @@ UBTeacherBarWidget::~UBTeacherBarWidget() DELETEPTR(mpStackWidget); } +void UBTeacherBarWidget::onActiveDocumentChanged() +{ + loadContent(true); +} + void UBTeacherBarWidget::onValueChanged() { if(isEmpty()) @@ -93,22 +100,31 @@ void UBTeacherBarWidget::saveContent() mData.saveContent(); } -void UBTeacherBarWidget::loadContent() +void UBTeacherBarWidget::loadContentInfos() +{ + loadContent(false); +} + +void UBTeacherBarWidget::loadContent(bool docChanged) { // Clear the old datas mpPageEditWidget->clearFields(); mpPreview->clearFields(); - mpDocEditWidget->clearFields(); - mpDocPreviewWidget->clearFields(); + if(docChanged){ + mpDocEditWidget->clearFields(); + mpDocPreviewWidget->clearFields(); + } // Update the datas - mData.loadContent(); + mData.loadContent(docChanged); // Update the fields mpPageEditWidget->updateFields(); mpPreview->updateFields(); - mpDocEditWidget->updateFields(); - mpDocPreviewWidget->updateFields(); + if(docChanged){ + mpDocEditWidget->updateFields(); + mpDocPreviewWidget->updateFields(); + } if(!isEmpty()){ onTBStateChanged(eTeacherBarState_PagePreview); @@ -127,9 +143,7 @@ bool UBTeacherBarWidget::isEmpty() mData.urls()->empty() && mData.actions()->empty() && mData.medias()->empty() && - mData.comments() == "" && - mData.sessionTarget() == "" && - mData.sessionTitle() == ""; + mData.comments() == ""; } void UBTeacherBarWidget::onShowEditMode() diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 6b38645b..2bea6677 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -34,12 +34,14 @@ public: private slots: void saveContent(); - void loadContent(); + void loadContentInfos(); void onValueChanged(); void onShowEditMode(); void onTBStateChanged(eTeacherBarState state); + void onActiveDocumentChanged(); private: + void loadContent(bool docChanged = false); bool isEmpty(); QVBoxLayout mLayout;