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
3be48374
Commit
3be48374
authored
Apr 17, 2013
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
instanciate frame on demand
parent
7c45b593
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
112 additions
and
49 deletions
+112
-49
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+15
-1
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+95
-47
UBGraphicsItemDelegate.h
src/domain/UBGraphicsItemDelegate.h
+2
-1
No files found.
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
3be48374
...
...
@@ -384,6 +384,8 @@ UBSvgSubsetAdaptor::UBSvgSubsetReader::UBSvgSubsetReader(UBDocumentProxy* pProxy
UBGraphicsScene
*
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
loadScene
()
{
qDebug
()
<<
"loadScene() : starting reading..."
;
QTime
time
;
time
.
start
();
mScene
=
0
;
UBGraphicsWidgetItem
*
currentWidget
=
0
;
...
...
@@ -992,6 +994,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
mScene
->
enableUndoRedoStack
();
qDebug
()
<<
"loadScene() : created scene and read file"
;
qDebug
()
<<
"spent milliseconds: "
<<
time
.
elapsed
();
return
mScene
;
}
...
...
@@ -1003,7 +1006,6 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup()
QString
id
=
mXmlReader
.
attributes
().
value
(
aId
).
toString
();
id
=
id
.
mid
(
1
,
id
.
length
()
-
2
);
qDebug
()
<<
id
;
bool
shouldSkipSubElements
=
false
;
if
(
mStrokesList
.
contains
(
id
))
shouldSkipSubElements
=
true
;
...
...
@@ -1667,6 +1669,18 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol
if
(
!
svgPoints
.
isNull
())
{
// int lenght = strlen(svgPoints.toUtf8().constData()) + 1;
// char pippo[lenght];
// memcpy(pippo,svgPoints.toUtf8().constData(),lenght);
// char* localPosition = (char*) &pippo[0];
// do{
// float x = atof(localPosition);
// localPosition = strchr(localPosition,',') + 1;
// float y = atof(localPosition);
// localPosition = strchrnul(localPosition,' ');
// polygon << QPointF(x,y);
// }while(localPosition - pippo > lenght - 5);
QStringList
ts
=
svgPoints
.
toString
().
split
(
QLatin1Char
(
' '
),
QString
::
SkipEmptyParts
);
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
3be48374
...
...
@@ -179,67 +179,114 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
void
UBGraphicsItemDelegate
::
init
()
{
// if (mToolBarUsed)
// mToolBarItem = new UBGraphicsToolBarItem(mDelegated);
// mFrame = new UBGraphicsDelegateFrame(this, QRectF(0, 0, 0, 0), mFrameWidth, mRespectRatio);
// mFrame->hide();
// mFrame->setFlag(QGraphicsItem::ItemIsSelectable, true);
// mDeleteButton = new DelegateButton(":/images/close.svg", mDelegated, mFrame, Qt::TopLeftSection);
// mButtons << mDeleteButton;
// connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove()));
// if (canDuplicate()){
// mDuplicateButton = new DelegateButton(":/images/duplicate.svg", mDelegated, mFrame, Qt::TopLeftSection);
// connect(mDuplicateButton, SIGNAL(clicked(bool)), this, SLOT(duplicate()));
// mButtons << mDuplicateButton;
// }
// mMenuButton = new DelegateButton(":/images/menu.svg", mDelegated, mFrame, Qt::TopLeftSection);
// connect(mMenuButton, SIGNAL(clicked()), this, SLOT(showMenu()));
// mButtons << mMenuButton;
// mZOrderUpButton = new DelegateButton(":/images/z_layer_up.svg", mDelegated, mFrame, Qt::BottomLeftSection);
// mZOrderUpButton->setShowProgressIndicator(true);
// connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZLevelUp()));
// connect(mZOrderUpButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelTop()));
// mButtons << mZOrderUpButton;
// mZOrderDownButton = new DelegateButton(":/images/z_layer_down.svg", mDelegated, mFrame, Qt::BottomLeftSection);
// mZOrderDownButton->setShowProgressIndicator(true);
// connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(increaseZLevelDown()));
// connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom()));
// mButtons << mZOrderDownButton;
// buildButtons();
// foreach(DelegateButton* button, mButtons)
// {
// if (button->getSection() != Qt::TitleBarArea)
// {
// button->hide();
// button->setFlag(QGraphicsItem::ItemIsSelectable, true);
// }
// }
// //Wrapper function. Use it to set correct data() to QGraphicsItem as well
// setFlippable(false);
// setRotatable(false);
}
UBGraphicsItemDelegate
::~
UBGraphicsItemDelegate
()
{
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
}
void
UBGraphicsItemDelegate
::
decorate
()
{
if
(
mToolBarUsed
)
mToolBarItem
=
new
UBGraphicsToolBarItem
(
mDelegated
);
mFrame
=
new
UBGraphicsDelegateFrame
(
this
,
QRectF
(
0
,
0
,
0
,
0
),
mFrameWidth
,
mRespectRatio
);
mFrame
->
hide
();
mFrame
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
mDeleteButton
=
new
DelegateButton
(
":/images/close.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
mButtons
<<
mDeleteButton
;
connect
(
mDeleteButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
remove
()));
if
(
canDuplicate
()){
mDuplicateButton
=
new
DelegateButton
(
":/images/duplicate.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mDuplicateButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
duplicate
()));
mButtons
<<
mDuplicateButton
;
}
mMenuButton
=
new
DelegateButton
(
":/images/menu.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mMenuButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
showMenu
()));
mButtons
<<
mMenuButton
;
if
(
!
mFrame
){
mFrame
=
new
UBGraphicsDelegateFrame
(
this
,
QRectF
(
0
,
0
,
0
,
0
),
mFrameWidth
,
mRespectRatio
);
mFrame
->
hide
();
mFrame
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
mDeleteButton
=
new
DelegateButton
(
":/images/close.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
mButtons
<<
mDeleteButton
;
connect
(
mDeleteButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
remove
()));
if
(
canDuplicate
()){
mDuplicateButton
=
new
DelegateButton
(
":/images/duplicate.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mDuplicateButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
duplicate
()));
mButtons
<<
mDuplicateButton
;
}
mMenuButton
=
new
DelegateButton
(
":/images/menu.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mMenuButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
showMenu
()));
mButtons
<<
mMenuButton
;
mZOrderUpButton
=
new
DelegateButton
(
":/images/z_layer_up.svg"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
mZOrderUpButton
->
setShowProgressIndicator
(
true
);
connect
(
mZOrderUpButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevelUp
()));
connect
(
mZOrderUpButton
,
SIGNAL
(
longClicked
()),
this
,
SLOT
(
increaseZlevelTop
()));
mButtons
<<
mZOrderUpButton
;
mZOrderUpButton
=
new
DelegateButton
(
":/images/z_layer_up.svg"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
mZOrderUpButton
->
setShowProgressIndicator
(
true
);
connect
(
mZOrderUpButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevelUp
()));
connect
(
mZOrderUpButton
,
SIGNAL
(
longClicked
()),
this
,
SLOT
(
increaseZlevelTop
()));
mButtons
<<
mZOrderUpButton
;
mZOrderDownButton
=
new
DelegateButton
(
":/images/z_layer_down.svg"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
mZOrderDownButton
->
setShowProgressIndicator
(
true
);
connect
(
mZOrderDownButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevelDown
()));
connect
(
mZOrderDownButton
,
SIGNAL
(
longClicked
()),
this
,
SLOT
(
increaseZlevelBottom
()));
mButtons
<<
mZOrderDownButton
;
mZOrderDownButton
=
new
DelegateButton
(
":/images/z_layer_down.svg"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
mZOrderDownButton
->
setShowProgressIndicator
(
true
);
connect
(
mZOrderDownButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevelDown
()));
connect
(
mZOrderDownButton
,
SIGNAL
(
longClicked
()),
this
,
SLOT
(
increaseZlevelBottom
()));
mButtons
<<
mZOrderDownButton
;
buildButtons
();
buildButtons
();
foreach
(
DelegateButton
*
button
,
mButtons
)
{
if
(
button
->
getSection
()
!=
Qt
::
TitleBarArea
)
foreach
(
DelegateButton
*
button
,
mButtons
)
{
button
->
hide
();
button
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
if
(
button
->
getSection
()
!=
Qt
::
TitleBarArea
)
{
button
->
hide
();
button
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
}
}
}
//Wrapper function. Use it to set correct data() to QGraphicsItem as well
setFlippable
(
false
);
setRotatable
(
false
);
}
UBGraphicsItemDelegate
::~
UBGraphicsItemDelegate
()
{
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
}
QVariant
UBGraphicsItemDelegate
::
itemChange
(
QGraphicsItem
::
GraphicsItemChange
change
,
const
QVariant
&
value
)
{
if
(
change
==
QGraphicsItem
::
ItemChildAddedChange
){
}
else
if
(
change
==
QGraphicsItem
::
ItemSelectedHasChanged
)
{
if
(
change
==
QGraphicsItem
::
ItemSelectedHasChanged
)
{
bool
ok
;
bool
selected
=
value
.
toUInt
(
&
ok
);
if
(
ok
)
{
...
...
@@ -687,6 +734,7 @@ bool UBGraphicsItemDelegate::isFlippable()
void
UBGraphicsItemDelegate
::
updateFrame
()
{
decorate
();
if
(
mFrame
&&
!
mFrame
->
scene
()
&&
mDelegated
->
scene
())
{
mDelegated
->
scene
()
->
addItem
(
mFrame
);
...
...
src/domain/UBGraphicsItemDelegate.h
View file @
3be48374
...
...
@@ -189,7 +189,7 @@ class UBGraphicsToolBarItem : public QGraphicsRectItem, public QObject
bool
isVisibleOnBoard
()
const
{
return
mVisible
;
}
void
setVisibleOnBoard
(
bool
visible
)
{
mVisible
=
visible
;
}
bool
isShifting
()
const
{
return
mShifting
;
}
void
setShifting
(
bool
shifting
)
{
mShifting
=
shifting
;
}
void
setShifting
(
bool
shifting
)
{
mShifting
=
shifting
;
}
QList
<
QGraphicsItem
*>
itemsOnToolBar
()
const
{
return
mItemsOnToolBar
;
}
void
setItemsOnToolBar
(
QList
<
QGraphicsItem
*>
itemsOnToolBar
)
{
mItemsOnToolBar
=
itemsOnToolBar
;}
int
minWidth
()
{
return
mMinWidth
;
}
...
...
@@ -319,6 +319,7 @@ protected slots:
virtual
void
gotoContentSource
();
private
:
void
decorate
();
void
updateFrame
();
void
updateButtons
(
bool
showUpdated
=
false
);
inline
void
showHideRecurs
(
const
QVariant
&
pShow
,
QGraphicsItem
*
pItem
);
...
...
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