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
7acbcaab
Commit
7acbcaab
authored
Aug 22, 2012
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:Sankore/Sankore-3.1
parents
474e71a0
97c2f6f7
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
234 additions
and
19 deletions
+234
-19
UBBoardController.cpp
src/board/UBBoardController.cpp
+7
-6
UBBoardView.cpp
src/board/UBBoardView.cpp
+11
-1
UBBoardView.h
src/board/UBBoardView.h
+2
-0
UBDocumentManager.cpp
src/core/UBDocumentManager.cpp
+0
-2
UBAbstractUndoCommand.h
src/domain/UBAbstractUndoCommand.h
+2
-1
UBGraphicsDelegateFrame.cpp
src/domain/UBGraphicsDelegateFrame.cpp
+69
-0
UBGraphicsDelegateFrame.h
src/domain/UBGraphicsDelegateFrame.h
+6
-0
UBGraphicsItemGroupUndoCommand.cpp
src/domain/UBGraphicsItemGroupUndoCommand.cpp
+58
-0
UBGraphicsItemGroupUndoCommand.h
src/domain/UBGraphicsItemGroupUndoCommand.h
+30
-0
UBGraphicsItemTransformUndoCommand.h
src/domain/UBGraphicsItemTransformUndoCommand.h
+1
-1
UBGraphicsItemUndoCommand.cpp
src/domain/UBGraphicsItemUndoCommand.cpp
+9
-0
UBGraphicsItemUndoCommand.h
src/domain/UBGraphicsItemUndoCommand.h
+3
-3
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+2
-1
UBGraphicsStrokesGroup.cpp
src/domain/UBGraphicsStrokesGroup.cpp
+20
-0
UBGraphicsStrokesGroup.h
src/domain/UBGraphicsStrokesGroup.h
+3
-0
domain.pri
src/domain/domain.pri
+4
-2
UBDocumentNavigator.cpp
src/gui/UBDocumentNavigator.cpp
+1
-2
UBFeaturesWidget.cpp
src/gui/UBFeaturesWidget.cpp
+6
-0
No files found.
src/board/UBBoardController.cpp
View file @
7acbcaab
...
...
@@ -624,7 +624,7 @@ void UBBoardController::duplicateItem(UBItem *item)
void
UBBoardController
::
deleteScene
(
int
nIndex
)
{
if
(
selectedDocument
()
->
pageCount
()
>
2
)
if
(
selectedDocument
()
->
pageCount
()
>
=
2
)
{
QApplication
::
setOverrideCursor
(
QCursor
(
Qt
::
WaitCursor
));
persistCurrentScene
();
...
...
@@ -1466,12 +1466,13 @@ void UBBoardController::ClearUndoStack()
while
(
itUniq
.
hasNext
())
{
QGraphicsItem
*
item
=
itUniq
.
next
();
UBGraphicsScene
*
scene
=
NULL
;
if
(
item
->
scene
())
{
UBGraphicsScene
*
scene
=
dynamic_cast
<
UBGraphicsScene
*>
(
item
->
scene
());
if
(
!
scene
)
{
mActiveScene
->
deleteItem
(
item
);
}
scene
=
dynamic_cast
<
UBGraphicsScene
*>
(
item
->
scene
());
}
if
(
!
scene
)
{
mActiveScene
->
deleteItem
(
item
);
}
}
...
...
src/board/UBBoardView.cpp
View file @
7acbcaab
...
...
@@ -596,7 +596,7 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event)
mLastPressedMousePos
=
mapToScene
(
event
->
pos
());
if
(
movingItem
&&
QGraphicsSvgItem
::
Type
!=
movingItem
->
type
()
if
(
movingItem
&&
!
hasSelectedParents
(
movingItem
)
&&
QGraphicsSvgItem
::
Type
!=
movingItem
->
type
()
&&
UBGraphicsDelegateFrame
::
Type
!=
movingItem
->
type
()
&&
!
mMultipleSelectionIsEnabled
)
{
...
...
@@ -1405,3 +1405,13 @@ UBBoardView::setToolCursor (int tool)
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
penCursor
);
}
}
bool
UBBoardView
::
hasSelectedParents
(
QGraphicsItem
*
item
)
{
if
(
item
->
isSelected
())
return
true
;
if
(
item
->
parentItem
()
==
NULL
)
return
false
;
return
hasSelectedParents
(
item
->
parentItem
());
}
src/board/UBBoardView.h
View file @
7acbcaab
...
...
@@ -148,6 +148,8 @@ class UBBoardView : public QGraphicsView
bool
mIsDragInProgress
;
bool
mMultipleSelectionIsEnabled
;
static
bool
hasSelectedParents
(
QGraphicsItem
*
item
);
private
slots
:
void
settingChanged
(
QVariant
newValue
);
...
...
src/core/UBDocumentManager.cpp
View file @
7acbcaab
...
...
@@ -236,8 +236,6 @@ int UBDocumentManager::addFilesToDocument(UBDocumentProxy* document, QStringList
UBGraphicsScene
*
scene
=
UBPersistenceManager
::
persistenceManager
()
->
createDocumentSceneAt
(
document
,
pageIndex
);
importAdaptor
->
placeImportedItemToScene
(
scene
,
page
);
UBPersistenceManager
::
persistenceManager
()
->
persistDocumentScene
(
document
,
scene
,
pageIndex
);
// TODO: Add an empty pixmap for the thumbnail here
UBApplication
::
boardController
->
addEmptyThumbPage
();
}
...
...
src/domain/UBAbstractUndoCommand.h
View file @
7acbcaab
...
...
@@ -32,7 +32,8 @@ class UBAbstractUndoCommand : public QUndoCommand
undotype_GRAPHICITEMTRANSFORM
=
2
,
undotype_GRAPHICITEM
=
3
,
undotype_GRAPHICTEXTITEM
=
4
,
undotype_PAGESIZE
=
5
undotype_PAGESIZE
=
5
,
undotype_GRAPHICSGROUPITEM
=
6
};
virtual
UndoType
getType
()
{
return
undotype_UNKNOWN
;
}
...
...
src/domain/UBGraphicsDelegateFrame.cpp
View file @
7acbcaab
...
...
@@ -228,6 +228,9 @@ void UBGraphicsDelegateFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
mCurrentTool
=
toolFromPos
(
event
->
pos
());
setCursorFromAngle
(
QString
(
""
));
event
->
accept
();
prepareFramesToMove
(
getLinkedFrames
());
}
void
UBGraphicsDelegateFrame
::
setCursorFromAngle
(
QString
angle
)
...
...
@@ -469,6 +472,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
mTranslateX
=
move
.
dx
();
mTranslateY
=
move
.
dy
();
moveLinkedItems
(
move
);
}
QTransform
tr
=
buildTransform
();
...
...
@@ -534,6 +538,71 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
event
->
accept
();
}
QList
<
UBGraphicsDelegateFrame
*>
UBGraphicsDelegateFrame
::
getLinkedFrames
()
{
QList
<
UBGraphicsDelegateFrame
*>
linkedFrames
;
QList
<
QGraphicsItem
*>
sItems
=
mDelegate
->
delegated
()
->
scene
()
->
selectedItems
();
if
(
sItems
.
count
())
{
sItems
.
removeAll
(
delegated
());
foreach
(
QGraphicsItem
*
item
,
sItems
)
{
UBGraphicsItem
*
gitem
=
dynamic_cast
<
UBGraphicsItem
*>
(
item
);
if
(
gitem
)
linkedFrames
<<
gitem
->
Delegate
()
->
frame
();
}
}
return
linkedFrames
;
}
void
UBGraphicsDelegateFrame
::
prepareFramesToMove
(
QList
<
UBGraphicsDelegateFrame
*>
framesToMove
)
{
mLinkedFrames
=
framesToMove
;
foreach
(
UBGraphicsDelegateFrame
*
frame
,
mLinkedFrames
)
{
frame
->
prepareLinkedFrameToMove
();
}
}
void
UBGraphicsDelegateFrame
::
prepareLinkedFrameToMove
()
{
mDelegate
->
startUndoStep
();
mStartingPoint
=
QPointF
(
0
,
0
);
initializeTransform
();
mScaleX
=
1
;
mScaleY
=
1
;
mTranslateX
=
0
;
mTranslateY
=
0
;
mAngleOffset
=
0
;
mInitialTransform
=
buildTransform
();
mCurrentTool
=
Move
;
}
void
UBGraphicsDelegateFrame
::
moveLinkedItems
(
QLineF
movingVector
,
bool
bLinked
)
{
if
(
bLinked
)
{
mCurrentTool
=
Move
;
mTranslateX
=
movingVector
.
dx
();
mTranslateY
=
movingVector
.
dy
();
delegated
()
->
setTransform
(
buildTransform
(),
false
);
}
else
{
foreach
(
UBGraphicsDelegateFrame
*
frame
,
mLinkedFrames
)
{
frame
->
moveLinkedItems
(
movingVector
,
true
);
}
}
}
QTransform
UBGraphicsDelegateFrame
::
buildTransform
()
{
...
...
src/domain/UBGraphicsDelegateFrame.h
View file @
7acbcaab
...
...
@@ -48,6 +48,10 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
enum
OperationMode
{
Scaling
,
Resizing
,
ResizingHorizontally
};
void
setOperationMode
(
OperationMode
pMode
)
{
mOperationMode
=
pMode
;}
bool
isResizing
(){
return
mResizing
;}
void
moveLinkedItems
(
QLineF
movingVector
,
bool
bLinked
=
false
);
void
prepareFramesToMove
(
QList
<
UBGraphicsDelegateFrame
*>
framesToMove
);
void
prepareLinkedFrameToMove
();
QList
<
UBGraphicsDelegateFrame
*>
getLinkedFrames
();
private
:
QRectF
bottomRightResizeGripRect
()
const
;
...
...
@@ -120,5 +124,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
bool
mResizing
;
bool
mMirroredXAtStart
;
bool
mMirroredYAtStart
;
QList
<
UBGraphicsDelegateFrame
*>
mLinkedFrames
;
};
#endif
/* UBGRAPHICSDELEGATEFRAME_H_ */
src/domain/UBGraphicsItemGroupUndoCommand.cpp
0 → 100644
View file @
7acbcaab
#include "UBGraphicsItemGroupUndoCommand.h"
#include "UBGraphicsGroupContainerItem.h"
#include "UBGraphicsScene.h"
#include "core/memcheck.h"
UBGraphicsItemGroupUndoCommand
::
UBGraphicsItemGroupUndoCommand
(
UBGraphicsScene
*
pScene
,
UBGraphicsGroupContainerItem
*
pGroupCreated
)
:
mScene
(
pScene
),
mGroup
(
pGroupCreated
),
mFirstRedo
(
true
)
{
if
(
pGroupCreated
->
childItems
().
count
())
{
foreach
(
QGraphicsItem
*
item
,
pGroupCreated
->
childItems
())
{
mItems
<<
item
;
}
}
}
UBGraphicsItemGroupUndoCommand
::~
UBGraphicsItemGroupUndoCommand
()
{
}
void
UBGraphicsItemGroupUndoCommand
::
undo
()
{
mGroup
->
destroy
();
foreach
(
QGraphicsItem
*
item
,
mItems
)
{
item
->
setSelected
(
true
);
}
}
void
UBGraphicsItemGroupUndoCommand
::
redo
()
{
if
(
mFirstRedo
)
{
//Work around. TODO determine why does Qt call the redo function on pushing to undo
mFirstRedo
=
false
;
return
;
}
foreach
(
QGraphicsItem
*
item
,
mItems
)
{
if
(
item
->
type
()
==
UBGraphicsGroupContainerItem
::
Type
)
{
QList
<
QGraphicsItem
*>
childItems
=
item
->
childItems
();
UBGraphicsGroupContainerItem
*
currentGroup
=
dynamic_cast
<
UBGraphicsGroupContainerItem
*>
(
item
);
if
(
currentGroup
)
{
currentGroup
->
destroy
();
}
foreach
(
QGraphicsItem
*
chItem
,
childItems
)
{
mGroup
->
addToGroup
(
chItem
);
}
}
else
{
mGroup
->
addToGroup
(
item
);
}
}
mScene
->
addItem
(
mGroup
);
mGroup
->
setVisible
(
true
);
mGroup
->
setFocus
();
mGroup
->
setSelected
(
true
);
}
src/domain/UBGraphicsItemGroupUndoCommand.h
0 → 100644
View file @
7acbcaab
#ifndef UBGRAPHICSITEMGROUPUNDOCOMMAND_H
#define UBGRAPHICSITEMGROUPUNDOCOMMAND_H
#include <QList>
#include "UBAbstractUndoCommand.h"
class
UBGraphicsScene
;
class
UBGraphicsGroupContainerItem
;
class
UBGraphicsItemGroupUndoCommand
:
public
UBAbstractUndoCommand
{
public
:
UBGraphicsItemGroupUndoCommand
(
UBGraphicsScene
*
pScene
,
UBGraphicsGroupContainerItem
*
pGroupCreated
);
virtual
~
UBGraphicsItemGroupUndoCommand
();
virtual
UndoType
getType
()
{
return
undotype_GRAPHICSGROUPITEM
;
}
protected
:
virtual
void
undo
();
virtual
void
redo
();
private
:
UBGraphicsScene
*
mScene
;
UBGraphicsGroupContainerItem
*
mGroup
;
QList
<
QGraphicsItem
*>
mItems
;
bool
mFirstRedo
;
};
#endif // UBGRAPHICSITEMGROUPUNDOCOMMAND_H
src/domain/UBGraphicsItemTransformUndoCommand.h
View file @
7acbcaab
...
...
@@ -32,7 +32,7 @@ class UBGraphicsItemTransformUndoCommand : public UBAbstractUndoCommand
const
QSizeF
&
prevSize
=
QSizeF
());
virtual
~
UBGraphicsItemTransformUndoCommand
();
virtual
UndoType
getType
()
{
return
undotype_GRAPHICITEMTRANSFORM
;
}
;
virtual
UndoType
getType
()
{
return
undotype_GRAPHICITEMTRANSFORM
;
}
protected
:
virtual
void
undo
();
...
...
src/domain/UBGraphicsItemUndoCommand.cpp
View file @
7acbcaab
...
...
@@ -24,6 +24,7 @@
#include "board/UBBoardController.h"
#include "core/memcheck.h"
#include "domain/UBGraphicsGroupContainerItem.h"
UBGraphicsItemUndoCommand
::
UBGraphicsItemUndoCommand
(
UBGraphicsScene
*
pScene
,
const
QSet
<
QGraphicsItem
*>&
pRemovedItems
,
const
QSet
<
QGraphicsItem
*>&
pAddedItems
)
...
...
@@ -81,6 +82,14 @@ void UBGraphicsItemUndoCommand::undo()
{
QGraphicsItem
*
item
=
itAdded
.
next
();
//if removing group
if
(
item
->
type
()
==
UBGraphicsGroupContainerItem
::
Type
)
{
UBGraphicsGroupContainerItem
*
curGroup
=
qgraphicsitem_cast
<
UBGraphicsGroupContainerItem
*>
(
item
);
if
(
curGroup
)
{
curGroup
->
destroy
();
}
}
UBApplication
::
boardController
->
freezeW3CWidget
(
item
,
true
);
item
->
setSelected
(
false
);
mScene
->
removeItem
(
item
);
...
...
src/domain/UBGraphicsItemUndoCommand.h
View file @
7acbcaab
...
...
@@ -34,10 +34,10 @@ class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand
virtual
~
UBGraphicsItemUndoCommand
();
QSet
<
QGraphicsItem
*>
GetAddedList
()
{
return
mAddedItems
;
}
;
QSet
<
QGraphicsItem
*>
GetRemovedList
()
{
return
mRemovedItems
;
}
;
QSet
<
QGraphicsItem
*>
GetAddedList
()
{
return
mAddedItems
;
}
QSet
<
QGraphicsItem
*>
GetRemovedList
()
{
return
mRemovedItems
;
}
virtual
UndoType
getType
()
{
return
undotype_GRAPHICITEM
;
}
;
virtual
UndoType
getType
()
{
return
undotype_GRAPHICITEM
;
}
protected
:
virtual
void
undo
();
...
...
src/domain/UBGraphicsScene.cpp
View file @
7acbcaab
...
...
@@ -47,6 +47,7 @@
#include "board/UBBoardView.h"
#include "UBGraphicsItemUndoCommand.h"
#include "UBGraphicsItemGroupUndoCommand.h"
#include "UBGraphicsTextItemUndoCommand.h"
#include "UBGraphicsProxyWidget.h"
#include "UBGraphicsPixmapItem.h"
...
...
@@ -1521,7 +1522,7 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *
groupItem
->
setFocus
();
if
(
enableUndoRedoStack
)
{
//should be deleted after scene own undo stack implemented
UBGraphicsItem
UndoCommand
*
uc
=
new
UBGraphicsItemUndoCommand
(
this
,
0
,
groupItem
);
UBGraphicsItem
GroupUndoCommand
*
uc
=
new
UBGraphicsItemGroupUndoCommand
(
this
,
groupItem
);
UBApplication
::
undoStack
->
push
(
uc
);
}
...
...
src/domain/UBGraphicsStrokesGroup.cpp
View file @
7acbcaab
...
...
@@ -115,3 +115,23 @@ QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVa
QVariant
newValue
=
mDelegate
->
itemChange
(
change
,
value
);
return
QGraphicsItemGroup
::
itemChange
(
change
,
newValue
);
}
QPainterPath
UBGraphicsStrokesGroup
::
shape
()
const
{
QPainterPath
path
;
if
(
isSelected
())
{
path
.
addRect
(
boundingRect
());
}
else
{
foreach
(
QGraphicsItem
*
item
,
childItems
())
{
path
.
addPath
(
item
->
shape
());
}
}
return
path
;
}
src/domain/UBGraphicsStrokesGroup.h
View file @
7acbcaab
...
...
@@ -25,6 +25,9 @@ public:
virtual
void
setUuid
(
const
QUuid
&
pUuid
);
protected
:
virtual
QPainterPath
shape
()
const
;
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
...
src/domain/domain.pri
View file @
7acbcaab
...
...
@@ -20,7 +20,8 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBAbstractUndoCommand.h\
src/domain/UBGraphicsGroupContainerItem.h \
src/domain/UBGraphicsGroupContainerItemDelegate.h \
src/domain/UBGraphicsStrokesGroup.h
src/domain/UBGraphicsStrokesGroup.h \
src/domain/UBGraphicsItemGroupUndoCommand.h
HEADERS += src/domain/UBGraphicsItemDelegate.h \
src/domain/UBGraphicsTextItemDelegate.h \
...
...
@@ -51,7 +52,8 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBAbstractUndoCommand.cpp \
src/domain/ubgraphicsgroupcontaineritem.cpp \
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \
src/domain/UBGraphicsStrokesGroup.cpp
src/domain/UBGraphicsStrokesGroup.cpp \
src/domain/UBGraphicsItemGroupUndoCommand.cpp
SOURCES += src/domain/UBGraphicsItemDelegate.cpp \
src/domain/UBGraphicsTextItemDelegate.cpp \
...
...
src/gui/UBDocumentNavigator.cpp
View file @
7acbcaab
...
...
@@ -84,8 +84,7 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source)
for
(
int
i
=
0
;
i
<
source
->
selectedDocument
()
->
pageCount
();
i
++
)
{
qDebug
()
<<
"source->selectedDocument()->pageCount: "
<<
source
->
selectedDocument
()
->
pageCount
()
<<
", source->pageCount: "
<<
source
->
pageCount
()
<<
", source->pageAt("
<<
i
<<
")"
;
const
QPixmap
*
pix
=
source
->
pageAt
(
i
);
const
QPixmap
*
pix
=
source
->
pageAt
(
i
);
UBSceneThumbnailNavigPixmap
*
pixmapItem
=
new
UBSceneThumbnailNavigPixmap
(
*
pix
,
source
->
selectedDocument
(),
i
);
int
pageIndex
=
UBDocumentContainer
::
pageFromSceneIndex
(
i
);
QString
label
=
pageIndex
==
0
?
tr
(
"Title page"
)
:
tr
(
"Page %0"
).
arg
(
pageIndex
);
...
...
src/gui/UBFeaturesWidget.cpp
View file @
7acbcaab
...
...
@@ -379,6 +379,12 @@ void UBFeaturesListView::dragMoveEvent( QDragMoveEvent *event )
event
->
ignore
();
return
;
}
foreach
(
UBFeature
curFeature
,
fMimeData
->
features
())
{
if
(
curFeature
==
onFeature
)
{
event
->
ignore
();
return
;
}
}
}
if
(
event
->
mimeData
()
->
hasUrls
()
||
event
->
mimeData
()
->
hasImage
()
)
{
...
...
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