diff options
author | Bea Lam <bea.lam@nokia.com> | 2009-11-04 04:30:21 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2009-11-04 04:30:21 (GMT) |
commit | 7a249a72f118f5adacc7ca3af498ac6434dc8c65 (patch) | |
tree | 278c1d71f58e5235fc52b8c4160998682dd5bc9e /tools | |
parent | e0688cfd4d9a31d53b456d0c211ab39565305064 (diff) | |
download | Qt-7a249a72f118f5adacc7ca3af498ac6434dc8c65.zip Qt-7a249a72f118f5adacc7ca3af498ac6434dc8c65.tar.gz Qt-7a249a72f118f5adacc7ca3af498ac6434dc8c65.tar.bz2 |
Show source file and line of an object in the text editor when it
is double clicked in the object tree.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmldebugger/creatorplugin/creatorplugin.pro | 1 | ||||
-rw-r--r-- | tools/qmldebugger/creatorplugin/qmlinspectormode.cpp | 24 | ||||
-rw-r--r-- | tools/qmldebugger/creatorplugin/qmlinspectormode.h | 2 | ||||
-rw-r--r-- | tools/qmldebugger/standalone/objecttree.cpp | 20 | ||||
-rw-r--r-- | tools/qmldebugger/standalone/objecttree.h | 2 |
5 files changed, 44 insertions, 5 deletions
diff --git a/tools/qmldebugger/creatorplugin/creatorplugin.pro b/tools/qmldebugger/creatorplugin/creatorplugin.pro index d191a37..ff7f3da 100644 --- a/tools/qmldebugger/creatorplugin/creatorplugin.pro +++ b/tools/qmldebugger/creatorplugin/creatorplugin.pro @@ -25,5 +25,6 @@ IDE_BUILD_TREE=$$(CREATOR_BUILD_DIR) include($$(CREATOR_SRC_DIR)/src/qtcreatorplugin.pri) include($$(CREATOR_SRC_DIR)/src/plugins/projectexplorer/projectexplorer.pri) include($$(CREATOR_SRC_DIR)/src/plugins/coreplugin/coreplugin.pri) +include($$(CREATOR_SRC_DIR)/src/plugins/texteditor/texteditor.pri) LIBS += -L$$(CREATOR_BUILD_DIR)/lib/qtcreator diff --git a/tools/qmldebugger/creatorplugin/qmlinspectormode.cpp b/tools/qmldebugger/creatorplugin/qmlinspectormode.cpp index a1ca2fc..ce8ef30 100644 --- a/tools/qmldebugger/creatorplugin/qmlinspectormode.cpp +++ b/tools/qmldebugger/creatorplugin/qmlinspectormode.cpp @@ -65,6 +65,8 @@ #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/actionmanager/actionmanager.h> +#include <texteditor/itexteditor.h> + #include <projectexplorer/runconfiguration.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorerconstants.h> @@ -435,8 +437,12 @@ void QmlInspectorMode::initWidgets() WatchTableHeaderView *header = new WatchTableHeaderView(m_watchTableModel); m_watchTableView->setHorizontalHeader(header); + connect(m_objectTreeWidget, SIGNAL(activated(QmlDebugObjectReference)), + this, SLOT(treeObjectActivated(QmlDebugObjectReference))); + connect(m_objectTreeWidget, SIGNAL(currentObjectChanged(QmlDebugObjectReference)), m_propertiesWidget, SLOT(reload(QmlDebugObjectReference))); + connect(m_objectTreeWidget, SIGNAL(expressionWatchRequested(QmlDebugObjectReference,QString)), m_watchTableModel, SLOT(expressionWatchRequested(QmlDebugObjectReference,QString))); @@ -536,6 +542,24 @@ void QmlInspectorMode::contextChanged() delete m_contextQuery; m_contextQuery = 0; } +void QmlInspectorMode::treeObjectActivated(const QmlDebugObjectReference &obj) +{ + QmlDebugFileReference source = obj.source(); + QString fileName = source.url().toLocalFile(); + + if (source.lineNumber() < 0 || !QFile::exists(fileName)) + return; + + Core::EditorManager *editorManager = Core::EditorManager::instance(); + TextEditor::ITextEditor *editor = qobject_cast<TextEditor::ITextEditor*>(editorManager->openEditor(fileName)); + if (editor) { + editorManager->ensureEditorManagerVisible(); + editorManager->addCurrentPositionToNavigationHistory(); + editor->gotoLine(source.lineNumber()); + editor->widget()->setFocus(); + } +} + QT_END_NAMESPACE #include "qmlinspectormode.moc" diff --git a/tools/qmldebugger/creatorplugin/qmlinspectormode.h b/tools/qmldebugger/creatorplugin/qmlinspectormode.h index 93c2e44..b4158f1 100644 --- a/tools/qmldebugger/creatorplugin/qmlinspectormode.h +++ b/tools/qmldebugger/creatorplugin/qmlinspectormode.h @@ -57,6 +57,7 @@ class QmlEngineDebug; class QmlDebugConnection; class QmlDebugEnginesQuery; class QmlDebugRootContextQuery; +class QmlDebugObjectReference; class ObjectTree; class WatchTableModel; class WatchTableView; @@ -92,6 +93,7 @@ private slots: void enginesChanged(); void queryEngineContext(int); void contextChanged(); + void treeObjectActivated(const QmlDebugObjectReference &obj); private: struct Actions { diff --git a/tools/qmldebugger/standalone/objecttree.cpp b/tools/qmldebugger/standalone/objecttree.cpp index b06d377..4dbc1a7 100644 --- a/tools/qmldebugger/standalone/objecttree.cpp +++ b/tools/qmldebugger/standalone/objecttree.cpp @@ -59,9 +59,12 @@ ObjectTree::ObjectTree(QmlEngineDebug *client, QWidget *parent) { setHeaderHidden(true); setMinimumWidth(250); + setExpandsOnDoubleClick(false); connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), - this, SLOT(currentItemChanged(QTreeWidgetItem *))); + SLOT(currentItemChanged(QTreeWidgetItem *))); + connect(this, SIGNAL(itemActivated(QTreeWidgetItem *, int)), + SLOT(activated(QTreeWidgetItem *))); } void ObjectTree::setEngineDebug(QmlEngineDebug *client) @@ -113,11 +116,18 @@ void ObjectTree::currentItemChanged(QTreeWidgetItem *item) return; QmlDebugObjectReference obj = item->data(0, Qt::UserRole).value<QmlDebugObjectReference>(); - if (obj.debugId() < 0) { - qWarning("QML Object Tree: bad object id"); + if (obj.debugId() >= 0) + emit currentObjectChanged(obj); +} + +void ObjectTree::activated(QTreeWidgetItem *item) +{ + if (!item) return; - } - emit currentObjectChanged(obj); + + QmlDebugObjectReference obj = item->data(0, Qt::UserRole).value<QmlDebugObjectReference>(); + if (obj.debugId() >= 0) + emit activated(obj); } void ObjectTree::buildTree(const QmlDebugObjectReference &obj, QTreeWidgetItem *parent) diff --git a/tools/qmldebugger/standalone/objecttree.h b/tools/qmldebugger/standalone/objecttree.h index f7b3a3f..c8d625c 100644 --- a/tools/qmldebugger/standalone/objecttree.h +++ b/tools/qmldebugger/standalone/objecttree.h @@ -64,6 +64,7 @@ public: signals: void currentObjectChanged(const QmlDebugObjectReference &); + void activated(const QmlDebugObjectReference &); void expressionWatchRequested(const QmlDebugObjectReference &, const QString &); public slots: @@ -76,6 +77,7 @@ protected: private slots: void objectFetched(); void currentItemChanged(QTreeWidgetItem *); + void activated(QTreeWidgetItem *); private: QTreeWidgetItem *findItemByObjectId(int debugId) const; |