QmlInspector: Some code cleanups
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Fri, 10 Jun 2011 15:52:25 +0000 (17:52 +0200)
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Thu, 23 Jun 2011 14:26:11 +0000 (16:26 +0200)
* Inlined empty method implementations
* Removed unused QDeclarativeViewInspectorPrivate::cursosPos
* Small simplification in setting shortcuts
* Prefer const & for QList parameter

Change-Id: I5c2c04f32bb311a835d79a59206d6ebab212c73b

src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp
src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h
src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp
src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h
src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp
src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h
src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h

index 91dd43b..6085d81 100644 (file)
@@ -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);
index a3dcd0a..2c281cd 100644 (file)
@@ -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;
 
index 3a4b6bf..c8ade82 100644 (file)
@@ -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 &centerPos)
 {
 
index 94735cf..de93559 100644 (file)
@@ -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();
index 67a581d..3351df9 100644 (file)
@@ -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)
index 3cd53ff..c77cd2c 100644 (file)
@@ -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;
 
index a6e6a3c..bfa857c 100644 (file)
@@ -70,7 +70,6 @@ public:
     QDeclarativeViewInspector *q;
     QWeakPointer<QWidget> viewport;
 
-    QPointF cursorPos;
     QList<QWeakPointer<QGraphicsObject> > currentSelection;
 
     LiveSelectionTool *selectionTool;