backup of the teacherbar rework

preferencesAboutTextFull
shibakaneki 13 years ago
parent 3dd07bb46d
commit 9ec9128412
  1. 10
      src/gui/UBTBDocumentEditWidget.cpp
  2. 2
      src/gui/UBTBDocumentEditWidget.h
  3. 9
      src/gui/UBTBDocumentPreviewWidget.cpp
  4. 2
      src/gui/UBTBDocumentPreviewWidget.h
  5. 219
      src/gui/UBTBPageEditWidget.cpp
  6. 51
      src/gui/UBTBPageEditWidget.h
  7. 115
      src/gui/UBTeacherBarDataMgr.cpp
  8. 58
      src/gui/UBTeacherBarDataMgr.h
  9. 13
      src/gui/UBTeacherBarPreviewWidget.cpp
  10. 3
      src/gui/UBTeacherBarPreviewWidget.h
  11. 128
      src/gui/UBTeacherBarWidget.cpp
  12. 2
      src/gui/UBTeacherBarWidget.h

@ -86,3 +86,13 @@ void UBTBDocumentEditWidget::onPreview()
{ {
emit changeTBState(eTeacherBarState_DocumentPreview); emit changeTBState(eTeacherBarState_DocumentPreview);
} }
void UBTBDocumentEditWidget::updateFields()
{
}
void UBTBDocumentEditWidget::clearFields()
{
}

@ -15,6 +15,8 @@ class UBTBDocumentEditWidget : public QWidget
public: public:
UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentEditWidget"); UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentEditWidget");
~UBTBDocumentEditWidget(); ~UBTBDocumentEditWidget();
void updateFields();
void clearFields();
signals: signals:
void changeTBState(eTeacherBarState state); void changeTBState(eTeacherBarState state);

@ -46,3 +46,12 @@ void UBTBDocumentPreviewWidget::onPageView()
emit changeTBState(eTeacherBarState_PagePreview); emit changeTBState(eTeacherBarState_PagePreview);
} }
void UBTBDocumentPreviewWidget::updateFields()
{
}
void UBTBDocumentPreviewWidget::clearFields()
{
}

@ -12,6 +12,8 @@ class UBTBDocumentPreviewWidget : public QWidget
public: public:
UBTBDocumentPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentPreviewWidget"); UBTBDocumentPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentPreviewWidget");
~UBTBDocumentPreviewWidget(); ~UBTBDocumentPreviewWidget();
void updateFields();
void clearFields();
signals: signals:
void changeTBState(eTeacherBarState state); void changeTBState(eTeacherBarState state);

@ -25,6 +25,8 @@ UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *p
{ {
Q_UNUSED(name); Q_UNUSED(name);
mpDataMgr = pDataMgr; mpDataMgr = pDataMgr;
mActions.clear();
mUrls.clear();
setAttribute(Qt::WA_StyledBackground, true); setAttribute(Qt::WA_StyledBackground, true);
setStyleSheet(UBApplication::globalStyleSheet()); setStyleSheet(UBApplication::globalStyleSheet());
@ -93,6 +95,7 @@ UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *p
mLayout.addLayout(&mPagePreviewLayout, 0); mLayout.addLayout(&mPagePreviewLayout, 0);
connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged())); connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged()));
connect(mpComments, SIGNAL(textChanged()), this, SLOT(onValueChanged()));
connect(mpActionButton, SIGNAL(clicked()), this, SLOT(onActionButton())); connect(mpActionButton, SIGNAL(clicked()), this, SLOT(onActionButton()));
connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton())); connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton()));
connect(mpDocumentEditbutton, SIGNAL(clicked()), this, SLOT(onDocumentEditClicked())); connect(mpDocumentEditbutton, SIGNAL(clicked()), this, SLOT(onDocumentEditClicked()));
@ -126,14 +129,14 @@ void UBTBPageEditWidget::onValueChanged()
void UBTBPageEditWidget::onActionButton() void UBTBPageEditWidget::onActionButton()
{ {
UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this);
mpDataMgr->actions() << pAction; mActions << pAction;
mpActions->addWidget(pAction); mpActions->addWidget(pAction);
} }
void UBTBPageEditWidget::onLinkButton() void UBTBPageEditWidget::onLinkButton()
{ {
UBUrlWidget* pUrl = new UBUrlWidget(this); UBUrlWidget* pUrl = new UBUrlWidget(this);
mpDataMgr->urls() << pUrl; mUrls << pUrl;
mpLinks->addWidget(pUrl); mpLinks->addWidget(pUrl);
} }
@ -143,91 +146,87 @@ void UBTBPageEditWidget::onMediaDropped(const QString &url)
QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); QWidget* pMedia = mpMediaContainer->generateMediaWidget(url);
if(NULL != pMedia){ if(NULL != pMedia){
mpDataMgr->medias() << pMedia; mpDataMgr->medias() << pMedia;
mpDataMgr->addMediaUrl(url);
mpMediaContainer->addWidget(pMedia); mpMediaContainer->addWidget(pMedia);
} }
} }
} }
void UBTBPageEditWidget::onDocumentEditClicked()
void UBTBPageEditWidget::saveInfos(sTeacherBarInfos *infos)
{ {
if(NULL != infos){ emit changeTBState(eTeacherBarState_DocumentEdit);
infos->title = mpTitle->text(); }
// Actions void UBTBPageEditWidget::onPagePreviewClicked()
for(int i=0; i<mpDataMgr->actions().size(); i++){ {
infos->actions << QString("%0;%1").arg(mpDataMgr->actions().at(i)->comboValue()).arg(mpDataMgr->actions().at(i)->text()); emit changeTBState(eTeacherBarState_PagePreview);
} }
// Media
foreach(QString media, mpMediaContainer->mediaUrls()){
infos->medias << media;
}
// Links void UBTBPageEditWidget::saveFields()
for(int j=0; j<mpDataMgr->urls().size(); j++){ {
if("" != mpDataMgr->urls().at(j)->url()){ mpDataMgr->actions()->clear();
infos->urls << mpDataMgr->urls().at(j)->url(); mpDataMgr->urls()->clear();
} foreach(UBTeacherStudentAction* pAct, mActions){
} sAction action;
// Comments action.type = pAct->comboValue().toInt();
infos->comments = mpComments->document()->toPlainText(); action.content = pAct->text();
mpDataMgr->actions()->append(action);
}
foreach(UBUrlWidget* pUrl, mUrls){
sLink link;
link.title = pUrl->title();
link.link = pUrl->url();
mpDataMgr->urls()->append(link);
} }
// TODO : Medias
} }
void UBTBPageEditWidget::loadInfos(sTeacherBarInfos* infos) void UBTBPageEditWidget::updateFields()
{ {
if(NULL != infos){ mpTitle->setText(mpDataMgr->pageTitle());
// Title qDebug() << "mpComments will become: " << mpDataMgr->comments();
mpTitle->setText(infos->title);
mpDataMgr->setPageTitle(infos->title); foreach(sAction action, *mpDataMgr->actions()){
UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this);
// Actions pAction->setComboValue(action.type);
for(int i=0; i<infos->actions.size(); i++){ pAction->setText(action.content);
QStringList qslAction = infos->actions.at(i).split(";"); mActions << pAction;
if(qslAction.size() >= 2){ mpActions->addWidget(pAction);
UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); }
pAction->setComboValue(qslAction.at(0).toInt());
pAction->setText(qslAction.at(1));
mpDataMgr->actions() << pAction;
mpActions->addWidget(pAction);
}
}
// Media
foreach(QString url, infos->medias){
if("" != url){
QWidget* pMedia = mpMediaContainer->generateMediaWidget(url);
if(NULL != pMedia){
mpDataMgr->medias() << pMedia;
mpMediaContainer->addWidget(pMedia);
}
}
}
// Links foreach(sLink link, *mpDataMgr->urls()){
for(int j=0; j<infos->urls.size(); j++){ UBUrlWidget* urlWidget = new UBUrlWidget(this);
QString qsUrl = infos->urls.at(j); urlWidget->setTitle(link.title);
if("" != qsUrl){ urlWidget->setUrl(link.link);
UBUrlWidget* pLink = new UBUrlWidget(this); mUrls << urlWidget;
pLink->setUrl(qsUrl); mpLinks->addWidget(urlWidget);
mpDataMgr->urls() << pLink;
mpLinks->addWidget(pLink);
}
}
// Comments
if(NULL != mpComments){
mpComments->document()->setPlainText(infos->comments);
}
} }
}
void UBTBPageEditWidget::onDocumentEditClicked() // TODO: add the medias
{
emit changeTBState(eTeacherBarState_DocumentEdit); qDebug() << "mpComments will become: " << mpDataMgr->comments();
mpComments->setPlainText(mpDataMgr->comments());
} }
void UBTBPageEditWidget::onPagePreviewClicked() void UBTBPageEditWidget::clearFields()
{ {
emit changeTBState(eTeacherBarState_PagePreview); mpTitle->setText("");
mpComments->setText("");
foreach(UBTeacherStudentAction* pAction, mActions){
mpActions->removeWidget(pAction);
DELETEPTR(pAction);
}
mActions.clear();
foreach(UBUrlWidget* pLink, mUrls){
mpLinks->removeWidget(pLink);
DELETEPTR(pLink);
}
mUrls.clear();
// TODO: clean the media?
} }
// --------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------
@ -287,10 +286,8 @@ QString UBUrlWidget::url()
void UBUrlWidget::setUrl(const QString &url) void UBUrlWidget::setUrl(const QString &url)
{ {
QStringList list = url.split(";");
if(NULL != mpUrl){ if(NULL != mpUrl){
mpUrl->setText(list.at(0)); mpUrl->setText(url);
mpTitle->setText(list.at(1));
} }
} }
@ -415,3 +412,81 @@ QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url)
return pW; return pW;
} }
UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent)
, mpText(NULL)
, mpLayout(NULL)
, mpComboLayout(NULL)
, mpCombo(NULL)
{
setObjectName(name);
setAttribute(Qt::WA_StyledBackground, true);
setStyleSheet(UBApplication::globalStyleSheet());
// Create the GUI
mpLayout = new QHBoxLayout(this);
setLayout(mpLayout);
mpComboLayout = new QVBoxLayout();
mpCombo = new QComboBox(this);
mpCombo->setObjectName("DockPaletteWidgetComboBox");
mpCombo->setMinimumWidth(80);
mpCombo->addItem(tr("Teacher"));
mpCombo->addItem(tr("Student"));
mpComboLayout->addWidget(mpCombo, 0);
mpComboLayout->addStretch(1);
mpLayout->addLayout(mpComboLayout, 0);
mpText = new QTextEdit(this);
mpText->setObjectName("DockPaletteWidgetBox");
mpText->setStyleSheet("background:white;");
mpLayout->addWidget(mpText, 1);
}
UBTeacherStudentAction::~UBTeacherStudentAction()
{
DELETEPTR(mpCombo);
DELETEPTR(mpText);
DELETEPTR(mpComboLayout);
DELETEPTR(mpLayout);
}
QString UBTeacherStudentAction::text()
{
QString str;
if(NULL != mpText){
str = mpText->document()->toPlainText();
}
return str;
}
QString UBTeacherStudentAction::comboValue()
{
QString str;
if(NULL != mpCombo){
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);
}
}

@ -14,6 +14,48 @@
#include "interfaces/IDropable.h" #include "interfaces/IDropable.h"
#include "UBTeacherBarDataMgr.h" #include "UBTeacherBarDataMgr.h"
class UBTeacherStudentAction : public QWidget
{
Q_OBJECT
public:
UBTeacherStudentAction(QWidget* parent=0, const char* name="UBTeacherStudentAction");
~UBTeacherStudentAction();
QString text();
QString comboValue();
void setComboValue(int value);
void setText(const QString& text);
private:
QTextEdit* mpText;
QHBoxLayout* mpLayout;
QVBoxLayout* mpComboLayout;
QComboBox* mpCombo;
};
class UBUrlWidget : public QWidget
{
public:
UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget");
~UBUrlWidget();
QString url();
void setUrl(const QString& url);
QString title(){return mpTitle->text();}
void setTitle(const QString& title){mpTitle->setText(title);}
private:
QVBoxLayout* mpLayout;
QHBoxLayout* mpLabelLayout;
QHBoxLayout* mpTitleLayout;
QLabel* mpUrlLabel;
QLineEdit* mpUrl;
QLabel* mpTitleLabel;
QLineEdit* mpTitle;
};
class UBTBMediaContainer : public UBWidgetList class UBTBMediaContainer : public UBWidgetList
, public IDropable , public IDropable
{ {
@ -46,9 +88,9 @@ class UBTBPageEditWidget : public QWidget
public: public:
UBTBPageEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBPageEditWidget"); UBTBPageEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBPageEditWidget");
~UBTBPageEditWidget(); ~UBTBPageEditWidget();
void saveFields();
void saveInfos(sTeacherBarInfos* infos); void updateFields();
void loadInfos(sTeacherBarInfos* infos); void clearFields();
signals: signals:
void valueChanged(); void valueChanged();
@ -87,6 +129,9 @@ private:
QPushButton* mpDocumentEditbutton; QPushButton* mpDocumentEditbutton;
QPushButton* mpPagePreviewButton; QPushButton* mpPagePreviewButton;
QWidget* mpContainer; QWidget* mpContainer;
QVector<UBTeacherStudentAction*> mActions;
QVector<UBUrlWidget*> mUrls;
}; };
#endif // UBTBPAGEEDITWIDGET_H #endif // UBTBPAGEEDITWIDGET_H

@ -1,5 +1,8 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/UBPersistenceManager.h"
#include "board/UBBoardController.h"
#include "customWidgets/UBGlobals.h" #include "customWidgets/UBGlobals.h"
#include "UBTeacherBarDataMgr.h" #include "UBTeacherBarDataMgr.h"
UBTeacherBarDataMgr::UBTeacherBarDataMgr() UBTeacherBarDataMgr::UBTeacherBarDataMgr()
@ -19,79 +22,75 @@ void UBTeacherBarDataMgr::clearLists()
mMediaList.clear(); mMediaList.clear();
} }
UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) void UBTeacherBarDataMgr::saveContent()
, mpText(NULL)
, mpLayout(NULL)
, mpComboLayout(NULL)
, mpCombo(NULL)
{ {
setObjectName(name); // Store the page information in the UBZ
sTeacherBarInfos infos;
setAttribute(Qt::WA_StyledBackground, true); infos.title = mPageTitle;
setStyleSheet(UBApplication::globalStyleSheet());
// Create the GUI // Actions
mpLayout = new QHBoxLayout(this); foreach(sAction action, mActionList){
setLayout(mpLayout); infos.actions << QString("%0;%1").arg(action.type).arg(action.content);
}
mpComboLayout = new QVBoxLayout(); // Media
foreach(QString media, mMediaUrls){
infos.medias << media;
}
mpCombo = new QComboBox(this); // Links
mpCombo->setObjectName("DockPaletteWidgetComboBox"); foreach(sLink link, mUrlList){
mpCombo->setMinimumWidth(80); if("" != link.title && "" != link.link){
mpCombo->addItem(tr("Teacher")); infos.urls << QString("%0;%1").arg(link.title).arg(link.link);
mpCombo->addItem(tr("Student")); }
mpComboLayout->addWidget(mpCombo, 0); }
mpComboLayout->addStretch(1);
mpLayout->addLayout(mpComboLayout, 0); // Comments
infos.comments = mComments;
mpText = new QTextEdit(this); UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos);
mpText->setObjectName("DockPaletteWidgetBox");
mpText->setStyleSheet("background:white;");
mpLayout->addWidget(mpText, 1); // TODO: Store the document metadata somewhere
} }
UBTeacherStudentAction::~UBTeacherStudentAction() void UBTeacherBarDataMgr::loadContent()
{ {
DELETEPTR(mpCombo); clearLists();
DELETEPTR(mpText);
DELETEPTR(mpComboLayout); sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex());
DELETEPTR(mpLayout);
} // Page Title
mPageTitle = nextInfos.title;
QString UBTeacherStudentAction::text() // Actions
{ foreach(QString eachAction, nextInfos.actions){
QString str; QStringList qslAction = eachAction.split(";");
if(NULL != mpText){ if(2 <= qslAction.size()){
str = mpText->document()->toPlainText(); sAction action;
action.type = qslAction.at(0).toInt();
action.content = qslAction.at(1);
mActionList << action;
}
} }
return str; // Media URL
} mMediaUrls = nextInfos.medias;
QString UBTeacherStudentAction::comboValue() // Links
{ foreach(QString eachUrl, nextInfos.urls){
QString str; QStringList qslUrl = eachUrl.split(';');
if(2 <= qslUrl.size()){
if(NULL != mpCombo){ sLink link;
str = QString("%0").arg(mpCombo->currentIndex()); link.title = qslUrl.at(0);
link.link = qslUrl.at(1);
mUrlList << link;
}
} }
return str; // Comments
} mComments = nextInfos.comments;
void UBTeacherStudentAction::setComboValue(int value) // TODO : Read the document metadata file and populate the metadata infos here
{
if(NULL != mpCombo){
mpCombo->setCurrentIndex(value);
}
}
void UBTeacherStudentAction::setText(const QString& text)
{
if(NULL != mpText){
mpText->document()->setPlainText(text);
}
} }

@ -22,44 +22,15 @@ typedef enum{
eActionOwner_Student eActionOwner_Student
}eActionOwner; }eActionOwner;
class UBTeacherStudentAction : public QWidget typedef struct{
{ int type;
Q_OBJECT QString content;
}sAction;
public:
UBTeacherStudentAction(QWidget* parent=0, const char* name="UBTeacherStudentAction");
~UBTeacherStudentAction();
QString text();
QString comboValue();
void setComboValue(int value);
void setText(const QString& text);
private:
QTextEdit* mpText;
QHBoxLayout* mpLayout;
QVBoxLayout* mpComboLayout;
QComboBox* mpCombo;
};
class UBUrlWidget : public QWidget typedef struct{
{ QString title;
public: QString link;
UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget"); }sLink;
~UBUrlWidget();
QString url();
void setUrl(const QString& url);
private:
QVBoxLayout* mpLayout;
QHBoxLayout* mpLabelLayout;
QHBoxLayout* mpTitleLayout;
QLabel* mpUrlLabel;
QLineEdit* mpUrl;
QLabel* mpTitleLabel;
QLineEdit* mpTitle;
};
class UBTeacherBarDataMgr class UBTeacherBarDataMgr
{ {
@ -80,13 +51,15 @@ public:
QString pageTitle(){return mPageTitle;} QString pageTitle(){return mPageTitle;}
// Actions // Actions
QVector<UBTeacherStudentAction*> actions(){return mActionList;} QVector<sAction>* actions(){return &mActionList;}
// Medias // Medias
QVector<QWidget*> medias(){return mMediaList;} QVector<QWidget*> medias(){return mMediaList;}
void addMediaUrl(const QString& url){mMediaUrls << url;}
QStringList mediaUrls(){return mMediaUrls;}
// Urls // Urls
QVector<UBUrlWidget*> urls(){return mUrlList;} QVector<sLink>* urls(){return &mUrlList;}
// Comments // Comments
void setComments(const QString& c){mComments = c;} void setComments(const QString& c){mComments = c;}
@ -94,6 +67,8 @@ public:
// Others // Others
void clearLists(); void clearLists();
void saveContent();
void loadContent();
private: private:
QString mSessionTitle; QString mSessionTitle;
@ -101,9 +76,10 @@ private:
QString mPageTitle; QString mPageTitle;
QString mComments; QString mComments;
QVector<UBTeacherStudentAction*> mActionList; QVector<sAction> mActionList;
QVector<UBUrlWidget*> mUrlList; QVector<sLink> mUrlList;
QVector<QWidget*> mMediaList; QVector<QWidget*> mMediaList;
QStringList mMediaUrls;
}; };
#endif // UBTEACHERBARDATAMGR_H #endif // UBTEACHERBARDATAMGR_H

@ -302,13 +302,12 @@ void UBTeacherBarPreviewWidget::setLinks(QStringList links)
} }
} }
void UBTeacherBarPreviewWidget::loadInfos(sTeacherBarInfos *infos) void UBTeacherBarPreviewWidget::updateFields()
{
}
void UBTeacherBarPreviewWidget::clearFields()
{ {
if(NULL != infos){
setTitle(infos->title);
mediaViewer()->loadMedia(infos->medias);
// Add the comments
//setComments();
}
} }

@ -61,7 +61,8 @@ public:
void setLinks(QStringList links); void setLinks(QStringList links);
void clean(); void clean();
QLabel* mediaLabel() { return mpMediaLabel;} QLabel* mediaLabel() { return mpMediaLabel;}
void loadInfos(sTeacherBarInfos* infos); void updateFields();
void clearFields();
signals: signals:
void showEditMode(); void showEditMode();

@ -59,6 +59,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock
connect(mpDocPreviewWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); connect(mpDocPreviewWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState)));
connect(mpDocEditWidget, 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(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState)));
connect(mpPageEditWidget, SIGNAL(valueChanged()), this, SLOT(onValueChanged()));
} }
UBTeacherBarWidget::~UBTeacherBarWidget() UBTeacherBarWidget::~UBTeacherBarWidget()
@ -88,110 +89,49 @@ void UBTeacherBarWidget::onValueChanged()
void UBTeacherBarWidget::saveContent() void UBTeacherBarWidget::saveContent()
{ {
sTeacherBarInfos infos; mpPageEditWidget->saveFields();
mpPageEditWidget->saveInfos(&infos); mData.saveContent();
UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos);
} }
void UBTeacherBarWidget::loadContent() void UBTeacherBarWidget::loadContent()
{ {
// clearWidgetLists(); // Clear the old datas
// sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); mpPageEditWidget->clearFields();
mpPreview->clearFields();
// mpPageEditWidget->loadInfos(&nextInfos); mpDocEditWidget->clearFields();
// mpPreview->mediaViewer()->cleanMedia(); mpDocPreviewWidget->clearFields();
// if(!isEmpty()){ // Update the datas
// // Update the fields of the preview widget mData.loadContent();
// onTBStateChanged(eTeacherBarState_PagePreview);
// mpPreview->clean(); qDebug() << mData.comments();
// mpPreview->loadInfos(&nextInfos);
// Update the fields
// // Add the actions mpPageEditWidget->updateFields();
// if(!mActionList.empty()){ mpPreview->updateFields();
// QStringList actions; mpDocEditWidget->updateFields();
// foreach(UBTeacherStudentAction* action, mActionList){ mpDocPreviewWidget->updateFields();
// QString desc = QString("%0;%1").arg(action->comboValue()).arg(action->text());
// actions << desc; if(!isEmpty()){
// } onTBStateChanged(eTeacherBarState_PagePreview);
// mpPreview->setActions(actions); }else{
// } if(1 == UBApplication::boardController->activeDocument()->pageCount()){
onTBStateChanged(eTeacherBarState_DocumentEdit);
// // Add the media }else{
// if(nextInfos.medias.count() > 0){ onTBStateChanged(eTeacherBarState_PageEdit);
// QList<QWidget*> widgetList; }
// widgetList.append(mpPreview->mediaLabel()); }
// mpPreview->mediaViewer()->loadWidgets(widgetList,false);
// int loadedMedia = mpPreview->mediaViewer()->loadMedia(nextInfos.medias);
// if(loadedMedia)
// mpPreview->mediaLabel()->setVisible(true);
// }
// // Add the links
// if(!mUrlList.empty()){
// QStringList links;
// foreach(UBUrlWidget* url, mUrlList){
// QStringList list = url->url().split(";");
// QString formedlink = "<a href=";
// if(!list.at(0).startsWith("http://"))
// formedlink += "http://";
// formedlink += list.at(0) + ">" + list.at(1) + "</a>";
// links << formedlink;
// }
// mpPreview->setLinks(links);
// }
// }
// else{
// // If the document has only one page, show the document edit page
// if(1 == UBApplication::boardController->activeDocument()->pageCount()){
// onTBStateChanged(eTeacherBarState_DocumentEdit);
// }else{
// onTBStateChanged(eTeacherBarState_PageEdit);
// }
// }
} }
bool UBTeacherBarWidget::isEmpty() bool UBTeacherBarWidget::isEmpty()
{ {
return mData.pageTitle() == "" && return mData.pageTitle() == "" &&
mData.urls().empty() && mData.urls()->empty() &&
mData.actions().empty() && mData.actions()->empty() &&
mData.medias().empty() && mData.medias().empty() &&
mData.comments() == ""; mData.comments() == "" &&
} mData.sessionTarget() == "" &&
mData.sessionTitle() == "";
void UBTeacherBarWidget::onTitleTextChanged(const QString& text)
{
//mpTitle->setToolTip(text);
}
void UBTeacherBarWidget::clearWidgetLists()
{
// if(NULL != mpMediaContainer){
// for(int i=0; i<mMediaList.size(); i++){
// mpMediaContainer->removeWidget(mMediaList.at(i));
// delete mMediaList.at(i);
// }
// mMediaList.clear();
// mpMediaContainer->cleanMedias();
// }
// if(NULL != mpActions){
// for(int i=0; i<mActionList.size(); i++){
// mpActions->removeWidget(mActionList.at(i));
// delete mActionList.at(i);
// }
// mActionList.clear();
// }
// if(NULL != mpLinks){
// for(int i=0; i<mUrlList.size(); i++){
// mpLinks->removeWidget(mUrlList.at(i));
// delete mUrlList.at(i);
// }
// mUrlList.clear();
// }
} }
void UBTeacherBarWidget::onShowEditMode() void UBTeacherBarWidget::onShowEditMode()

@ -36,12 +36,10 @@ private slots:
void saveContent(); void saveContent();
void loadContent(); void loadContent();
void onValueChanged(); void onValueChanged();
void onTitleTextChanged(const QString& text);
void onShowEditMode(); void onShowEditMode();
void onTBStateChanged(eTeacherBarState state); void onTBStateChanged(eTeacherBarState state);
private: private:
void clearWidgetLists();
bool isEmpty(); bool isEmpty();
QVBoxLayout mLayout; QVBoxLayout mLayout;

Loading…
Cancel
Save