Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
76d5c99e
Commit
76d5c99e
authored
May 09, 2012
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed issue with teacher guide data persistance
parent
75b7fd56
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
79 additions
and
49 deletions
+79
-49
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+69
-35
UBSvgSubsetAdaptor.h
src/adaptors/UBSvgSubsetAdaptor.h
+1
-1
UBBoardController.cpp
src/board/UBBoardController.cpp
+1
-0
UBPersistenceManager.cpp
src/core/UBPersistenceManager.cpp
+1
-8
UBPersistenceManager.h
src/core/UBPersistenceManager.h
+2
-0
UBDocumentProxy.cpp
src/document/UBDocumentProxy.cpp
+0
-2
UBTeacherGuideWidget.cpp
src/gui/UBTeacherGuideWidget.cpp
+4
-2
IDataStorage.h
src/interfaces/IDataStorage.h
+1
-1
No files found.
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
76d5c99e
...
...
@@ -72,16 +72,6 @@ const QString UBSvgSubsetAdaptor::sFontStylePrefix = "font-style:";
const
QString
UBSvgSubsetAdaptor
::
sFormerUniboardDocumentNamespaceUri
=
"http://www.mnemis.com/uniboard"
;
QMap
<
QString
,
IDataStorage
*>
UBSvgSubsetAdaptor
::
additionalElementToStore
;
// Why using such a string?
// Media file path are relative to the current document. So if we are reading the
// first page of a document the document path has not been updated.
// Concatenate relative media path with the old document path leads to mess
// This string is so used only for activeDocumentChanged signal
QString
UBSvgSubsetAdaptor
::
sTeacherGuideNode
=
""
;
QString
UBSvgSubsetAdaptor
::
toSvgTransform
(
const
QMatrix
&
matrix
)
{
return
QString
(
"matrix(%1, %2, %3, %4, %5, %6)"
)
...
...
@@ -259,8 +249,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::loadScene(UBDocumentProxy* proxy, const int
QUuid
UBSvgSubsetAdaptor
::
sceneUuid
(
UBDocumentProxy
*
proxy
,
const
int
pageIndex
)
{
QString
fileName
=
proxy
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.svg"
,
pageIndex
);
QString
fileName
=
proxy
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.svg"
,
pageIndex
);
QFile
file
(
fileName
);
...
...
@@ -312,6 +301,53 @@ UBGraphicsScene* UBSvgSubsetAdaptor::loadScene(UBDocumentProxy* proxy, const QBy
}
QString
UBSvgSubsetAdaptor
::
readTeacherGuideNode
(
int
sceneIndex
)
{
QString
result
;
QString
fileName
=
UBApplication
::
boardController
->
activeDocument
()
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.svg"
,
sceneIndex
);
QFile
file
(
fileName
);
file
.
open
(
QIODevice
::
ReadOnly
);
QByteArray
fileByteArray
=
file
.
readAll
();
file
.
close
();
QXmlStreamReader
mXmlReader
(
fileByteArray
);
while
(
!
mXmlReader
.
atEnd
())
{
mXmlReader
.
readNext
();
if
(
mXmlReader
.
isStartElement
())
{
if
(
mXmlReader
.
name
()
==
"teacherBar"
||
mXmlReader
.
name
()
==
"teacherGuide"
){
result
.
clear
();
result
+=
"<teacherGuide version=
\"
"
+
mXmlReader
.
attributes
().
value
(
"version"
).
toString
()
+
"
\"
>"
;
result
+=
"
\n
"
;
}
else
if
(
mXmlReader
.
name
()
==
"media"
||
mXmlReader
.
name
()
==
"link"
||
mXmlReader
.
name
()
==
"title"
||
mXmlReader
.
name
()
==
"comment"
||
mXmlReader
.
name
()
==
"action"
)
{
result
+=
"<"
+
mXmlReader
.
name
().
toString
()
+
" "
;
foreach
(
QXmlStreamAttribute
attribute
,
mXmlReader
.
attributes
())
result
+=
attribute
.
name
().
toString
()
+
"=
\"
"
+
attribute
.
value
().
toString
()
+
"
\"
"
;
result
+=
" />
\n
"
;
}
else
{
// NOOP
}
}
else
if
(
mXmlReader
.
isEndElement
()
&&
(
mXmlReader
.
name
()
==
"teacherBar"
||
mXmlReader
.
name
()
==
"teacherGuide"
)){
result
+=
"</teacherGuide>"
;
}
}
if
(
mXmlReader
.
hasError
())
{
qWarning
()
<<
"error parsing Sankore file "
<<
mXmlReader
.
errorString
();
}
return
result
;
}
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
UBSvgSubsetReader
(
UBDocumentProxy
*
pProxy
,
const
QByteArray
&
pXmlData
)
:
mXmlReader
(
pXmlData
)
,
mProxy
(
pProxy
)
...
...
@@ -333,8 +369,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
UBGraphicsStrokesGroup
*
strokesGroup
=
0
;
UBDrawingController
*
dc
=
UBDrawingController
::
drawingController
();
sTeacherGuideNode
=
""
;
while
(
!
mXmlReader
.
atEnd
())
{
...
...
@@ -851,18 +885,18 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
currentWidget
->
setDatastoreEntry
(
key
,
value
);
}
else
if
(
mXmlReader
.
name
()
==
"teacherBar"
||
mXmlReader
.
name
()
==
"teacherGuide"
){
sTeacherGuideNode
.
clear
();
sTeacherGuideNode
+=
"<teacherGuide version=
\"
"
+
mXmlReader
.
attributes
().
value
(
"version"
).
toString
()
+
"
\"
>"
;
sTeacherGuideNode
+=
"
\n
"
;
}
else
if
(
mXmlReader
.
name
()
==
"media"
||
mXmlReader
.
name
()
==
"link"
||
mXmlReader
.
name
()
==
"title"
||
mXmlReader
.
name
()
==
"comment"
||
mXmlReader
.
name
()
==
"action"
)
{
sTeacherGuideNode
+=
"<"
+
mXmlReader
.
name
().
toString
()
+
" "
;
foreach
(
QXmlStreamAttribute
attribute
,
mXmlReader
.
attributes
())
sTeacherGuideNode
+=
attribute
.
name
().
toString
()
+
"=
\"
"
+
attribute
.
value
().
toString
()
+
"
\"
"
;
sTeacherGuideNode
+=
" />
\n
"
;
}
//
else if (mXmlReader.name() == "teacherBar" || mXmlReader.name() == "teacherGuide"){
//
sTeacherGuideNode.clear();
//
sTeacherGuideNode += "<teacherGuide version=\"" + mXmlReader.attributes().value("version").toString() + "\">";
//
sTeacherGuideNode += "\n";
//
}
//
else if (mXmlReader.name() == "media" || mXmlReader.name() == "link" || mXmlReader.name() == "title" || mXmlReader.name() == "comment" || mXmlReader.name() == "action")
//
{
//
sTeacherGuideNode += "<" + mXmlReader.name().toString() + " ";
//
foreach(QXmlStreamAttribute attribute, mXmlReader.attributes())
//
sTeacherGuideNode += attribute.name().toString() + "=\"" + attribute.value().toString() + "\" ";
//
sTeacherGuideNode += " />\n";
//
}
else
{
// NOOP
...
...
@@ -886,14 +920,15 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
mGroupDarkBackgroundColor
=
QColor
();
mGroupLightBackgroundColor
=
QColor
();
}
else
if
(
mXmlReader
.
name
()
==
"teacherBar"
||
mXmlReader
.
name
()
==
"teacherGuide"
){
sTeacherGuideNode
+=
"</teacherGuide>"
;
QMap
<
QString
,
IDataStorage
*>
elements
=
getAdditionalElementToStore
();
IDataStorage
*
storageClass
=
elements
.
value
(
"teacherGuide"
);
if
(
storageClass
){
storageClass
->
load
(
sTeacherGuideNode
);
}
}
// else if (mXmlReader.name() == "teacherBar" || mXmlReader.name() == "teacherGuide"){
// sTeacherGuideNode += "</teacherGuide>";
// qDebug() << sTeacherGuideNode;
// QMap<QString,IDataStorage*> elements = getAdditionalElementToStore();
// IDataStorage* storageClass = elements.value("teacherGuide");
// if(storageClass){
// storageClass->load(sTeacherGuideNode);
// }
// }
}
}
...
...
@@ -969,7 +1004,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::writeSvgElement()
bool
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
persistScene
(
int
pageIndex
)
{
sTeacherGuideNode
=
""
;
if
(
mScene
->
isModified
())
{
QBuffer
buffer
;
...
...
src/adaptors/UBSvgSubsetAdaptor.h
View file @
76d5c99e
...
...
@@ -65,7 +65,6 @@ class UBSvgSubsetAdaptor
static
void
convertSvgImagesToImages
(
UBDocumentProxy
*
proxy
);
static
QMap
<
QString
,
IDataStorage
*>
getAdditionalElementToStore
()
{
return
additionalElementToStore
;}
static
QString
sTeacherGuideNode
;
static
const
QString
nsSvg
;
static
const
QString
nsXLink
;
...
...
@@ -79,6 +78,7 @@ class UBSvgSubsetAdaptor
static
const
QString
sFontWeightPrefix
;
static
const
QString
sFontStylePrefix
;
static
QString
readTeacherGuideNode
(
int
sceneIndex
);
private
:
static
UBGraphicsScene
*
loadScene
(
UBDocumentProxy
*
proxy
,
const
QByteArray
&
pArray
);
...
...
src/board/UBBoardController.cpp
View file @
76d5c99e
...
...
@@ -62,6 +62,7 @@
#include "podcast/UBPodcastController.h"
#include "adaptors/UBMetadataDcSubsetAdaptor.h"
#include "adaptors/UBSvgSubsetAdaptor.h"
#include "UBBoardPaletteManager.h"
...
...
src/core/UBPersistenceManager.cpp
View file @
76d5c99e
...
...
@@ -580,15 +580,8 @@ void UBPersistenceManager::moveSceneToIndex(UBDocumentProxy* proxy, int source,
UBGraphicsScene
*
UBPersistenceManager
::
loadDocumentScene
(
UBDocumentProxy
*
proxy
,
int
sceneIndex
)
{
if
(
mSceneCache
.
contains
(
proxy
,
sceneIndex
))
{
//qDebug() << "scene" << sceneIndex << "retrieved from cache ...";
//updating teacher guide node
//TODO Claudio find a way to store extra information like teacher guid
UBSvgSubsetAdaptor
::
loadScene
(
proxy
,
sceneIndex
);
return
mSceneCache
.
value
(
proxy
,
sceneIndex
);
}
else
{
else
{
qDebug
()
<<
"scene"
<<
sceneIndex
<<
"retrieved from file ..."
;
UBGraphicsScene
*
scene
=
UBSvgSubsetAdaptor
::
loadScene
(
proxy
,
sceneIndex
);
...
...
src/core/UBPersistenceManager.h
View file @
76d5c99e
...
...
@@ -157,6 +157,8 @@ class UBPersistenceManager : public QObject
QString
mDocumentRepositoryPath
;
QHash
<
int
,
QString
>
teacherBarNodeString
;
private
slots
:
void
documentRepositoryChanged
(
const
QString
&
path
);
...
...
src/document/UBDocumentProxy.cpp
View file @
76d5c99e
...
...
@@ -209,8 +209,6 @@ void UBDocumentProxy::setUuid(const QUuid& uuid)
QDateTime
UBDocumentProxy
::
documentDate
()
{
qDebug
()
<<
UBSettings
::
documentDate
;
qDebug
()
<<
mMetaDatas
;
if
(
mMetaDatas
.
contains
(
UBSettings
::
documentDate
))
return
UBStringUtils
::
fromUtcIsoDate
(
metaData
(
UBSettings
::
documentDate
).
toString
());
return
QDateTime
::
currentDateTime
();
...
...
src/gui/UBTeacherGuideWidget.cpp
View file @
76d5c99e
...
...
@@ -161,7 +161,9 @@ void UBTeacherGuideEditionWidget::showEvent(QShowEvent* event)
void
UBTeacherGuideEditionWidget
::
onActiveDocumentChanged
()
{
load
(
UBSvgSubsetAdaptor
::
sTeacherGuideNode
);
int
activeSceneIndex
=
UBApplication
::
boardController
->
activeSceneIndex
();
if
(
UBApplication
::
boardController
->
pageFromSceneIndex
(
activeSceneIndex
)
!=
0
)
load
(
UBSvgSubsetAdaptor
::
readTeacherGuideNode
(
activeSceneIndex
));
}
void
UBTeacherGuideEditionWidget
::
load
(
QString
element
)
...
...
@@ -238,7 +240,7 @@ void UBTeacherGuideEditionWidget::onActiveSceneChanged()
int
currentPage
=
UBApplication
::
boardController
->
currentPage
();
if
(
currentPage
>
0
){
cleanData
();
load
(
UBSvgSubsetAdaptor
::
sTeacherGuideNode
);
load
(
UBSvgSubsetAdaptor
::
readTeacherGuideNode
(
UBApplication
::
boardController
->
activeSceneIndex
())
);
mpPageNumberLabel
->
setText
(
tr
(
"Page: %0"
).
arg
(
currentPage
));
UBDocumentProxy
*
documentProxy
=
UBApplication
::
boardController
->
activeDocument
();
if
(
mpDocumentTitle
)
...
...
src/interfaces/IDataStorage.h
View file @
76d5c99e
...
...
@@ -36,7 +36,7 @@ typedef struct
class
IDataStorage
{
public
:
virtual
void
load
(
QString
element
)
=
0
;
//
virtual void load(QString element) = 0;
virtual
QVector
<
tIDataStorage
*>
save
(
int
pageIndex
)
=
0
;
};
#endif // IDATASTORAGE_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment