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
9bd20fdb
Commit
9bd20fdb
authored
Apr 25, 2012
by
Ivan Ilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Grouping items available
parent
0eed7eef
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
292 additions
and
6 deletions
+292
-6
mainWindow.ui
resources/forms/mainWindow.ui
+16
-0
UBBoardView.cpp
src/board/UBBoardView.cpp
+3
-1
UBGraphicsPolygonItem.cpp
src/domain/UBGraphicsPolygonItem.cpp
+13
-0
UBGraphicsPolygonItem.h
src/domain/UBGraphicsPolygonItem.h
+2
-0
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+43
-3
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+4
-0
domain.pri
src/domain/domain.pri
+6
-2
ubgraphicsgroupcontaineritem.cpp
src/domain/ubgraphicsgroupcontaineritem.cpp
+86
-0
ubgraphicsgroupcontaineritem.h
src/domain/ubgraphicsgroupcontaineritem.h
+32
-0
ubgraphicsgroupcontaineritemdelegate.cpp
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp
+58
-0
ubgraphicsgroupcontaineritemdelegate.h
src/domain/ubgraphicsgroupcontaineritemdelegate.h
+29
-0
No files found.
resources/forms/mainWindow.ui
View file @
9bd20fdb
...
...
@@ -69,6 +69,7 @@
<addaction
name=
"actionForward"
/>
<addaction
name=
"separator"
/>
<addaction
name=
"actionErase"
/>
<addaction
name=
"actionGroupItems"
/>
<addaction
name=
"actionBoard"
/>
<addaction
name=
"actionTutorial"
/>
<addaction
name=
"actionWeb"
/>
...
...
@@ -1633,6 +1634,21 @@
<string>
Import old Sankore or Uniboard documents
</string>
</property>
</action>
<action
name=
"actionGroupItems"
>
<property
name=
"enabled"
>
<bool>
false
</bool>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../sankore.qrc"
>
<normaloff>
:/images/toolbar/library.png
</normaloff>
:/images/toolbar/library.png
</iconset>
</property>
<property
name=
"text"
>
<string>
Gtorup items
</string>
</property>
<property
name=
"toolTip"
>
<string>
Erase Content
</string>
</property>
</action>
</widget>
<resources>
<include
location=
"../sankore.qrc"
/>
...
...
src/board/UBBoardView.cpp
View file @
9bd20fdb
...
...
@@ -440,7 +440,9 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
||
movingItem
->
type
()
==
UBGraphicsPolygonItem
::
Type
||
movingItem
->
type
()
==
UBGraphicsCache
::
Type
||
movingItem
->
type
()
==
UBGraphicsTriangle
::
Type
||
movingItem
==
this
->
scene
()
->
backgroundObject
())
||
movingItem
==
this
->
scene
()
->
backgroundObject
()
||
movingItem
->
group
())
{
movingItem
=
NULL
;
QGraphicsView
::
mousePressEvent
(
event
);
...
...
src/domain/UBGraphicsPolygonItem.cpp
View file @
9bd20fdb
...
...
@@ -185,6 +185,19 @@ void UBGraphicsPolygonItem::paint ( QPainter * painter, const QStyleOptionGraphi
QGraphicsPolygonItem
::
paint
(
painter
,
option
,
widget
);
}
QPainterPath
UBGraphicsPolygonItem
::
shape
()
const
{
QPainterPath
path
;
path
.
addRect
(
boundingRect
());
return
path
;
// static QPainterPath shapePath = QGraphicsPolygonItem::shape();
// return shapePath;
}
UBGraphicsScene
*
UBGraphicsPolygonItem
::
scene
()
{
...
...
src/domain/UBGraphicsPolygonItem.h
View file @
9bd20fdb
...
...
@@ -115,6 +115,8 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
protected
:
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
QPainterPath
shape
()
const
;
private
:
...
...
src/domain/UBGraphicsScene.cpp
View file @
9bd20fdb
...
...
@@ -30,6 +30,7 @@
#include "core/UBPersistenceManager.h"
#include "gui/UBMagnifer.h"
#include "gui/UBMainWindow.h"
#include "tools/UBGraphicsRuler.h"
#include "tools/UBGraphicsProtractor.h"
...
...
@@ -54,6 +55,7 @@
#include "UBGraphicsWidgetItem.h"
#include "UBGraphicsPDFItem.h"
#include "UBGraphicsTextItem.h"
#include "domain/ubgraphicsgroupcontaineritem.h"
#include "UBAppleWidget.h"
#include "UBW3CWidget.h"
...
...
@@ -157,9 +159,6 @@ qreal UBZLayerController::changeZLevelTo(QGraphicsItem *item, moveDestination de
while
(
iCurElement
.
hasNext
()
&&
iCurElement
.
peekNext
().
value
()
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
()
==
nextZ
)
{
UBGraphicsItem
::
assignZValue
(
iCurElement
.
next
().
value
(),
nextZ
);
}
item
->
scene
()
->
clearSelection
();
item
->
setSelected
(
true
);
}
}
...
...
@@ -289,6 +288,9 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
}
connect
(
this
,
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
selectionChangedProcessing
()));
connect
(
this
,
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
enableGroupingButton
()));
connect
(
UBApplication
::
mainWindow
->
actionGroupItems
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
processGroupItems
()));
}
UBGraphicsScene
::~
UBGraphicsScene
()
...
...
@@ -307,6 +309,36 @@ 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
::
enableGroupingButton
()
{
QAction
*
groupAction
=
UBApplication
::
mainWindow
->
actionGroupItems
;
if
(
selectedItems
().
count
()
>
1
)
{
groupAction
->
setEnabled
(
true
);
}
else
{
groupAction
->
setEnabled
(
false
);
}
}
void
UBGraphicsScene
::
processGroupItems
()
{
qDebug
()
<<
"processing grouping items"
;
UBGraphicsGroupContainerItem
*
groupItem
=
new
UBGraphicsGroupContainerItem
();
foreach
(
QGraphicsItem
*
item
,
selectedItems
())
{
item
->
setSelected
(
false
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
false
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
false
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsFocusable
);
groupItem
->
addToGroup
(
item
);
}
addItem
(
groupItem
);
// groupItem->setPos(50, 50);
groupItem
->
setVisible
(
true
);
groupItem
->
setFocus
();
qDebug
()
<<
groupItem
->
boundingRect
();
}
// MARK: -
// MARK: Mouse/Tablet events handling
...
...
@@ -1916,6 +1948,14 @@ void UBGraphicsScene::setOwnZlevel(QGraphicsItem *item)
{
item
->
setZValue
(
item
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
());
}
void
UBGraphicsScene
::
groupItems
(
QList
<
QGraphicsItem
*>
&
itemList
)
{
foreach
(
QGraphicsItem
*
item
,
itemList
)
{
qDebug
()
<<
"selected item found"
;
item
->
setSelected
(
false
);
}
}
qreal
UBGraphicsScene
::
changeZLevelTo
(
QGraphicsItem
*
item
,
UBZLayerController
::
moveDestination
dest
)
{
...
...
src/domain/UBGraphicsScene.h
View file @
9bd20fdb
...
...
@@ -287,6 +287,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void
setSelectedZLevel
(
QGraphicsItem
*
item
);
void
setOwnZlevel
(
QGraphicsItem
*
item
);
void
groupItems
(
QList
<
QGraphicsItem
*>
&
itemList
);
public
slots
:
void
hideEraser
();
...
...
@@ -303,6 +305,8 @@ public slots:
void
setToolCursor
(
int
tool
);
void
selectionChangedProcessing
();
void
enableGroupingButton
();
void
processGroupItems
();
void
moveMagnifier
(
QPoint
newPos
);
void
closeMagnifier
();
...
...
src/domain/domain.pri
View file @
9bd20fdb
...
...
@@ -23,7 +23,9 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBGraphicsAudioItem.h \
src/domain/UBGraphicsAudioItemDelegate.h \
src/domain/UBAbstractUndoCommand.h\
src/domain/UBAngleWidget.h
src/domain/UBAngleWidget.h \
src/domain/ubgraphicsgroupcontaineritem.h \
src/domain/ubgraphicsgroupcontaineritemdelegate.h
HEADERS += src/domain/UBGraphicsItemDelegate.h \
src/domain/UBGraphicsVideoItemDelegate.h \
...
...
@@ -56,7 +58,9 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsAudioItem.cpp \
src/domain/UBGraphicsAudioItemDelegate.cpp \
src/domain/UBAbstractUndoCommand.cpp \
src/domain/UBAngleWidget.cpp
src/domain/UBAngleWidget.cpp \
src/domain/ubgraphicsgroupcontaineritem.cpp \
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp
SOURCES += src/domain/UBGraphicsItemDelegate.cpp \
src/domain/UBGraphicsVideoItemDelegate.cpp \
...
...
src/domain/ubgraphicsgroupcontaineritem.cpp
0 → 100644
View file @
9bd20fdb
#include "ubgraphicsgroupcontaineritem.h"
#include <QtGui>
#include "domain/UBGraphicsItemDelegate.h"
#include "domain/ubgraphicsgroupcontaineritemdelegate.h"
#include "domain/UBGraphicsScene.h"
UBGraphicsGroupContainerItem
::
UBGraphicsGroupContainerItem
(
QGraphicsItem
*
parent
)
:
QGraphicsItemGroup
(
parent
)
{
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
mDelegate
=
new
UBGraphicsGroupContainerItemDelegate
(
this
,
0
);
mDelegate
->
init
();
setFlag
(
QGraphicsItem
::
ItemSendsGeometryChanges
,
true
);
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
UBGraphicsGroupContainerItem
::
setAcceptHoverEvents
(
true
);
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
//Necessary to set if we want z value to be assigned correctly
}
UBGraphicsScene
*
UBGraphicsGroupContainerItem
::
scene
()
{
UBGraphicsScene
*
castScene
=
dynamic_cast
<
UBGraphicsScene
*>
(
scene
());
return
castScene
;
}
UBGraphicsGroupContainerItem
*
UBGraphicsGroupContainerItem
::
deepCopy
()
const
{
UBGraphicsGroupContainerItem
*
copy
=
new
UBGraphicsGroupContainerItem
(
parentItem
());
copy
->
setPos
(
this
->
pos
());
copy
->
setTransform
(
this
->
transform
());
copy
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
copy
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
copy
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
this
->
data
(
UBGraphicsItemData
::
ItemLayerType
));
copy
->
setData
(
UBGraphicsItemData
::
ItemLocked
,
this
->
data
(
UBGraphicsItemData
::
ItemLocked
));
copy
->
setUuid
(
this
->
uuid
());
// this is OK for now as long as Widgets are imutable
// copy->resize(this->size());
return
copy
;
}
void
UBGraphicsGroupContainerItem
::
remove
()
{
if
(
mDelegate
)
mDelegate
->
remove
();
}
void
UBGraphicsGroupContainerItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
(
mDelegate
->
mousePressEvent
(
event
))
{
//NOOP
}
else
{
QGraphicsItemGroup
::
mousePressEvent
(
event
);
setSelected
(
true
);
}
}
void
UBGraphicsGroupContainerItem
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
(
mDelegate
->
mouseMoveEvent
(
event
))
{
// NOOP;
}
else
{
QGraphicsItemGroup
::
mouseMoveEvent
(
event
);
}
}
void
UBGraphicsGroupContainerItem
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
mDelegate
->
mouseReleaseEvent
(
event
);
QGraphicsItemGroup
::
mouseReleaseEvent
(
event
);
}
QVariant
UBGraphicsGroupContainerItem
::
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
)
{
QVariant
newValue
=
mDelegate
->
itemChange
(
change
,
value
);
return
QGraphicsItemGroup
::
itemChange
(
change
,
newValue
);
}
src/domain/ubgraphicsgroupcontaineritem.h
0 → 100644
View file @
9bd20fdb
#ifndef UBGRAPHICSGROUPCONTAINERITEM_H
#define UBGRAPHICSGROUPCONTAINERITEM_H
#include <QGraphicsItem>
#include "domain/UBItem.h"
class
UBGraphicsGroupContainerItem
:
public
QGraphicsItemGroup
,
public
UBItem
,
public
UBGraphicsItem
{
public
:
UBGraphicsGroupContainerItem
(
QGraphicsItem
*
parent
=
0
);
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
UBGraphicsScene
*
scene
();
virtual
UBGraphicsGroupContainerItem
*
deepCopy
()
const
;
virtual
void
remove
();
protected
:
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
QVariant
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
);
private
:
};
#endif // UBGRAPHICSGROUPCONTAINERITEM_H
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp
0 → 100644
View file @
9bd20fdb
#include "ubgraphicsgroupcontaineritemdelegate.h"
#include <QtGui>
#include "UBGraphicsScene.h"
#include "gui/UBResources.h"
#include "domain/UBGraphicsDelegateFrame.h"
#include "domain/ubgraphicsgroupcontaineritem.h"
#include "core/memcheck.h"
#include "board/UBBoardController.h"
UBGraphicsGroupContainerItemDelegate
::
UBGraphicsGroupContainerItemDelegate
(
QGraphicsItem
*
pDelegated
,
QObject
*
parent
)
:
UBGraphicsItemDelegate
(
pDelegated
,
parent
),
mDestroyGroupButton
(
0
)
{
}
UBGraphicsGroupContainerItem
*
UBGraphicsGroupContainerItemDelegate
::
delegated
()
{
return
dynamic_cast
<
UBGraphicsGroupContainerItem
*>
(
mDelegated
);
}
void
UBGraphicsGroupContainerItemDelegate
::
decorateMenu
(
QMenu
*
menu
)
{
mLockAction
=
menu
->
addAction
(
tr
(
"Locked"
),
this
,
SLOT
(
lock
(
bool
)));
QIcon
lockIcon
;
lockIcon
.
addPixmap
(
QPixmap
(
":/images/locked.svg"
),
QIcon
::
Normal
,
QIcon
::
On
);
lockIcon
.
addPixmap
(
QPixmap
(
":/images/unlocked.svg"
),
QIcon
::
Normal
,
QIcon
::
Off
);
mLockAction
->
setIcon
(
lockIcon
);
mLockAction
->
setCheckable
(
true
);
mShowOnDisplayAction
=
mMenu
->
addAction
(
tr
(
"Visible on Extended Screen"
),
this
,
SLOT
(
showHide
(
bool
)));
mShowOnDisplayAction
->
setCheckable
(
true
);
QIcon
showIcon
;
showIcon
.
addPixmap
(
QPixmap
(
":/images/eyeOpened.svg"
),
QIcon
::
Normal
,
QIcon
::
On
);
showIcon
.
addPixmap
(
QPixmap
(
":/images/eyeClosed.svg"
),
QIcon
::
Normal
,
QIcon
::
Off
);
mShowOnDisplayAction
->
setIcon
(
showIcon
);
}
void
UBGraphicsGroupContainerItemDelegate
::
buildButtons
()
{
UBGraphicsItemDelegate
::
buildButtons
();
mDestroyGroupButton
=
new
DelegateButton
(
":/images/font.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
mButtons
<<
mDestroyGroupButton
;
connect
(
mDestroyGroupButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
destroyGroup
()));
}
void
UBGraphicsGroupContainerItemDelegate
::
destroyGroup
()
{
castUBGraphicsScene
()
->
destroyItemGroup
(
delegated
());
}
src/domain/ubgraphicsgroupcontaineritemdelegate.h
0 → 100644
View file @
9bd20fdb
#ifndef UBGRAPHICSGROUPCONTAINERITEMDELEGATE_H
#define UBGRAPHICSGROUPCONTAINERITEMDELEGATE_H
#include "domain/UBGraphicsItemDelegate.h"
class
UBGraphicsGroupContainerItem
;
class
UBGraphicsGroupContainerItemDelegate
:
public
UBGraphicsItemDelegate
{
public
:
UBGraphicsGroupContainerItemDelegate
(
QGraphicsItem
*
pDelegated
,
QObject
*
parent
=
0
);
UBGraphicsGroupContainerItem
*
delegated
();
protected
:
virtual
void
decorateMenu
(
QMenu
*
menu
);
virtual
void
buildButtons
();
private
slots
:
void
destroyGroup
();
private
:
DelegateButton
*
mDestroyGroupButton
;
};
#endif // UBGRAPHICSGROUPCONTAINERITEMDELEGATE_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