diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2011-06-10 15:52:25 (GMT) |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2011-06-23 14:38:42 (GMT) |
commit | cf56b0be5ee15663c8b3e6b87dc4161bbbc911b4 (patch) | |
tree | 9f2cc4cc7ac2db6a05afc9cb25c6dd330bdbc32d /src/plugins | |
parent | c70aef5c0fa2bfcf63457d679ed956f5077fefff (diff) | |
download | Qt-cf56b0be5ee15663c8b3e6b87dc4161bbbc911b4.zip Qt-cf56b0be5ee15663c8b3e6b87dc4161bbbc911b4.tar.gz Qt-cf56b0be5ee15663c8b3e6b87dc4161bbbc911b4.tar.bz2 |
QmlInspector: Some code cleanups
* Inlined empty method implementations
* Removed unused QDeclarativeViewInspectorPrivate::cursosPos
* Small simplification in setting shortcuts
* Prefer const & for QList parameter
(cherry picked from commit df1835f06c99d95a6f35ab84abc5fa7950cb5fe7 in
Qt 5 / QtDeclarative, to make synchronizing future changes easier)
Change-Id: Ib543c8433380e82f2fdf096d0962682595d7e2bf
Reviewed-by: Kai Koehne
Diffstat (limited to 'src/plugins')
7 files changed, 11 insertions, 51 deletions
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp index 91dd43b..6085d81 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp @@ -132,7 +132,7 @@ void LiveSelectionTool::mousePressEvent(QMouseEvent *event) } } -void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos) +void LiveSelectionTool::createContextMenu(const QList<QGraphicsItem*> &itemList, QPoint globalPos) { QMenu contextMenu; connect(&contextMenu, SIGNAL(hovered(QAction*)), @@ -143,7 +143,6 @@ void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint contextMenu.addAction(tr("Items")); contextMenu.addSeparator(); int shortcutKey = Qt::Key_1; - bool addKeySequence = true; int i = 0; foreach (QGraphicsItem * const item, itemList) { @@ -158,12 +157,11 @@ void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint } elementAction->setData(i); - if (addKeySequence) - elementAction->setShortcut(QKeySequence(shortcutKey)); - shortcutKey++; - if (shortcutKey > Qt::Key_9) - addKeySequence = false; + if (shortcutKey <= Qt::Key_9) { + elementAction->setShortcut(QKeySequence(shortcutKey)); + shortcutKey++; + } ++i; } @@ -305,10 +303,6 @@ void LiveSelectionTool::mouseReleaseEvent(QMouseEvent *event) } } -void LiveSelectionTool::mouseDoubleClickEvent(QMouseEvent * /*event*/) -{ -} - void LiveSelectionTool::keyPressEvent(QKeyEvent *event) { switch (event->key()) { @@ -323,11 +317,6 @@ void LiveSelectionTool::keyPressEvent(QKeyEvent *event) } } -void LiveSelectionTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/) -{ - -} - void LiveSelectionTool::wheelEvent(QWheelEvent *event) { if (event->orientation() == Qt::Horizontal || m_rubberbandSelectionMode) @@ -372,10 +361,6 @@ void LiveSelectionTool::setSelectOnlyContentItems(bool selectOnlyContentItems) m_selectOnlyContentItems = selectOnlyContentItems; } -void LiveSelectionTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/) -{ -} - void LiveSelectionTool::clear() { view()->setCursor(Qt::ArrowCursor); diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h index a3dcd0a..2c281cd 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h @@ -68,13 +68,13 @@ public: void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); + void mouseDoubleClickEvent(QMouseEvent *) {} void hoverMoveEvent(QMouseEvent *event); void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *keyEvent); + void keyReleaseEvent(QKeyEvent *) {} void wheelEvent(QWheelEvent *event); - void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList); + void itemsAboutToRemoved(const QList<QGraphicsItem*> &) {} // QVariant itemChange(const QList<QGraphicsItem*> &itemList, // QGraphicsItem::GraphicsItemChange change, // const QVariant &value ); @@ -97,7 +97,7 @@ private slots: void repaintBoundingRects(); private: - void createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos); + void createContextMenu(const QList<QGraphicsItem*> &itemList, QPoint globalPos); LiveSingleSelectionManipulator::SelectionType getSelectionType(Qt::KeyboardModifiers modifiers); bool alreadySelected(const QList<QGraphicsItem*> &itemList) const; diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp index 3a4b6bf..c8ade82 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp @@ -242,19 +242,11 @@ void ZoomTool::keyReleaseEvent(QKeyEvent *event) } -void ZoomTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/) -{ -} - void ZoomTool::clear() { view()->setCursor(Qt::ArrowCursor); } -void ZoomTool::selectedItemsChanged(const QList<QGraphicsItem*> &/*itemList*/) -{ -} - void ZoomTool::scaleView(const QPointF ¢erPos) { diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h index 94735cf..de93559 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h @@ -73,12 +73,12 @@ public: void keyPressEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *keyEvent); - void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList); + void itemsAboutToRemoved(const QList<QGraphicsItem*> &) {} void clear(); protected: - void selectedItemsChanged(const QList<QGraphicsItem*> &itemList); + void selectedItemsChanged(const QList<QGraphicsItem*> &) {} private slots: void zoomTo100(); diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp index 67a581d..3351df9 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp @@ -191,16 +191,8 @@ bool QDeclarativeViewInspector::leaveEvent(QEvent *event) return AbstractViewInspector::leaveEvent(event); } -bool QDeclarativeViewInspector::mousePressEvent(QMouseEvent *event) -{ - data->cursorPos = event->pos(); - return AbstractViewInspector::mousePressEvent(event); -} - bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event) { - data->cursorPos = event->pos(); - QList<QGraphicsItem*> selItems = data->selectableItems(event->pos()); if (!selItems.isEmpty()) { declarativeView()->setToolTip(currentTool()->titleForItem(selItems.first())); @@ -211,12 +203,6 @@ bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event) return AbstractViewInspector::mouseMoveEvent(event); } -bool QDeclarativeViewInspector::mouseReleaseEvent(QMouseEvent *event) -{ - data->cursorPos = event->pos(); - return AbstractViewInspector::mouseReleaseEvent(event); -} - void QDeclarativeViewInspector::reparentQmlObject(QObject *object, QObject *newParent) { if (!newParent) diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h index 3cd53ff..c77cd2c 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h @@ -82,9 +82,7 @@ protected: bool eventFilter(QObject *obj, QEvent *event); bool leaveEvent(QEvent *); - bool mousePressEvent(QMouseEvent *event); bool mouseMoveEvent(QMouseEvent *event); - bool mouseReleaseEvent(QMouseEvent *event); AbstractLiveEditTool *currentTool() const; diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h index a6e6a3c..bfa857c 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h @@ -70,7 +70,6 @@ public: QDeclarativeViewInspector *q; QWeakPointer<QWidget> viewport; - QPointF cursorPos; QList<QWeakPointer<QGraphicsObject> > currentSelection; LiveSelectionTool *selectionTool; |