Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Tobias Hunger
qt-creator
Commits
4b5b9631
Commit
4b5b9631
authored
Aug 03, 2010
by
Lasse Holmstedt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QML Observer: Update selection rects when item's geometry changes
parent
514ec10c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
18 deletions
+38
-18
src/libs/qmljsdebugger/editor/selectionindicator.cpp
src/libs/qmljsdebugger/editor/selectionindicator.cpp
+7
-14
src/libs/qmljsdebugger/editor/selectionindicator.h
src/libs/qmljsdebugger/editor/selectionindicator.h
+1
-2
src/libs/qmljsdebugger/editor/selectiontool.cpp
src/libs/qmljsdebugger/editor/selectiontool.cpp
+27
-1
src/libs/qmljsdebugger/editor/selectiontool.h
src/libs/qmljsdebugger/editor/selectiontool.h
+3
-0
src/libs/qmljsdebugger/editor/singleselectionmanipulator.h
src/libs/qmljsdebugger/editor/singleselectionmanipulator.h
+0
-1
No files found.
src/libs/qmljsdebugger/editor/selectionindicator.cpp
View file @
4b5b9631
...
...
@@ -81,13 +81,18 @@ QPolygonF SelectionIndicator::addBoundingRectToPolygon(QGraphicsItem *item, QPol
return
polygon
;
}
void
SelectionIndicator
::
setItems
(
const
QList
<
QGraphicsObject
*
>
&
itemList
)
void
SelectionIndicator
::
setItems
(
const
QList
<
QWeakPointer
<
QGraphicsObject
>
>
&
itemList
)
{
clear
();
// set selections to also all children if they are not editor items
foreach
(
QGraphicsItem
*
item
,
itemList
)
{
foreach
(
QWeakPointer
<
QGraphicsObject
>
obj
,
itemList
)
{
if
(
obj
.
isNull
())
continue
;
QGraphicsItem
*
item
=
obj
.
data
();
QGraphicsPolygonItem
*
newSelectionIndicatorGraphicsItem
=
new
QGraphicsPolygonItem
(
m_layerItem
.
data
());
m_indicatorShapeHash
.
insert
(
item
,
newSelectionIndicatorGraphicsItem
);
...
...
@@ -106,17 +111,5 @@ void SelectionIndicator::setItems(const QList<QGraphicsObject*> &itemList)
}
}
void
SelectionIndicator
::
updateItems
(
const
QList
<
QGraphicsObject
*>
&
itemList
)
{
foreach
(
QGraphicsItem
*
item
,
itemList
)
{
if
(
m_indicatorShapeHash
.
contains
(
item
))
{
QGraphicsPolygonItem
*
indicatorGraphicsItem
=
m_indicatorShapeHash
.
value
(
item
);
QPolygonF
boundingRectInSceneSpace
(
item
->
mapToScene
(
item
->
boundingRect
()));
QPolygonF
boundingRectInLayerItemSpace
=
m_layerItem
->
mapFromScene
(
boundingRectInSceneSpace
);
indicatorGraphicsItem
->
setPolygon
(
boundingRectInLayerItemSpace
);
}
}
}
}
//namespace QmlViewer
src/libs/qmljsdebugger/editor/selectionindicator.h
View file @
4b5b9631
...
...
@@ -49,8 +49,7 @@ public:
void
clear
();
void
setItems
(
const
QList
<
QGraphicsObject
*>
&
itemList
);
void
updateItems
(
const
QList
<
QGraphicsObject
*>
&
itemList
);
void
setItems
(
const
QList
<
QWeakPointer
<
QGraphicsObject
>
>
&
itemList
);
private:
QPolygonF
addBoundingRectToPolygon
(
QGraphicsItem
*
item
,
QPolygonF
&
polygon
);
...
...
src/libs/qmljsdebugger/editor/selectiontool.cpp
View file @
4b5b9631
...
...
@@ -407,10 +407,36 @@ void SelectionTool::clear()
void
SelectionTool
::
selectedItemsChanged
(
const
QList
<
QGraphicsItem
*>
&
itemList
)
{
m_selectionIndicator
.
setItems
(
toGraphicsObjectList
(
itemList
));
foreach
(
QWeakPointer
<
QGraphicsObject
>
obj
,
m_selectedItemList
)
{
if
(
!
obj
.
isNull
())
{
disconnect
(
obj
.
data
(),
SIGNAL
(
xChanged
()),
this
,
SLOT
(
repaintBoundingRects
()));
disconnect
(
obj
.
data
(),
SIGNAL
(
yChanged
()),
this
,
SLOT
(
repaintBoundingRects
()));
disconnect
(
obj
.
data
(),
SIGNAL
(
widthChanged
()),
this
,
SLOT
(
repaintBoundingRects
()));
disconnect
(
obj
.
data
(),
SIGNAL
(
heightChanged
()),
this
,
SLOT
(
repaintBoundingRects
()));
disconnect
(
obj
.
data
(),
SIGNAL
(
rotationChanged
()),
this
,
SLOT
(
repaintBoundingRects
()));
}
}
QList
<
QGraphicsObject
*>
objects
=
toGraphicsObjectList
(
itemList
);
m_selectedItemList
.
clear
();
foreach
(
QGraphicsObject
*
obj
,
objects
)
{
m_selectedItemList
.
append
(
obj
);
connect
(
obj
,
SIGNAL
(
xChanged
()),
this
,
SLOT
(
repaintBoundingRects
()));
connect
(
obj
,
SIGNAL
(
yChanged
()),
this
,
SLOT
(
repaintBoundingRects
()));
connect
(
obj
,
SIGNAL
(
widthChanged
()),
this
,
SLOT
(
repaintBoundingRects
()));
connect
(
obj
,
SIGNAL
(
heightChanged
()),
this
,
SLOT
(
repaintBoundingRects
()));
connect
(
obj
,
SIGNAL
(
rotationChanged
()),
this
,
SLOT
(
repaintBoundingRects
()));
}
m_selectionIndicator
.
setItems
(
m_selectedItemList
);
//m_resizeIndicator.setItems(toGraphicsObjectList(itemList));
}
void
SelectionTool
::
repaintBoundingRects
()
{
m_selectionIndicator
.
setItems
(
m_selectedItemList
);
}
void
SelectionTool
::
selectUnderPoint
(
QMouseEvent
*
event
)
{
m_singleSelectionManipulator
.
begin
(
event
->
pos
());
...
...
src/libs/qmljsdebugger/editor/selectiontool.h
View file @
4b5b9631
...
...
@@ -85,6 +85,7 @@ public:
private
slots
:
void
contextMenuElementSelected
();
void
contextMenuElementHovered
(
QAction
*
action
);
void
repaintBoundingRects
();
private:
void
createContextMenu
(
QList
<
QGraphicsItem
*>
itemList
,
QPoint
globalPos
);
...
...
@@ -100,6 +101,8 @@ private:
QTime
m_mousePressTimer
;
bool
m_selectOnlyContentItems
;
QList
<
QWeakPointer
<
QGraphicsObject
>
>
m_selectedItemList
;
QList
<
QGraphicsItem
*>
m_contextMenuItemList
;
};
...
...
src/libs/qmljsdebugger/editor/singleselectionmanipulator.h
View file @
4b5b9631
...
...
@@ -30,7 +30,6 @@
#ifndef SINGLESELECTIONMANIPULATOR_H
#define SINGLESELECTIONMANIPULATOR_H
#include "selectionrectangle.h"
#include <QPointF>
#include <QList>
...
...
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