Added some logic for the Document description datas in the teacherbar

preferencesAboutTextFull
shibakaneki 13 years ago
parent 4e6a17b6b9
commit 6e81d74d41
  1. 2
      src/core/UBPersistenceManager.cpp
  2. 3
      src/core/UBPersistenceManager.h
  3. 22
      src/gui/UBTBDocumentEditWidget.cpp
  4. 3
      src/gui/UBTBDocumentEditWidget.h
  5. 1
      src/gui/UBTBPageEditWidget.cpp
  6. 25
      src/gui/UBTeacherBarDataMgr.cpp
  7. 2
      src/gui/UBTeacherBarDataMgr.h
  8. 26
      src/gui/UBTeacherBarWidget.cpp
  9. 4
      src/gui/UBTeacherBarWidget.h

@ -1086,7 +1086,6 @@ 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("duration", QString("%0").arg(infos.Duration));
QString qsAct; QString qsAct;
for(int i=0; i<infos.actions.size(); i++){ for(int i=0; i<infos.actions.size(); i++){
@ -1146,7 +1145,6 @@ 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.Duration = teacherBarNode.toElement().attributeNode("duration").value().toInt();
infos.actions = teacherBarNode.toElement().attributeNode("actions").value().split("@"); infos.actions = teacherBarNode.toElement().attributeNode("actions").value().split("@");
infos.medias = teacherBarNode.toElement().attributeNode("medias").value().split("@"); infos.medias = teacherBarNode.toElement().attributeNode("medias").value().split("@");
infos.urls = teacherBarNode.toElement().attributeNode("links").value().split("@"); infos.urls = teacherBarNode.toElement().attributeNode("links").value().split("@");

@ -23,7 +23,6 @@
struct sTeacherBarInfos struct sTeacherBarInfos
{ {
QString title; QString title;
int Duration;
QStringList actions; QStringList actions;
QStringList medias; QStringList medias;
QStringList urls; QStringList urls;
@ -36,7 +35,7 @@ class UBGraphicsScene;
class UBPersistenceManager : public QObject class UBPersistenceManager : public QObject
{ {
Q_OBJECT; Q_OBJECT
private: private:
UBPersistenceManager(QObject *pParent = 0); UBPersistenceManager(QObject *pParent = 0);

@ -63,6 +63,8 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW
connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView())); connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView()));
connect(mpPreviewButton, SIGNAL(clicked()), this, SLOT(onPreview())); connect(mpPreviewButton, SIGNAL(clicked()), this, SLOT(onPreview()));
connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onSessionTitleChanged()));
connect(mpTarget, SIGNAL(textChanged()), this, SLOT(onSessionTargetChanged()));
} }
UBTBDocumentEditWidget::~UBTBDocumentEditWidget() UBTBDocumentEditWidget::~UBTBDocumentEditWidget()
@ -87,12 +89,28 @@ void UBTBDocumentEditWidget::onPreview()
emit changeTBState(eTeacherBarState_DocumentPreview); emit changeTBState(eTeacherBarState_DocumentPreview);
} }
void UBTBDocumentEditWidget::updateFields() void UBTBDocumentEditWidget::onSessionTitleChanged()
{ {
mpDataMgr->setSessionTitle(mpTitle->text());
emit valueChanged();
}
void UBTBDocumentEditWidget::onSessionTargetChanged()
{
mpDataMgr->setSessionTarget(mpTarget->document()->toPlainText());
emit valueChanged();
} }
void UBTBDocumentEditWidget::clearFields() void UBTBDocumentEditWidget::updateFields()
{ {
mpTitle->setText(mpDataMgr->sessionTitle());
mpTarget->setPlainText(mpDataMgr->sessionTarget());
}
void UBTBDocumentEditWidget::clearFields()
{
mpTitle->setText("");
mpTarget->setPlainText("");
} }

@ -20,10 +20,13 @@ public:
signals: signals:
void changeTBState(eTeacherBarState state); void changeTBState(eTeacherBarState state);
void valueChanged();
private slots: private slots:
void onPageView(); void onPageView();
void onPreview(); void onPreview();
void onSessionTitleChanged();
void onSessionTargetChanged();
private: private:
QVBoxLayout mLayout; QVBoxLayout mLayout;

@ -42,7 +42,6 @@ UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *p
mpTitleLabel = new QLabel(tr("Title"), mpContainer); mpTitleLabel = new QLabel(tr("Title"), mpContainer);
mpTitle = new QLineEdit(mpContainer); mpTitle = new QLineEdit(mpContainer);
mpTitle->setObjectName("DockPaletteWidgetLineEdit"); mpTitle->setObjectName("DockPaletteWidgetLineEdit");
connect(mpTitle, SIGNAL(textChanged(const QString&)), this, SLOT(onTitleTextChanged(const QString&)));
mContainerLayout.addWidget(mpTitleLabel, 0); mContainerLayout.addWidget(mpTitleLabel, 0);
mContainerLayout.addWidget(mpTitle, 0); mContainerLayout.addWidget(mpTitle, 0);

@ -20,6 +20,7 @@ void UBTeacherBarDataMgr::clearLists()
mActionList.clear(); mActionList.clear();
mUrlList.clear(); mUrlList.clear();
mMediaList.clear(); mMediaList.clear();
mMediaUrls.clear();
} }
void UBTeacherBarDataMgr::saveContent() void UBTeacherBarDataMgr::saveContent()
@ -27,40 +28,49 @@ void UBTeacherBarDataMgr::saveContent()
// Store the page information in the UBZ // Store the page information in the UBZ
sTeacherBarInfos infos; sTeacherBarInfos infos;
// Page Title
infos.title = mPageTitle; infos.title = mPageTitle;
// Actions // Actions
foreach(sAction action, mActionList){ foreach(sAction action, mActionList){
infos.actions << QString("%0;%1").arg(action.type).arg(action.content); infos.actions << QString("%0;%1").arg(action.type).arg(action.content);
} }
// Media // Media
foreach(QString media, mMediaUrls){ foreach(QString media, mMediaUrls){
infos.medias << media; infos.medias << media;
} }
// Links // Links
foreach(sLink link, mUrlList){ foreach(sLink link, mUrlList){
if("" != link.title && "" != link.link){ if("" != link.title && "" != link.link){
infos.urls << QString("%0;%1").arg(link.title).arg(link.link); infos.urls << QString("%0;%1").arg(link.title).arg(link.link);
} }
} }
// Comments // Comments
infos.comments = mComments; infos.comments = mComments;
UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos); UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos);
// TODO: Store the document metadata somewhere // TODO: Store the document metadata somewhere
// Session Title
//... = mSessionTitle;
// Session Target
//... = mSessionTarget;
} }
void UBTeacherBarDataMgr::loadContent() void UBTeacherBarDataMgr::loadContent(bool docChanged)
{ {
clearLists(); clearLists();
sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex());
if(docChanged){
// TODO: Read these information from the metadata file
// Session Title
//mSessionTitle = ...;
// Session Target
//mSessionTarget = ...;
}
// Page Title // Page Title
mPageTitle = nextInfos.title; mPageTitle = nextInfos.title;
// Actions // Actions
@ -74,7 +84,12 @@ void UBTeacherBarDataMgr::loadContent()
} }
} }
// Media URL // Media URL
if((nextInfos.medias.size() == 1) && (nextInfos.medias.at(0) == "")){
// Do not retrieve it
}
else{
mMediaUrls = nextInfos.medias; mMediaUrls = nextInfos.medias;
}
// Links // Links
foreach(QString eachUrl, nextInfos.urls){ foreach(QString eachUrl, nextInfos.urls){

@ -68,7 +68,7 @@ public:
// Others // Others
void clearLists(); void clearLists();
void saveContent(); void saveContent();
void loadContent(); void loadContent(bool docChanged = false);
private: private:
QString mSessionTitle; QString mSessionTitle;

@ -52,14 +52,16 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock
mpStackWidget->addWidget(mpDocEditWidget); mpStackWidget->addWidget(mpDocEditWidget);
connect(UBApplication::boardController, SIGNAL(activeSceneWillChange()), this, SLOT(saveContent())); connect(UBApplication::boardController, SIGNAL(activeSceneWillChange()), this, SLOT(saveContent()));
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContent()));
connect(UBApplication::mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(saveContent())); connect(UBApplication::mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(saveContent()));
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContentInfos()));
connect(UBApplication::boardController, SIGNAL(activeDocumentChanged()), this, SLOT(onActiveDocumentChanged()));
connect(mpPreview, SIGNAL(showEditMode()), this, SLOT(onShowEditMode())); connect(mpPreview, SIGNAL(showEditMode()), this, SLOT(onShowEditMode()));
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())); connect(mpPageEditWidget, SIGNAL(valueChanged()), this, SLOT(onValueChanged()));
connect(mpDocEditWidget, SIGNAL(valueChanged()), this, SLOT(onValueChanged()));
} }
UBTeacherBarWidget::~UBTeacherBarWidget() UBTeacherBarWidget::~UBTeacherBarWidget()
@ -71,6 +73,11 @@ UBTeacherBarWidget::~UBTeacherBarWidget()
DELETEPTR(mpStackWidget); DELETEPTR(mpStackWidget);
} }
void UBTeacherBarWidget::onActiveDocumentChanged()
{
loadContent(true);
}
void UBTeacherBarWidget::onValueChanged() void UBTeacherBarWidget::onValueChanged()
{ {
if(isEmpty()) if(isEmpty())
@ -93,22 +100,31 @@ void UBTeacherBarWidget::saveContent()
mData.saveContent(); mData.saveContent();
} }
void UBTeacherBarWidget::loadContent() void UBTeacherBarWidget::loadContentInfos()
{
loadContent(false);
}
void UBTeacherBarWidget::loadContent(bool docChanged)
{ {
// Clear the old datas // Clear the old datas
mpPageEditWidget->clearFields(); mpPageEditWidget->clearFields();
mpPreview->clearFields(); mpPreview->clearFields();
if(docChanged){
mpDocEditWidget->clearFields(); mpDocEditWidget->clearFields();
mpDocPreviewWidget->clearFields(); mpDocPreviewWidget->clearFields();
}
// Update the datas // Update the datas
mData.loadContent(); mData.loadContent(docChanged);
// Update the fields // Update the fields
mpPageEditWidget->updateFields(); mpPageEditWidget->updateFields();
mpPreview->updateFields(); mpPreview->updateFields();
if(docChanged){
mpDocEditWidget->updateFields(); mpDocEditWidget->updateFields();
mpDocPreviewWidget->updateFields(); mpDocPreviewWidget->updateFields();
}
if(!isEmpty()){ if(!isEmpty()){
onTBStateChanged(eTeacherBarState_PagePreview); onTBStateChanged(eTeacherBarState_PagePreview);
@ -127,9 +143,7 @@ bool UBTeacherBarWidget::isEmpty()
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::onShowEditMode() void UBTeacherBarWidget::onShowEditMode()

@ -34,12 +34,14 @@ public:
private slots: private slots:
void saveContent(); void saveContent();
void loadContent(); void loadContentInfos();
void onValueChanged(); void onValueChanged();
void onShowEditMode(); void onShowEditMode();
void onTBStateChanged(eTeacherBarState state); void onTBStateChanged(eTeacherBarState state);
void onActiveDocumentChanged();
private: private:
void loadContent(bool docChanged = false);
bool isEmpty(); bool isEmpty();
QVBoxLayout mLayout; QVBoxLayout mLayout;

Loading…
Cancel
Save