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
f8a21c1b
Commit
f8a21c1b
authored
Jul 11, 2013
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
page zero issue after importing documents using the Importer program
parent
d452b2dd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
48 deletions
+31
-48
UBImportDocument.cpp
src/adaptors/UBImportDocument.cpp
+1
-1
UBPersistenceManager.cpp
src/core/UBPersistenceManager.cpp
+27
-39
UBPersistenceManager.h
src/core/UBPersistenceManager.h
+2
-8
UBDocumentController.cpp
src/document/UBDocumentController.cpp
+1
-0
No files found.
src/adaptors/UBImportDocument.cpp
View file @
f8a21c1b
...
...
@@ -179,7 +179,7 @@ UBDocumentProxy* UBImportDocument::importFile(const QFile& pFile, const QString&
return
NULL
;
}
UBDocumentProxy
*
newDocument
=
UBPersistenceManager
::
persistenceManager
()
->
createDocumentFromDir
(
documentRootFolder
,
pGroup
,
""
,
false
,
false
);
UBDocumentProxy
*
newDocument
=
UBPersistenceManager
::
persistenceManager
()
->
createDocumentFromDir
(
documentRootFolder
,
pGroup
,
""
);
UBApplication
::
showMessage
(
tr
(
"Import successful."
));
return
newDocument
;
}
...
...
src/core/UBPersistenceManager.cpp
View file @
f8a21c1b
...
...
@@ -65,7 +65,7 @@ UBPersistenceManager::UBPersistenceManager(QObject *pParent)
mDocumentSubDirectories
<<
audioDirectory
;
documentProxies
=
allDocumentProxies
();
emit
proxyListChanged
();
}
UBPersistenceManager
*
UBPersistenceManager
::
persistenceManager
()
...
...
@@ -102,6 +102,13 @@ QList<QPointer<UBDocumentProxy> > UBPersistenceManager::allDocumentProxies()
rootDir
.
mkpath
(
rootDir
.
path
());
QStringList
dirList
=
rootDir
.
entryList
(
QDir
::
Dirs
|
QDir
::
NoDotAndDotDot
,
QDir
::
Time
|
QDir
::
Reversed
);
foreach
(
QString
path
,
dirList
)
{
shiftPagesToStartWithTheZeroOne
(
rootDir
.
path
()
+
"/"
+
path
);
}
QFileSystemWatcher
*
watcher
=
new
QFileSystemWatcher
(
this
);
watcher
->
addPath
(
mDocumentRepositoryPath
);
...
...
@@ -109,8 +116,7 @@ QList<QPointer<UBDocumentProxy> > UBPersistenceManager::allDocumentProxies()
QList
<
QPointer
<
UBDocumentProxy
>
>
proxies
;
foreach
(
QString
path
,
rootDir
.
entryList
(
QDir
::
Dirs
|
QDir
::
NoDotAndDotDot
,
QDir
::
Time
|
QDir
::
Reversed
))
foreach
(
QString
path
,
dirList
)
{
QString
fullPath
=
rootDir
.
path
()
+
"/"
+
path
;
...
...
@@ -257,8 +263,6 @@ UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName,
documentProxies
.
insert
(
0
,
QPointer
<
UBDocumentProxy
>
(
doc
));
emit
proxyListChanged
();
emit
documentCreated
(
doc
);
mDocumentCreatedDuringSession
<<
doc
;
...
...
@@ -266,7 +270,7 @@ UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName,
return
doc
;
}
UBDocumentProxy
*
UBPersistenceManager
::
createDocumentFromDir
(
const
QString
&
pDocumentDirectory
,
const
QString
&
pGroupName
,
const
QString
&
pName
,
bool
withEmptyPage
,
bool
addTitlePage
)
UBDocumentProxy
*
UBPersistenceManager
::
createDocumentFromDir
(
const
QString
&
pDocumentDirectory
,
const
QString
&
pGroupName
,
const
QString
&
pName
)
{
checkIfDocumentRepositoryExists
();
...
...
@@ -281,8 +285,6 @@ UBDocumentProxy* UBPersistenceManager::createDocumentFromDir(const QString& pDoc
{
doc
->
setMetaData
(
UBSettings
::
documentName
,
pName
);
}
if
(
withEmptyPage
)
createDocumentSceneAt
(
doc
,
0
);
if
(
addTitlePage
)
persistDocumentScene
(
doc
,
mSceneCache
.
createScene
(
doc
,
0
,
false
),
0
);
QMap
<
QString
,
QVariant
>
metadatas
=
UBMetadataDcSubsetAdaptor
::
load
(
pDocumentDirectory
);
...
...
@@ -303,7 +305,6 @@ UBDocumentProxy* UBPersistenceManager::createDocumentFromDir(const QString& pDoc
documentProxies
<<
QPointer
<
UBDocumentProxy
>
(
doc
);
emit
proxyListChanged
();
emit
documentCreated
(
doc
);
...
...
@@ -326,8 +327,6 @@ void UBPersistenceManager::deleteDocument(UBDocumentProxy* pDocumentProxy)
pDocumentProxy
->
deleteLater
();
emit
proxyListChanged
();
}
...
...
@@ -363,8 +362,6 @@ UBDocumentProxy* UBPersistenceManager::duplicateDocument(UBDocumentProxy* pDocum
documentProxies
<<
QPointer
<
UBDocumentProxy
>
(
copy
);
emit
proxyListChanged
();
emit
documentCreated
(
copy
);
return
copy
;
...
...
@@ -652,7 +649,6 @@ void UBPersistenceManager::copyPage(UBDocumentProxy* pDocumentProxy, const int s
int
UBPersistenceManager
::
sceneCount
(
const
UBDocumentProxy
*
proxy
)
{
const
QString
pPath
=
proxy
->
persistencePath
();
int
pageIndex
=
0
;
bool
moreToProcess
=
true
;
...
...
@@ -739,31 +735,6 @@ bool UBPersistenceManager::addDirectoryContentToDocument(const QString& document
}
void
UBPersistenceManager
::
upgradeDocumentIfNeeded
(
UBDocumentProxy
*
pDocumentProxy
)
{
int
pageCount
=
pDocumentProxy
->
pageCount
();
for
(
int
index
=
0
;
index
<
pageCount
;
index
++
)
{
UBSvgSubsetAdaptor
::
upgradeScene
(
pDocumentProxy
,
index
);
}
pDocumentProxy
->
setMetaData
(
UBSettings
::
documentVersion
,
UBSettings
::
currentFileVersion
);
UBMetadataDcSubsetAdaptor
::
persist
(
pDocumentProxy
);
}
void
UBPersistenceManager
::
upgradeAllDocumentsIfNeeded
()
{
foreach
(
QPointer
<
UBDocumentProxy
>
proxy
,
documentProxies
)
{
upgradeDocumentIfNeeded
(
proxy
);
}
}
UBDocumentProxy
*
UBPersistenceManager
::
documentByUuid
(
const
QUuid
&
pUuid
)
{
for
(
int
i
=
0
;
i
<
documentProxies
.
length
();
i
++
)
...
...
@@ -935,3 +906,20 @@ void UBPersistenceManager::checkIfDocumentRepositoryExists()
UBApplication
::
quit
();
}
}
void
UBPersistenceManager
::
shiftPagesToStartWithTheZeroOne
(
QString
persistencePath
)
{
if
(
!
QFile
(
persistencePath
+
"/page000.svg"
).
exists
()
&&
QFile
(
persistencePath
+
"/page001.svg"
).
exists
()){
int
i
=
1
;
while
(
QFile
(
persistencePath
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.svg"
,
i
)).
exists
()){
QFile
svg
(
persistencePath
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.svg"
,
i
));
svg
.
rename
(
persistencePath
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.svg"
,
i
-
1
));
QFile
thumb
(
persistencePath
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
i
));
thumb
.
rename
(
persistencePath
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
i
-
1
));
i
+=
1
;
}
}
}
src/core/UBPersistenceManager.h
View file @
f8a21c1b
...
...
@@ -50,12 +50,13 @@ class UBPersistenceManager : public QObject
static
const
QString
audioDirectory
;
static
const
QString
widgetDirectory
;
static
const
QString
teacherGuideDirectory
;
static
void
shiftPagesToStartWithTheZeroOne
(
QString
persistencePath
);
static
UBPersistenceManager
*
persistenceManager
();
static
void
destroy
();
virtual
UBDocumentProxy
*
createDocument
(
const
QString
&
pGroupName
=
""
,
const
QString
&
pName
=
""
,
bool
withEmptyPage
=
true
);
virtual
UBDocumentProxy
*
createDocumentFromDir
(
const
QString
&
pDocumentDirectory
,
const
QString
&
pGroupName
=
""
,
const
QString
&
pName
=
""
,
bool
withEmptyPage
=
false
,
bool
addTitlePage
=
false
);
virtual
UBDocumentProxy
*
createDocumentFromDir
(
const
QString
&
pDocumentDirectory
,
const
QString
&
pGroupName
=
""
,
const
QString
&
pName
=
""
);
virtual
UBDocumentProxy
*
persistDocumentMetadata
(
UBDocumentProxy
*
pDocumentProxy
);
...
...
@@ -92,10 +93,6 @@ class UBPersistenceManager : public QObject
bool
addDirectoryContentToDocument
(
const
QString
&
documentRootFolder
,
UBDocumentProxy
*
pDocument
);
virtual
void
upgradeDocumentIfNeeded
(
UBDocumentProxy
*
pDocumentProxy
);
virtual
void
upgradeAllDocumentsIfNeeded
();
virtual
UBDocumentProxy
*
documentByUuid
(
const
QUuid
&
pUuid
);
QStringList
documentSubDirectories
()
...
...
@@ -110,9 +107,6 @@ class UBPersistenceManager : public QObject
bool
addFileToDocument
(
UBDocumentProxy
*
pDocumentProxy
,
QString
path
,
const
QString
&
subdir
,
QUuid
objectUuid
,
QString
&
destinationPath
,
QByteArray
*
data
=
NULL
);
signals
:
void
proxyListChanged
();
void
documentCreated
(
UBDocumentProxy
*
pDocumentProxy
);
void
documentMetadataChanged
(
UBDocumentProxy
*
pDocumentProxy
);
void
documentWillBeDeleted
(
UBDocumentProxy
*
pDocumentProxy
);
...
...
src/document/UBDocumentController.cpp
View file @
f8a21c1b
...
...
@@ -818,6 +818,7 @@ void UBDocumentController::loadDocumentProxies()
{
QString
docGroup
=
proxy
->
metaData
(
UBSettings
::
documentGroupName
).
toString
();
bool
isEmptyGroupName
=
false
;
bool
isInTrash
=
false
;
...
...
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