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
69fec641
Commit
69fec641
authored
Sep 10, 2012
by
shibakaneki
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into shiba-dev
parents
77aa2783
1a799632
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
260 additions
and
107 deletions
+260
-107
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+1
-1
UBBoardController.cpp
src/board/UBBoardController.cpp
+3
-3
UBFeaturesController.cpp
src/board/UBFeaturesController.cpp
+7
-7
UBPersistenceManager.cpp
src/core/UBPersistenceManager.cpp
+3
-0
UBGraphicsDelegateFrame.cpp
src/domain/UBGraphicsDelegateFrame.cpp
+131
-68
UBGraphicsDelegateFrame.h
src/domain/UBGraphicsDelegateFrame.h
+3
-0
UBGraphicsGroupContainerItem.cpp
src/domain/UBGraphicsGroupContainerItem.cpp
+4
-2
UBGraphicsGroupContainerItem.h
src/domain/UBGraphicsGroupContainerItem.h
+1
-1
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+2
-1
UBGraphicsItemGroupUndoCommand.cpp
src/domain/UBGraphicsItemGroupUndoCommand.cpp
+2
-2
UBGraphicsItemUndoCommand.cpp
src/domain/UBGraphicsItemUndoCommand.cpp
+63
-3
UBGraphicsItemUndoCommand.h
src/domain/UBGraphicsItemUndoCommand.h
+5
-1
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+14
-4
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+1
-1
UBGraphicsStrokesGroup.cpp
src/domain/UBGraphicsStrokesGroup.cpp
+1
-1
UBGraphicsTextItem.cpp
src/domain/UBGraphicsTextItem.cpp
+3
-3
UBItem.cpp
src/domain/UBItem.cpp
+8
-3
UBItem.h
src/domain/UBItem.h
+2
-2
UBTeacherGuideWidget.cpp
src/gui/UBTeacherGuideWidget.cpp
+4
-2
UBWebController.cpp
src/web/UBWebController.cpp
+2
-2
No files found.
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
69fec641
...
...
@@ -1084,7 +1084,7 @@ QGraphicsItem *UBSvgSubsetAdaptor::UBSvgSubsetReader::readElementFromGroup()
{
QGraphicsItem
*
result
=
0
;
result
=
mScene
->
item
By
Uuid
(
QUuid
(
mXmlReader
.
attributes
().
value
(
aId
).
toString
()));
result
=
mScene
->
item
For
Uuid
(
QUuid
(
mXmlReader
.
attributes
().
value
(
aId
).
toString
()));
mXmlReader
.
skipCurrentElement
();
mXmlReader
.
readNext
();
...
...
src/board/UBBoardController.cpp
View file @
69fec641
...
...
@@ -645,7 +645,7 @@ void UBBoardController::duplicateItem(UBItem *item)
{
mActiveScene
->
addItem
(
gitem
);
gitem
->
setPos
(
itemPos
);
mLastCreatedItem
=
gitem
;
mLastCreatedItem
=
gitem
;
gitem
->
setSelected
(
true
);
}
return
;
...
...
@@ -1132,7 +1132,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
QString
destFile
;
bool
b
=
UBPersistenceManager
::
persistenceManager
()
->
addFileToDocument
(
selectedDocument
(),
""
,
sourceUrl
.
toString
(),
UBPersistenceManager
::
videoDirectory
,
uuid
,
destFile
,
...
...
@@ -1175,7 +1175,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
QString
destFile
;
bool
b
=
UBPersistenceManager
::
persistenceManager
()
->
addFileToDocument
(
selectedDocument
(),
""
,
sourceUrl
.
toString
(),
UBPersistenceManager
::
audioDirectory
,
uuid
,
destFile
,
...
...
src/board/UBFeaturesController.cpp
View file @
69fec641
...
...
@@ -144,7 +144,7 @@ void UBFeaturesComputingThread::compute(const QList<QPair<QUrl, UBFeature> > &pS
void
UBFeaturesComputingThread
::
run
()
{
forever
{
qDebug
()
<<
"Custom thread started execution"
;
//
qDebug() << "Custom thread started execution";
mMutex
.
lock
();
QList
<
QPair
<
QUrl
,
UBFeature
>
>
searchData
=
mScanningData
;
...
...
@@ -158,17 +158,17 @@ void UBFeaturesComputingThread::run()
break
;
}
QTime
curTime
=
QTime
::
currentTime
();
//
QTime curTime = QTime::currentTime();
int
fsCnt
=
featuresCountAll
(
searchData
);
int
msecsto
=
curTime
.
msecsTo
(
QTime
::
currentTime
());
qDebug
()
<<
"time on evaluation"
<<
msecsto
;
//
int msecsto = curTime.msecsTo(QTime::currentTime());
//
qDebug() << "time on evaluation" << msecsto;
emit
maxFilesCountEvaluated
(
fsCnt
);
emit
scanStarted
();
curTime
=
QTime
::
currentTime
();
//
curTime = QTime::currentTime();
scanAll
(
searchData
,
favoriteSet
);
qDebug
()
<<
"Time on finishing"
<<
curTime
.
msecsTo
(
QTime
::
currentTime
());
//
qDebug() << "Time on finishing" << curTime.msecsTo(QTime::currentTime());
emit
scanFinished
();
mMutex
.
lock
();
...
...
@@ -183,7 +183,7 @@ void UBFeaturesComputingThread::run()
UBFeaturesComputingThread
::~
UBFeaturesComputingThread
()
{
qDebug
()
<<
"thread destructor catched"
;
//
qDebug() << "thread destructor catched";
mMutex
.
lock
();
abort
=
true
;
...
...
src/core/UBPersistenceManager.cpp
View file @
69fec641
...
...
@@ -913,6 +913,7 @@ bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy,
QString
&
destinationPath
,
QByteArray
*
data
)
{
Q_ASSERT
(
path
.
length
());
QFileInfo
fi
(
path
);
if
(
!
pDocumentProxy
||
objectUuid
.
isNull
())
...
...
@@ -920,6 +921,8 @@ bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy,
if
(
data
==
NULL
&&
!
fi
.
exists
())
return
false
;
qDebug
()
<<
fi
.
suffix
();
QString
fileName
=
subdir
+
"/"
+
objectUuid
.
toString
()
+
"."
+
fi
.
suffix
();
destinationPath
=
pDocumentProxy
->
persistencePath
()
+
"/"
+
fileName
;
...
...
src/domain/UBGraphicsDelegateFrame.cpp
View file @
69fec641
...
...
@@ -286,18 +286,111 @@ bool UBGraphicsDelegateFrame::canResizeBottomRight(qreal width, qreal height, qr
return
res
;
}
QPointF
UBGraphicsDelegateFrame
::
getFixedPointFromPos
()
{
QPointF
fixedPoint
;
if
(
!
moving
()
&&
!
rotating
())
{
if
(
resizingTop
())
{
if
(
mMirrorX
&&
mMirrorY
)
{
if
((
0
<
mAngle
)
&&
(
mAngle
<
90
))
fixedPoint
=
delegated
()
->
sceneBoundingRect
().
topLeft
();
else
fixedPoint
=
delegated
()
->
sceneBoundingRect
().
topRight
();
}
else
{
if
((
0
<
mAngle
)
&&
(
mAngle
<=
90
))
fixedPoint
=
delegated
()
->
sceneBoundingRect
().
bottomRight
();
else
fixedPoint
=
delegated
()
->
sceneBoundingRect
().
bottomLeft
();
}
}
else
if
(
resizingLeft
())
{
if
(
mMirrorX
&&
mMirrorY
)
{
if
((
0
<
mAngle
)
&&
(
mAngle
<
90
))
fixedPoint
=
delegated
()
->
sceneBoundingRect
().
bottomLeft
();
else
fixedPoint
=
delegated
()
->
sceneBoundingRect
().
topLeft
();
}
else
{
if
((
0
<
mAngle
)
&&
(
mAngle
<=
90
))
fixedPoint
=
delegated
()
->
sceneBoundingRect
().
topRight
();
else
fixedPoint
=
delegated
()
->
sceneBoundingRect
().
bottomRight
();
}
}
}
return
fixedPoint
;
}
QSizeF
UBGraphicsDelegateFrame
::
getResizeVector
(
qreal
moveX
,
qreal
moveY
)
{
qreal
dPosX
=
0
;
qreal
dPosY
=
0
;
if
(
resizingTop
())
{
if
(
mMirrorX
&&
mMirrorY
)
dPosY
=
moveY
;
else
dPosY
=
-
moveY
;
}
else
if
(
resizingLeft
())
{
if
(
mMirrorX
&&
mMirrorY
)
dPosX
=
moveX
;
else
dPosX
=
-
moveX
;
}
else
if
(
resizingRight
())
dPosX
=
(
mMirrorX
)
?
-
moveX
:
moveX
;
else
if
(
resizingBottom
())
dPosY
=
mMirrorY
?
-
moveY
:
moveY
;
return
QSizeF
(
dPosX
,
dPosY
);
}
void
UBGraphicsDelegateFrame
::
resizeDelegate
(
qreal
moveX
,
qreal
moveY
)
{
QPointF
fixedPoint
=
getFixedPointFromPos
();
UBResizableGraphicsItem
*
resizableItem
=
dynamic_cast
<
UBResizableGraphicsItem
*>
(
delegated
());
if
(
resizableItem
)
{
QSizeF
originalSize
=
delegated
()
->
boundingRect
().
size
();
resizableItem
->
resize
(
originalSize
+
getResizeVector
(
moveX
,
moveY
));
if
(
resizingTop
()
||
resizingLeft
()
||
((
mMirrorX
||
mMirrorY
)
&&
resizingBottomRight
()))
{
delegated
()
->
setPos
(
delegated
()
->
pos
()
-
getFixedPointFromPos
()
+
fixedPoint
);
}
}
}
void
UBGraphicsDelegateFrame
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
(
None
==
mCurrentTool
)
return
;
QLineF
move
(
mStartingPoint
,
event
->
scenePos
());
QLineF
move
;
if
(
rotating
()
||
moving
()
||
mOperationMode
==
Scaling
)
move
=
QLineF
(
mStartingPoint
,
event
->
scenePos
());
else
move
=
QLineF
(
event
->
lastScenePos
(),
event
->
scenePos
());
qreal
moveX
=
move
.
length
()
*
cos
((
move
.
angle
()
-
mAngle
)
*
PI
/
180
);
qreal
moveY
=
-
move
.
length
()
*
sin
((
move
.
angle
()
-
mAngle
)
*
PI
/
180
);
qreal
width
=
delegated
()
->
boundingRect
().
width
()
*
mTotalScaleX
;
qreal
height
=
delegated
()
->
boundingRect
().
height
()
*
mTotalScaleY
;
if
(
mOperationMode
==
Scaling
)
if
(
!
rotating
()
)
{
mTranslateX
=
moveX
;
// Perform the resize
...
...
@@ -398,44 +491,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
}
}
else
if
(
mOperationMode
==
Resizing
||
mOperationMode
==
ResizingHorizontally
)
{
mTranslateX
=
moveX
;
UBResizableGraphicsItem
*
resizableItem
=
dynamic_cast
<
UBResizableGraphicsItem
*>
(
delegated
());
if
(
resizableItem
)
{
QLineF
mousePosDelta
(
delegated
()
->
mapFromScene
(
event
->
lastScenePos
())
,
delegated
()
->
mapFromScene
(
event
->
scenePos
()));
QSizeF
incVector
(
0
,
0
);
if
(
resizingBottomRight
())
{
incVector
=
QSizeF
(
mousePosDelta
.
dx
(),
mousePosDelta
.
dy
());
}
else
if
(
resizingRight
())
{
incVector
=
QSizeF
(
mousePosDelta
.
dx
(),
0
);
}
else
if
(
resizingBottom
())
{
incVector
=
QSizeF
(
0
,
mousePosDelta
.
dy
());
}
else
if
(
resizingLeft
())
{
incVector
=
QSizeF
(
-
mousePosDelta
.
dx
(),
0
);
}
else
if
(
resizingTop
())
{
incVector
=
QSizeF
(
0
,
-
mousePosDelta
.
dy
());
}
QSizeF
newSize
=
resizableItem
->
size
()
+
incVector
;
resizableItem
->
resize
(
newSize
);
}
}
if
(
rotating
())
{
mTranslateX
=
0
;
...
...
@@ -483,49 +539,56 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
// we just detects coordinates of corner before and after scaling and then moves object at diff between them.
if
(
resizingBottomRight
()
&&
mMirrorX
)
{
mTranslateX
+=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
bottomRight
()).
x
()
-
tr
.
map
(
delegated
()
->
boundingRect
().
bottomRight
()).
x
();
else
mTranslateX
+=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
topLeft
()).
x
()
-
tr
.
map
(
delegated
()
->
boundingRect
().
topLeft
()).
x
();
if
(
resizingBottomRight
()
&&
mMirrorY
)
mTranslateY
+=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
bottomRight
()).
y
()
-
tr
.
map
(
delegated
()
->
boundingRect
().
bottomRight
()).
y
();
}
else
{
mTranslateX
+=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
topLeft
()).
x
()
-
tr
.
map
(
delegated
()
->
boundingRect
().
topLeft
()).
x
();
mTranslateY
+=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
topLeft
()).
y
()
-
tr
.
map
(
delegated
()
->
boundingRect
().
topLeft
()).
y
();
}
}
else
if
(
resizingTop
()
||
resizingLeft
())
{
QPointF
bottomRight
=
tr
.
map
(
delegated
()
->
boundingRect
().
bottomRight
());
QPointF
fixedPoint
=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
bottomRight
());
mTranslateX
+=
fixedPoint
.
x
()
-
bottomRight
.
x
();
mTranslateY
+=
fixedPoint
.
y
()
-
bottomRight
.
y
();
}
// Update the transform
if
(
mOperationMode
==
Scaling
||
moving
()
||
rotating
())
{
tr
=
buildTransform
();
delegated
()
->
setTransform
(
tr
);
}
else
if
(
resizingTop
()
||
resizingLeft
()
)
else
if
(
mOperationMode
==
Resizing
)
{
if
(
mOperationMode
==
Scaling
)
if
(
!
moving
()
&&
!
rotating
()
)
{
QPointF
bottomRight
=
tr
.
map
(
delegated
()
->
boundingRect
().
bottomRight
());
QPointF
fixedPoint
=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
bottomRight
());
mTranslateX
+=
fixedPoint
.
x
()
-
bottomRight
.
x
();
mTranslateY
+=
fixedPoint
.
y
()
-
bottomRight
.
y
();
}
else
{
QLineF
vector
;
if
(
resizingLeft
())
if
(
resizingBottomRight
())
{
QPointF
topRight1
=
mInitialTransform
.
map
(
QPointF
(
delegated
()
->
boundingRect
().
width
()
-
moveX
,
0
));
QPointF
topRight2
=
mInitialTransform
.
map
(
QPointF
(
delegated
()
->
boundingRect
().
width
(),
0
));
vector
.
setPoints
(
topRight1
,
topRight2
);
if
(
mMirrorX
&&
mMirrorY
)
mCurrentTool
=
ResizeTop
;
else
mCurrentTool
=
ResizeBottom
;
resizeDelegate
(
moveX
,
moveY
);
if
(
mMirrorX
&&
mMirrorY
)
mCurrentTool
=
ResizeLeft
;
else
mCurrentTool
=
ResizeRight
;
resizeDelegate
(
moveX
,
moveY
);
mCurrentTool
=
ResizeBottomRight
;
}
else
{
QPointF
bottomLeft1
=
mInitialTransform
.
map
(
QPointF
(
0
,
delegated
()
->
boundingRect
().
height
()
-
moveY
));
QPointF
bottomLeft2
=
mInitialTransform
.
map
(
QPointF
(
0
,
delegated
()
->
boundingRect
().
height
()));
vector
.
setPoints
(
bottomLeft1
,
bottomLeft2
);
}
mTranslateX
=
vector
.
dx
();
mTranslateY
=
vector
.
dy
();
resizeDelegate
(
moveX
,
moveY
);
}
tr
=
buildTransform
();
}
delegated
()
->
setTransform
(
tr
);
event
->
accept
();
}
...
...
src/domain/UBGraphicsDelegateFrame.h
View file @
69fec641
...
...
@@ -37,6 +37,9 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
QPainterPath
shape
()
const
;
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
QPointF
getFixedPointFromPos
();
QSizeF
getResizeVector
(
qreal
moveX
,
qreal
moveY
);
void
resizeDelegate
(
qreal
moveX
,
qreal
moveY
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
...
src/domain/UBGraphicsGroupContainerItem.cpp
View file @
69fec641
...
...
@@ -123,6 +123,8 @@ void UBGraphicsGroupContainerItem::removeFromGroup(QGraphicsItem *item)
pRemoveFromGroup
(
item
);
item
->
setFlags
(
ItemIsSelectable
|
ItemIsFocusable
);
}
void
UBGraphicsGroupContainerItem
::
deselectCurrentItem
()
...
...
@@ -211,7 +213,7 @@ void UBGraphicsGroupContainerItem::setUuid(const QUuid &pUuid)
setData
(
UBGraphicsItemData
::
ItemUuid
,
QVariant
(
pUuid
));
//store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
void
UBGraphicsGroupContainerItem
::
destroy
()
{
void
UBGraphicsGroupContainerItem
::
destroy
(
bool
canUndo
)
{
foreach
(
QGraphicsItem
*
item
,
childItems
())
{
pRemoveFromGroup
(
item
);
...
...
@@ -219,7 +221,7 @@ void UBGraphicsGroupContainerItem::destroy() {
item
->
setFlag
(
QGraphicsItem
::
ItemIsFocusable
,
true
);
}
remove
();
remove
(
canUndo
);
}
void
UBGraphicsGroupContainerItem
::
clearSource
()
...
...
src/domain/UBGraphicsGroupContainerItem.h
View file @
69fec641
...
...
@@ -34,7 +34,7 @@ public:
}
virtual
void
setUuid
(
const
QUuid
&
pUuid
);
void
destroy
();
void
destroy
(
bool
canUndo
=
true
);
virtual
void
clearSource
();
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
69fec641
...
...
@@ -166,7 +166,8 @@ void UBGraphicsItemDelegate::init()
UBGraphicsItemDelegate
::~
UBGraphicsItemDelegate
()
{
disconnect
(
UBApplication
::
boardController
,
SIGNAL
(
zoomChanged
(
qreal
)),
this
,
SLOT
(
onZoomChanged
()));
if
(
UBApplication
::
boardController
)
disconnect
(
UBApplication
::
boardController
,
SIGNAL
(
zoomChanged
(
qreal
)),
this
,
SLOT
(
onZoomChanged
()));
// do not release mMimeData.
// the mMimeData is owned by QDrag since the setMimeData call as specified in the documentation
}
...
...
src/domain/UBGraphicsItemGroupUndoCommand.cpp
View file @
69fec641
...
...
@@ -22,7 +22,7 @@ UBGraphicsItemGroupUndoCommand::~UBGraphicsItemGroupUndoCommand()
void
UBGraphicsItemGroupUndoCommand
::
undo
()
{
mGroup
->
destroy
();
mGroup
->
destroy
(
false
);
foreach
(
QGraphicsItem
*
item
,
mItems
)
{
item
->
setSelected
(
true
);
}
...
...
@@ -41,7 +41,7 @@ void UBGraphicsItemGroupUndoCommand::redo()
QList
<
QGraphicsItem
*>
childItems
=
item
->
childItems
();
UBGraphicsGroupContainerItem
*
currentGroup
=
dynamic_cast
<
UBGraphicsGroupContainerItem
*>
(
item
);
if
(
currentGroup
)
{
currentGroup
->
destroy
();
currentGroup
->
destroy
(
false
);
}
foreach
(
QGraphicsItem
*
chItem
,
childItems
)
{
mGroup
->
addToGroup
(
chItem
);
...
...
src/domain/UBGraphicsItemUndoCommand.cpp
View file @
69fec641
...
...
@@ -27,10 +27,11 @@
#include "domain/UBGraphicsGroupContainerItem.h"
UBGraphicsItemUndoCommand
::
UBGraphicsItemUndoCommand
(
UBGraphicsScene
*
pScene
,
const
QSet
<
QGraphicsItem
*>&
pRemovedItems
,
const
QSet
<
QGraphicsItem
*>&
pAddedItems
)
const
QSet
<
QGraphicsItem
*>&
pAddedItems
,
const
GroupDataTable
&
groupsMap
)
:
mScene
(
pScene
)
,
mRemovedItems
(
pRemovedItems
-
pAddedItems
)
,
mAddedItems
(
pAddedItems
-
pRemovedItems
)
,
mRemovedItems
(
pRemovedItems
-
pAddedItems
)
,
mAddedItems
(
pAddedItems
-
pRemovedItems
)
,
mExcludedFromGroup
(
groupsMap
)
{
mFirstRedo
=
true
;
...
...
@@ -110,6 +111,36 @@ void UBGraphicsItemUndoCommand::undo()
}
}
QMapIterator
<
UBGraphicsGroupContainerItem
*
,
QUuid
>
curMapElement
(
mExcludedFromGroup
);
UBGraphicsGroupContainerItem
*
nextGroup
=
0
;
UBGraphicsGroupContainerItem
*
previousGroupItem
;
bool
groupChanged
=
false
;
while
(
curMapElement
.
hasNext
())
{
curMapElement
.
next
();
groupChanged
=
previousGroupItem
!=
curMapElement
.
key
();
//trying to find the group on the scene;
if
(
!
nextGroup
||
groupChanged
)
{
UBGraphicsGroupContainerItem
*
groupCandidate
=
curMapElement
.
key
();
if
(
groupCandidate
)
{
nextGroup
=
groupCandidate
;
if
(
!
mScene
->
items
().
contains
(
nextGroup
))
{
mScene
->
addItem
(
nextGroup
);
}
nextGroup
->
setVisible
(
true
);
}
}
QGraphicsItem
*
groupedItem
=
mScene
->
itemForUuid
(
curMapElement
.
value
());
if
(
groupedItem
)
{
nextGroup
->
addToGroup
(
groupedItem
);
}
previousGroupItem
=
curMapElement
.
key
();
UBGraphicsItem
::
Delegate
(
nextGroup
)
->
update
();
}
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
mScene
->
update
(
mScene
->
sceneRect
());
...
...
@@ -125,6 +156,35 @@ void UBGraphicsItemUndoCommand::redo()
return
;
}
QMapIterator
<
UBGraphicsGroupContainerItem
*
,
QUuid
>
curMapElement
(
mExcludedFromGroup
);
UBGraphicsGroupContainerItem
*
nextGroup
=
0
;
UBGraphicsGroupContainerItem
*
previousGroupItem
;
bool
groupChanged
=
false
;
while
(
curMapElement
.
hasNext
())
{
curMapElement
.
next
();
groupChanged
=
previousGroupItem
!=
curMapElement
.
key
();
//trying to find the group on the scene;
if
(
!
nextGroup
||
groupChanged
)
{
UBGraphicsGroupContainerItem
*
groupCandidate
=
curMapElement
.
key
();
if
(
groupCandidate
)
{
nextGroup
=
groupCandidate
;
}
}
QGraphicsItem
*
groupedItem
=
mScene
->
itemForUuid
(
curMapElement
.
value
());
if
(
groupedItem
)
{
if
(
nextGroup
->
childItems
().
count
()
==
1
)
{
nextGroup
->
destroy
(
false
);
break
;
}
nextGroup
->
removeFromGroup
(
groupedItem
);
}
previousGroupItem
=
curMapElement
.
key
();
UBGraphicsItem
::
Delegate
(
nextGroup
)
->
update
();
}
QSetIterator
<
QGraphicsItem
*>
itRemoved
(
mRemovedItems
);
while
(
itRemoved
.
hasNext
())
{
...
...
src/domain/UBGraphicsItemUndoCommand.h
View file @
69fec641
...
...
@@ -18,6 +18,7 @@
#include <QtGui>
#include "UBAbstractUndoCommand.h"
#include "UBGraphicsGroupContainerItem.h"
class
UBGraphicsScene
;
...
...
@@ -26,8 +27,10 @@ class UBGraphicsScene;
class
UBGraphicsItemUndoCommand
:
public
UBAbstractUndoCommand
{
public
:
typedef
QMultiMap
<
UBGraphicsGroupContainerItem
*
,
QUuid
>
GroupDataTable
;
UBGraphicsItemUndoCommand
(
UBGraphicsScene
*
pScene
,
const
QSet
<
QGraphicsItem
*>&
pRemovedItems
,
const
QSet
<
QGraphicsItem
*>&
pAddedItems
);
const
QSet
<
QGraphicsItem
*>&
pAddedItems
,
const
GroupDataTable
&
groupsMap
=
GroupDataTable
()
);
UBGraphicsItemUndoCommand
(
UBGraphicsScene
*
pScene
,
QGraphicsItem
*
pRemovedItem
,
QGraphicsItem
*
pAddedItem
);
...
...
@@ -47,6 +50,7 @@ class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand
UBGraphicsScene
*
mScene
;
QSet
<
QGraphicsItem
*>
mRemovedItems
;
QSet
<
QGraphicsItem
*>
mAddedItems
;
GroupDataTable
mExcludedFromGroup
;
bool
mFirstRedo
;
};
...
...
src/domain/UBGraphicsScene.cpp
View file @
69fec641
...
...
@@ -1067,6 +1067,7 @@ UBItem* UBGraphicsScene::deepCopy() const
void
UBGraphicsScene
::
clearContent
(
clearCase
pCase
)
{
QSet
<
QGraphicsItem
*>
removedItems
;
UBGraphicsItemUndoCommand
::
GroupDataTable
groupsMap
;
switch
(
pCase
)
{
case
clearBackground
:
...
...
@@ -1106,8 +1107,14 @@ void UBGraphicsScene::clearContent(clearCase pCase)
if
(
shouldDelete
)
{
if
(
itemGroup
)
{
itemGroup
->
removeFromGroup
(
item
);
groupsMap
.
insert
(
itemGroup
,
UBGraphicsItem
::
getOwnUuid
(
item
));
if
(
itemGroup
->
childItems
().
count
()
==
1
)
{
itemGroup
->
destroy
();
groupsMap
.
insert
(
itemGroup
,
UBGraphicsItem
::
getOwnUuid
(
itemGroup
->
childItems
().
first
()));
QGraphicsItem
*
lastItem
=
itemGroup
->
childItems
().
first
();
bool
isSelected
=
itemGroup
->
isSelected
();
itemGroup
->
destroy
(
false
);
lastItem
->
setSelected
(
isSelected
);
}
itemGroup
->
Delegate
()
->
update
();
}
...
...
@@ -1123,7 +1130,8 @@ void UBGraphicsScene::clearContent(clearCase pCase)
update
(
sceneRect
());
if
(
enableUndoRedoStack
)
{
//should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand
*
uc
=
new
UBGraphicsItemUndoCommand
(
this
,
removedItems
,
QSet
<
QGraphicsItem
*>
());
UBGraphicsItemUndoCommand
*
uc
=
new
UBGraphicsItemUndoCommand
(
this
,
removedItems
,
QSet
<
QGraphicsItem
*>
(),
groupsMap
);
UBApplication
::
undoStack
->
push
(
uc
);
}
...
...
@@ -1442,6 +1450,7 @@ UBGraphicsTextItem* UBGraphicsScene::textForObjectName(const QString& pString, c
textItem
->
setObjectName
(
objectName
);
QSizeF
size
=
textItem
->
size
();
textItem
->
setPos
(
QPointF
(
-
size
.
width
()
/
2.0
,
-
size
.
height
()
/
2.0
));
textItem
->
setData
(
UBGraphicsItemData
::
ItemEditable
,
QVariant
(
false
));
}
textItem
->
setPlainText
(
pString
);
...
...
@@ -1571,8 +1580,9 @@ void UBGraphicsScene::removeItem(QGraphicsItem* item)
void
UBGraphicsScene
::
removeItems
(
const
QSet
<
QGraphicsItem
*>&
items
)
{
foreach
(
QGraphicsItem
*
item
,
items
)
foreach
(
QGraphicsItem
*
item
,
items
)
{
UBCoreGraphicsScene
::
removeItem
(
item
);
}
mItemCount
-=
items
.
size
();
...
...
@@ -1665,7 +1675,7 @@ QRectF UBGraphicsScene::normalizedSceneRect(qreal ratio)
return
normalizedRect
;
}
QGraphicsItem
*
UBGraphicsScene
::
item
By
Uuid
(
QUuid
uuid
)
QGraphicsItem
*
UBGraphicsScene
::
item
For
Uuid
(
QUuid
uuid
)
{
QGraphicsItem
*
result
=
0
;
...
...
src/domain/UBGraphicsScene.h
View file @
69fec641
...
...
@@ -174,7 +174,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
QRectF
normalizedSceneRect
(
qreal
ratio
=
-
1
.
0
);
QGraphicsItem
*
item
By
Uuid
(
QUuid
uuid
);
QGraphicsItem
*
item
For
Uuid
(
QUuid
uuid
);
void
moveTo
(
const
QPointF
&
pPoint
);
void
drawLineTo
(
const
QPointF
&
pEndPoint
,
const
qreal
&
pWidth
,
bool
bLineStyle
);
...
...
src/domain/UBGraphicsStrokesGroup.cpp
View file @
69fec641
...
...
@@ -5,7 +5,7 @@
#include "core/memcheck.h"
UBGraphicsStrokesGroup
::
UBGraphicsStrokesGroup
(
QGraphicsItem
*
parent
)
:
UBGraphicsItem
(),
QGraphicsItemGroup
(
parent
)
:
QGraphicsItemGroup
(
parent
),
UBGraphicsItem
(
)
{
setDelegate
(
new
UBGraphicsItemDelegate
(
this
,
0
,
true
,
true
,
false
));
Delegate
()
->
init
();
...
...
src/domain/UBGraphicsTextItem.cpp
View file @
69fec641
...
...
@@ -30,9 +30,9 @@
QColor
UBGraphicsTextItem
::
lastUsedTextColor
;
UBGraphicsTextItem
::
UBGraphicsTextItem
(
QGraphicsItem
*
parent
)
:
UBGraphicsItem
(
)
,
QGraphicsTextItem
(
parent
)
UBGraphicsTextItem
::
UBGraphicsTextItem
(
QGraphicsItem
*
parent
)
:
QGraphicsTextItem
(
parent
)
,
UBGraphicsItem
(
)
,
mMultiClickState
(
0
)
,
mLastMousePressTime
(
QTime
::
currentTime
())
{
...
...
src/domain/UBItem.cpp
View file @
69fec641
...
...
@@ -66,12 +66,17 @@ bool UBGraphicsItem::isRotatable(QGraphicsItem *item)
return
item
->
data
(
UBGraphicsItemData
::
ItemRotatable
).
toBool
();
}
void
UBGraphicsItem
::
remove
(
)
QUuid
UBGraphicsItem
::
getOwnUuid
(
QGraphicsItem
*
item
)
{
if
(
Delegate
())
Delegate
()
->
remove
(
this
);
QString
idCandidate
=
item
->
data
(
UBGraphicsItemData
::
ItemUuid
).
toString
();
return
idCandidate
==
QUuid
().
toString
()
?
QUuid
()
:
QUuid
(
idCandidate
);
}
void
UBGraphicsItem
::
remove
(
bool
canUndo
)
{
if
(
Delegate
())
Delegate
()
->
remove
(
canUndo
);
}
UBGraphicsItemDelegate
*
UBGraphicsItem
::
Delegate
(
QGraphicsItem
*
pItem
)
{
...
...
src/domain/UBItem.h
View file @
69fec641
...
...
@@ -104,11 +104,11 @@ public:
static
void
assignZValue
(
QGraphicsItem
*
,
qreal
value
);
static
bool
isRotatable
(
QGraphicsItem
*
item
);
static
bool
isFlippable
(
QGraphicsItem
*
item
);
static
QUuid
getOwnUuid
(
QGraphicsItem
*
item
);
static
UBGraphicsItemDelegate
*
Delegate
(
QGraphicsItem
*
pItem
);
void
remove
();
void
remove
(
bool
canUndo
=
true
);
virtual
void
clearSource
(){}
...
...
src/gui/UBTeacherGuideWidget.cpp
View file @
69fec641
...
...
@@ -163,7 +163,8 @@ UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget()
void
UBTeacherGuideEditionWidget
::
onSliderMoved
(
int
size
)
{
Q_UNUSED
(
size
);
mpAddAMediaItem
->
setExpanded
(
true
);
if
(
mpAddAMediaItem
)
mpAddAMediaItem
->
setExpanded
(
true
);
}
#endif
void
UBTeacherGuideEditionWidget
::
showEvent
(
QShowEvent
*
event
)
...
...
@@ -491,7 +492,8 @@ UBTeacherGuidePresentationWidget::~UBTeacherGuidePresentationWidget()
void
UBTeacherGuidePresentationWidget
::
onSliderMoved
(
int
size
)
{
Q_UNUSED
(
size
);
mpMediaSwitchItem
->
setExpanded
(
true
);
if
(
mpMediaSwitchItem
)
mpMediaSwitchItem
->
setExpanded
(
true
);
}
#endif
...
...
src/web/UBWebController.cpp
View file @
69fec641
...
...
@@ -733,8 +733,8 @@ bool UBWebController::isEduMedia(const QUrl& pUrl)
void
UBWebController
::
loadUrl
(
const
QUrl
&
url
)
{
bool
webBrowserAlreadyInstanciated
=
dynamic_cast
<
WBBrowserWindow
*>
(
mStackedWidget
->
widget
(
WebBrowser
))
!=
NULL
;
UBApplication
::
applicationController
->
showInternet
();
bool
webBrowserAlreadyInstanciated
=
dynamic_cast
<
WBBrowserWindow
*>
(
mStackedWidget
->
widget
(
WebBrowser
))
!=
NULL
;
UBApplication
::
applicationController
->
showInternet
();
if
(
UBSettings
::
settings
()
->
webUseExternalBrowser
->
get
().
toBool
())
{
QDesktopServices
::
openUrl
(
url
);
...
...
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