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
2806b135
Commit
2806b135
authored
May 17, 2013
by
Ilia Ryabokon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Safe controls allocation
parent
741298c0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
33 deletions
+59
-33
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+55
-31
UBGraphicsItemDelegate.h
src/domain/UBGraphicsItemDelegate.h
+4
-2
No files found.
src/domain/UBGraphicsItemDelegate.cpp
View file @
2806b135
...
...
@@ -186,13 +186,16 @@ void UBGraphicsItemDelegate::init()
void
UBGraphicsItemDelegate
::
createControls
()
{
if
(
mToolBarUsed
)
if
(
mToolBarUsed
&&
!
mToolBarItem
)
mToolBarItem
=
new
UBGraphicsToolBarItem
(
mDelegated
);
if
(
!
mFrame
)
{
mFrame
=
new
UBGraphicsDelegateFrame
(
this
,
QRectF
(
0
,
0
,
0
,
0
),
mFrameWidth
,
mRespectRatio
);
mFrame
->
hide
();
mFrame
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
}
if
(
!
mDeleteButton
)
{
mDeleteButton
=
new
DelegateButton
(
":/images/close.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
mButtons
<<
mDeleteButton
;
connect
(
mDeleteButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
remove
()));
...
...
@@ -201,21 +204,29 @@ void UBGraphicsItemDelegate::createControls()
connect
(
mDuplicateButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
duplicate
()));
mButtons
<<
mDuplicateButton
;
}
}
if
(
!
mMenuButton
)
{
mMenuButton
=
new
DelegateButton
(
":/images/menu.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mMenuButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
showMenu
()));
mButtons
<<
mMenuButton
;
}
if
(
!
mZOrderUpButton
)
{
mZOrderUpButton
=
new
DelegateButton
(
":/images/z_layer_up.svg"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
mZOrderUpButton
->
setShowProgressIndicator
(
true
);
connect
(
mZOrderUpButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevelUp
()));
connect
(
mZOrderUpButton
,
SIGNAL
(
longClicked
()),
this
,
SLOT
(
increaseZlevelTop
()));
mButtons
<<
mZOrderUpButton
;
}
if
(
!
mZOrderDownButton
)
{
mZOrderDownButton
=
new
DelegateButton
(
":/images/z_layer_down.svg"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
mZOrderDownButton
->
setShowProgressIndicator
(
true
);
connect
(
mZOrderDownButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevelDown
()));
connect
(
mZOrderDownButton
,
SIGNAL
(
longClicked
()),
this
,
SLOT
(
increaseZlevelBottom
()));
mButtons
<<
mZOrderDownButton
;
}
buildButtons
();
...
...
@@ -242,6 +253,16 @@ void UBGraphicsItemDelegate::freeControls()
freeButtons
();
}
bool
UBGraphicsItemDelegate
::
controlsExist
()
const
{
return
mFrame
&&
mDeleteButton
&&
mMenuButton
&&
mZOrderUpButton
&&
mZOrderDownButton
;
}
UBGraphicsItemDelegate
::~
UBGraphicsItemDelegate
()
{
...
...
@@ -255,12 +276,13 @@ UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
QVariant
UBGraphicsItemDelegate
::
itemChange
(
QGraphicsItem
::
GraphicsItemChange
change
,
const
QVariant
&
value
)
{
UBGraphicsScene
*
ubScene
=
castUBGraphicsScene
();
if
(
change
==
QGraphicsItem
::
ItemSelectedHasChanged
)
{
bool
ok
;
bool
selected
=
value
.
toUInt
(
&
ok
);
if
(
ok
)
{
UBGraphicsScene
*
ubScene
=
castUBGraphicsScene
();
if
(
ubScene
&&
!
ubScene
->
multipleSelectionProcess
())
{
if
(
selected
)
{
ubScene
->
setSelectedZLevel
(
delegated
());
...
...
@@ -271,14 +293,16 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch
}
}
if
((
change
==
QGraphicsItem
::
ItemSelectedHasChanged
||
change
==
QGraphicsItem
::
ItemPositionHasChanged
||
change
==
QGraphicsItem
::
ItemTransformHasChanged
)
&&
mDelegated
->
scene
()
&&
ubScene
&&
!
ubScene
->
multipleSelectionProcess
()
&&
UBApplication
::
boardController
)
{
if
(
!
controlsExist
())
{
createControls
();
}
mAntiScaleRatio
=
1
/
(
UBApplication
::
boardController
->
systemScaleFactor
()
*
UBApplication
::
boardController
->
currentZoom
());
positionHandles
();
}
...
...
src/domain/UBGraphicsItemDelegate.h
View file @
2806b135
...
...
@@ -30,6 +30,7 @@
Scene->removeItem(Object); \
} \
delete Object; \
Object = 0; \
} \
#include <QtGui>
...
...
@@ -228,8 +229,9 @@ class UBGraphicsItemDelegate : public QObject
virtual
~
UBGraphicsItemDelegate
();
void
init
();
void
createControls
();
void
freeControls
();
virtual
void
createControls
();
virtual
void
freeControls
();
virtual
bool
controlsExist
()
const
;
virtual
bool
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
bool
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
...
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