Added the save / load media in the teacherbar

preferencesAboutTextFull
shibakaneki 13 years ago
parent ce73e5035d
commit 4e6a17b6b9
  1. 36
      src/gui/UBTBPageEditWidget.cpp

@ -171,6 +171,7 @@ void UBTBPageEditWidget::saveFields()
{ {
mpDataMgr->actions()->clear(); mpDataMgr->actions()->clear();
mpDataMgr->urls()->clear(); mpDataMgr->urls()->clear();
foreach(UBTeacherStudentAction* pAct, mActions){ foreach(UBTeacherStudentAction* pAct, mActions){
sAction action; sAction action;
action.type = pAct->comboValue().toInt(); action.type = pAct->comboValue().toInt();
@ -183,14 +184,13 @@ void UBTBPageEditWidget::saveFields()
link.link = pUrl->url(); link.link = pUrl->url();
mpDataMgr->urls()->append(link); mpDataMgr->urls()->append(link);
} }
// TODO : Medias
} }
void UBTBPageEditWidget::updateFields() void UBTBPageEditWidget::updateFields()
{ {
// Title
mpTitle->setText(mpDataMgr->pageTitle()); mpTitle->setText(mpDataMgr->pageTitle());
// Actions
foreach(sAction action, *mpDataMgr->actions()){ foreach(sAction action, *mpDataMgr->actions()){
UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this);
pAction->setComboValue(action.type); pAction->setComboValue(action.type);
@ -198,7 +198,13 @@ void UBTBPageEditWidget::updateFields()
mActions << pAction; mActions << pAction;
mpActions->addWidget(pAction); mpActions->addWidget(pAction);
} }
// Medias
foreach(QString url, mpDataMgr->mediaUrls()){
QWidget* pWidget = mpMediaContainer->generateMediaWidget(url);
mpDataMgr->medias()->append(pWidget);
mpMediaContainer->addWidget(pWidget);
}
// Links
foreach(sLink link, *mpDataMgr->urls()){ foreach(sLink link, *mpDataMgr->urls()){
UBUrlWidget* urlWidget = new UBUrlWidget(this); UBUrlWidget* urlWidget = new UBUrlWidget(this);
urlWidget->setTitle(link.title); urlWidget->setTitle(link.title);
@ -206,30 +212,36 @@ void UBTBPageEditWidget::updateFields()
mUrls << urlWidget; mUrls << urlWidget;
mpLinks->addWidget(urlWidget); mpLinks->addWidget(urlWidget);
} }
// Comments
// TODO: add the medias
mpComments->document()->setPlainText(mpDataMgr->comments()); mpComments->document()->setPlainText(mpDataMgr->comments());
} }
void UBTBPageEditWidget::clearFields() void UBTBPageEditWidget::clearFields()
{ {
// Title
mpTitle->setText(""); mpTitle->setText("");
mpComments->setText(""); // Actions
foreach(UBTeacherStudentAction* pAction, mActions){ foreach(UBTeacherStudentAction* pAction, mActions){
mpActions->removeWidget(pAction); mpActions->removeWidget(pAction);
DELETEPTR(pAction); DELETEPTR(pAction);
} }
mActions.clear(); mActions.clear();
// Medias
foreach(QWidget* pMedia, *mpDataMgr->medias()){
if(NULL != pMedia){
mpMediaContainer->removeWidget(pMedia);
DELETEPTR(pMedia);
}
}
mpDataMgr->mediaUrls().clear();
// Links
foreach(UBUrlWidget* pLink, mUrls){ foreach(UBUrlWidget* pLink, mUrls){
mpLinks->removeWidget(pLink); mpLinks->removeWidget(pLink);
DELETEPTR(pLink); DELETEPTR(pLink);
} }
mUrls.clear(); mUrls.clear();
// Comments
mpMediaContainer->cleanMedias(); mpComments->setText("");
} }
// --------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------

Loading…
Cancel
Save