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
fd4d2201
Commit
fd4d2201
authored
Jun 07, 2013
by
Ilia Ryabokon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove button implemented
parent
0594cfe0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
125 additions
and
5 deletions
+125
-5
UBGraphicsItemDelegate.h
src/domain/UBGraphicsItemDelegate.h
+1
-0
UBSelectionFrame.cpp
src/domain/UBSelectionFrame.cpp
+112
-4
UBSelectionFrame.h
src/domain/UBSelectionFrame.h
+12
-1
No files found.
src/domain/UBGraphicsItemDelegate.h
View file @
fd4d2201
...
...
@@ -314,6 +314,7 @@ class UBGraphicsItemDelegate : public QObject
virtual
void
freeButtons
();
virtual
void
decorateMenu
(
QMenu
*
menu
);
virtual
void
updateMenuActionState
();
QList
<
DelegateButton
*>
buttons
()
{
return
mButtons
;}
QGraphicsItem
*
mDelegated
;
...
...
src/domain/UBSelectionFrame.cpp
View file @
fd4d2201
...
...
@@ -11,11 +11,37 @@
UBSelectionFrame
::
UBSelectionFrame
()
:
mThickness
(
UBSettings
::
settings
()
->
objectFrameWidth
)
,
mAntiscaleRatio
(
1.0
)
,
mDeleteButton
(
0
)
,
mDuplicateButton
(
0
)
,
mZOrderUpButton
(
0
)
,
mZOrderDownButton
(
0
)
{
setLocalBrush
(
QBrush
(
UBSettings
::
paletteColor
));
setPen
(
Qt
::
NoPen
);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
setFlags
(
QGraphicsItem
::
ItemSendsGeometryChanges
/*| QGraphicsItem::ItemIsSelectable*/
|
ItemIsMovable
);
setFlags
(
QGraphicsItem
::
ItemSendsGeometryChanges
|
QGraphicsItem
::
ItemIsSelectable
|
ItemIsMovable
);
mDeleteButton
=
new
DelegateButton
(
":/images/close.svg"
,
this
,
0
,
Qt
::
TopLeftSection
);
mButtons
<<
mDeleteButton
;
connect
(
mDeleteButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
remove
()));
mDuplicateButton
=
new
DelegateButton
(
":/images/duplicate.svg"
,
this
,
0
,
Qt
::
TopLeftSection
);
// connect(mDuplicateButton, SIGNAL(clicked(bool)), this, SLOT(duplicate()));
mButtons
<<
mDuplicateButton
;
mZOrderUpButton
=
new
DelegateButton
(
":/images/z_layer_up.svg"
,
this
,
0
,
Qt
::
BottomLeftSection
);
mZOrderUpButton
->
setShowProgressIndicator
(
true
);
// connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZLevelUp()));
// connect(mZOrderUpButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelTop()));
mButtons
<<
mZOrderUpButton
;
mZOrderDownButton
=
new
DelegateButton
(
":/images/z_layer_down.svg"
,
this
,
0
,
Qt
::
BottomLeftSection
);
mZOrderDownButton
->
setShowProgressIndicator
(
true
);
// connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(increaseZLevelDown()));
// connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom()));
mButtons
<<
mZOrderDownButton
;
connect
(
UBApplication
::
boardController
,
SIGNAL
(
zoomChanged
(
qreal
)),
this
,
SLOT
(
onZoomChanged
(
qreal
)));
}
...
...
@@ -61,6 +87,9 @@ QPainterPath UBSelectionFrame::shape() const
void
UBSelectionFrame
::
setEnclosedItems
(
const
QList
<
QGraphicsItem
*>
pGraphicsItems
)
{
mButtons
.
clear
();
mButtons
.
append
(
mDeleteButton
);
QRegion
resultRegion
;
mEnclosedtems
.
clear
();
foreach
(
QGraphicsItem
*
nextItem
,
pGraphicsItems
)
{
...
...
@@ -74,6 +103,9 @@ void UBSelectionFrame::setEnclosedItems(const QList<QGraphicsItem*> pGraphicsIte
QRectF
resultRect
=
resultRegion
.
boundingRect
();
setRect
(
resultRect
);
placeButtons
();
if
(
resultRect
.
isEmpty
())
{
hide
();
}
...
...
@@ -89,6 +121,8 @@ void UBSelectionFrame::updateRect()
QRectF
result
=
resultRegion
.
boundingRect
();
setRect
(
result
);
placeButtons
();
if
(
result
.
isEmpty
())
{
setVisible
(
false
);
}
...
...
@@ -143,7 +177,7 @@ void UBSelectionFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void
UBSelectionFrame
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*/
*
event
*/
)
{
mPressedPos
=
mLastMovedPos
=
QPointF
();
mPressedPos
=
mLastMovedPos
=
mLastTranslateOffset
=
QPointF
();
// foreach (UBGraphicsItemDelegate *curDelegate, mEnclosedtems) {
// qDebug() << "TransformBefore" << curDelegate->delegated()->transform();
// }
...
...
@@ -152,12 +186,86 @@ void UBSelectionFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent */*event*/)
void
UBSelectionFrame
::
onZoomChanged
(
qreal
pZoom
)
{
mAntiscaleRatio
=
pZoom
;
updateScale
();
// mAntiscaleRatio = pZoom;
// updateScale();
}
void
UBSelectionFrame
::
remove
()
{
foreach
(
UBGraphicsItemDelegate
*
d
,
mEnclosedtems
)
{
d
->
remove
(
true
);
}
updateRect
();
}
void
UBSelectionFrame
::
translateItem
(
QGraphicsItem
*/
*
item
*/
,
const
QPointF
&
/*translatePoint*/
)
{
}
void
UBSelectionFrame
::
placeButtons
()
{
QTransform
tr
;
// tr.scale(mAntiScaleRatio, mAntiScaleRatio);
mDeleteButton
->
setParentItem
(
this
);
// mDeleteButton->setTransform(tr);
qreal
topX
=
rect
().
left
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
width
()
/** mAntiScaleRatio*/
*
1.2
;
qreal
topY
=
rect
().
top
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
height
()
/** mAntiScaleRatio*/
*
1.2
;
qreal
bottomX
=
rect
().
left
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
width
()
/** mAntiScaleRatio*/
/
2
;
qreal
bottomY
=
rect
().
bottom
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
height
()
/** mAntiScaleRatio*/
/
2
;
mDeleteButton
->
setPos
(
topX
,
topY
);
// mDeleteButton->setPos(0, 0);
// if (!mDeleteButton->scene())
// {
// if (scene())
// scene()->addItem(mDeleteButton);
// }
mDeleteButton
->
show
();
// if (showUpdated)
// mDeleteButton->show();
// int i = 1, j = 0, k = 0;
// while ((i + j + k) < mButtons.size()) {
// DelegateButton* button = mButtons[i + j];
// if (button->getSection() == Qt::TopLeftSection) {
// button->setParentItem(mFrame);
// button->setPos(topX + (i++ * 1.6 * mFrameWidth * mAntiScaleRatio), topY);
// button->setTransform(tr);
// } else if (button->getSection() == Qt::BottomLeftSection) {
// button->setParentItem(mFrame);
// button->setPos(bottomX + (++j * 1.6 * mFrameWidth * mAntiScaleRatio), bottomY);
// button->setTransform(tr);
// } else if (button->getSection() == Qt::TitleBarArea || button->getSection() == Qt::NoSection){
// ++k;
// }
// if (!button->scene())
// {
// if (mDelegated->scene())
// mDelegated->scene()->addItem(button);
// }
// if (showUpdated) {
// button->show();
// button->setZValue(delegated()->zValue());
// }
// }
}
void
UBSelectionFrame
::
clearButtons
()
{
foreach
(
DelegateButton
*
b
,
mButtons
)
{
b
->
setParentItem
(
0
);
b
->
hide
();
}
mButtons
.
clear
();
}
src/domain/UBSelectionFrame.h
View file @
fd4d2201
...
...
@@ -4,6 +4,7 @@
#include <QGraphicsRectItem>
#include <QtGui>
class
DelegateButton
;
class
UBGraphicsItemDelegate
;
class
UBSelectionFrame
:
public
QObject
,
public
QGraphicsRectItem
...
...
@@ -19,7 +20,7 @@ public:
void
setLocalBrush
(
const
QBrush
&
pBrush
)
{
mLocalBrush
=
pBrush
;}
QBrush
localBrush
()
const
{
return
mLocalBrush
;}
void
setEnclosedItems
(
const
QList
<
UBGraphicsItemDelegate
*>
pEncItems
)
{
mEnclosedtems
=
pEncItems
;
updateRect
();}
//
void setEnclosedItems(const QList<UBGraphicsItemDelegate*> pEncItems) {mEnclosedtems = pEncItems; updateRect();}
void
setEnclosedItems
(
const
QList
<
QGraphicsItem
*>
pGraphicsItems
);
void
updateRect
();
void
updateScale
();
...
...
@@ -33,9 +34,12 @@ protected:
private
slots
:
void
setAntiScaleRatio
(
qreal
pAntiscaleRatio
)
{
mAntiscaleRatio
=
pAntiscaleRatio
;}
void
onZoomChanged
(
qreal
pZoom
);
void
remove
();
private
:
void
translateItem
(
QGraphicsItem
*
item
,
const
QPointF
&
translatePoint
);
void
placeButtons
();
void
clearButtons
();
private
:
int
mThickness
;
...
...
@@ -46,6 +50,13 @@ private:
QPointF
mPressedPos
;
QPointF
mLastMovedPos
;
QPointF
mLastTranslateOffset
;
QList
<
DelegateButton
*>
mButtons
;
DelegateButton
*
mDeleteButton
;
DelegateButton
*
mDuplicateButton
;
DelegateButton
*
mZOrderUpButton
;
DelegateButton
*
mZOrderDownButton
;
};
#endif // UBSELECTIONFRAME_H
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