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
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();
}

@ -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;

@ -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);
}
}

@ -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;

Loading…
Cancel
Save