Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
801c8bb6
Commit
801c8bb6
authored
Dec 01, 2010
by
Kai Koehne
Browse files
QmlJSDebugger: Code cleanup
Fix indentation + line length.
parent
845480d4
Changes
25
Hide whitespace changes
Inline
Side-by-side
share/qtcreator/qml/qmljsdebugger/editor/abstractformeditortool.cpp
View file @
801c8bb6
...
...
@@ -86,7 +86,8 @@ bool AbstractFormEditorTool::topItemIsMovable(const QList<QGraphicsItem*> & item
if
(
firstSelectableItem
==
0
)
return
false
;
QDeclarativeItem
*
declarativeItem
=
dynamic_cast
<
QDeclarativeItem
*>
(
firstSelectableItem
->
toGraphicsObject
());
QDeclarativeItem
*
declarativeItem
=
dynamic_cast
<
QDeclarativeItem
*>
(
firstSelectableItem
->
toGraphicsObject
());
if
(
declarativeItem
!=
0
)
return
true
;
...
...
@@ -102,8 +103,8 @@ bool AbstractFormEditorTool::topSelectedItemIsMovable(const QList<QGraphicsItem*
foreach
(
QGraphicsItem
*
item
,
itemList
)
{
QDeclarativeItem
*
declarativeItem
=
toQDeclarativeItem
(
item
);
if
(
declarativeItem
&&
selectedItems
.
contains
(
declarativeItem
)
/*&& (declarativeItem->qmlItemNode().hasShowContent() || selectNonContentItems)*/
)
&&
selectedItems
.
contains
(
declarativeItem
)
/*&& (declarativeItem->qmlItemNode().hasShowContent() || selectNonContentItems)*/
)
return
true
;
}
...
...
@@ -130,7 +131,8 @@ QGraphicsItem *AbstractFormEditorTool::topMovableGraphicsItem(const QList<QGraph
return
0
;
}
QDeclarativeItem
*
AbstractFormEditorTool
::
topMovableDeclarativeItem
(
const
QList
<
QGraphicsItem
*>
&
itemList
)
QDeclarativeItem
*
AbstractFormEditorTool
::
topMovableDeclarativeItem
(
const
QList
<
QGraphicsItem
*>
&
itemList
)
{
foreach
(
QGraphicsItem
*
item
,
itemList
)
{
QDeclarativeItem
*
declarativeItem
=
toQDeclarativeItem
(
item
);
...
...
@@ -141,7 +143,8 @@ QDeclarativeItem *AbstractFormEditorTool::topMovableDeclarativeItem(const QList<
return
0
;
}
QList
<
QGraphicsObject
*>
AbstractFormEditorTool
::
toGraphicsObjectList
(
const
QList
<
QGraphicsItem
*>
&
itemList
)
QList
<
QGraphicsObject
*>
AbstractFormEditorTool
::
toGraphicsObjectList
(
const
QList
<
QGraphicsItem
*>
&
itemList
)
{
QList
<
QGraphicsObject
*>
gfxObjects
;
foreach
(
QGraphicsItem
*
item
,
itemList
)
{
...
...
share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.cpp
View file @
801c8bb6
...
...
@@ -43,7 +43,8 @@ const qreal AnimDelta = 0.025f;
const
int
AnimInterval
=
30
;
const
int
AnimFrames
=
10
;
BoundingBox
::
BoundingBox
(
QGraphicsObject
*
itemToHighlight
,
QGraphicsItem
*
parentItem
,
QObject
*
parent
)
BoundingBox
::
BoundingBox
(
QGraphicsObject
*
itemToHighlight
,
QGraphicsItem
*
parentItem
,
QObject
*
parent
)
:
QObject
(
parent
),
highlightedObject
(
itemToHighlight
),
highlightPolygon
(
0
),
...
...
@@ -243,7 +244,8 @@ void BoundingRectHighlighter::highlightAll(bool animate)
QPolygonF
boundingRectInSceneSpace
(
item
->
mapToScene
(
itemAndChildRect
));
QPolygonF
boundingRectInLayerItemSpace
=
mapFromScene
(
boundingRectInSceneSpace
);
QRectF
bboxRect
=
m_view
->
adjustToScreenBoundaries
(
boundingRectInLayerItemSpace
.
boundingRect
());
QRectF
bboxRect
=
m_view
->
adjustToScreenBoundaries
(
boundingRectInLayerItemSpace
.
boundingRect
());
QRectF
edgeRect
=
bboxRect
;
edgeRect
.
adjust
(
-
1
,
-
1
,
1
,
1
);
...
...
share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.h
View file @
801c8bb6
...
...
@@ -84,7 +84,8 @@ class BoundingBox : public QObject
{
Q_OBJECT
public:
explicit
BoundingBox
(
QGraphicsObject
*
itemToHighlight
,
QGraphicsItem
*
parentItem
,
QObject
*
parent
=
0
);
explicit
BoundingBox
(
QGraphicsObject
*
itemToHighlight
,
QGraphicsItem
*
parentItem
,
QObject
*
parent
=
0
);
~
BoundingBox
();
QWeakPointer
<
QGraphicsObject
>
highlightedObject
;
QGraphicsPolygonItem
*
highlightPolygon
;
...
...
share/qtcreator/qml/qmljsdebugger/editor/colorpickertool.cpp
View file @
801c8bb6
...
...
@@ -41,7 +41,7 @@
namespace
QmlJSDebugger
{
ColorPickerTool
::
ColorPickerTool
(
QDeclarativeViewObserver
*
view
)
:
AbstractFormEditorTool
(
view
)
AbstractFormEditorTool
(
view
)
{
m_selectedColor
.
setRgb
(
0
,
0
,
0
);
}
...
...
share/qtcreator/qml/qmljsdebugger/editor/layeritem.cpp
View file @
801c8bb6
...
...
@@ -35,7 +35,7 @@
namespace
QmlJSDebugger
{
LayerItem
::
LayerItem
(
QGraphicsScene
*
scene
)
:
QGraphicsObject
()
:
QGraphicsObject
()
{
scene
->
addItem
(
this
);
setZValue
(
1
);
...
...
@@ -46,7 +46,8 @@ LayerItem::~LayerItem()
{
}
void
LayerItem
::
paint
(
QPainter
*
/*painter*/
,
const
QStyleOptionGraphicsItem
*
/*option*/
,
QWidget
*
/*widget*/
)
void
LayerItem
::
paint
(
QPainter
*
/*painter*/
,
const
QStyleOptionGraphicsItem
*
/*option*/
,
QWidget
*
/*widget*/
)
{
}
...
...
share/qtcreator/qml/qmljsdebugger/editor/layeritem.h
View file @
801c8bb6
...
...
@@ -40,9 +40,10 @@ class FormEditorScene;
class
LayerItem
:
public
QGraphicsObject
{
public:
LayerItem
(
QGraphicsScene
*
scene
);
LayerItem
(
QGraphicsScene
*
scene
);
~
LayerItem
();
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
=
0
);
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
=
0
);
QRectF
boundingRect
()
const
;
int
type
()
const
;
...
...
share/qtcreator/qml/qmljsdebugger/editor/qmltoolbar.cpp
View file @
801c8bb6
...
...
@@ -50,14 +50,19 @@ QmlToolbar::QmlToolbar(QWidget *parent)
ui
->
playIcon
=
QIcon
(
QLatin1String
(
":/qml/images/play-24.png"
));
ui
->
pauseIcon
=
QIcon
(
QLatin1String
(
":/qml/images/pause-24.png"
));
ui
->
designmode
=
new
QAction
(
QIcon
(
QLatin1String
(
":/qml/images/observermode-24.png"
)),
tr
(
"Observer Mode"
),
this
);
ui
->
designmode
=
new
QAction
(
QIcon
(
QLatin1String
(
":/qml/images/observermode-24.png"
)),
tr
(
"Observer Mode"
),
this
);
ui
->
play
=
new
QAction
(
ui
->
pauseIcon
,
tr
(
"Play/Pause Animations"
),
this
);
ui
->
select
=
new
QAction
(
QIcon
(
QLatin1String
(
":/qml/images/select-24.png"
)),
tr
(
"Select"
),
this
);
ui
->
selectMarquee
=
new
QAction
(
QIcon
(
QLatin1String
(
":/qml/images/select-marquee-24.png"
)),
tr
(
"Select (Marquee)"
),
this
);
ui
->
selectMarquee
=
new
QAction
(
QIcon
(
QLatin1String
(
":/qml/images/select-marquee-24.png"
)),
tr
(
"Select (Marquee)"
),
this
);
ui
->
zoom
=
new
QAction
(
QIcon
(
QLatin1String
(
":/qml/images/zoom-24.png"
)),
tr
(
"Zoom"
),
this
);
ui
->
colorPicker
=
new
QAction
(
QIcon
(
QLatin1String
(
":/qml/images/color-picker-24.png"
)),
tr
(
"Color Picker"
),
this
);
ui
->
toQml
=
new
QAction
(
QIcon
(
QLatin1String
(
":/qml/images/to-qml-24.png"
)),
tr
(
"Apply Changes to QML Viewer"
),
this
);
ui
->
fromQml
=
new
QAction
(
QIcon
(
QLatin1String
(
":/qml/images/from-qml-24.png"
)),
tr
(
"Apply Changes to Document"
),
this
);
ui
->
colorPicker
=
new
QAction
(
QIcon
(
QLatin1String
(
":/qml/images/color-picker-24.png"
)),
tr
(
"Color Picker"
),
this
);
ui
->
toQml
=
new
QAction
(
QIcon
(
QLatin1String
(
":/qml/images/to-qml-24.png"
)),
tr
(
"Apply Changes to QML Viewer"
),
this
);
ui
->
fromQml
=
new
QAction
(
QIcon
(
QLatin1String
(
":/qml/images/from-qml-24.png"
)),
tr
(
"Apply Changes to Document"
),
this
);
ui
->
designmode
->
setCheckable
(
true
);
ui
->
designmode
->
setChecked
(
false
);
...
...
@@ -94,24 +99,29 @@ QmlToolbar::QmlToolbar(QWidget *parent)
playSpeedMenuActions
->
setExclusive
(
true
);
playSpeedMenu
->
addAction
(
tr
(
"Animation Speed"
));
playSpeedMenu
->
addSeparator
();
ui
->
defaultAnimSpeedAction
=
playSpeedMenu
->
addAction
(
tr
(
"1x"
),
this
,
SLOT
(
changeToDefaultAnimSpeed
()));
ui
->
defaultAnimSpeedAction
=
playSpeedMenu
->
addAction
(
tr
(
"1x"
),
this
,
SLOT
(
changeToDefaultAnimSpeed
()));
ui
->
defaultAnimSpeedAction
->
setCheckable
(
true
);
ui
->
defaultAnimSpeedAction
->
setChecked
(
true
);
playSpeedMenuActions
->
addAction
(
ui
->
defaultAnimSpeedAction
);
ui
->
halfAnimSpeedAction
=
playSpeedMenu
->
addAction
(
tr
(
"0.5x"
),
this
,
SLOT
(
changeToHalfAnimSpeed
()));
ui
->
halfAnimSpeedAction
=
playSpeedMenu
->
addAction
(
tr
(
"0.5x"
),
this
,
SLOT
(
changeToHalfAnimSpeed
()));
ui
->
halfAnimSpeedAction
->
setCheckable
(
true
);
playSpeedMenuActions
->
addAction
(
ui
->
halfAnimSpeedAction
);
ui
->
fourthAnimSpeedAction
=
playSpeedMenu
->
addAction
(
tr
(
"0.25x"
),
this
,
SLOT
(
changeToFourthAnimSpeed
()));
ui
->
fourthAnimSpeedAction
=
playSpeedMenu
->
addAction
(
tr
(
"0.25x"
),
this
,
SLOT
(
changeToFourthAnimSpeed
()));
ui
->
fourthAnimSpeedAction
->
setCheckable
(
true
);
playSpeedMenuActions
->
addAction
(
ui
->
fourthAnimSpeedAction
);
ui
->
eighthAnimSpeedAction
=
playSpeedMenu
->
addAction
(
tr
(
"0.125x"
),
this
,
SLOT
(
changeToEighthAnimSpeed
()));
ui
->
eighthAnimSpeedAction
=
playSpeedMenu
->
addAction
(
tr
(
"0.125x"
),
this
,
SLOT
(
changeToEighthAnimSpeed
()));
ui
->
eighthAnimSpeedAction
->
setCheckable
(
true
);
playSpeedMenuActions
->
addAction
(
ui
->
eighthAnimSpeedAction
);
ui
->
tenthAnimSpeedAction
=
playSpeedMenu
->
addAction
(
tr
(
"0.1x"
),
this
,
SLOT
(
changeToTenthAnimSpeed
()));
ui
->
tenthAnimSpeedAction
=
playSpeedMenu
->
addAction
(
tr
(
"0.1x"
),
this
,
SLOT
(
changeToTenthAnimSpeed
()));
ui
->
tenthAnimSpeedAction
->
setCheckable
(
true
);
playSpeedMenuActions
->
addAction
(
ui
->
tenthAnimSpeedAction
);
...
...
share/qtcreator/qml/qmljsdebugger/editor/rubberbandselectionmanipulator.cpp
View file @
801c8bb6
...
...
@@ -34,11 +34,12 @@
namespace
QmlJSDebugger
{
RubberBandSelectionManipulator
::
RubberBandSelectionManipulator
(
QGraphicsObject
*
layerItem
,
QDeclarativeViewObserver
*
editorView
)
RubberBandSelectionManipulator
::
RubberBandSelectionManipulator
(
QGraphicsObject
*
layerItem
,
QDeclarativeViewObserver
*
editorView
)
:
m_selectionRectangleElement
(
layerItem
),
m_editorView
(
editorView
),
m_beginFormEditorItem
(
0
),
m_isActive
(
false
)
m_editorView
(
editorView
),
m_beginFormEditorItem
(
0
),
m_isActive
(
false
)
{
m_selectionRectangleElement
.
hide
();
}
...
...
@@ -52,7 +53,8 @@ void RubberBandSelectionManipulator::clear()
m_oldSelectionList
.
clear
();
}
QGraphicsItem
*
RubberBandSelectionManipulator
::
topFormEditorItem
(
const
QList
<
QGraphicsItem
*>
&
itemList
)
QGraphicsItem
*
RubberBandSelectionManipulator
::
topFormEditorItem
(
const
QList
<
QGraphicsItem
*>
&
itemList
)
{
if
(
itemList
.
isEmpty
())
return
0
;
...
...
@@ -66,7 +68,9 @@ void RubberBandSelectionManipulator::begin(const QPointF& beginPoint)
m_selectionRectangleElement
.
setRect
(
m_beginPoint
,
m_beginPoint
);
m_selectionRectangleElement
.
show
();
m_isActive
=
true
;
m_beginFormEditorItem
=
topFormEditorItem
(
QDeclarativeViewObserverPrivate
::
get
(
m_editorView
)
->
selectableItems
(
beginPoint
));
QDeclarativeViewObserverPrivate
*
observerPrivate
=
QDeclarativeViewObserverPrivate
::
get
(
m_editorView
);
m_beginFormEditorItem
=
topFormEditorItem
(
observerPrivate
->
selectableItems
(
beginPoint
));
m_oldSelectionList
=
m_editorView
->
selectedItems
();
}
...
...
@@ -84,16 +88,19 @@ void RubberBandSelectionManipulator::end()
void
RubberBandSelectionManipulator
::
select
(
SelectionType
selectionType
)
{
QList
<
QGraphicsItem
*>
itemList
=
QDeclarativeViewObserverPrivate
::
get
(
m_editorView
)
->
selectableItems
(
m_selectionRectangleElement
.
rect
(),
Qt
::
IntersectsItemShape
);
QDeclarativeViewObserverPrivate
*
observerPrivate
=
QDeclarativeViewObserverPrivate
::
get
(
m_editorView
);
QList
<
QGraphicsItem
*>
itemList
=
observerPrivate
->
selectableItems
(
m_selectionRectangleElement
.
rect
(),
Qt
::
IntersectsItemShape
);
QList
<
QGraphicsItem
*>
newSelectionList
;
foreach
(
QGraphicsItem
*
item
,
itemList
)
{
if
(
item
&&
item
->
parentItem
()
&&
!
newSelectionList
.
contains
(
item
)
//&& m_beginFormEditorItem->childItems().contains(item) // TODO activate this test
)
&&
item
->
parentItem
()
&&
!
newSelectionList
.
contains
(
item
)
//&& m_beginFormEditorItem->childItems().contains(item) // TODO activate this test
)
{
newSelectionList
.
append
(
item
);
}
...
...
@@ -106,19 +113,19 @@ void RubberBandSelectionManipulator::select(SelectionType selectionType)
switch
(
selectionType
)
{
case
AddToSelection
:
{
resultList
.
append
(
m_oldSelectionList
);
resultList
.
append
(
newSelectionList
);
}
resultList
.
append
(
m_oldSelectionList
);
resultList
.
append
(
newSelectionList
);
}
break
;
case
ReplaceSelection
:
{
resultList
.
append
(
newSelectionList
);
}
resultList
.
append
(
newSelectionList
);
}
break
;
case
RemoveFromSelection
:
{
QSet
<
QGraphicsItem
*>
oldSelectionSet
(
m_oldSelectionList
.
toSet
());
QSet
<
QGraphicsItem
*>
newSelectionSet
(
newSelectionList
.
toSet
());
resultList
.
append
(
oldSelectionSet
.
subtract
(
newSelectionSet
).
toList
());
}
QSet
<
QGraphicsItem
*>
oldSelectionSet
(
m_oldSelectionList
.
toSet
());
QSet
<
QGraphicsItem
*>
newSelectionSet
(
newSelectionList
.
toSet
());
resultList
.
append
(
oldSelectionSet
.
subtract
(
newSelectionSet
).
toList
());
}
}
m_editorView
->
setSelectedItems
(
resultList
);
...
...
@@ -138,7 +145,6 @@ QPointF RubberBandSelectionManipulator::beginPoint() const
bool
RubberBandSelectionManipulator
::
isActive
()
const
{
return
m_isActive
;
}
}
}
// namespace QmlJSDebugger
share/qtcreator/qml/qmljsdebugger/editor/rubberbandselectionmanipulator.h
View file @
801c8bb6
...
...
@@ -46,8 +46,8 @@ public:
RemoveFromSelection
};
RubberBandSelectionManipulator
(
QGraphicsObject
*
layerItem
,
QDeclarativeViewObserver
*
editorView
);
RubberBandSelectionManipulator
(
QGraphicsObject
*
layerItem
,
QDeclarativeViewObserver
*
editorView
);
void
setItems
(
const
QList
<
QGraphicsItem
*>
&
itemList
);
...
...
@@ -66,7 +66,6 @@ public:
protected:
QGraphicsItem
*
topFormEditorItem
(
const
QList
<
QGraphicsItem
*>
&
itemList
);
private:
QList
<
QGraphicsItem
*>
m_itemList
;
QList
<
QGraphicsItem
*>
m_oldSelectionList
;
...
...
share/qtcreator/qml/qmljsdebugger/editor/selectionindicator.cpp
View file @
801c8bb6
...
...
@@ -38,7 +38,8 @@
namespace
QmlJSDebugger
{
SelectionIndicator
::
SelectionIndicator
(
QDeclarativeViewObserver
*
editorView
,
QGraphicsObject
*
layerItem
)
SelectionIndicator
::
SelectionIndicator
(
QDeclarativeViewObserver
*
editorView
,
QGraphicsObject
*
layerItem
)
:
m_layerItem
(
layerItem
),
m_view
(
editorView
)
{
}
...
...
@@ -103,19 +104,22 @@ void SelectionIndicator::setItems(const QList<QWeakPointer<QGraphicsObject> > &i
QGraphicsItem
*
item
=
object
.
data
();
QGraphicsPolygonItem
*
newSelectionIndicatorGraphicsItem
=
new
QGraphicsPolygonItem
(
m_layerItem
.
data
());
QGraphicsPolygonItem
*
newSelectionIndicatorGraphicsItem
=
new
QGraphicsPolygonItem
(
m_layerItem
.
data
());
if
(
!
m_indicatorShapeHash
.
contains
(
item
))
{
m_indicatorShapeHash
.
insert
(
item
,
newSelectionIndicatorGraphicsItem
);
QPolygonF
boundingShapeInSceneSpace
;
addBoundingRectToPolygon
(
item
,
boundingShapeInSceneSpace
);
QRectF
boundingRect
=
m_view
->
adjustToScreenBoundaries
(
boundingShapeInSceneSpace
.
boundingRect
());
QRectF
boundingRect
=
m_view
->
adjustToScreenBoundaries
(
boundingShapeInSceneSpace
.
boundingRect
());
QPolygonF
boundingRectInLayerItemSpace
=
m_layerItem
.
data
()
->
mapFromScene
(
boundingRect
);
QPen
pen
;
pen
.
setColor
(
QColor
(
108
,
141
,
221
));
newSelectionIndicatorGraphicsItem
->
setData
(
Constants
::
EditorItemDataKey
,
QVariant
(
true
));
newSelectionIndicatorGraphicsItem
->
setData
(
Constants
::
EditorItemDataKey
,
QVariant
(
true
));
newSelectionIndicatorGraphicsItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
false
);
newSelectionIndicatorGraphicsItem
->
setPolygon
(
boundingRectInLayerItemSpace
);
newSelectionIndicatorGraphicsItem
->
setPen
(
pen
);
...
...
share/qtcreator/qml/qmljsdebugger/editor/selectionrectangle.cpp
View file @
801c8bb6
...
...
@@ -47,7 +47,7 @@ public:
SelectionRectangle
::
SelectionRectangle
(
QGraphicsObject
*
layerItem
)
:
m_controlShape
(
new
SelectionRectShape
(
layerItem
)),
m_layerItem
(
layerItem
)
m_layerItem
(
layerItem
)
{
m_controlShape
->
setPen
(
QPen
(
Qt
::
black
));
m_controlShape
->
setBrush
(
QColor
(
128
,
128
,
128
,
50
));
...
...
@@ -85,8 +85,10 @@ void SelectionRectangle::setRect(const QPointF &firstPoint,
double
firstY
=
std
::
floor
(
firstPoint
.
y
())
+
0.5
;
double
secondX
=
std
::
floor
(
secondPoint
.
x
())
+
0.5
;
double
secondY
=
std
::
floor
(
secondPoint
.
y
())
+
0.5
;
QPointF
topLeftPoint
(
firstX
<
secondX
?
firstX
:
secondX
,
firstY
<
secondY
?
firstY
:
secondY
);
QPointF
bottomRightPoint
(
firstX
>
secondX
?
firstX
:
secondX
,
firstY
>
secondY
?
firstY
:
secondY
);
QPointF
topLeftPoint
(
firstX
<
secondX
?
firstX
:
secondX
,
firstY
<
secondY
?
firstY
:
secondY
);
QPointF
bottomRightPoint
(
firstX
>
secondX
?
firstX
:
secondX
,
firstY
>
secondY
?
firstY
:
secondY
);
QRectF
rect
(
topLeftPoint
,
bottomRightPoint
);
m_controlShape
->
setRect
(
rect
);
...
...
share/qtcreator/qml/qmljsdebugger/editor/selectiontool.cpp
View file @
801c8bb6
...
...
@@ -48,12 +48,14 @@
namespace
QmlJSDebugger
{
SelectionTool
::
SelectionTool
(
QDeclarativeViewObserver
*
editorView
)
:
AbstractFormEditorTool
(
editorView
),
SelectionTool
::
SelectionTool
(
QDeclarativeViewObserver
*
editorView
)
:
AbstractFormEditorTool
(
editorView
),
m_rubberbandSelectionMode
(
false
),
m_rubberbandSelectionManipulator
(
QDeclarativeViewObserverPrivate
::
get
(
editorView
)
->
manipulatorLayer
,
editorView
),
m_rubberbandSelectionManipulator
(
QDeclarativeViewObserverPrivate
::
get
(
editorView
)
->
manipulatorLayer
,
editorView
),
m_singleSelectionManipulator
(
editorView
),
m_selectionIndicator
(
editorView
,
QDeclarativeViewObserverPrivate
::
get
(
editorView
)
->
manipulatorLayer
),
m_selectionIndicator
(
editorView
,
QDeclarativeViewObserverPrivate
::
get
(
editorView
)
->
manipulatorLayer
),
//m_resizeIndicator(editorView->manipulatorLayer()),
m_selectOnlyContentItems
(
true
)
{
...
...
@@ -69,9 +71,11 @@ void SelectionTool::setRubberbandSelectionMode(bool value)
m_rubberbandSelectionMode
=
value
;
}
SingleSelectionManipulator
::
SelectionType
SelectionTool
::
getSelectionType
(
Qt
::
KeyboardModifiers
modifiers
)
SingleSelectionManipulator
::
SelectionType
SelectionTool
::
getSelectionType
(
Qt
::
KeyboardModifiers
modifiers
)
{
SingleSelectionManipulator
::
SelectionType
selectionType
=
SingleSelectionManipulator
::
ReplaceSelection
;
SingleSelectionManipulator
::
SelectionType
selectionType
=
SingleSelectionManipulator
::
ReplaceSelection
;
if
(
modifiers
.
testFlag
(
Qt
::
ControlModifier
))
{
selectionType
=
SingleSelectionManipulator
::
RemoveFromSelection
;
}
else
if
(
modifiers
.
testFlag
(
Qt
::
ShiftModifier
))
{
...
...
@@ -82,7 +86,9 @@ SingleSelectionManipulator::SelectionType SelectionTool::getSelectionType(Qt::Ke
bool
SelectionTool
::
alreadySelected
(
const
QList
<
QGraphicsItem
*>
&
itemList
)
const
{
const
QList
<
QGraphicsItem
*>
selectedItems
=
QDeclarativeViewObserverPrivate
::
get
(
observer
())
->
selectedItems
();
QDeclarativeViewObserverPrivate
*
observerPrivate
=
QDeclarativeViewObserverPrivate
::
get
(
observer
());
const
QList
<
QGraphicsItem
*>
selectedItems
=
observerPrivate
->
selectedItems
();
if
(
selectedItems
.
isEmpty
())
return
false
;
...
...
@@ -98,7 +104,9 @@ bool SelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) const
void
SelectionTool
::
mousePressEvent
(
QMouseEvent
*
event
)
{
QList
<
QGraphicsItem
*>
itemList
=
QDeclarativeViewObserverPrivate
::
get
(
observer
())
->
selectableItems
(
event
->
pos
());
QDeclarativeViewObserverPrivate
*
observerPrivate
=
QDeclarativeViewObserverPrivate
::
get
(
observer
());
QList
<
QGraphicsItem
*>
itemList
=
observerPrivate
->
selectableItems
(
event
->
pos
());
SingleSelectionManipulator
::
SelectionType
selectionType
=
getSelectionType
(
event
->
modifiers
());
if
(
event
->
buttons
()
&
Qt
::
LeftButton
)
{
...
...
@@ -121,7 +129,8 @@ void SelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint glo
return
;
QMenu
contextMenu
;
connect
(
&
contextMenu
,
SIGNAL
(
hovered
(
QAction
*
)),
this
,
SLOT
(
contextMenuElementHovered
(
QAction
*
)));
connect
(
&
contextMenu
,
SIGNAL
(
hovered
(
QAction
*
)),
this
,
SLOT
(
contextMenuElementHovered
(
QAction
*
)));
m_contextMenuItemList
=
itemList
;
...
...
@@ -133,7 +142,8 @@ void SelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint glo
foreach
(
QGraphicsItem
*
const
item
,
itemList
)
{
QString
itemTitle
=
titleForItem
(
item
);
QAction
*
elementAction
=
contextMenu
.
addAction
(
itemTitle
,
this
,
SLOT
(
contextMenuElementSelected
()));
QAction
*
elementAction
=
contextMenu
.
addAction
(
itemTitle
,
this
,
SLOT
(
contextMenuElementSelected
()));
if
(
observer
()
->
selectedItems
().
contains
(
item
))
{
QFont
boldFont
=
elementAction
->
font
();
...
...
@@ -152,9 +162,9 @@ void SelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint glo
++
i
;
}
// add root item separately
// QString itemTitle = QString(tr("%1")).arg(titleForItem(view()->currentRootItem()));
// contextMenu.addAction(itemTitle, this, SLOT(contextMenuElementSelected()));
// m_contextMenuItemList.append(view()->currentRootItem());
// QString itemTitle = QString(tr("%1")).arg(titleForItem(view()->currentRootItem()));
// contextMenu.addAction(itemTitle, this, SLOT(contextMenuElementSelected()));
// m_contextMenuItemList.append(view()->currentRootItem());
contextMenu
.
exec
(
globalPos
);
m_contextMenuItemList
.
clear
();
...
...
@@ -192,7 +202,7 @@ void SelectionTool::mouseMoveEvent(QMouseEvent *event)
QPointF
mouseMovementVector
=
m_singleSelectionManipulator
.
beginPoint
()
-
event
->
pos
();
if
((
mouseMovementVector
.
toPoint
().
manhattanLength
()
>
Constants
::
DragStartDistance
)
&&
(
m_mousePressTimer
.
elapsed
()
>
Constants
::
DragStartTime
))
&&
(
m_mousePressTimer
.
elapsed
()
>
Constants
::
DragStartTime
))
{
m_singleSelectionManipulator
.
end
(
event
->
pos
());
//view()->changeToMoveTool(m_singleSelectionManipulator.beginPoint());
...
...
@@ -202,15 +212,18 @@ void SelectionTool::mouseMoveEvent(QMouseEvent *event)
QPointF
mouseMovementVector
=
m_rubberbandSelectionManipulator
.
beginPoint
()
-
event
->
pos
();
if
((
mouseMovementVector
.
toPoint
().
manhattanLength
()
>
Constants
::
DragStartDistance
)
&&
(
m_mousePressTimer
.
elapsed
()
>
Constants
::
DragStartTime
))
{
&&
(
m_mousePressTimer
.
elapsed
()
>
Constants
::
DragStartTime
))
{
m_rubberbandSelectionManipulator
.
update
(
event
->
pos
());
if
(
event
->
modifiers
().
testFlag
(
Qt
::
ControlModifier
))
m_rubberbandSelectionManipulator
.
select
(
RubberBandSelectionManipulator
::
RemoveFromSelection
);
m_rubberbandSelectionManipulator
.
select
(
RubberBandSelectionManipulator
::
RemoveFromSelection
);
else
if
(
event
->
modifiers
().
testFlag
(
Qt
::
ShiftModifier
))
m_rubberbandSelectionManipulator
.
select
(
RubberBandSelectionManipulator
::
AddToSelection
);
m_rubberbandSelectionManipulator
.
select
(
RubberBandSelectionManipulator
::
AddToSelection
);
else
m_rubberbandSelectionManipulator
.
select
(
RubberBandSelectionManipulator
::
ReplaceSelection
);
m_rubberbandSelectionManipulator
.
select
(
RubberBandSelectionManipulator
::
ReplaceSelection
);
}
}
}
...
...
@@ -232,7 +245,10 @@ void SelectionTool::hoverMoveEvent(QMouseEvent * event)
// if (topSelectedItemIsMovable(itemList))
// view()->changeTool(Constants::MoveToolMode);
// }
QList
<
QGraphicsItem
*>
selectableItemList
=
QDeclarativeViewObserverPrivate
::
get
(
observer
())
->
selectableItems
(
event
->
pos
());
QDeclarativeViewObserverPrivate
*
observerPrivate
=
QDeclarativeViewObserverPrivate
::
get
(
observer
());
QList
<
QGraphicsItem
*>
selectableItemList
=
observerPrivate
->
selectableItems
(
event
->
pos
());
if
(
!
selectableItemList
.
isEmpty
())
{
QGraphicsObject
*
item
=
selectableItemList
.
first
()
->
toGraphicsObject
();
if
(
item
)
...
...
@@ -256,22 +272,28 @@ void SelectionTool::mouseReleaseEvent(QMouseEvent *event)
m_singleSelectionManipulator
.
begin
(
event
->
pos
());
if
(
event
->
modifiers
().
testFlag
(
Qt
::
ControlModifier
))
m_singleSelectionManipulator
.
select
(
SingleSelectionManipulator
::
RemoveFromSelection
,
m_selectOnlyContentItems
);
m_singleSelectionManipulator
.
select
(
SingleSelectionManipulator
::
RemoveFromSelection
,
m_selectOnlyContentItems
);
else
if
(
event
->
modifiers
().
testFlag
(
Qt
::
ShiftModifier
))
m_singleSelectionManipulator
.
select
(
SingleSelectionManipulator
::
AddToSelection
,
m_selectOnlyContentItems
);
m_singleSelectionManipulator
.
select
(
SingleSelectionManipulator
::
AddToSelection
,
m_selectOnlyContentItems
);
else
m_singleSelectionManipulator
.
select
(
SingleSelectionManipulator
::
InvertSelection
,
m_selectOnlyContentItems
);
m_singleSelectionManipulator
.
select
(
SingleSelectionManipulator
::
InvertSelection
,
m_selectOnlyContentItems
);
m_singleSelectionManipulator
.
end
(
event
->
pos
());
}
else
{
m_rubberbandSelectionManipulator
.
update
(
event
->
pos
());
if
(
event
->
modifiers
().
testFlag
(
Qt
::
ControlModifier
))
m_rubberbandSelectionManipulator
.
select
(
RubberBandSelectionManipulator
::
RemoveFromSelection
);
m_rubberbandSelectionManipulator
.
select
(
RubberBandSelectionManipulator
::
RemoveFromSelection
);
else
if
(
event
->
modifiers
().
testFlag
(
Qt
::
ShiftModifier
))
m_rubberbandSelectionManipulator
.
select
(
RubberBandSelectionManipulator
::
AddToSelection
);
m_rubberbandSelectionManipulator
.
select
(
RubberBandSelectionManipulator
::
AddToSelection
);
else
m_rubberbandSelectionManipulator
.
select
(
RubberBandSelectionManipulator
::
ReplaceSelection
);
m_rubberbandSelectionManipulator
.
select
(
RubberBandSelectionManipulator
::
ReplaceSelection
);
m_rubberbandSelectionManipulator
.
end
();
}
...
...
@@ -286,14 +308,14 @@ void SelectionTool::mouseDoubleClickEvent(QMouseEvent * /*event*/)
void
SelectionTool
::
keyPressEvent
(
QKeyEvent
*
event
)
{
switch
(
event
->
key
())
{
case
Qt
::
Key_Left
:
case
Qt
::
Key_Right
:
case
Qt
::
Key_Up
:
case
Qt
::
Key_Down
:
// disabled for now, cannot move stuff yet.
//view()->changeTool(Constants::MoveToolMode);
//view()->currentTool()->keyPressEvent(event);
break
;
case
Qt
::
Key_Left
:
case
Qt
::
Key_Right
:
case
Qt
::
Key_Up
:
case
Qt
::
Key_Down
:
// disabled for now, cannot move stuff yet.
//view()->changeTool(Constants::MoveToolMode);
//view()->currentTool()->keyPressEvent(event);
break
;
}
}
...
...
@@ -307,7 +329,9 @@ void SelectionTool::wheelEvent(QWheelEvent *event)
if
(
event
->
orientation
()
==
Qt
::
Horizontal
||
m_rubberbandSelectionMode
)
return
;
QList
<
QGraphicsItem
*>
itemList
=
QDeclarativeViewObserverPrivate
::
get
(
observer
())
->
selectableItems
(
event
->
pos
());
QDeclarativeViewObserverPrivate
*
observerPrivate
=
QDeclarativeViewObserverPrivate
::
get
(
observer
());
QList
<
QGraphicsItem
*>
itemList
=
observerPrivate
->
selectableItems
(
event
->
pos
());
if
(
itemList
.
isEmpty
())
return
;
...
...
@@ -353,7 +377,7 @@ void SelectionTool::clear()
{
view
()
->
setCursor
(
Qt
::
ArrowCursor
);
m_rubberbandSelectionManipulator
.
clear
(),
m_singleSelectionManipulator
.
clear
();
m_singleSelectionManipulator
.
clear
();
m_selectionIndicator
.
clear
();
//m_resizeIndicator.clear();
}
...
...
@@ -396,13 +420,16 @@ void SelectionTool::selectUnderPoint(QMouseEvent *event)
m_singleSelectionManipulator
.
begin
(
event
->
pos
());
if
(
event
->
modifiers
().
testFlag
(
Qt
::
ControlModifier
))
m_singleSelectionManipulator
.
select
(
SingleSelectionManipulator
::
RemoveFromSelection
,
m_selectOnlyContentItems
);
m_singleSelectionManipulator
.
select
(
SingleSelectionManipulator
::
RemoveFromSelection
,
m_selectOnlyContentItems
);
else
if
(
event
->
modifiers
().
testFlag
(
Qt
::
ShiftModifier
))
m_singleSelectionManipulator
.
select
(
SingleSelectionManipulator
::
AddToSelection
,
m_selectOnlyContentItems
);
m_singleSelectionManipulator
.
select
(
SingleSelectionManipulator
::
AddToSelection
,
m_selectOnlyContentItems
);
else
m_singleSelectionManipulator
.
select
(
SingleSelectionManipulator
::
InvertSelection
,
m_selectOnlyContentItems
);
m_singleSelectionManipulator
.
select
(
SingleSelectionManipulator
::
InvertSelection
,
m_selectOnlyContentItems
);
m_singleSelectionManipulator
.
end
(
event
->
pos
());