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
37b0eafa
Commit
37b0eafa
authored
Aug 21, 2012
by
Ilia Ryabokon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sankore-834
parent
134746af
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
109 additions
and
8 deletions
+109
-8
UBAbstractUndoCommand.h
src/domain/UBAbstractUndoCommand.h
+2
-1
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
domain.pri
src/domain/domain.pri
+4
-2
No files found.
src/domain/UBAbstractUndoCommand.h
View file @
37b0eafa
...
@@ -32,7 +32,8 @@ class UBAbstractUndoCommand : public QUndoCommand
...
@@ -32,7 +32,8 @@ class UBAbstractUndoCommand : public QUndoCommand
undotype_GRAPHICITEMTRANSFORM
=
2
,
undotype_GRAPHICITEMTRANSFORM
=
2
,
undotype_GRAPHICITEM
=
3
,
undotype_GRAPHICITEM
=
3
,
undotype_GRAPHICTEXTITEM
=
4
,
undotype_GRAPHICTEXTITEM
=
4
,
undotype_PAGESIZE
=
5
undotype_PAGESIZE
=
5
,
undotype_GRAPHICSGROUPITEM
=
6
};
};
virtual
UndoType
getType
()
{
return
undotype_UNKNOWN
;
}
virtual
UndoType
getType
()
{
return
undotype_UNKNOWN
;
}
...
...
src/domain/UBGraphicsItemGroupUndoCommand.cpp
0 → 100644
View file @
37b0eafa
#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 @
37b0eafa
#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 @
37b0eafa
...
@@ -32,7 +32,7 @@ class UBGraphicsItemTransformUndoCommand : public UBAbstractUndoCommand
...
@@ -32,7 +32,7 @@ class UBGraphicsItemTransformUndoCommand : public UBAbstractUndoCommand
const
QSizeF
&
prevSize
=
QSizeF
());
const
QSizeF
&
prevSize
=
QSizeF
());
virtual
~
UBGraphicsItemTransformUndoCommand
();
virtual
~
UBGraphicsItemTransformUndoCommand
();
virtual
UndoType
getType
()
{
return
undotype_GRAPHICITEMTRANSFORM
;
}
;
virtual
UndoType
getType
()
{
return
undotype_GRAPHICITEMTRANSFORM
;
}
protected
:
protected
:
virtual
void
undo
();
virtual
void
undo
();
...
...
src/domain/UBGraphicsItemUndoCommand.cpp
View file @
37b0eafa
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include "board/UBBoardController.h"
#include "board/UBBoardController.h"
#include "core/memcheck.h"
#include "core/memcheck.h"
#include "domain/UBGraphicsGroupContainerItem.h"
UBGraphicsItemUndoCommand
::
UBGraphicsItemUndoCommand
(
UBGraphicsScene
*
pScene
,
const
QSet
<
QGraphicsItem
*>&
pRemovedItems
,
UBGraphicsItemUndoCommand
::
UBGraphicsItemUndoCommand
(
UBGraphicsScene
*
pScene
,
const
QSet
<
QGraphicsItem
*>&
pRemovedItems
,
const
QSet
<
QGraphicsItem
*>&
pAddedItems
)
const
QSet
<
QGraphicsItem
*>&
pAddedItems
)
...
@@ -81,6 +82,14 @@ void UBGraphicsItemUndoCommand::undo()
...
@@ -81,6 +82,14 @@ void UBGraphicsItemUndoCommand::undo()
{
{
QGraphicsItem
*
item
=
itAdded
.
next
();
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
);
UBApplication
::
boardController
->
freezeW3CWidget
(
item
,
true
);
item
->
setSelected
(
false
);
item
->
setSelected
(
false
);
mScene
->
removeItem
(
item
);
mScene
->
removeItem
(
item
);
...
...
src/domain/UBGraphicsItemUndoCommand.h
View file @
37b0eafa
...
@@ -34,10 +34,10 @@ class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand
...
@@ -34,10 +34,10 @@ class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand
virtual
~
UBGraphicsItemUndoCommand
();
virtual
~
UBGraphicsItemUndoCommand
();
QSet
<
QGraphicsItem
*>
GetAddedList
()
{
return
mAddedItems
;
}
;
QSet
<
QGraphicsItem
*>
GetAddedList
()
{
return
mAddedItems
;
}
QSet
<
QGraphicsItem
*>
GetRemovedList
()
{
return
mRemovedItems
;
}
;
QSet
<
QGraphicsItem
*>
GetRemovedList
()
{
return
mRemovedItems
;
}
virtual
UndoType
getType
()
{
return
undotype_GRAPHICITEM
;
}
;
virtual
UndoType
getType
()
{
return
undotype_GRAPHICITEM
;
}
protected
:
protected
:
virtual
void
undo
();
virtual
void
undo
();
...
...
src/domain/UBGraphicsScene.cpp
View file @
37b0eafa
...
@@ -47,6 +47,7 @@
...
@@ -47,6 +47,7 @@
#include "board/UBBoardView.h"
#include "board/UBBoardView.h"
#include "UBGraphicsItemUndoCommand.h"
#include "UBGraphicsItemUndoCommand.h"
#include "UBGraphicsItemGroupUndoCommand.h"
#include "UBGraphicsTextItemUndoCommand.h"
#include "UBGraphicsTextItemUndoCommand.h"
#include "UBGraphicsProxyWidget.h"
#include "UBGraphicsProxyWidget.h"
#include "UBGraphicsPixmapItem.h"
#include "UBGraphicsPixmapItem.h"
...
@@ -1521,7 +1522,7 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *
...
@@ -1521,7 +1522,7 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *
groupItem
->
setFocus
();
groupItem
->
setFocus
();
if
(
enableUndoRedoStack
)
{
//should be deleted after scene own undo stack implemented
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
);
UBApplication
::
undoStack
->
push
(
uc
);
}
}
...
...
src/domain/domain.pri
View file @
37b0eafa
...
@@ -20,7 +20,8 @@ HEADERS += src/domain/UBGraphicsScene.h \
...
@@ -20,7 +20,8 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBAbstractUndoCommand.h\
src/domain/UBAbstractUndoCommand.h\
src/domain/UBGraphicsGroupContainerItem.h \
src/domain/UBGraphicsGroupContainerItem.h \
src/domain/UBGraphicsGroupContainerItemDelegate.h \
src/domain/UBGraphicsGroupContainerItemDelegate.h \
src/domain/UBGraphicsStrokesGroup.h
src/domain/UBGraphicsStrokesGroup.h \
src/domain/UBGraphicsItemGroupUndoCommand.h
HEADERS += src/domain/UBGraphicsItemDelegate.h \
HEADERS += src/domain/UBGraphicsItemDelegate.h \
src/domain/UBGraphicsTextItemDelegate.h \
src/domain/UBGraphicsTextItemDelegate.h \
...
@@ -51,7 +52,8 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
...
@@ -51,7 +52,8 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBAbstractUndoCommand.cpp \
src/domain/UBAbstractUndoCommand.cpp \
src/domain/ubgraphicsgroupcontaineritem.cpp \
src/domain/ubgraphicsgroupcontaineritem.cpp \
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \
src/domain/UBGraphicsStrokesGroup.cpp
src/domain/UBGraphicsStrokesGroup.cpp \
src/domain/UBGraphicsItemGroupUndoCommand.cpp
SOURCES += src/domain/UBGraphicsItemDelegate.cpp \
SOURCES += src/domain/UBGraphicsItemDelegate.cpp \
src/domain/UBGraphicsTextItemDelegate.cpp \
src/domain/UBGraphicsTextItemDelegate.cpp \
...
...
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