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
be14bdc6
Commit
be14bdc6
authored
Aug 02, 2013
by
Didier Clerc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed an issue related to z-level management
parent
03480053
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
143 additions
and
19 deletions
+143
-19
UB.h
src/core/UB.h
+1
-1
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+4
-4
UBGraphicsItemZLevelUndoCommand.cpp
src/domain/UBGraphicsItemZLevelUndoCommand.cpp
+59
-0
UBGraphicsItemZLevelUndoCommand.h
src/domain/UBGraphicsItemZLevelUndoCommand.h
+32
-0
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+12
-4
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+1
-2
UBSelectionFrame.cpp
src/domain/UBSelectionFrame.cpp
+27
-5
UBSelectionFrame.h
src/domain/UBSelectionFrame.h
+3
-1
domain.pri
src/domain/domain.pri
+4
-2
No files found.
src/core/UB.h
View file @
be14bdc6
...
...
@@ -200,7 +200,7 @@ struct UBUndoType
{
enum
Enum
{
undotype_UNKNOWN
=
0
,
undotype_DOCUMENT
,
undotype_GRAPHICITEMTRANSFORM
,
undotype_GRAPHICITEM
,
undotype_GRAPHICTEXTITEM
,
undotype_PAGESIZE
,
undotype_GRAPHICSGROUPITEM
undotype_UNKNOWN
=
0
,
undotype_DOCUMENT
,
undotype_GRAPHICITEMTRANSFORM
,
undotype_GRAPHICITEM
,
undotype_GRAPHICTEXTITEM
,
undotype_PAGESIZE
,
undotype_GRAPHICSGROUPITEM
,
undotype_GRAPHICITEMZVALUE
};
};
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
be14bdc6
...
...
@@ -524,28 +524,28 @@ void UBGraphicsItemDelegate::increaseZLevelUp()
{
UBGraphicsScene
*
curScene
=
castUBGraphicsScene
();
if
(
curScene
)
{
curScene
->
changeZLevelTo
(
delegated
(),
UBZLayerController
::
up
);
curScene
->
changeZLevelTo
(
delegated
(),
UBZLayerController
::
up
,
true
);
}
}
void
UBGraphicsItemDelegate
::
increaseZlevelTop
()
{
UBGraphicsScene
*
curScene
=
castUBGraphicsScene
();
if
(
curScene
)
{
curScene
->
changeZLevelTo
(
delegated
(),
UBZLayerController
::
top
);
curScene
->
changeZLevelTo
(
delegated
(),
UBZLayerController
::
top
,
true
);
}
}
void
UBGraphicsItemDelegate
::
increaseZLevelDown
()
{
UBGraphicsScene
*
curScene
=
castUBGraphicsScene
();
if
(
curScene
)
{
curScene
->
changeZLevelTo
(
delegated
(),
UBZLayerController
::
down
);
curScene
->
changeZLevelTo
(
delegated
(),
UBZLayerController
::
down
,
true
);
}
}
void
UBGraphicsItemDelegate
::
increaseZlevelBottom
()
{
UBGraphicsScene
*
curScene
=
castUBGraphicsScene
();
if
(
curScene
)
{
curScene
->
changeZLevelTo
(
delegated
(),
UBZLayerController
::
bottom
);
curScene
->
changeZLevelTo
(
delegated
(),
UBZLayerController
::
bottom
,
true
);
}
}
...
...
src/domain/UBGraphicsItemZLevelUndoCommand.cpp
0 → 100644
View file @
be14bdc6
#include "UBGraphicsItemZLevelUndoCommand.h"
UBGraphicsItemZLevelUndoCommand
::
UBGraphicsItemZLevelUndoCommand
(
UBGraphicsScene
*
_scene
,
const
QList
<
QGraphicsItem
*>&
_items
,
qreal
_previousZLevel
,
UBZLayerController
::
moveDestination
dest
)
:
UBUndoCommand
(){
Q_ASSERT
(
_scene
!=
NULL
);
mpScene
=
_scene
;
mItems
=
_items
;
mPreviousZLevel
=
_previousZLevel
;
mDest
=
dest
;
mHack
=
false
;
}
UBGraphicsItemZLevelUndoCommand
::
UBGraphicsItemZLevelUndoCommand
(
UBGraphicsScene
*
_scene
,
QGraphicsItem
*
_item
,
qreal
_previousZLevel
,
UBZLayerController
::
moveDestination
dest
)
:
UBUndoCommand
(){
Q_ASSERT
(
_scene
!=
NULL
);
mpScene
=
_scene
;
if
(
NULL
!=
_item
)
mItems
.
append
(
_item
);
mPreviousZLevel
=
_previousZLevel
;
mDest
=
dest
;
mHack
=
false
;
}
UBGraphicsItemZLevelUndoCommand
::~
UBGraphicsItemZLevelUndoCommand
(){
}
void
UBGraphicsItemZLevelUndoCommand
::
undo
(){
if
(
!
mpScene
)
return
;
foreach
(
QGraphicsItem
*
item
,
mItems
){
if
(
mDest
==
UBZLayerController
::
down
){
mpScene
->
changeZLevelTo
(
item
,
UBZLayerController
::
up
);
}
else
if
(
mDest
==
UBZLayerController
::
up
){
mpScene
->
changeZLevelTo
(
item
,
UBZLayerController
::
down
);
}
updateLazyScene
();
}
}
void
UBGraphicsItemZLevelUndoCommand
::
redo
(){
if
(
!
mHack
){
// Ugly! But pushing a new command to QUndoStack calls redo by itself.
mHack
=
true
;
}
else
{
if
(
!
mpScene
)
return
;
foreach
(
QGraphicsItem
*
item
,
mItems
){
mpScene
->
changeZLevelTo
(
item
,
mDest
);
updateLazyScene
();
}
}
}
void
UBGraphicsItemZLevelUndoCommand
::
updateLazyScene
(){
mpScene
->
update
(
mpScene
->
sceneRect
());
mpScene
->
updateSelectionFrame
();
}
src/domain/UBGraphicsItemZLevelUndoCommand.h
0 → 100644
View file @
be14bdc6
#ifndef UBGRAPHICSITEMZLEVELUNDOCOMMAND_H
#define UBGRAPHICSITEMZLEVELUNDOCOMMAND_H
#include <QGraphicsItem>
#include "UBUndoCommand.h"
#include "UBGraphicsScene.h"
class
UBGraphicsItemZLevelUndoCommand
:
public
UBUndoCommand
{
public
:
UBGraphicsItemZLevelUndoCommand
(
UBGraphicsScene
*
_scene
,
const
QList
<
QGraphicsItem
*>&
_items
,
qreal
_previousZLevel
,
UBZLayerController
::
moveDestination
dest
);
UBGraphicsItemZLevelUndoCommand
(
UBGraphicsScene
*
_scene
,
QGraphicsItem
*
_item
,
qreal
_previousZLevel
,
UBZLayerController
::
moveDestination
dest
);
~
UBGraphicsItemZLevelUndoCommand
();
virtual
int
getType
()
const
{
return
UBUndoType
::
undotype_GRAPHICITEMZVALUE
;
}
protected
:
virtual
void
undo
();
virtual
void
redo
();
private
:
void
updateLazyScene
();
qreal
mPreviousZLevel
;
QList
<
QGraphicsItem
*>
mItems
;
UBGraphicsScene
*
mpScene
;
UBZLayerController
::
moveDestination
mDest
;
bool
mHack
;
};
#endif // UBGRAPHICSITEMZLEVELUNDOCOMMAND_H
src/domain/UBGraphicsScene.cpp
View file @
be14bdc6
...
...
@@ -68,6 +68,7 @@
#include "UBGraphicsTextItem.h"
#include "UBGraphicsStrokesGroup.h"
#include "UBSelectionFrame.h"
#include "UBGraphicsItemZLevelUndoCommand.h"
#include "domain/UBGraphicsGroupContainerItem.h"
...
...
@@ -164,6 +165,7 @@ qreal UBZLayerController::changeZLevelTo(QGraphicsItem *item, moveDestination de
QMapIterator
<
qreal
,
QGraphicsItem
*>
iCurElement
(
sortedItems
);
if
(
dest
==
up
)
{
qDebug
()
<<
"item data zvalue= "
<<
item
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
();
if
(
iCurElement
.
findNext
(
item
))
{
if
(
iCurElement
.
hasNext
())
{
qreal
nextZ
=
iCurElement
.
peekNext
().
value
()
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
();
...
...
@@ -1068,8 +1070,6 @@ void UBGraphicsScene::notifyZChanged(QGraphicsItem *item, qreal zValue)
void
UBGraphicsScene
::
updateSelectionFrame
()
{
qDebug
()
<<
"selected item count"
<<
selectedItems
().
count
();
if
(
!
mSelectionFrame
)
{
mSelectionFrame
=
new
UBSelectionFrame
();
addItem
(
mSelectionFrame
);
...
...
@@ -2170,9 +2170,17 @@ QUuid UBGraphicsScene::getPersonalUuid(QGraphicsItem *item)
return
idCandidate
==
QUuid
().
toString
()
?
QUuid
()
:
QUuid
(
idCandidate
);
}
qreal
UBGraphicsScene
::
changeZLevelTo
(
QGraphicsItem
*
item
,
UBZLayerController
::
moveDestination
dest
)
qreal
UBGraphicsScene
::
changeZLevelTo
(
QGraphicsItem
*
item
,
UBZLayerController
::
moveDestination
dest
,
bool
addUndo
)
{
return
mZLayerController
->
changeZLevelTo
(
item
,
dest
);
qreal
previousZVal
=
item
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
();
qreal
res
=
mZLayerController
->
changeZLevelTo
(
item
,
dest
);
if
(
addUndo
){
UBGraphicsItemZLevelUndoCommand
*
uc
=
new
UBGraphicsItemZLevelUndoCommand
(
this
,
item
,
previousZVal
,
dest
);
UBApplication
::
undoStack
->
push
(
uc
);
}
return
res
;
}
QGraphicsItem
*
UBGraphicsScene
::
rootItem
(
QGraphicsItem
*
item
)
const
...
...
src/domain/UBGraphicsScene.h
View file @
be14bdc6
...
...
@@ -275,7 +275,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void
setNominalSize
(
int
pWidth
,
int
pHeight
);
qreal
changeZLevelTo
(
QGraphicsItem
*
item
,
UBZLayerController
::
moveDestination
dest
);
qreal
changeZLevelTo
(
QGraphicsItem
*
item
,
UBZLayerController
::
moveDestination
dest
,
bool
addUndo
=
false
);
enum
RenderingContext
{
...
...
@@ -314,7 +314,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBBoardView
*
controlView
();
void
notifyZChanged
(
QGraphicsItem
*
item
,
qreal
zValue
);
public
slots
:
void
updateSelectionFrame
();
void
updateSelectionFrameWrapper
(
int
);
...
...
src/domain/UBSelectionFrame.cpp
View file @
be14bdc6
...
...
@@ -3,12 +3,12 @@
#include <QtGui>
#include "domain/UBItem.h"
#include "domain/UBGraphicsItemZLevelUndoCommand.h"
#include "board/UBBoardController.h"
#include "core/UBSettings.h"
#include "core/UBApplication.h"
#include "gui/UBResources.h"
#include "core/UBApplication.h"
#include "domain/UBGraphicsScene.h"
#include "board/UBBoardView.h"
UBSelectionFrame
::
UBSelectionFrame
()
...
...
@@ -245,37 +245,58 @@ void UBSelectionFrame::duplicate()
void
UBSelectionFrame
::
increaseZlevelUp
()
{
foreach
(
QGraphicsItem
*
item
,
sortedByZ
(
scene
()
->
selectedItems
()))
{
QList
<
QGraphicsItem
*>
selItems
=
sortedByZ
(
scene
()
->
selectedItems
());
QList
<
QGraphicsItem
*>::
iterator
itemIt
=
selItems
.
end
();
while
(
itemIt
!=
selItems
.
begin
()){
itemIt
--
;
QGraphicsItem
*
item
=
*
itemIt
;
ubscene
()
->
changeZLevelTo
(
item
,
UBZLayerController
::
up
);
}
addSelectionUndo
(
selItems
,
UBZLayerController
::
up
);
}
void
UBSelectionFrame
::
increaseZlevelTop
()
{
foreach
(
QGraphicsItem
*
item
,
sortedByZ
(
scene
()
->
selectedItems
()))
{
QList
<
QGraphicsItem
*>
selItems
=
sortedByZ
(
scene
()
->
selectedItems
());
foreach
(
QGraphicsItem
*
item
,
selItems
)
{
ubscene
()
->
changeZLevelTo
(
item
,
UBZLayerController
::
top
);
}
addSelectionUndo
(
selItems
,
UBZLayerController
::
top
);
}
void
UBSelectionFrame
::
increaseZlevelDown
()
{
foreach
(
QGraphicsItem
*
item
,
sortedByZ
(
scene
()
->
selectedItems
()))
{
QList
<
QGraphicsItem
*>
selItems
=
sortedByZ
(
scene
()
->
selectedItems
());
foreach
(
QGraphicsItem
*
item
,
selItems
)
{
ubscene
()
->
changeZLevelTo
(
item
,
UBZLayerController
::
down
);
}
addSelectionUndo
(
selItems
,
UBZLayerController
::
down
);
}
void
UBSelectionFrame
::
increaseZlevelBottom
()
{
QListIterator
<
QGraphicsItem
*>
iter
(
sortedByZ
(
scene
()
->
selectedItems
()));
QList
<
QGraphicsItem
*>
selItems
=
sortedByZ
(
scene
()
->
selectedItems
());
QListIterator
<
QGraphicsItem
*>
iter
(
selItems
);
iter
.
toBack
();
while
(
iter
.
hasPrevious
())
{
ubscene
()
->
changeZLevelTo
(
iter
.
previous
(),
UBZLayerController
::
bottom
);
}
addSelectionUndo
(
selItems
,
UBZLayerController
::
bottom
);
// foreach (QGraphicsItem *item, sortedByZ(scene()->selectedItems())) {
// ubscene()->changeZLevelTo(item, UBZLayerController::bottom);
// }
}
void
UBSelectionFrame
::
addSelectionUndo
(
QList
<
QGraphicsItem
*>
items
,
UBZLayerController
::
moveDestination
dest
){
if
(
!
items
.
empty
()){
qreal
topItemLevel
=
items
.
at
(
0
)
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
();
UBGraphicsItemZLevelUndoCommand
*
cmd
=
new
UBGraphicsItemZLevelUndoCommand
(
ubscene
(),
items
,
topItemLevel
,
dest
);
UBApplication
::
undoStack
->
push
(
cmd
);
}
}
void
UBSelectionFrame
::
translateItem
(
QGraphicsItem
*/
*
item
*/
,
const
QPointF
&
/*translatePoint*/
)
{
}
...
...
@@ -388,6 +409,7 @@ void UBSelectionFrame::setCursorFromAngle(QString angle)
QList
<
QGraphicsItem
*>
UBSelectionFrame
::
sortedByZ
(
const
QList
<
QGraphicsItem
*>
&
pItems
)
{
//select only items wiht the same z-level as item's one and push it to sortedItems QMultiMap
// It means: keep only the selected items and remove the selection frame from the list
QMultiMap
<
qreal
,
QGraphicsItem
*>
sortedItems
;
foreach
(
QGraphicsItem
*
tmpItem
,
pItems
)
{
if
(
tmpItem
->
type
()
==
Type
)
{
...
...
src/domain/UBSelectionFrame.h
View file @
be14bdc6
...
...
@@ -5,9 +5,10 @@
#include <QtGui>
#include <core/UB.h>
#include "domain/UBGraphicsScene.h"
class
DelegateButton
;
class
UBGraphicsItemDelegate
;
class
UBGraphicsScene
;
class
UBSelectionFrame
:
public
QObject
,
public
QGraphicsRectItem
{
...
...
@@ -48,6 +49,7 @@ private slots:
void
increaseZlevelBottom
();
private
:
void
addSelectionUndo
(
QList
<
QGraphicsItem
*>
items
,
UBZLayerController
::
moveDestination
dest
);
void
translateItem
(
QGraphicsItem
*
item
,
const
QPointF
&
translatePoint
);
void
placeButtons
();
void
placeExceptionButton
(
DelegateButton
*
pButton
,
QTransform
pTransform
);
...
...
src/domain/domain.pri
View file @
be14bdc6
...
...
@@ -24,7 +24,8 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBGraphicsWidgetItemDelegate.h \
src/domain/UBGraphicsMediaItemDelegate.h \
src/domain/UBSelectionFrame.h \
src/domain/UBUndoCommand.h
src/domain/UBUndoCommand.h \
src/domain/UBGraphicsItemZLevelUndoCommand.h
SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsItemUndoCommand.cpp \
...
...
@@ -52,4 +53,5 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsDelegateFrame.cpp \
src/domain/UBGraphicsWidgetItemDelegate.cpp \
src/domain/UBSelectionFrame.cpp \
src/domain/UBUndoCommand.cpp
src/domain/UBUndoCommand.cpp \
src/domain/UBGraphicsItemZLevelUndoCommand.cpp
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