Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
b19c4172
Commit
b19c4172
authored
Jul 09, 2010
by
Lasse Holmstedt
Committed by
Olivier Goffart
Jul 14, 2010
Browse files
fixed selection issues with child items
parent
ec1fc77a
Changes
12
Hide whitespace changes
Inline
Side-by-side
src/tools/qml/qmlviewer/editor/boundingrecthighlighter.cpp
View file @
b19c4172
...
...
@@ -87,13 +87,17 @@ void BoundingRectHighlighter::highlight(QGraphicsObject* item)
polygonItemEdge
=
m_highlightPolygonEdge
;
}
QPolygonF
boundingRectInSceneSpace
(
item
->
mapToScene
(
item
->
boundingRect
()));
QPolygonF
boundingRectInLayerItemSpace
=
mapFromScene
(
boundingRectInSceneSpace
);
polygonItem
->
setPolygon
(
boundingRectInLayerItemSpace
);
polygonItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
false
);
QRectF
itemAndChildRect
=
item
->
boundingRect
()
|
item
->
childrenBoundingRect
();
QPolygonF
boundingRectInSceneSpace
(
item
->
mapToScene
(
itemAndChildRect
));
QPolygonF
boundingRectInLayerItemSpace
=
mapFromScene
(
boundingRectInSceneSpace
);
QRectF
bboxRect
=
boundingRectInLayerItemSpace
.
boundingRect
();
QRectF
edgeRect
=
boundingRectInLayerItemSpace
.
boundingRect
();
edgeRect
.
adjust
(
-
1
,
-
1
,
1
,
1
);
polygonItem
->
setPolygon
(
QPolygonF
(
bboxRect
));
polygonItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
false
);
polygonItemEdge
->
setPolygon
(
QPolygonF
(
edgeRect
));
polygonItemEdge
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
false
);
...
...
src/tools/qml/qmlviewer/editor/colorpickertool.cpp
View file @
b19c4172
...
...
@@ -7,8 +7,7 @@
#include
<QRgb>
#include
<QImage>
#include
<QApplication>
#include
<QDebug>
#include
<QPalette>
namespace
QmlViewer
{
...
...
@@ -25,7 +24,6 @@ ColorPickerTool::~ColorPickerTool()
void
ColorPickerTool
::
mousePressEvent
(
QMouseEvent
*/
*
event
*/
)
{
}
void
ColorPickerTool
::
mouseMoveEvent
(
QMouseEvent
*
event
)
...
...
@@ -40,33 +38,26 @@ void ColorPickerTool::mouseReleaseEvent(QMouseEvent *event)
void
ColorPickerTool
::
mouseDoubleClickEvent
(
QMouseEvent
*/
*
event
*/
)
{
}
void
ColorPickerTool
::
hoverMoveEvent
(
QMouseEvent
*/
*
event
*/
)
{
}
void
ColorPickerTool
::
keyPressEvent
(
QKeyEvent
*/
*
event
*/
)
{
}
void
ColorPickerTool
::
keyReleaseEvent
(
QKeyEvent
*/
*
keyEvent
*/
)
{
}
void
ColorPickerTool
::
wheelEvent
(
QWheelEvent
*/
*
event
*/
)
{
}
void
ColorPickerTool
::
itemsAboutToRemoved
(
const
QList
<
QGraphicsItem
*>
&
/*itemList*/
)
{
}
void
ColorPickerTool
::
clear
()
...
...
@@ -76,19 +67,22 @@ void ColorPickerTool::clear()
void
ColorPickerTool
::
graphicsObjectsChanged
(
const
QList
<
QGraphicsObject
*>
&
/*itemList*/
)
{
}
void
ColorPickerTool
::
selectedItemsChanged
(
const
QList
<
QGraphicsItem
*>
&
/*itemList*/
)
{
}
void
ColorPickerTool
::
pickColor
(
const
QPoint
&
pos
)
{
QRgb
fillColor
=
view
()
->
backgroundBrush
().
color
().
rgb
();
if
(
view
()
->
backgroundBrush
().
style
()
==
Qt
::
NoBrush
)
fillColor
=
view
()
->
palette
().
color
(
QPalette
::
Base
).
rgb
();
QRectF
target
(
0
,
0
,
1
,
1
);
QRect
source
(
pos
.
x
(),
pos
.
y
(),
1
,
1
);
QImage
img
(
1
,
1
,
QImage
::
Format_ARGB32
);
img
.
fill
(
fillColor
);
QPainter
painter
(
&
img
);
view
()
->
render
(
&
painter
,
target
,
source
);
m_selectedColor
=
QColor
::
fromRgb
(
img
.
pixel
(
0
,
0
));
...
...
src/tools/qml/qmlviewer/editor/qmlviewerconstants.h
View file @
b19c4172
...
...
@@ -25,6 +25,8 @@ static const int DragStartDistance = 20;
static
const
double
ZoomSnapDelta
=
0.04
;
static
const
int
EditorItemDataKey
=
1000
;
enum
GraphicsItemTypes
{
EditorItemType
=
0xEAAA
,
ResizeHandleItemType
=
0xEAEA
...
...
src/tools/qml/qmlviewer/editor/selectionindicator.cpp
View file @
b19c4172
...
...
@@ -28,6 +28,8 @@
**************************************************************************/
#include
"selectionindicator.h"
#include
"qdeclarativedesignview.h"
#include
"qmlviewerconstants.h"
#include
<QPen>
#include
<cmath>
...
...
@@ -35,8 +37,8 @@
namespace
QmlViewer
{
SelectionIndicator
::
SelectionIndicator
(
LayerItem
*
layerItem
)
:
m_layerItem
(
layerItem
)
SelectionIndicator
::
SelectionIndicator
(
QDeclarativeDesignView
*
editorView
,
LayerItem
*
layerItem
)
:
m_layerItem
(
layerItem
)
,
m_view
(
editorView
)
{
}
...
...
@@ -77,27 +79,41 @@ void SelectionIndicator::clear()
//
//}
QPolygonF
SelectionIndicator
::
addBoundingRectToPolygon
(
QGraphicsItem
*
item
,
QPolygonF
&
polygon
)
{
polygon
=
polygon
.
united
(
item
->
mapToScene
(
item
->
boundingRect
()));
foreach
(
QGraphicsItem
*
child
,
item
->
childItems
())
{
if
(
!
m_view
->
isEditorItem
(
child
))
addBoundingRectToPolygon
(
child
,
polygon
);
}
return
polygon
;
}
void
SelectionIndicator
::
setItems
(
const
QList
<
QGraphicsObject
*>
&
itemList
)
{
clear
();
// set selections to also all children if they are not editor items
foreach
(
QGraphicsItem
*
item
,
itemList
)
{
QGraphicsPolygonItem
*
newSelectionIndicatorGraphicsItem
=
new
QGraphicsPolygonItem
(
m_layerItem
.
data
());
m_indicatorShapeHash
.
insert
(
item
,
newSelectionIndicatorGraphicsItem
);
QPolygonF
boundingRectInSceneSpace
(
item
->
mapToScene
(
item
->
boundingRect
()));
QPolygonF
boundingRectInLayerItemSpace
=
m_layerItem
->
mapFromScene
(
boundingRectInSceneSpace
);
newSelectionIndicatorGraphicsItem
->
setPolygon
(
boundingRectInLayerItemSpace
);
newSelectionIndicatorGraphicsItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
false
);
QPolygonF
boundingShapeInSceneSpace
;
addBoundingRectToPolygon
(
item
,
boundingShapeInSceneSpace
);
QPolygonF
boundingRectInLayerItemSpace
=
m_layerItem
->
mapFromScene
(
boundingShapeInSceneSpace
);
QPen
pen
;
pen
.
setColor
(
QColor
(
108
,
141
,
221
));
newSelectionIndicatorGraphicsItem
->
setData
(
Constants
::
EditorItemDataKey
,
QVariant
(
true
));
newSelectionIndicatorGraphicsItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
false
);
newSelectionIndicatorGraphicsItem
->
setPolygon
(
boundingRectInLayerItemSpace
);
newSelectionIndicatorGraphicsItem
->
setPen
(
pen
);
}
}
void
SelectionIndicator
::
updateItems
(
const
QList
<
QGraphicsObject
*>
&
itemList
)
{
foreach
(
QGraphicsItem
*
item
,
itemList
)
{
...
...
src/tools/qml/qmlviewer/editor/selectionindicator.h
View file @
b19c4172
...
...
@@ -36,10 +36,12 @@
namespace
QmlViewer
{
class
QDeclarativeDesignView
;
class
SelectionIndicator
{
public:
SelectionIndicator
(
LayerItem
*
layerItem
);
SelectionIndicator
(
QDeclarativeDesignView
*
editorView
,
LayerItem
*
layerItem
);
~
SelectionIndicator
();
void
show
();
...
...
@@ -50,9 +52,13 @@ public:
void
setItems
(
const
QList
<
QGraphicsObject
*>
&
itemList
);
void
updateItems
(
const
QList
<
QGraphicsObject
*>
&
itemList
);
private:
QPolygonF
addBoundingRectToPolygon
(
QGraphicsItem
*
item
,
QPolygonF
&
polygon
);
private:
QHash
<
QGraphicsItem
*
,
QGraphicsPolygonItem
*>
m_indicatorShapeHash
;
QWeakPointer
<
LayerItem
>
m_layerItem
;
QDeclarativeDesignView
*
m_view
;
};
...
...
src/tools/qml/qmlviewer/editor/selectionrectangle.cpp
View file @
b19c4172
...
...
@@ -28,6 +28,7 @@
**************************************************************************/
#include
"selectionrectangle.h"
#include
"qmlviewerconstants.h"
#include
<QPen>
#include
<QGraphicsScene>
...
...
@@ -37,8 +38,15 @@
namespace
QmlViewer
{
class
SelectionRectShape
:
public
QGraphicsRectItem
{
public:
SelectionRectShape
(
QGraphicsItem
*
parent
=
0
)
:
QGraphicsRectItem
(
parent
)
{}
int
type
()
const
{
return
Constants
::
EditorItemType
;
}
};
SelectionRectangle
::
SelectionRectangle
(
LayerItem
*
layerItem
)
:
m_controlShape
(
new
QGraphicsRectItem
(
layerItem
)),
:
m_controlShape
(
new
SelectionRectShape
(
layerItem
)),
m_layerItem
(
layerItem
)
{
m_controlShape
->
setPen
(
QPen
(
Qt
::
black
));
...
...
src/tools/qml/qmlviewer/editor/selectiontool.cpp
View file @
b19c4172
...
...
@@ -54,7 +54,7 @@ SelectionTool::SelectionTool(QDeclarativeDesignView *editorView)
m_rubberbandSelectionMode
(
false
),
m_rubberbandSelectionManipulator
(
editorView
->
manipulatorLayer
(),
editorView
),
m_singleSelectionManipulator
(
editorView
),
m_selectionIndicator
(
editorView
->
manipulatorLayer
()),
m_selectionIndicator
(
editorView
,
editorView
->
manipulatorLayer
()),
//m_resizeIndicator(editorView->manipulatorLayer()),
m_selectOnlyContentItems
(
true
)
{
...
...
@@ -166,10 +166,6 @@ void SelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint glo
QMenu
contextMenu
;
connect
(
&
contextMenu
,
SIGNAL
(
hovered
(
QAction
*
)),
this
,
SLOT
(
contextMenuElementHovered
(
QAction
*
)));
// QList<QGraphicsItem*> sortedList;
// for(int i = itemList.length(); i>= 0; i--) {
// }
m_contextMenuItemList
=
itemList
;
contextMenu
.
addAction
(
"Items"
);
...
...
@@ -276,13 +272,12 @@ void SelectionTool::hoverMoveEvent(QMouseEvent * event)
// view()->changeTool(Constants::MoveToolMode);
}
QList
<
QGraphicsItem
*>
selectableItemList
=
view
()
->
selectableI
tems
(
event
->
pos
());
QList
<
QGraphicsItem
*>
selectableItemList
=
view
()
->
i
tems
(
event
->
pos
());
if
(
!
selectableItemList
.
isEmpty
())
{
QGraphicsItem
*
topSelectableItem
=
0
;
foreach
(
QGraphicsItem
*
item
,
selectableItemList
)
{
if
(
item
&&
item
->
type
()
!=
Constants
::
EditorItemType
if
(
!
view
()
->
isEditorItem
(
item
)
/*&& !item->qmlItemNode().isRootNode()
&& (QGraphicsItem->qmlItemNode().hasShowContent() || !m_selectOnlyContentItems)*/
)
{
...
...
@@ -292,7 +287,10 @@ void SelectionTool::hoverMoveEvent(QMouseEvent * event)
}
view
()
->
highlightBoundingRect
(
topSelectableItem
);
}
else
{
view
()
->
clearHighlightBoundingRect
();
}
}
void
SelectionTool
::
mouseReleaseEvent
(
QMouseEvent
*
event
)
...
...
@@ -341,8 +339,9 @@ void SelectionTool::keyPressEvent(QKeyEvent *event)
case
Qt
::
Key_Right
:
case
Qt
::
Key_Up
:
case
Qt
::
Key_Down
:
view
()
->
changeTool
(
Constants
::
MoveToolMode
);
view
()
->
currentTool
()
->
keyPressEvent
(
event
);
// disabled for now, cannot move stuff yet.
//view()->changeTool(Constants::MoveToolMode);
//view()->currentTool()->keyPressEvent(event);
break
;
}
}
...
...
src/tools/qml/qmlviewer/editor/subcomponenteditortool.cpp
View file @
b19c4172
...
...
@@ -14,6 +14,8 @@
namespace
QmlViewer
{
const
qreal
MaxOpacity
=
0.5
f
;
SubcomponentEditorTool
::
SubcomponentEditorTool
(
QDeclarativeDesignView
*
view
)
:
AbstractFormEditorTool
(
view
),
m_animIncrement
(
0.05
f
),
...
...
@@ -44,8 +46,6 @@ bool SubcomponentEditorTool::containsCursor(const QPoint &mousePos) const
if
(
!
m_currentContext
.
size
())
return
false
;
qDebug
()
<<
__FUNCTION__
<<
m_currentContext
.
top
();
QPointF
scenePos
=
view
()
->
mapToScene
(
mousePos
);
QRectF
itemRect
=
m_currentContext
.
top
()
->
boundingRect
()
|
m_currentContext
.
top
()
->
childrenBoundingRect
();
QRectF
polyRect
=
m_currentContext
.
top
()
->
mapToScene
(
itemRect
).
boundingRect
();
...
...
@@ -98,11 +98,11 @@ void SubcomponentEditorTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*
void
SubcomponentEditorTool
::
animate
()
{
if
(
m_animIncrement
>
0
)
{
if
(
m_mask
->
opacity
()
+
m_animIncrement
<
0.5
f
)
{
if
(
m_mask
->
opacity
()
+
m_animIncrement
<
MaxOpacity
)
{
m_mask
->
setOpacity
(
m_mask
->
opacity
()
+
m_animIncrement
);
}
else
{
m_animTimer
->
stop
();
m_mask
->
setOpacity
(
0.5
f
);
m_mask
->
setOpacity
(
MaxOpacity
);
}
}
else
{
if
(
m_mask
->
opacity
()
+
m_animIncrement
>
0
)
{
...
...
@@ -171,6 +171,29 @@ void SubcomponentEditorTool::setCurrentItem(QGraphicsItem* contextItem)
}
}
QGraphicsItem
*
SubcomponentEditorTool
::
firstChildOfContext
(
QGraphicsItem
*
item
)
const
{
if
(
!
item
)
return
0
;
if
(
isDirectChildOfContext
(
item
))
return
item
;
QGraphicsItem
*
parent
=
item
->
parentItem
();
while
(
parent
)
{
if
(
isDirectChildOfContext
(
parent
))
return
parent
;
parent
=
parent
->
parentItem
();
}
return
0
;
}
bool
SubcomponentEditorTool
::
isChildOfContext
(
QGraphicsItem
*
item
)
const
{
return
(
firstChildOfContext
(
item
)
!=
0
);
}
bool
SubcomponentEditorTool
::
isDirectChildOfContext
(
QGraphicsItem
*
item
)
const
{
return
(
item
->
parentItem
()
==
m_currentContext
.
top
());
...
...
@@ -212,7 +235,7 @@ QGraphicsObject *SubcomponentEditorTool::popContext()
QGraphicsObject
*
popped
=
m_currentContext
.
pop
();
if
(
m_currentContext
.
size
()
>
1
)
{
m_mask
->
setCurrentItem
(
m_currentContext
.
top
());
m_mask
->
setOpacity
(
0.5
f
);
m_mask
->
setOpacity
(
MaxOpacity
);
m_mask
->
setVisible
(
true
);
}
...
...
src/tools/qml/qmlviewer/editor/subcomponenteditortool.h
View file @
b19c4172
...
...
@@ -37,7 +37,10 @@ public:
bool
containsCursor
(
const
QPoint
&
mousePos
)
const
;
bool
itemIsChildOfQmlSubComponent
(
QGraphicsItem
*
item
)
const
;
bool
isChildOfContext
(
QGraphicsItem
*
item
)
const
;
bool
isDirectChildOfContext
(
QGraphicsItem
*
item
)
const
;
QGraphicsItem
*
firstChildOfContext
(
QGraphicsItem
*
item
)
const
;
void
setCurrentItem
(
QGraphicsItem
*
contextObject
);
...
...
@@ -45,6 +48,7 @@ public:
QGraphicsObject
*
popContext
();
QGraphicsObject
*
currentRootItem
()
const
;
signals:
void
exitContextRequested
();
...
...
src/tools/qml/qmlviewer/editor/subcomponentmasklayeritem.cpp
View file @
b19c4172
...
...
@@ -13,8 +13,9 @@ SubcomponentMaskLayerItem::SubcomponentMaskLayerItem(QDeclarativeDesignView *vie
{
m_borderRect
->
setRect
(
0
,
0
,
0
,
0
);
m_borderRect
->
setPen
(
QPen
(
QColor
(
60
,
60
,
60
),
1
));
m_borderRect
->
setData
(
Constants
::
EditorItemDataKey
,
QVariant
(
true
));
setBrush
(
QBrush
(
Q
t
::
black
));
setBrush
(
QBrush
(
Q
Color
(
160
,
160
,
160
)
));
setPen
(
Qt
::
NoPen
);
}
...
...
src/tools/qml/qmlviewer/qdeclarativedesignview.cpp
View file @
b19c4172
...
...
@@ -67,6 +67,15 @@ void QDeclarativeDesignView::reloadView()
emit
reloadRequested
();
}
void
QDeclarativeDesignView
::
leaveEvent
(
QEvent
*
event
)
{
if
(
!
designModeBehavior
())
{
QDeclarativeView
::
leaveEvent
(
event
);
return
;
}
clearHighlightBoundingRect
();
}
void
QDeclarativeDesignView
::
mousePressEvent
(
QMouseEvent
*
event
)
{
if
(
!
designModeBehavior
())
{
...
...
@@ -140,6 +149,12 @@ void QDeclarativeDesignView::keyReleaseEvent(QKeyEvent *event)
case
Qt
::
Key_M
:
changeToMarqueeSelectTool
();
break
;
case
Qt
::
Key_I
:
changeToColorPickerTool
();
break
;
case
Qt
::
Key_Z
:
changeToZoomTool
();
break
;
case
Qt
::
Key_Enter
:
case
Qt
::
Key_Return
:
if
(
!
selectedItems
().
isEmpty
())
...
...
@@ -171,13 +186,18 @@ void QDeclarativeDesignView::mouseDoubleClickEvent(QMouseEvent *event)
return
;
}
QGraphicsItem
*
itemToEnter
=
0
;
QList
<
QGraphicsItem
*>
itemList
=
selectableItems
(
event
->
pos
());
QList
<
QGraphicsItem
*>
itemList
=
items
(
event
->
pos
());
filterForSelection
(
itemList
);
if
(
selectedItems
().
isEmpty
()
&&
!
itemList
.
isEmpty
())
{
itemToEnter
=
itemList
.
first
();
}
else
if
(
!
selectedItems
().
isEmpty
()
&&
!
itemList
.
isEmpty
())
{
itemToEnter
=
itemList
.
first
();
}
if
(
itemToEnter
)
itemToEnter
=
m_subcomponentEditorTool
->
firstChildOfContext
(
itemToEnter
);
m_subcomponentEditorTool
->
setCurrentItem
(
itemToEnter
);
m_subcomponentEditorTool
->
mouseDoubleClickEvent
(
event
);
...
...
@@ -251,8 +271,13 @@ void QDeclarativeDesignView::highlightBoundingRect(QGraphicsItem *item)
{
if
(
!
item
)
return
;
QGraphicsItem
*
itemToHighlight
=
m_subcomponentEditorTool
->
firstChildOfContext
(
item
);
m_boundingRectHighlighter
->
highlight
(
item
->
toGraphicsObject
());
if
(
itemToHighlight
)
{
m_boundingRectHighlighter
->
highlight
(
itemToHighlight
->
toGraphicsObject
());
}
else
{
clearHighlightBoundingRect
();
}
}
bool
QDeclarativeDesignView
::
mouseInsideContextItem
()
const
...
...
@@ -263,20 +288,20 @@ bool QDeclarativeDesignView::mouseInsideContextItem() const
QList
<
QGraphicsItem
*>
QDeclarativeDesignView
::
selectableItems
(
const
QPointF
&
scenePos
)
const
{
QList
<
QGraphicsItem
*>
itemlist
=
scene
()
->
items
(
scenePos
);
return
filter
edItemLis
t
(
itemlist
);
return
filter
ForCurrentContex
t
(
itemlist
);
}
QList
<
QGraphicsItem
*>
QDeclarativeDesignView
::
selectableItems
(
const
QPoint
&
pos
)
const
{
QList
<
QGraphicsItem
*>
itemlist
=
items
(
pos
);
return
filter
edItemLis
t
(
itemlist
);
return
filter
ForCurrentContex
t
(
itemlist
);
}
QList
<
QGraphicsItem
*>
QDeclarativeDesignView
::
selectableItems
(
const
QRectF
&
sceneRect
,
Qt
::
ItemSelectionMode
selectionMode
)
const
{
QList
<
QGraphicsItem
*>
itemlist
=
scene
()
->
items
(
sceneRect
,
selectionMode
);
return
filter
edItemLis
t
(
itemlist
);
return
filter
ForCurrentContex
t
(
itemlist
);
}
void
QDeclarativeDesignView
::
changeToSingleSelectTool
()
...
...
@@ -369,13 +394,12 @@ void QDeclarativeDesignView::continueExecution(qreal slowdownFactor)
void
QDeclarativeDesignView
::
pauseExecution
()
{
QUnifiedTimer
*
timer
=
QUnifiedTimer
::
instance
();
m_slowdownFactor
=
0
;
timer
->
setSlowdownFactor
(
m_slowdownFactor
);
timer
->
setSlowdownFactor
(
0
);
timer
->
setSlowModeEnabled
(
true
);
m_executionPaused
=
true
;
emit
executionPaused
();
qmlDesignDebugServer
()
->
setAnimationSpeed
(
m_slowdownFactor
);
qmlDesignDebugServer
()
->
setAnimationSpeed
(
0
);
}
void
QDeclarativeDesignView
::
applyChangesFromClient
()
...
...
@@ -388,20 +412,46 @@ LayerItem *QDeclarativeDesignView::manipulatorLayer() const
return
m_manipulatorLayer
;
}
QList
<
QGraphicsItem
*>
QDeclarativeDesignView
::
filter
edItemList
(
QList
<
QGraphicsItem
*>
&
itemlist
)
const
QList
<
QGraphicsItem
*>
QDeclarativeDesignView
::
filter
ForSelection
(
QList
<
QGraphicsItem
*>
&
itemlist
)
const
{
foreach
(
QGraphicsItem
*
item
,
itemlist
)
{
if
(
item
->
type
()
==
Constants
::
EditorItemType
||
item
->
type
()
==
Constants
::
ResizeHandleItemType
||
!
m_subcomponentEditorTool
->
isDirectChildOfContext
(
item
))
{
if
(
isEditorItem
(
item
)
||
!
m_subcomponentEditorTool
->
isChildOfContext
(
item
))
itemlist
.
removeOne
(
item
);
}
return
itemlist
;
}
QList
<
QGraphicsItem
*>
QDeclarativeDesignView
::
filterForCurrentContext
(
QList
<
QGraphicsItem
*>
&
itemlist
)
const
{
foreach
(
QGraphicsItem
*
item
,
itemlist
)
{
if
(
isEditorItem
(
item
)
||
!
m_subcomponentEditorTool
->
isDirectChildOfContext
(
item
))
{
int
index
=
itemlist
.
indexOf
(
item
);
// if we're a child, but not directly, replace with the parent that is directly in context.
if
(
QGraphicsItem
*
contextParent
=
m_subcomponentEditorTool
->
firstChildOfContext
(
item
))
{
if
(
index
>=
0
)
{
itemlist
.
replace
(
index
,
contextParent
);
}
else
{
itemlist
.
append
(
contextParent
);
}
}
else
{
itemlist
.
removeAt
(
index
);
}
}
}
return
itemlist
;
}
bool
QDeclarativeDesignView
::
isEditorItem
(
QGraphicsItem
*
item
)
const
{
return
(
item
->
type
()
==
Constants
::
EditorItemType
||
item
->
type
()
==
Constants
::
ResizeHandleItemType
||
item
->
data
(
Constants
::
EditorItemDataKey
).
toBool
());
}
void
QDeclarativeDesignView
::
onStatusChanged
(
QDeclarativeView
::
Status
status
)
{
...
...
src/tools/qml/qmlviewer/qdeclarativedesignview.h
View file @
b19c4172
...
...
@@ -39,6 +39,8 @@ public:
void
highlightBoundingRect
(
QGraphicsItem
*
item
);
bool
mouseInsideContextItem
()
const
;
bool
isEditorItem
(
QGraphicsItem
*
item
)
const
;
QList
<
QGraphicsItem
*>
selectableItems
(
const
QPoint
&
pos
)
const
;
QList
<
QGraphicsItem
*>
selectableItems
(
const
QPointF
&
scenePos
)
const
;
QList
<
QGraphicsItem
*>
selectableItems
(
const
QRectF
&
sceneRect
,
Qt
::
ItemSelectionMode
selectionMode
)
const
;
...
...
@@ -71,6 +73,7 @@ Q_SIGNALS:
void
executionPaused
();
protected:
void
leaveEvent
(
QEvent
*
);
void
mousePressEvent
(
QMouseEvent
*
event
);
void
mouseMoveEvent
(
QMouseEvent
*
event
);
void
mouseReleaseEvent
(
QMouseEvent
*
event
);
...
...
@@ -88,7 +91,8 @@ private Q_SLOTS:
private:
void
createToolbar
();
void
changeToSelectTool
();
QList
<
QGraphicsItem
*>
filteredItemList
(
QList
<
QGraphicsItem
*>
&
itemlist
)
const
;
QList
<
QGraphicsItem
*>
filterForCurrentContext
(
QList
<
QGraphicsItem
*>
&
itemlist
)
const
;
QList
<
QGraphicsItem
*>
filterForSelection
(
QList
<
QGraphicsItem
*>
&
itemlist
)
const
;
private:
QPointF
m_cursorPos
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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