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
5e363a3a
Commit
5e363a3a
authored
May 11, 2012
by
Ivan Ilyin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unstable groups implementation
parent
e1adcda8
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
231 additions
and
172 deletions
+231
-172
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+122
-100
UBSvgSubsetAdaptor.h
src/adaptors/UBSvgSubsetAdaptor.h
+1
-0
UBBoardController.cpp
src/board/UBBoardController.cpp
+6
-4
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+14
-16
UBGraphicsPolygonItem.cpp
src/domain/UBGraphicsPolygonItem.cpp
+8
-8
UBGraphicsPolygonItem.h
src/domain/UBGraphicsPolygonItem.h
+1
-1
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+21
-28
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+1
-2
ubgraphicsgroupcontaineritem.cpp
src/domain/ubgraphicsgroupcontaineritem.cpp
+32
-13
ubgraphicsgroupcontaineritemdelegate.cpp
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp
+21
-0
ubgraphicsgroupcontaineritemdelegate.h
src/domain/ubgraphicsgroupcontaineritemdelegate.h
+4
-0
No files found.
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
5e363a3a
...
...
@@ -30,6 +30,7 @@
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsStroke.h"
#include "domain/UBGraphicsStrokesGroup.h"
#include "domain/ubgraphicsgroupcontaineritem.h"
#include "domain/UBItem.h"
#include "tools/UBGraphicsRuler.h"
...
...
@@ -929,8 +930,13 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::writeSvgElement()
bool
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
persistScene
()
{
if
(
mScene
->
isModified
())
{
static
int
i
=
0
;
qDebug
()
<<
"persist call no is "
<<
++
i
;
QBuffer
buffer
;
buffer
.
open
(
QBuffer
::
WriteOnly
);
mXmlWriter
.
setDevice
(
&
buffer
);
...
...
@@ -1035,146 +1041,162 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene()
openStroke
=
0
;
}
UBGraphics
PixmapItem
*
pixmapItem
=
qgraphicsitem_cast
<
UBGraphicsPixmapItem
*>
(
item
);
UBGraphics
GroupContainerItem
*
groupItem
=
qgraphicsitem_cast
<
UBGraphicsGroupContainerItem
*>
(
item
);
if
(
pixmapItem
&&
pixma
pItem
->
isVisible
())
if
(
groupItem
&&
grou
pItem
->
isVisible
())
{
pixmapItemToLinkedImage
(
pixmapItem
)
;
qDebug
()
<<
"came across the group during the parsing"
;
continue
;
}
UBGraphicsSvgItem
*
svgItem
=
qgraphicsitem_cast
<
UBGraphicsSvgItem
*>
(
item
);
parseCommonItems
(
item
);
}
if
(
svgItem
&&
svgItem
->
isVisible
())
{
svgItemToLinkedSvg
(
svgItem
);
continue
;
}
if
(
openStroke
)
{
mXmlWriter
.
writeEndElement
();
groupHoldsInfo
=
false
;
openStroke
=
0
;
}
UBGraphicsVideoItem
*
videoItem
=
qgraphicsitem_cast
<
UBGraphicsVideoItem
*>
(
item
);
mXmlWriter
.
writeEndDocument
();
QString
fileName
=
mDocumentPath
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.svg"
,
mPageIndex
+
1
);
QFile
file
(
fileName
);
if
(
videoItem
&&
videoItem
->
isVisible
())
{
videoItemToLinkedVideo
(
videoItem
);
continue
;
}
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Truncate
))
{
qCritical
()
<<
"cannot open "
<<
fileName
<<
" for writing ..."
;
return
false
;
}
file
.
write
(
buffer
.
data
());
file
.
flush
();
file
.
close
();
UBGraphicsAudioItem
*
audioItem
=
qgraphicsitem_cast
<
UBGraphicsAudioItem
*>
(
item
);
if
(
audioItem
&&
audioItem
->
isVisible
())
{
audioItemToLinkedAudio
(
audioItem
);
continue
;
}
}
else
{
qDebug
()
<<
"ignoring unmodified page"
<<
mPageIndex
+
1
;
}
UBGraphicsAppleWidgetItem
*
appleWidgetItem
=
qgraphicsitem_cast
<
UBGraphicsAppleWidgetItem
*>
(
item
);
return
true
;
}
if
(
appleWidgetItem
&&
appleWidgetItem
->
isVisible
())
{
graphicsAppleWidgetToSvg
(
appleWidgetItem
);
continue
;
}
bool
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
parseCommonItems
(
QGraphicsItem
*
item
)
{
UBGraphicsPixmapItem
*
pixmapItem
=
qgraphicsitem_cast
<
UBGraphicsPixmapItem
*>
(
item
);
UBGraphicsW3CWidgetItem
*
w3cWidgetItem
=
qgraphicsitem_cast
<
UBGraphicsW3CWidgetItem
*>
(
item
);
if
(
pixmapItem
&&
pixmapItem
->
isVisible
())
{
pixmapItemToLinkedImage
(
pixmapItem
);
return
true
;
}
if
(
w3cWidgetItem
&&
w3cWidgetItem
->
isVisible
())
{
graphicsW3CWidgetToSvg
(
w3cWidgetItem
);
continue
;
}
UBGraphicsSvgItem
*
svgItem
=
qgraphicsitem_cast
<
UBGraphicsSvgItem
*>
(
item
);
UBGraphicsPDFItem
*
pdfItem
=
qgraphicsitem_cast
<
UBGraphicsPDFItem
*>
(
item
);
if
(
svgItem
&&
svgItem
->
isVisible
())
{
svgItemToLinkedSvg
(
svgItem
);
return
true
;
}
if
(
pdfItem
&&
pdfItem
->
isVisible
())
{
pdfItemToLinkedPDF
(
pdfItem
);
continue
;
}
UBGraphicsVideoItem
*
videoItem
=
qgraphicsitem_cast
<
UBGraphicsVideoItem
*>
(
item
);
UBGraphicsTextItem
*
textItem
=
qgraphicsitem_cast
<
UBGraphicsTextItem
*>
(
item
);
if
(
videoItem
&&
videoItem
->
isVisible
())
{
videoItemToLinkedVideo
(
videoItem
);
return
true
;
}
if
(
textItem
&&
textItem
->
isVisible
())
{
textItemToSvg
(
text
Item
);
contin
ue
;
}
UBGraphicsAudioItem
*
audioItem
=
qgraphicsitem_cast
<
UBGraphicsAudioItem
*>
(
item
);
if
(
audioItem
&&
audioItem
->
isVisible
())
{
audioItemToLinkedAudio
(
audio
Item
);
return
tr
ue
;
}
UBGraphicsCurtainItem
*
curtainItem
=
qgraphicsitem_cast
<
UBGraphicsCurtain
Item
*>
(
item
);
UBGraphicsAppleWidgetItem
*
appleWidgetItem
=
qgraphicsitem_cast
<
UBGraphicsAppleWidget
Item
*>
(
item
);
if
(
curtainItem
&&
curtain
Item
->
isVisible
())
{
curtainItemToSvg
(
curtain
Item
);
contin
ue
;
}
if
(
appleWidgetItem
&&
appleWidget
Item
->
isVisible
())
{
graphicsAppleWidgetToSvg
(
appleWidget
Item
);
return
tr
ue
;
}
UBGraphicsRuler
*
ruler
=
qgraphicsitem_cast
<
UBGraphicsRuler
*>
(
item
);
UBGraphicsW3CWidgetItem
*
w3cWidgetItem
=
qgraphicsitem_cast
<
UBGraphicsW3CWidgetItem
*>
(
item
);
if
(
ruler
&&
ruler
->
isVisible
())
{
rulerToSvg
(
ruler
);
contin
ue
;
}
if
(
w3cWidgetItem
&&
w3cWidgetItem
->
isVisible
())
{
graphicsW3CWidgetToSvg
(
w3cWidgetItem
);
return
tr
ue
;
}
UBGraphicsCache
*
cache
=
qgraphicsitem_cast
<
UBGraphicsCache
*>
(
item
);
if
(
cache
&&
cache
->
isVisible
())
{
cacheToSvg
(
cache
);
continue
;
}
UBGraphicsPDFItem
*
pdfItem
=
qgraphicsitem_cast
<
UBGraphicsPDFItem
*>
(
item
);
UBGraphicsCompass
*
compass
=
qgraphicsitem_cast
<
UBGraphicsCompass
*>
(
item
);
if
(
pdfItem
&&
pdfItem
->
isVisible
())
{
pdfItemToLinkedPDF
(
pdfItem
);
return
true
;
}
if
(
compass
&&
compass
->
isVisible
())
{
compassToSvg
(
compass
);
continue
;
}
UBGraphicsTextItem
*
textItem
=
qgraphicsitem_cast
<
UBGraphicsTextItem
*>
(
item
);
UBGraphicsProtractor
*
protractor
=
qgraphicsitem_cast
<
UBGraphicsProtractor
*>
(
item
);
if
(
textItem
&&
textItem
->
isVisible
())
{
textItemToSvg
(
textItem
);
return
true
;
}
if
(
protractor
&&
protractor
->
isVisible
())
{
protractorToSvg
(
protractor
);
continue
;
}
UBGraphicsCurtainItem
*
curtainItem
=
qgraphicsitem_cast
<
UBGraphicsCurtainItem
*>
(
item
);
UBGraphicsTriangle
*
triangle
=
qgraphicsitem_cast
<
UBGraphicsTriangle
*>
(
item
);
if
(
curtainItem
&&
curtainItem
->
isVisible
())
{
curtainItemToSvg
(
curtainItem
);
return
true
;
}
if
(
triangle
&&
triangle
->
isVisible
())
{
triangleToSvg
(
triangle
);
continue
;
}
}
UBGraphicsRuler
*
ruler
=
qgraphicsitem_cast
<
UBGraphicsRuler
*>
(
item
);
if
(
openStroke
)
{
mXmlWriter
.
writeEndElement
();
groupHoldsInfo
=
false
;
openStroke
=
0
;
}
if
(
ruler
&&
ruler
->
isVisible
())
{
rulerToSvg
(
ruler
);
return
true
;
}
mXmlWriter
.
writeEndDocument
();
QString
fileName
=
mDocumentPath
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.svg"
,
mPageIndex
+
1
);
QFile
file
(
fileName
);
UBGraphicsCache
*
cache
=
qgraphicsitem_cast
<
UBGraphicsCache
*>
(
item
);
if
(
cache
&&
cache
->
isVisible
())
{
cacheToSvg
(
cache
);
return
true
;
}
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Truncate
))
{
qCritical
()
<<
"cannot open "
<<
fileName
<<
" for writing ..."
;
return
false
;
}
file
.
write
(
buffer
.
data
());
file
.
flush
();
file
.
close
();
UBGraphicsCompass
*
compass
=
qgraphicsitem_cast
<
UBGraphicsCompass
*>
(
item
);
if
(
compass
&&
compass
->
isVisible
())
{
compassToSvg
(
compass
);
return
true
;
}
else
UBGraphicsProtractor
*
protractor
=
qgraphicsitem_cast
<
UBGraphicsProtractor
*>
(
item
);
if
(
protractor
&&
protractor
->
isVisible
())
{
qDebug
()
<<
"ignoring unmodified page"
<<
mPageIndex
+
1
;
protractorToSvg
(
protractor
);
return
true
;
}
UBGraphicsTriangle
*
triangle
=
qgraphicsitem_cast
<
UBGraphicsTriangle
*>
(
item
);
if
(
triangle
&&
triangle
->
isVisible
())
{
triangleToSvg
(
triangle
);
return
true
;
}
return
true
;
}
void
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
polygonItemToSvgLine
(
UBGraphicsPolygonItem
*
polygonItem
,
bool
groupHoldsInfo
)
{
mXmlWriter
.
writeStartElement
(
"line"
);
...
...
src/adaptors/UBSvgSubsetAdaptor.h
View file @
5e363a3a
...
...
@@ -156,6 +156,7 @@ class UBSvgSubsetAdaptor
UBSvgSubsetWriter
(
UBDocumentProxy
*
proxy
,
UBGraphicsScene
*
pScene
,
const
int
pageIndex
);
bool
persistScene
();
bool
parseCommonItems
(
QGraphicsItem
*
item
);
virtual
~
UBSvgSubsetWriter
(){}
...
...
src/board/UBBoardController.cpp
View file @
5e363a3a
...
...
@@ -1235,10 +1235,12 @@ void UBBoardController::ClearUndoStack()
while
(
itUniq
.
hasNext
())
{
QGraphicsItem
*
item
=
itUniq
.
next
();
UBGraphicsScene
*
scene
=
dynamic_cast
<
UBGraphicsScene
*>
(
item
->
scene
());
if
(
!
scene
)
{
mActiveScene
->
deleteItem
(
item
);
if
(
item
->
scene
())
{
UBGraphicsScene
*
scene
=
dynamic_cast
<
UBGraphicsScene
*>
(
item
->
scene
());
if
(
!
scene
)
{
mActiveScene
->
deleteItem
(
item
);
}
}
}
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
5e363a3a
...
...
@@ -236,27 +236,25 @@ void UBGraphicsItemDelegate::setMimeData(QMimeData *mimeData)
bool
UBGraphicsItemDelegate
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
((
NULL
!=
mMimeData
)
&&
((
event
->
pos
()
-
mDragStartPosition
).
manhattanLength
()
<
QApplication
::
startDragDistance
()))
{
QDrag
*
mDrag
=
new
QDrag
(
event
->
widget
());
mDrag
->
setMimeData
(
mMimeData
);
if
(
!
mDragPixmap
.
isNull
())
{
mDrag
->
setPixmap
(
mDragPixmap
);
mDrag
->
setHotSpot
(
mDragPixmap
.
rect
().
center
());
}
mDrag
->
exec
();
mDragPixmap
=
QPixmap
();
return
true
;
if
(
mMimeData
)
{
QDrag
*
mDrag
=
new
QDrag
(
event
->
widget
());
mDrag
->
setMimeData
(
mMimeData
);
if
(
!
mDragPixmap
.
isNull
())
{
mDrag
->
setPixmap
(
mDragPixmap
);
mDrag
->
setHotSpot
(
mDragPixmap
.
rect
().
center
());
}
mDrag
->
exec
();
mDragPixmap
=
QPixmap
();
if
(
isLocked
())
{
event
->
accept
();
return
true
;
}
return
true
;
if
(
isLocked
())
{
event
->
accept
();
return
true
;
}
else
{
return
false
;
}
}
bool
UBGraphicsItemDelegate
::
weelEvent
(
QGraphicsSceneWheelEvent
*
event
)
...
...
src/domain/UBGraphicsPolygonItem.cpp
View file @
5e363a3a
...
...
@@ -189,18 +189,18 @@ void UBGraphicsPolygonItem::paint ( QPainter * painter, const QStyleOptionGraphi
QGraphicsPolygonItem
::
paint
(
painter
,
option
,
widget
);
}
//
QPainterPath UBGraphicsPolygonItem::shape() const
//
{
QPainterPath
UBGraphicsPolygonItem
::
shape
()
const
{
//
QPainterPath path;
//
path.addRect(boundingRect());
QPainterPath
path
;
path
.
addRect
(
boundingRect
());
//
return path;
return
path
;
//
//
static QPainterPath shapePath = QGraphicsPolygonItem::shape();
// static QPainterPath shapePath = QGraphicsPolygonItem::shape();
//
//
return shapePath;
//
}
// return shapePath;
}
UBGraphicsScene
*
UBGraphicsPolygonItem
::
scene
()
...
...
src/domain/UBGraphicsPolygonItem.h
View file @
5e363a3a
...
...
@@ -118,7 +118,7 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
protected
:
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
//
QPainterPath shape () const;
QPainterPath
shape
()
const
;
private
:
...
...
src/domain/UBGraphicsScene.cpp
View file @
5e363a3a
...
...
@@ -294,9 +294,15 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
}
connect
(
this
,
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
selectionChangedProcessing
()));
connect
(
this
,
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
groupButtonProcessing
()));
connect
(
this
,
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
updateGroupButtonState
()));
connect
(
UBApplication
::
mainWindow
->
actionGroupItems
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
groupButtonClicked
()));
// just a stub don't treat as a result code
// static int i = 0;
// i++;
// if (i == 1) {
connect
(
UBApplication
::
mainWindow
->
actionGroupItems
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
groupButtonClicked
()));
// qDebug() << "the connect is accepted";
// }
}
UBGraphicsScene
::~
UBGraphicsScene
()
...
...
@@ -315,7 +321,7 @@ void UBGraphicsScene::selectionChangedProcessing()
UBApplication
::
showMessage
(
"ZValue is "
+
QString
::
number
(
selectedItems
().
first
()
->
zValue
(),
'f'
)
+
"own z value is "
+
QString
::
number
(
selectedItems
().
first
()
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
(),
'f'
));
}
void
UBGraphicsScene
::
groupButtonProcessing
()
void
UBGraphicsScene
::
updateGroupButtonState
()
{
QAction
*
groupAction
=
UBApplication
::
mainWindow
->
actionGroupItems
;
QList
<
QGraphicsItem
*>
selItems
=
selectedItems
();
...
...
@@ -351,11 +357,18 @@ void UBGraphicsScene::groupButtonClicked()
UBGraphicsGroupContainerItem
*
groupItem
=
new
UBGraphicsGroupContainerItem
();
foreach
(
QGraphicsItem
*
item
,
selItems
)
{
item
->
setSelected
(
false
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
false
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
false
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsFocusable
);
groupItem
->
addToGroup
(
item
);
if
(
item
->
type
()
==
UBGraphicsGroupContainerItem
::
Type
)
{
QList
<
QGraphicsItem
*>
childItems
=
item
->
childItems
();
UBGraphicsGroupContainerItem
*
currentGroup
=
dynamic_cast
<
UBGraphicsGroupContainerItem
*>
(
item
);
if
(
currentGroup
)
{
currentGroup
->
destroy
();
}
foreach
(
QGraphicsItem
*
chItem
,
childItems
)
{
groupItem
->
addToGroup
(
chItem
);
}
}
else
{
groupItem
->
addToGroup
(
item
);
}
}
addItem
(
groupItem
);
...
...
@@ -375,26 +388,6 @@ void UBGraphicsScene::groupButtonClicked()
}
}
void
UBGraphicsScene
::
processGroupItems
()
{
qDebug
()
<<
"processing grouping items"
;
UBGraphicsGroupContainerItem
*
groupItem
=
new
UBGraphicsGroupContainerItem
();
foreach
(
QGraphicsItem
*
item
,
selectedItems
())
{
item
->
setSelected
(
false
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
false
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsFocusable
,
true
);
groupItem
->
addToGroup
(
item
);
}
addItem
(
groupItem
);
// groupItem->setPos(50, 50);
groupItem
->
setVisible
(
true
);
groupItem
->
setFocus
();
qDebug
()
<<
groupItem
->
boundingRect
();
}
// MARK: -
// MARK: Mouse/Tablet events handling
...
...
src/domain/UBGraphicsScene.h
View file @
5e363a3a
...
...
@@ -305,9 +305,8 @@ public slots:
void
setToolCursor
(
int
tool
);
void
selectionChangedProcessing
();
void
groupButtonProcessing
();
void
updateGroupButtonState
();
void
groupButtonClicked
();
void
processGroupItems
();
void
moveMagnifier
(
QPoint
newPos
);
void
closeMagnifier
();
...
...
src/domain/ubgraphicsgroupcontaineritem.cpp
View file @
5e363a3a
...
...
@@ -46,6 +46,12 @@ void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
return
;
}
//setting item flags to given item
item
->
setSelected
(
false
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
false
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
false
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsFocusable
,
true
);
QTransform
newItemTransform
(
itemTransform
);
item
->
setPos
(
mapFromItem
(
item
,
0
,
0
));
item
->
setParentItem
(
this
);
...
...
@@ -130,20 +136,24 @@ void UBGraphicsGroupContainerItem::paint(QPainter *painter, const QStyleOptionGr
QWidget
*
widget
)
{
Q_UNUSED
(
widget
);
if
(
option
->
state
&
QStyle
::
State_Selected
)
{
painter
->
setBrush
(
Qt
::
NoBrush
);
QPen
tmpPen
;
qreal
tmpPenWidth
=
1.0
;
tmpPen
.
setWidth
(
tmpPenWidth
);
tmpPen
.
setColor
(
Qt
::
lightGray
);
painter
->
setPen
(
tmpPen
);
painter
->
drawRect
(
itemsBoundingRect
.
adjusted
(
tmpPenWidth
/
2
,
tmpPenWidth
/
2
,
-
tmpPenWidth
/
2
,
-
tmpPenWidth
/
2
));
}
Q_UNUSED
(
painter
);
Q_UNUSED
(
option
);
// we would not use paint smth for the moment
// if (option->state & QStyle::State_Selected) {
// painter->setBrush(Qt::NoBrush);
// QPen tmpPen;
// qreal tmpPenWidth = 1.0;
// tmpPen.setWidth(tmpPenWidth);
// tmpPen.setColor(Qt::lightGray);
// painter->setPen(tmpPen);
// painter->drawRect(itemsBoundingRect.adjusted(tmpPenWidth / 2, tmpPenWidth / 2, -tmpPenWidth / 2, -tmpPenWidth / 2));
// }
}
UBGraphicsScene
*
UBGraphicsGroupContainerItem
::
scene
()
{
UBGraphicsScene
*
castScene
=
dynamic_cast
<
UBGraphicsScene
*>
(
scene
());
UBGraphicsScene
*
castScene
=
dynamic_cast
<
UBGraphicsScene
*>
(
QGraphicsItem
::
scene
());
return
castScene
;
}
...
...
@@ -178,7 +188,12 @@ void UBGraphicsGroupContainerItem::destroy() {
item
->
setFlag
(
QGraphicsItem
::
ItemIsFocusable
,
true
);
}
mDelegate
->
remove
(
true
);
remove
();
if
(
scene
())
{
qDebug
()
<<
"scene is well casted"
;
scene
()
->
removeItem
(
this
);
}
}
void
UBGraphicsGroupContainerItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
...
...
@@ -186,9 +201,12 @@ void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *eve
if
(
mDelegate
->
mousePressEvent
(
event
))
{
//NOOP
}
else
{
QGraphicsItem
::
mousePressEvent
(
event
);
QGraphicsItem
::
mousePressEvent
(
event
);
setSelected
(
true
);
}
}
void
UBGraphicsGroupContainerItem
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
...
...
@@ -198,11 +216,12 @@ void UBGraphicsGroupContainerItem::mouseMoveEvent(QGraphicsSceneMouseEvent *even
}
else
{
QGraphicsItem
::
mouseMoveEvent
(
event
);
}
}
void
UBGraphicsGroupContainerItem
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
mDelegate
->
mouseReleaseEvent
(
event
);
//
mDelegate->mouseReleaseEvent(event);
QGraphicsItem
::
mouseReleaseEvent
(
event
);
}
...
...
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp
View file @
5e363a3a
...
...
@@ -46,3 +46,24 @@ void UBGraphicsGroupContainerItemDelegate::buildButtons()
{
UBGraphicsItemDelegate
::
buildButtons
();
}
bool
UBGraphicsGroupContainerItemDelegate
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
Q_UNUSED
(
event
)
return
false
;
}
bool
UBGraphicsGroupContainerItemDelegate
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
Q_UNUSED
(
event
)
return
false
;
}
bool
UBGraphicsGroupContainerItemDelegate
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
Q_UNUSED
(
event
)
return
false
;
}
src/domain/ubgraphicsgroupcontaineritemdelegate.h
View file @
5e363a3a
...
...
@@ -17,6 +17,10 @@ protected:
virtual
void
decorateMenu
(
QMenu
*
menu
);
virtual
void
buildButtons
();
virtual
bool
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
bool
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
bool
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
private
:
DelegateButton
*
mDestroyGroupButton
;
};
...
...
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