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
8d4be60b
Commit
8d4be60b
authored
Jul 25, 2013
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
good behavior horror code
parent
34deb9d9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
0 deletions
+78
-0
UBPersistenceManager.cpp
src/core/UBPersistenceManager.cpp
+74
-0
UBGraphicsMediaItem.h
src/domain/UBGraphicsMediaItem.h
+2
-0
UBGraphicsWidgetItem.cpp
src/domain/UBGraphicsWidgetItem.cpp
+1
-0
UBGraphicsWidgetItem.h
src/domain/UBGraphicsWidgetItem.h
+1
-0
No files found.
src/core/UBPersistenceManager.cpp
View file @
8d4be60b
...
...
@@ -40,6 +40,11 @@
#include "adaptors/UBThumbnailAdaptor.h"
#include "adaptors/UBMetadataDcSubsetAdaptor.h"
#include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsSvgItem.h"
#include "board/UBBoardController.h"
#include "board/UBBoardPaletteManager.h"
...
...
@@ -469,6 +474,8 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL
}
void
UBPersistenceManager
::
duplicateDocumentScene
(
UBDocumentProxy
*
proxy
,
int
index
)
{
checkIfDocumentRepositoryExists
();
...
...
@@ -485,6 +492,73 @@ void UBPersistenceManager::duplicateDocumentScene(UBDocumentProxy* proxy, int in
copyPage
(
proxy
,
index
,
index
+
1
);
//TODO: write a proper way to handle object on disk
UBGraphicsScene
*
scene
=
loadDocumentScene
(
proxy
,
index
+
1
);
foreach
(
QGraphicsItem
*
item
,
scene
->
items
())
{
UBGraphicsMediaItem
*
mediaItem
=
qgraphicsitem_cast
<
UBGraphicsMediaItem
*>
(
item
);
if
(
mediaItem
){
QString
source
=
mediaItem
->
mediaFileUrl
().
toLocalFile
();
QString
destination
=
source
;
QUuid
newUuid
=
QUuid
::
createUuid
();
QString
fileName
=
QFileInfo
(
source
).
completeBaseName
();
destination
=
destination
.
replace
(
fileName
,
newUuid
.
toString
());
Q_ASSERT
(
QFile
::
copy
(
source
,
destination
));
mediaItem
->
mediaFileUrl
(
QUrl
::
fromLocalFile
(
destination
));
continue
;
}
UBGraphicsWidgetItem
*
widget
=
qgraphicsitem_cast
<
UBGraphicsWidgetItem
*>
(
item
);
if
(
widget
){
QUuid
newUUid
=
QUuid
::
createUuid
();
QString
newUUidString
=
newUUid
.
toString
().
remove
(
"{"
).
remove
(
"}"
);
QString
actualUuidString
=
widget
->
uuid
().
toString
().
remove
(
"{"
).
remove
(
"}"
);
qDebug
()
<<
actualUuidString
;
QString
widgetSourcePath
=
proxy
->
persistencePath
()
+
"/"
+
UBPersistenceManager
::
widgetDirectory
+
"/{"
+
actualUuidString
+
"}.wgt"
;
QString
screenshotSourcePath
=
proxy
->
persistencePath
()
+
"/"
+
UBPersistenceManager
::
widgetDirectory
+
"/"
+
actualUuidString
+
".png"
;
QString
widgetDestinationPath
=
widgetSourcePath
;
widgetDestinationPath
=
widgetDestinationPath
.
replace
(
actualUuidString
,
newUUidString
);
QString
screenshotDestinationPath
=
screenshotSourcePath
;
screenshotDestinationPath
=
screenshotDestinationPath
.
replace
(
actualUuidString
,
newUUidString
);
qDebug
()
<<
"widgetSourcePath "
<<
widgetSourcePath
;
qDebug
()
<<
"widgetDestinationPath "
<<
widgetDestinationPath
;
qDebug
()
<<
"screenshotSourcePath "
<<
screenshotSourcePath
;
qDebug
()
<<
"screenshotDestinationPath "
<<
screenshotDestinationPath
;
Q_ASSERT
(
UBFileSystemUtils
::
copyDir
(
widgetSourcePath
,
widgetDestinationPath
));
Q_ASSERT
(
QFile
::
copy
(
screenshotSourcePath
,
screenshotDestinationPath
));
widget
->
setUuid
(
newUUid
);
widget
->
widgetUrl
(
QUrl
::
fromLocalFile
(
widgetDestinationPath
));
continue
;
}
UBGraphicsPixmapItem
*
pixmapItem
=
qgraphicsitem_cast
<
UBGraphicsPixmapItem
*>
(
item
);
if
(
pixmapItem
){
pixmapItem
->
setUuid
(
QUuid
::
createUuid
());
continue
;
}
UBGraphicsSvgItem
*
svgItem
=
qgraphicsitem_cast
<
UBGraphicsSvgItem
*>
(
item
);
if
(
svgItem
){
svgItem
->
setUuid
(
QUuid
::
createUuid
());
continue
;
}
}
scene
->
setModified
(
true
);
persistDocumentScene
(
proxy
,
scene
,
index
+
1
);
proxy
->
incPageCount
();
emit
documentSceneCreated
(
proxy
,
index
+
1
);
...
...
src/domain/UBGraphicsMediaItem.h
View file @
8d4be60b
...
...
@@ -57,6 +57,8 @@ public:
return
mMediaFileUrl
;
}
virtual
void
mediaFileUrl
(
QUrl
url
){
mMediaFileUrl
=
url
;}
Phonon
::
MediaObject
*
mediaObject
()
const
{
return
mMediaObject
;
...
...
src/domain/UBGraphicsWidgetItem.cpp
View file @
8d4be60b
...
...
@@ -149,6 +149,7 @@ QUrl UBGraphicsWidgetItem::widgetUrl()
{
return
mWidgetUrl
;
}
QString
UBGraphicsWidgetItem
::
mainHtmlFileName
()
{
return
mMainHtmlFileName
;
...
...
src/domain/UBGraphicsWidgetItem.h
View file @
8d4be60b
...
...
@@ -69,6 +69,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
QUrl
mainHtml
();
void
loadMainHtml
();
QUrl
widgetUrl
();
void
widgetUrl
(
QUrl
url
)
{
mWidgetUrl
=
url
;
}
QString
mainHtmlFileName
();
bool
canBeContent
();
...
...
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