Added the ability to save the values of the teacher bar in the UBZ file

preferencesAboutTextFull
shibakaneki 13 years ago
parent 0fb7cad988
commit ca29e0d5e3
  1. 53
      src/core/UBPersistenceManager.cpp
  2. 13
      src/core/UBPersistenceManager.h
  3. 88
      src/gui/UBTeacherBarWidget.cpp
  4. 3
      src/gui/UBTeacherBarWidget.h

@ -1086,16 +1086,36 @@ void UBPersistenceManager::persistTeacherBar(UBDocumentProxy* pDocumentProxy, in
// Set the <teacherBar> element values // Set the <teacherBar> element values
QDomElement teacherBarElem = teacherBarNode.toElement(); QDomElement teacherBarElem = teacherBarNode.toElement();
teacherBarElem.setAttribute("title", infos.title); teacherBarElem.setAttribute("title", infos.title);
teacherBarElem.setAttribute("phasis", infos.phasis); teacherBarElem.setAttribute("duration", QString("%0").arg(infos.Duration));
teacherBarElem.setAttribute("duration", infos.Duration);
teacherBarElem.setAttribute("equipment", infos.material); QString qsAct;
teacherBarElem.setAttribute("activity", infos.activity); for(int i=0; i<infos.actions.size(); i++){
teacherBarElem.setAttribute("action1Teacher", infos.action1Master); if(0 != i){
teacherBarElem.setAttribute("action1Student", infos.action1Student); qsAct.append('@');
teacherBarElem.setAttribute("action2Teacher", infos.action2Master); }
teacherBarElem.setAttribute("action2Student", infos.action2Student); qsAct.append(infos.actions.at(i));
teacherBarElem.setAttribute("action3Teacher", infos.action3Master); }
teacherBarElem.setAttribute("action3Student", infos.action3Student); 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 // Save the file
f.write(domDoc.toString().toAscii()); f.write(domDoc.toString().toAscii());
@ -1126,16 +1146,11 @@ sTeacherBarInfos UBPersistenceManager::getTeacherBarInfos(UBDocumentProxy* pDocu
QDomNode teacherBarNode = rootElem.namedItem("teacherBar"); QDomNode teacherBarNode = rootElem.namedItem("teacherBar");
infos.title = teacherBarNode.toElement().attributeNode("title").value(); infos.title = teacherBarNode.toElement().attributeNode("title").value();
infos.phasis = teacherBarNode.toElement().attributeNode("phasis").value().toInt();
infos.Duration = teacherBarNode.toElement().attributeNode("duration").value().toInt(); infos.Duration = teacherBarNode.toElement().attributeNode("duration").value().toInt();
infos.material = teacherBarNode.toElement().attributeNode("equipment").value(); infos.actions = teacherBarNode.toElement().attributeNode("actions").value().split("@");
infos.activity = teacherBarNode.toElement().attributeNode("activity").value().toInt(); infos.medias = teacherBarNode.toElement().attributeNode("medias").value().split("@");
infos.action1Master = teacherBarNode.toElement().attributeNode("action1Teacher").value(); infos.urls = teacherBarNode.toElement().attributeNode("links").value().split("@");
infos.action1Student = teacherBarNode.toElement().attributeNode("action1Student").value(); infos.comments = teacherBarNode.toElement().attributeNode("comments").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();
} }
f.close(); f.close();
} }

@ -23,16 +23,11 @@
struct sTeacherBarInfos struct sTeacherBarInfos
{ {
QString title; QString title;
int phasis;
int Duration; int Duration;
QString material; QStringList actions;
int activity; QStringList medias;
QString action1Master; QStringList urls;
QString action1Student; QString comments;
QString action2Master;
QString action2Student;
QString action3Master;
QString action3Student;
}; };
class UBDocument; class UBDocument;

@ -266,14 +266,79 @@ void UBTeacherBarWidget::onValueChanged()
void UBTeacherBarWidget::saveContent() void UBTeacherBarWidget::saveContent()
{ {
sTeacherBarInfos infos; sTeacherBarInfos infos;
// Title
infos.title = mpTitle->text(); 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); UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos);
} }
void UBTeacherBarWidget::loadContent() void UBTeacherBarWidget::loadContent()
{ {
sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex());
// Title
mpTitle->setText(nextInfos.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) void UBTeacherBarWidget::onTitleTextChanged(const QString& text)
@ -365,12 +430,26 @@ QString UBTeacherStudentAction::comboValue()
QString str; QString str;
if(NULL != mpCombo){ if(NULL != mpCombo){
str = mpCombo->currentText(); str = QString("%0").arg(mpCombo->currentIndex());
} }
return str; 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) UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):QWidget(parent)
@ -507,3 +586,10 @@ QString UBUrlWidget::url()
return str; return str;
} }
void UBUrlWidget::setUrl(const QString &url)
{
if(NULL != mpUrl){
mpUrl->setText(url);
}
}

@ -29,6 +29,8 @@ public:
~UBTeacherStudentAction(); ~UBTeacherStudentAction();
QString comboValue(); QString comboValue();
QString text(); QString text();
void setComboValue(int value);
void setText(const QString& text);
private: private:
QTextEdit* mpText; QTextEdit* mpText;
@ -67,6 +69,7 @@ public:
~UBUrlWidget(); ~UBUrlWidget();
QString url(); QString url();
void setUrl(const QString& url);
private: private:
QHBoxLayout* mpLayout; QHBoxLayout* mpLayout;

Loading…
Cancel
Save