Adding the teacher bar widget

preferencesAboutTextFull
shibakaneki 13 years ago
parent 68ffb3f526
commit 191e21ee5d
  1. 1
      src/board/UBBoardController.cpp
  2. 1
      src/board/UBBoardController.h
  3. 2
      src/board/UBBoardPaletteManager.cpp
  4. 89
      src/core/UBPersistenceManager.cpp
  5. 19
      src/core/UBPersistenceManager.h
  6. 7
      src/gui/UBDocumentNavigator.cpp
  7. 54
      src/gui/UBTeacherBarWidget.cpp
  8. 7
      src/gui/UBTeacherBarWidget.h

@ -1981,4 +1981,3 @@ void UBBoardController::notifyPageChanged()
}

@ -263,6 +263,7 @@ class UBBoardController : public QObject
void pageChanged();
void setDocOnPageNavigator(UBDocumentProxy* doc);
void documentReorganized(int index);
void pageWillChange(int page, int nextPage);
protected:

@ -164,7 +164,7 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mRightPalette->addTabWidget(mpLibWidget);
mRightPalette->registerWidget(mpTeacherBarWidget);
//mRightPalette->addTabWidget(mpTeacherBarWidget);
mRightPalette->addTabWidget(mpTeacherBarWidget);
mRightPalette->connectSignals();
mLeftPalette->showTabWidget(0);
mRightPalette->showTabWidget(0);

@ -592,7 +592,6 @@ UBGraphicsScene* UBPersistenceManager::loadDocumentScene(UBDocumentProxy* proxy,
{
if (mSceneCache.contains(proxy, sceneIndex))
{
//qDebug() << "scene" << sceneIndex << "retrieved from cache ...";
return mSceneCache.value(proxy, sceneIndex);
}
else
@ -618,8 +617,6 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy,
QDir dir(pDocumentProxy->persistencePath());
dir.mkpath(pDocumentProxy->persistencePath());
qDebug() << "saving page" << pSceneIndex + 1 << pDocumentProxy->persistencePath();
if (pDocumentProxy->isModified())
UBMetadataDcSubsetAdaptor::persist(pDocumentProxy);
@ -638,6 +635,92 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy,
}
void UBPersistenceManager::persistTeacherBar(UBDocumentProxy* pDocumentProxy, int page, sTeacherBarInfos infos)
{
if(NULL != pDocumentProxy)
{
QFile f(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", page + 1));
if(f.exists())
{
if(f.open(QIODevice::ReadOnly))
{
QDomDocument domDoc;
if(domDoc.setContent(f.readAll()))
{
f.close();
if(f.open(QIODevice::WriteOnly))
{
QDomElement rootElem = domDoc.documentElement();
QDomNode teacherBarNode = domDoc.namedItem("teacherBar");
if(teacherBarNode.isNull())
{
// Create the element
QDomElement teacherElem = domDoc.createElement("teacherBar");
rootElem.appendChild(teacherElem);
teacherBarNode = teacherElem;
}
// 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);
// Save the file
f.write(domDoc.toString().toAscii());
f.close();
}
}
f.close();
}
}
}
}
sTeacherBarInfos UBPersistenceManager::getTeacherBarInfos(UBDocumentProxy* pDocumentProxy, int page)
{
sTeacherBarInfos infos;
if(NULL != pDocumentProxy)
{
QFile f(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", page + 1));
if(f.exists())
{
if(f.open(QIODevice::ReadWrite))
{
QDomDocument domDoc;
if(domDoc.setContent(f.readAll()))
{
QDomElement rootElem = domDoc.documentElement();
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();
}
f.close();
}
}
}
return infos;
}
UBDocumentProxy* UBPersistenceManager::persistDocumentMetadata(UBDocumentProxy* pDocumentProxy)
{

@ -20,6 +20,21 @@
#include "UBSceneCache.h"
struct sTeacherBarInfos
{
QString title;
int phasis;
int Duration;
QString material;
int activity;
QString action1Master;
QString action1Student;
QString action2Master;
QString action2Student;
QString action3Master;
QString action3Student;
};
class UBDocument;
class UBDocumentProxy;
class UBGraphicsScene;
@ -60,6 +75,10 @@ class UBPersistenceManager : public QObject
virtual void persistDocumentScene(UBDocumentProxy* pDocumentProxy,
UBGraphicsScene* pScene, const int pSceneIndex);
virtual void persistTeacherBar(UBDocumentProxy* pDocumentProxy, int page, sTeacherBarInfos infos);
sTeacherBarInfos getTeacherBarInfos(UBDocumentProxy* pDocumentProxy, int page);
virtual UBGraphicsScene* createDocumentSceneAt(UBDocumentProxy* pDocumentProxy, int index);
virtual void insertDocumentSceneAt(UBDocumentProxy* pDocumentProxy, UBGraphicsScene* scene, int index);

@ -141,8 +141,13 @@ void UBDocumentNavigator::updateSpecificThumbnail(int iPage)
{
// Save the current state of the scene
pScene->setModified(true);
UBSvgSubsetAdaptor::persistScene(mCrntDoc,pScene, iPage);
if(UBApplication::boardController)
{
UBApplication::boardController->persistCurrentScene();
}
// Now, update the thumbnail
UBThumbnailAdaptor::persistScene(mCrntDoc->persistencePath(), pScene, iPage);
// Load it

@ -1,6 +1,12 @@
#include "UBTeacherBarWidget.h"
#include "core/UBApplication.h"
#include "core/UBPersistenceManager.h"
#include "document/UBDocumentController.h"
#include "document/UBDocumentProxy.h"
#include "board/UBBoardController.h"
UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent)
, mpLayout(NULL)
@ -110,6 +116,9 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock
mpLayout->addWidget(mpAction3);
populateCombos();
connect(UBApplication::boardController, SIGNAL(activeSceneWillChange()), this, SLOT(saveContent()));
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContent()));
}
UBTeacherBarWidget::~UBTeacherBarWidget()
@ -221,14 +230,50 @@ void UBTeacherBarWidget::populateCombos()
QStringList qslPhasis;
qslPhasis << tr("I discover") << tr("I experiment") << tr("I train myself") << tr("I play") << tr("I memorize");
mpPhasis->insertItems(0, qslPhasis);
mpPhasis->setCurrentIndex(0);
QStringList qslDuration;
qslDuration << tr("Short") << tr("Middle") << tr("Long");
mpDuration->insertItems(0, qslDuration);
mpDuration->setCurrentIndex(0);
QStringList qslActivity;
qslActivity << tr("Alone") << tr("By Group") << tr("All together");
mpActivity->insertItems(0, qslActivity);
mpActivity->setCurrentIndex(0);
}
void UBTeacherBarWidget::saveContent()
{
sTeacherBarInfos infos;
infos.title = mpTitle->text();
infos.phasis = mpPhasis->currentIndex();
infos.Duration = mpDuration->currentIndex();
infos.material = mpEquipment->text();
infos.activity = mpActivity->currentIndex();
infos.action1Master = mpAction1->teacherText();
infos.action1Student = mpAction1->studentText();
infos.action2Master = mpAction2->teacherText();
infos.action2Student = mpAction2->studentText();
infos.action3Master = mpAction3->teacherText();
infos.action3Student = mpAction3->studentText();
UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos);
}
void UBTeacherBarWidget::loadContent()
{
sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex());
mpTitle->setText(nextInfos.title);
mpPhasis->setCurrentIndex(nextInfos.phasis);
mpDuration->setCurrentIndex(nextInfos.Duration);
mpEquipment->setText(nextInfos.material);
mpActivity->setCurrentIndex(nextInfos.activity);
mpAction1->setTeacherText(nextInfos.action1Master);
mpAction1->setStudentText(nextInfos.action1Student);
mpAction2->setTeacherText(nextInfos.action2Master);
mpAction2->setStudentText(nextInfos.action2Student);
mpAction3->setTeacherText(nextInfos.action3Master);
mpAction3->setStudentText(nextInfos.action3Student);
}
UBTeacherStudentAction::UBTeacherStudentAction(int actionNumber, QWidget *parent, const char *name):QWidget(parent)
@ -327,3 +372,12 @@ QString UBTeacherStudentAction::studentText()
return mpStudent->document()->toPlainText();
}
void UBTeacherStudentAction::setTeacherText(QString text)
{
mpTeacher->setText(text);
}
void UBTeacherStudentAction::setStudentText(QString text)
{
mpStudent->setText(text);
}

@ -20,6 +20,8 @@ public:
~UBTeacherStudentAction();
QString teacherText();
QString studentText();
void setTeacherText(QString text);
void setStudentText(QString text);
private:
int mActionNumber;
@ -35,10 +37,15 @@ private:
class UBTeacherBarWidget : public UBDockPaletteWidget
{
Q_OBJECT
public:
UBTeacherBarWidget(QWidget* parent=0, const char* name="UBTeacherBarWidget");
~UBTeacherBarWidget();
private slots:
void saveContent();
void loadContent();
private:
void populateCombos();

Loading…
Cancel
Save