diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 9ac5d13a6f90dd7f35b395eb466d6d28cd2d6120..d3389c1996ab1d8165f3293cfb50288b1b5debef 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -1086,16 +1086,36 @@ void UBPersistenceManager::persistTeacherBar(UBDocumentProxy* pDocumentProxy, in // Set the <teacherBar> element values QDomElement teacherBarElem = teacherBarNode.toElement(); teacherBarElem.setAttribute("title", infos.title); - teacherBarElem.setAttribute("phasis", infos.phasis); - teacherBarElem.setAttribute("duration", infos.Duration); - teacherBarElem.setAttribute("equipment", infos.material); - teacherBarElem.setAttribute("activity", infos.activity); - teacherBarElem.setAttribute("action1Teacher", infos.action1Master); - teacherBarElem.setAttribute("action1Student", infos.action1Student); - teacherBarElem.setAttribute("action2Teacher", infos.action2Master); - teacherBarElem.setAttribute("action2Student", infos.action2Student); - teacherBarElem.setAttribute("action3Teacher", infos.action3Master); - teacherBarElem.setAttribute("action3Student", infos.action3Student); + teacherBarElem.setAttribute("duration", QString("%0").arg(infos.Duration)); + + QString qsAct; + for(int i=0; i<infos.actions.size(); i++){ + if(0 != i){ + qsAct.append('@'); + } + qsAct.append(infos.actions.at(i)); + } + teacherBarElem.setAttribute("actions", qsAct); + + QString qsMedias; + for(int j=0; j<infos.medias.size(); j++){ + if(0 != j){ + qsMedias.append('@'); + } + qsMedias.append(infos.medias.at(j)); + } + teacherBarElem.setAttribute("medias", qsMedias); + + QString qsUrls; + for(int k=0; k<infos.urls.size(); k++){ + if(0 != k){ + qsUrls.append('@'); + } + qsUrls.append(infos.urls.at(k)); + } + teacherBarElem.setAttribute("links", qsUrls); + + teacherBarElem.setAttribute("comments", infos.comments); // Save the file f.write(domDoc.toString().toAscii()); @@ -1126,16 +1146,11 @@ sTeacherBarInfos UBPersistenceManager::getTeacherBarInfos(UBDocumentProxy* pDocu QDomNode teacherBarNode = rootElem.namedItem("teacherBar"); infos.title = teacherBarNode.toElement().attributeNode("title").value(); - infos.phasis = teacherBarNode.toElement().attributeNode("phasis").value().toInt(); infos.Duration = teacherBarNode.toElement().attributeNode("duration").value().toInt(); - infos.material = teacherBarNode.toElement().attributeNode("equipment").value(); - infos.activity = teacherBarNode.toElement().attributeNode("activity").value().toInt(); - infos.action1Master = teacherBarNode.toElement().attributeNode("action1Teacher").value(); - infos.action1Student = teacherBarNode.toElement().attributeNode("action1Student").value(); - infos.action2Master = teacherBarNode.toElement().attributeNode("action2Teacher").value(); - infos.action2Student = teacherBarNode.toElement().attributeNode("action2Student").value(); - infos.action3Master = teacherBarNode.toElement().attributeNode("action3Teacher").value(); - infos.action3Student = teacherBarNode.toElement().attributeNode("action3Student").value(); + infos.actions = teacherBarNode.toElement().attributeNode("actions").value().split("@"); + infos.medias = teacherBarNode.toElement().attributeNode("medias").value().split("@"); + infos.urls = teacherBarNode.toElement().attributeNode("links").value().split("@"); + infos.comments = teacherBarNode.toElement().attributeNode("comments").value(); } f.close(); } diff --git a/src/core/UBPersistenceManager.h b/src/core/UBPersistenceManager.h index 74a3ab7c9b20e159c00d3a27a6e840245a141fe5..7ddc7ee5785d40317aebaff1eb0ca16a1ef34fad 100644 --- a/src/core/UBPersistenceManager.h +++ b/src/core/UBPersistenceManager.h @@ -23,16 +23,11 @@ struct sTeacherBarInfos { QString title; - int phasis; int Duration; - QString material; - int activity; - QString action1Master; - QString action1Student; - QString action2Master; - QString action2Student; - QString action3Master; - QString action3Student; + QStringList actions; + QStringList medias; + QStringList urls; + QString comments; }; class UBDocument; diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 93e1fc61b25a26dcb1a795c561e582ed76568e13..833e1796d0d2f219994f4c9d974f0686fb02225a 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -266,14 +266,79 @@ void UBTeacherBarWidget::onValueChanged() void UBTeacherBarWidget::saveContent() { sTeacherBarInfos infos; + // Title infos.title = mpTitle->text(); + // Duration + if(mpDuration1->isChecked()){ + infos.Duration = 0; + }else if(mpDuration2->isChecked()){ + infos.Duration = 1; + }else{ + infos.Duration = 2; + } + // Actions + for(int i=0; i<mActionList.size(); i++){ + infos.actions << QString("%0;%1").arg(mActionList.at(i)->comboValue()).arg(mActionList.at(i)->text()); + } + // Media + // TODO : Get the url of the dropped medias and store them in infos.medias + + // Links + for(int j=0; j<mUrlList.size(); j++){ + if("" != mUrlList.at(j)->url()){ + infos.urls << mUrlList.at(j)->url(); + } + } + // Comments + infos.comments = mpComments->document()->toPlainText(); + UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos); } void UBTeacherBarWidget::loadContent() { sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); + // Title mpTitle->setText(nextInfos.title); + // Duration + switch(nextInfos.Duration){ + case 0: mpDuration1->setChecked(true); + break; + case 1: mpDuration2->setChecked(true); + break; + case 2: mpDuration3->setChecked(true); + break; + default: mpDuration1->setChecked(true); + break; + } + // Actions + for(int i=0; i<nextInfos.actions.size(); i++){ + QStringList qslAction = nextInfos.actions.at(i).split(";"); + if(qslAction.size() >= 2){ + UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); + pAction->setComboValue(qslAction.at(0).toInt()); + pAction->setText(qslAction.at(1)); + mActionList << pAction; + mpActions->addWidget(pAction); + } + } + // Media + // TODO : Add the media items here + + // Links + for(int j=0; j<nextInfos.urls.size(); j++){ + QString qsUrl = nextInfos.urls.at(j); + if("" != qsUrl){ + UBUrlWidget* pLink = new UBUrlWidget(this); + pLink->setUrl(qsUrl); + mUrlList << pLink; + mpLinks->addWidget(pLink); + } + } + // Comments + if(NULL != mpComments){ + mpComments->document()->setPlainText(nextInfos.comments); + } } void UBTeacherBarWidget::onTitleTextChanged(const QString& text) @@ -365,12 +430,26 @@ QString UBTeacherStudentAction::comboValue() QString str; if(NULL != mpCombo){ - str = mpCombo->currentText(); + str = QString("%0").arg(mpCombo->currentIndex()); } return str; } +void UBTeacherStudentAction::setComboValue(int value) +{ + if(NULL != mpCombo){ + mpCombo->setCurrentIndex(value); + } +} + +void UBTeacherStudentAction::setText(const QString& text) +{ + if(NULL != mpText){ + mpText->document()->setPlainText(text); + } +} + // --------------------------------------------------------------------------------------------- UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):QWidget(parent) @@ -507,3 +586,10 @@ QString UBUrlWidget::url() return str; } + +void UBUrlWidget::setUrl(const QString &url) +{ + if(NULL != mpUrl){ + mpUrl->setText(url); + } +} diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index b29b5136cfe13781220fa3801af3eebe7c92aa2f..f59f64ed2e160658385f847da639cb1ee5bbb214 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -29,6 +29,8 @@ public: ~UBTeacherStudentAction(); QString comboValue(); QString text(); + void setComboValue(int value); + void setText(const QString& text); private: QTextEdit* mpText; @@ -67,6 +69,7 @@ public: ~UBUrlWidget(); QString url(); + void setUrl(const QString& url); private: QHBoxLayout* mpLayout;