Debugger: Remove widgets dependency for qtquick2 inspector
authorKai Koehne <kai.koehne@nokia.com>
Wed, 2 Nov 2011 11:19:56 +0000 (12:19 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 2 Nov 2011 13:10:46 +0000 (14:10 +0100)
Change-Id: I596a49375afc1e148fec1aabe0a7d47a81e7442a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
src/plugins/qmltooling/qmldbg_qtquick2/sgselectiontool.cpp
src/plugins/qmltooling/qmldbg_qtquick2/sgselectiontool.h

index 025aa2d..4d5fc37 100644 (file)
@@ -44,7 +44,6 @@
 #include "sghighlight.h"
 #include "sgviewinspector.h"
 
-#include <QtWidgets/QMenu>
 #include <QtGui/QMouseEvent>
 #include <QtDeclarative/QQuickView>
 #include <QtDeclarative/QQuickItem>
@@ -69,8 +68,7 @@ void SGSelectionTool::mousePressEvent(QMouseEvent *event)
         if (QQuickItem *item = inspector()->topVisibleItemAt(event->pos()))
             inspector()->setSelectedItems(QList<QQuickItem*>() << item);
     } else if (event->button() == Qt::RightButton) {
-        QList<QQuickItem*> items = inspector()->itemsAt(event->pos());
-        createContextMenu(items, event->globalPos());
+        // todo: Show context menu
     }
 }
 
@@ -85,49 +83,6 @@ void SGSelectionTool::hoverMoveEvent(QMouseEvent *event)
     }
 }
 
-void SGSelectionTool::createContextMenu(const QList<QQuickItem *> &items, QPoint pos)
-{
-    QMenu contextMenu;
-    connect(&contextMenu, SIGNAL(hovered(QAction*)),
-            this, SLOT(contextMenuElementHovered(QAction*)));
-
-    const QList<QQuickItem*> selectedItems = inspector()->selectedItems();
-    int shortcutKey = Qt::Key_1;
-
-    foreach (QQuickItem *item, items) {
-        const QString title = inspector()->titleForItem(item);
-        QAction *elementAction = contextMenu.addAction(title);
-        elementAction->setData(QVariant::fromValue(item));
-
-        connect(elementAction, SIGNAL(triggered()), this, SLOT(contextMenuElementSelected()));
-
-        if (selectedItems.contains(item)) {
-            QFont font = elementAction->font();
-            font.setBold(true);
-            elementAction->setFont(font);
-        }
-
-        if (shortcutKey <= Qt::Key_9) {
-            elementAction->setShortcut(QKeySequence(shortcutKey));
-            shortcutKey++;
-        }
-    }
-
-    contextMenu.exec(pos);
-}
-
-void SGSelectionTool::contextMenuElementHovered(QAction *action)
-{
-    if (QQuickItem *item = action->data().value<QQuickItem*>())
-        m_hoverHighlight->setItem(item);
-}
-
-void SGSelectionTool::contextMenuElementSelected()
-{
-    if (QQuickItem *item = static_cast<QAction*>(sender())->data().value<QQuickItem*>())
-        inspector()->setSelectedItems(QList<QQuickItem*>() << item);
-}
-
 SGViewInspector *SGSelectionTool::inspector() const
 {
     return static_cast<SGViewInspector*>(AbstractTool::inspector());
index fe338bd..faf75be 100644 (file)
@@ -47,7 +47,6 @@
 #include <QtCore/QList>
 #include <QtCore/QPoint>
 
-QT_FORWARD_DECLARE_CLASS(QAction)
 QT_FORWARD_DECLARE_CLASS(QQuickItem)
 
 namespace QmlJSDebugger {
@@ -75,13 +74,7 @@ public:
     void keyPressEvent(QKeyEvent *) {}
     void keyReleaseEvent(QKeyEvent *) {}
 
-private slots:
-    void contextMenuElementHovered(QAction *action);
-    void contextMenuElementSelected();
-
 private:
-    void createContextMenu(const QList<QQuickItem*> &items, QPoint pos);
-
     SGViewInspector *inspector() const;
 
     SGHoverHighlight *m_hoverHighlight;