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