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
75ddbf80
Commit
75ddbf80
authored
Jul 19, 2012
by
Aleksei Kanash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Undo-redo stack used for background objects.
parent
bf43a982
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
4 deletions
+37
-4
UBBoardController.cpp
src/board/UBBoardController.cpp
+13
-0
UBGraphicsItemUndoCommand.cpp
src/domain/UBGraphicsItemUndoCommand.cpp
+18
-4
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+5
-0
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+1
-0
No files found.
src/board/UBBoardController.cpp
View file @
75ddbf80
...
...
@@ -855,6 +855,10 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const
void
UBBoardController
::
downloadFinished
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
)
{
QGraphicsItem
*
oldBackgroundObject
=
NULL
;
if
(
isBackground
)
oldBackgroundObject
=
mActiveScene
->
backgroundObject
();
QString
mimeType
=
pContentTypeHeader
;
// In some cases "image/jpeg;charset=" is returned by the drag-n-drop. That is
...
...
@@ -1193,6 +1197,15 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
UBApplication
::
showMessage
(
tr
(
"Unknown content type %1"
).
arg
(
pContentTypeHeader
));
qWarning
()
<<
"ignoring mime type"
<<
pContentTypeHeader
;
}
if
(
isBackground
&&
oldBackgroundObject
!=
mActiveScene
->
backgroundObject
())
{
if
(
mActiveScene
->
isURStackIsEnabled
())
{
//should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand
*
uc
=
new
UBGraphicsItemUndoCommand
(
mActiveScene
,
oldBackgroundObject
,
mActiveScene
->
backgroundObject
());
UBApplication
::
undoStack
->
push
(
uc
);
}
}
}
...
...
src/domain/UBGraphicsItemUndoCommand.cpp
View file @
75ddbf80
...
...
@@ -91,9 +91,16 @@ void UBGraphicsItemUndoCommand::undo()
while
(
itRemoved
.
hasNext
())
{
QGraphicsItem
*
item
=
itRemoved
.
next
();
if
(
item
)
{
if
(
UBItemLayerType
::
FixedBackground
==
item
->
data
(
UBGraphicsItemData
::
ItemLayerType
))
mScene
->
setAsBackgroundObject
(
item
);
else
mScene
->
addItem
(
item
);
UBApplication
::
boardController
->
freezeW3CWidget
(
item
,
false
);
}
}
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
mScene
->
update
(
mScene
->
sceneRect
());
...
...
@@ -123,9 +130,16 @@ void UBGraphicsItemUndoCommand::redo()
while
(
itAdded
.
hasNext
())
{
QGraphicsItem
*
item
=
itAdded
.
next
();
if
(
item
)
{
if
(
UBItemLayerType
::
FixedBackground
==
item
->
data
(
UBGraphicsItemData
::
ItemLayerType
))
mScene
->
setAsBackgroundObject
(
item
);
else
mScene
->
addItem
(
item
);
UBApplication
::
boardController
->
freezeW3CWidget
(
item
,
false
);
}
}
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2) to trigger repaint
mScene
->
update
(
mScene
->
sceneRect
());
...
...
src/domain/UBGraphicsScene.cpp
View file @
75ddbf80
...
...
@@ -1292,6 +1292,11 @@ void UBGraphicsScene::clearBackground()
{
if
(
mBackgroundObject
){
removeItem
(
mBackgroundObject
);
if
(
enableUndoRedoStack
)
{
//should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand
*
uc
=
new
UBGraphicsItemUndoCommand
(
this
,
mBackgroundObject
,
NULL
);
UBApplication
::
undoStack
->
push
(
uc
);
}
mBackgroundObject
=
0
;
}
update
(
sceneRect
());
...
...
src/domain/UBGraphicsScene.h
View file @
75ddbf80
...
...
@@ -102,6 +102,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
// tmp stub for divide addings scene objects from undo mechanism implementation
void
setURStackEnable
(
bool
set
=
true
)
{
enableUndoRedoStack
=
set
;}
bool
isURStackIsEnabled
(){
return
enableUndoRedoStack
;}
UBGraphicsScene
(
UBDocumentProxy
*
parent
);
virtual
~
UBGraphicsScene
();
...
...
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