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
QDomElement teacherBarElem = teacherBarNode.toElement();
teacherBarElem.setAttribute("title", infos.title);
teacherBarElem.setAttribute("duration", QString("%0").arg(infos.Duration));
QString qsAct;
for(int i=0; i<infos.actions.size(); i++){
@ -1146,7 +1145,6 @@ sTeacherBarInfos UBPersistenceManager::getTeacherBarInfos(UBDocumentProxy* pDocu
QDomNode teacherBarNode = rootElem.namedItem("teacherBar");
infos.title = teacherBarNode.toElement().attributeNode("title").value();
infos.Duration = teacherBarNode.toElement().attributeNode("duration").value().toInt();
infos.actions = teacherBarNode.toElement().attributeNode("actions").value().split("@");
infos.medias = teacherBarNode.toElement().attributeNode("medias").value().split("@");
infos.urls = teacherBarNode.toElement().attributeNode("links").value().split("@");

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

@ -63,6 +63,8 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW
connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView()));
connect(mpPreviewButton, SIGNAL(clicked()), this, SLOT(onPreview()));
connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onSessionTitleChanged()));
connect(mpTarget, SIGNAL(textChanged()), this, SLOT(onSessionTargetChanged()));
}
UBTBDocumentEditWidget::~UBTBDocumentEditWidget()
@ -87,12 +89,28 @@ void UBTBDocumentEditWidget::onPreview()
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:
void changeTBState(eTeacherBarState state);
void valueChanged();
private slots:
void onPageView();
void onPreview();
void onSessionTitleChanged();
void onSessionTargetChanged();
private:
QVBoxLayout mLayout;

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

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

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

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

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

Loading…
Cancel
Save