diff options
author | hjk <hjk121@nokiamail.com> | 2014-09-19 15:26:41 +0200 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2014-09-19 16:00:24 +0200 |
commit | 970264a88e6bcc5360babda429f43d840501ffcf (patch) | |
tree | 68e5f47175a308b1082ef67ada9cef26d3952660 /src/plugins/debugger | |
parent | 74f24c96e1341a6fe287e562a905f6e4e70f4ab4 (diff) | |
download | qt-creator-970264a88e6bcc5360babda429f43d840501ffcf.tar.gz |
Debugger: Operate tooltips on TextEditorWidgets, not TextEditor
Less indirection.
Change-Id: Ifbd7195e853d02bfd6562c817fc7f30079913faf
Reviewed-by: hjk <hjk121@nokiamail.com>
Diffstat (limited to 'src/plugins/debugger')
-rw-r--r-- | src/plugins/debugger/cdb/cdbengine.cpp | 6 | ||||
-rw-r--r-- | src/plugins/debugger/cdb/cdbengine.h | 2 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerengine.cpp | 2 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerengine.h | 4 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerplugin.cpp | 2 | ||||
-rw-r--r-- | src/plugins/debugger/debuggertooltipmanager.cpp | 18 | ||||
-rw-r--r-- | src/plugins/debugger/debuggertooltipmanager.h | 4 | ||||
-rw-r--r-- | src/plugins/debugger/gdb/gdbengine.cpp | 2 | ||||
-rw-r--r-- | src/plugins/debugger/gdb/gdbengine.h | 2 | ||||
-rw-r--r-- | src/plugins/debugger/lldb/lldbengine.cpp | 4 | ||||
-rw-r--r-- | src/plugins/debugger/lldb/lldbengine.h | 2 | ||||
-rw-r--r-- | src/plugins/debugger/pdb/pdbengine.cpp | 20 | ||||
-rw-r--r-- | src/plugins/debugger/pdb/pdbengine.h | 2 | ||||
-rw-r--r-- | src/plugins/debugger/qml/qmlcppengine.cpp | 13 | ||||
-rw-r--r-- | src/plugins/debugger/qml/qmlcppengine.h | 2 | ||||
-rw-r--r-- | src/plugins/debugger/qml/qmlengine.cpp | 4 | ||||
-rw-r--r-- | src/plugins/debugger/qml/qmlengine.h | 4 | ||||
-rw-r--r-- | src/plugins/debugger/sourceutils.cpp | 25 | ||||
-rw-r--r-- | src/plugins/debugger/sourceutils.h | 7 |
19 files changed, 51 insertions, 74 deletions
diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 1c14b987af..8ee8a6b8a5 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -447,19 +447,19 @@ void CdbEngine::syncVerboseLog(bool verboseLog) postCommand(m_verboseLog ? QByteArray("!sym noisy") : QByteArray("!sym quiet"), 0); } -bool CdbEngine::setToolTipExpression(TextEditor::BaseTextEditor *editor, +bool CdbEngine::setToolTipExpression(TextEditor::BaseTextEditorWidget *editorWidget, const DebuggerToolTipContext &contextIn) { if (debug) qDebug() << Q_FUNC_INFO; // Need a stopped debuggee and a cpp file in a valid frame - if (state() != InferiorStopOk || !isCppEditor(editor) || stackHandler()->currentIndex() < 0) + if (state() != InferiorStopOk || !isCppEditor(editorWidget) || stackHandler()->currentIndex() < 0) return false; // Determine expression and function int line; int column; DebuggerToolTipContext context = contextIn; - QString exp = fixCppExpression(cppExpressionAt(editor, context.position, &line, &column, &context.function)); + QString exp = fixCppExpression(cppExpressionAt(editorWidget, context.position, &line, &column, &context.function)); // Are we in the current stack frame if (context.function.isEmpty() || exp.isEmpty() || context.function != stackHandler()->currentFrame().function) return false; diff --git a/src/plugins/debugger/cdb/cdbengine.h b/src/plugins/debugger/cdb/cdbengine.h index b33a0363f2..fb86fd7afc 100644 --- a/src/plugins/debugger/cdb/cdbengine.h +++ b/src/plugins/debugger/cdb/cdbengine.h @@ -76,7 +76,7 @@ public: // Factory function that returns 0 if the debug engine library cannot be found. - virtual bool setToolTipExpression(TextEditor::BaseTextEditor *editor, + virtual bool setToolTipExpression(TextEditor::BaseTextEditorWidget *editorWidget, const DebuggerToolTipContext &ctx); virtual void setupEngine(); virtual void setupInferior(); diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 7575b3b5bf..c2e0181eea 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -1365,7 +1365,7 @@ DebuggerRunControl *DebuggerEngine::runControl() const return d->runControl(); } -bool DebuggerEngine::setToolTipExpression(TextEditor::BaseTextEditor *, +bool DebuggerEngine::setToolTipExpression(TextEditor::BaseTextEditorWidget *, const DebuggerToolTipContext &) { return false; diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 716457fb2c..4453886227 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -46,7 +46,7 @@ class QMessageBox; class QAbstractItemModel; QT_END_NAMESPACE -namespace TextEditor { class BaseTextEditor; } +namespace TextEditor { class BaseTextEditorWidget; } namespace Core { class IOptionsPage; } namespace Debugger { @@ -144,7 +144,7 @@ public: const DebuggerStartParameters &startParameters() const; DebuggerStartParameters &startParameters(); - virtual bool setToolTipExpression(TextEditor::BaseTextEditor *editor, + virtual bool setToolTipExpression(TextEditor::BaseTextEditorWidget *, const Internal::DebuggerToolTipContext &); virtual void updateWatchData(const Internal::WatchData &data, diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 95ba90f53d..07506aeb86 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1105,7 +1105,7 @@ public slots: exp = tc.selectedText(); } else { int line, column; - exp = cppExpressionAt(textEditor, tc.position(), &line, &column); + exp = cppExpressionAt(textEditor->editorWidget(), tc.position(), &line, &column); } if (currentEngine()->hasCapability(WatchComplexExpressionsCapability)) exp = removeObviousSideEffects(exp); diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index c546f069f0..7a47c127e8 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -489,7 +489,7 @@ public: QList<QPointer<DebuggerToolTipWidget> > m_tooltips; bool m_debugModeActive; QPoint m_lastToolTipPoint; - Core::IEditor *m_lastToolTipEditor; + BaseTextEditorWidget *m_lastToolTipEditor; }; static DebuggerToolTipManagerData *d = 0; @@ -1304,15 +1304,15 @@ void DebuggerToolTipManager::slotTooltipOverrideRequested QTC_ASSERT(editor, return); const int movedDistance = (point - d->m_lastToolTipPoint).manhattanLength(); - if (d->m_lastToolTipEditor == editor && movedDistance < 25) { + if (d->m_lastToolTipEditor == editor->editorWidget() && movedDistance < 25) { *handled = true; return; } - *handled = tryHandleToolTipOverride(editor, point, pos); + *handled = tryHandleToolTipOverride(editor->editorWidget(), point, pos); if (*handled) { - d->m_lastToolTipEditor = editor; + d->m_lastToolTipEditor = editor->editorWidget(); d->m_lastToolTipPoint = point; } else { d->m_lastToolTipEditor = 0; @@ -1320,7 +1320,7 @@ void DebuggerToolTipManager::slotTooltipOverrideRequested } } -bool DebuggerToolTipManager::tryHandleToolTipOverride(BaseTextEditor *editor, const QPoint &point, int pos) +bool DebuggerToolTipManager::tryHandleToolTipOverride(BaseTextEditorWidget *editorWidget, const QPoint &point, int pos) { if (!boolSetting(UseToolTipsInMainEditor)) return false; @@ -1331,11 +1331,11 @@ bool DebuggerToolTipManager::tryHandleToolTipOverride(BaseTextEditor *editor, co DebuggerToolTipContext context; context.engineType = engine->objectName(); - context.fileName = editor->document()->filePath(); + context.fileName = editorWidget->textDocument()->filePath(); context.position = pos; context.mousePosition = point; - editor->convertPosition(pos, &context.line, &context.column); - QString raw = cppExpressionAt(editor, context.position, &context.line, &context.column, &context.function); + editorWidget->convertPosition(pos, &context.line, &context.column); + QString raw = cppExpressionAt(editorWidget, context.position, &context.line, &context.column, &context.function); context.expression = fixCppExpression(raw); if (context.expression.isEmpty()) { @@ -1356,7 +1356,7 @@ bool DebuggerToolTipManager::tryHandleToolTipOverride(BaseTextEditor *editor, co context.iname = "tooltip." + context.expression.toLatin1().toHex(); - if (engine->setToolTipExpression(editor, context)) + if (engine->setToolTipExpression(editorWidget, context)) return true; // Other tooltip, close all in case mouse never entered the tooltip diff --git a/src/plugins/debugger/debuggertooltipmanager.h b/src/plugins/debugger/debuggertooltipmanager.h index 08ed4764cc..748c3232d3 100644 --- a/src/plugins/debugger/debuggertooltipmanager.h +++ b/src/plugins/debugger/debuggertooltipmanager.h @@ -41,7 +41,7 @@ class QDebug; QT_END_NAMESPACE namespace Core { class IEditor; } -namespace TextEditor { class BaseTextEditor; } +namespace TextEditor { class BaseTextEditor; class BaseTextEditorWidget; } namespace Debugger { class DebuggerEngine; @@ -136,7 +136,7 @@ private slots: const QPoint &point, int pos, bool *handled); private: - bool tryHandleToolTipOverride(TextEditor::BaseTextEditor *editor, + bool tryHandleToolTipOverride(TextEditor::BaseTextEditorWidget *editorWidget, const QPoint &point, int pos); }; diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index a6cfb17e87..efc57a7054 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -3650,7 +3650,7 @@ void GdbEngine::resetLocation() DebuggerEngine::resetLocation(); } -bool GdbEngine::setToolTipExpression(TextEditor::BaseTextEditor *editor, +bool GdbEngine::setToolTipExpression(TextEditor::BaseTextEditorWidget *editor, const DebuggerToolTipContext &context) { if (state() != InferiorStopOk || !isCppEditor(editor)) { diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index b03682d2e8..61d9916338 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -407,7 +407,7 @@ protected: // // Watch specific stuff // - virtual bool setToolTipExpression(TextEditor::BaseTextEditor *editor, + virtual bool setToolTipExpression(TextEditor::BaseTextEditorWidget *editor, const DebuggerToolTipContext &); virtual void assignValueInDebugger(const WatchData *data, const QString &expr, const QVariant &value); diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index b99b985abc..ffe070e308 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -837,9 +837,9 @@ void LldbEngine::resetLocation() DebuggerEngine::resetLocation(); } -bool LldbEngine::setToolTipExpression(TextEditor::BaseTextEditor *editor, const DebuggerToolTipContext &context) +bool LldbEngine::setToolTipExpression(TextEditor::BaseTextEditorWidget *editorWidget, const DebuggerToolTipContext &context) { - if (state() != InferiorStopOk || !isCppEditor(editor)) { + if (state() != InferiorStopOk || !isCppEditor(editorWidget)) { //qDebug() << "SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED " // " OR NOT A CPPEDITOR"; return false; diff --git a/src/plugins/debugger/lldb/lldbengine.h b/src/plugins/debugger/lldb/lldbengine.h index b071bb6567..31dcd156ce 100644 --- a/src/plugins/debugger/lldb/lldbengine.h +++ b/src/plugins/debugger/lldb/lldbengine.h @@ -108,7 +108,7 @@ private: void abortDebugger(); void resetLocation(); - bool setToolTipExpression(TextEditor::BaseTextEditor *editor, + bool setToolTipExpression(TextEditor::BaseTextEditorWidget *editorWidget, const DebuggerToolTipContext &); void continueInferior(); diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index 60ef9dcb09..61b5c0a4ba 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -452,33 +452,21 @@ static WatchData m_toolTip; static QPoint m_toolTipPos; static QHash<QString, WatchData> m_toolTipCache; -bool PdbEngine::setToolTipExpression(TextEditor::BaseTextEditor *editor, +bool PdbEngine::setToolTipExpression(TextEditor::BaseTextEditorWidget *editorWidget, const DebuggerToolTipContext &ctx) { - Q_UNUSED(editor) - if (state() != InferiorStopOk) { //SDEBUG("SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED"); return false; } // Check mime type and get expression (borrowing some C++ - functions) - const QString javaPythonMimeType = - QLatin1String("application/javascript"); - if (!editor->document() || editor->document()->mimeType() != javaPythonMimeType) + const QString javaPythonMimeType = QLatin1String("application/javascript"); + if (editorWidget->textDocument()->mimeType() != javaPythonMimeType) return false; int line; int column; - QString exp = cppExpressionAt(editor, ctx.position, &line, &column); - -/* - if (m_toolTipCache.contains(exp)) { - const WatchData & data = m_toolTipCache[exp]; - q->watchHandler()->removeChildren(data.iname); - insertData(data); - return; - } -*/ + QString exp = cppExpressionAt(editorWidget, ctx.position, &line, &column); QToolTip::hideText(); if (exp.isEmpty() || exp.startsWith(QLatin1Char('#'))) { diff --git a/src/plugins/debugger/pdb/pdbengine.h b/src/plugins/debugger/pdb/pdbengine.h index eddc04796d..482dcc3b91 100644 --- a/src/plugins/debugger/pdb/pdbengine.h +++ b/src/plugins/debugger/pdb/pdbengine.h @@ -75,7 +75,7 @@ private: void shutdownInferior(); void shutdownEngine(); - bool setToolTipExpression(TextEditor::BaseTextEditor *editor, + bool setToolTipExpression(TextEditor::BaseTextEditorWidget *editorWidget, const DebuggerToolTipContext &); void continueInferior(); diff --git a/src/plugins/debugger/qml/qmlcppengine.cpp b/src/plugins/debugger/qml/qmlcppengine.cpp index 492b31c85c..8113c88e79 100644 --- a/src/plugins/debugger/qml/qmlcppengine.cpp +++ b/src/plugins/debugger/qml/qmlcppengine.cpp @@ -89,14 +89,15 @@ bool QmlCppEngine::canDisplayTooltip() const return m_cppEngine->canDisplayTooltip() || m_qmlEngine->canDisplayTooltip(); } -bool QmlCppEngine::setToolTipExpression(TextEditor::BaseTextEditor *editor, const DebuggerToolTipContext &ctx) +bool QmlCppEngine::setToolTipExpression(TextEditor::BaseTextEditorWidget *editorWidget, const DebuggerToolTipContext &ctx) { - QTC_ASSERT(editor, return false); + QTC_ASSERT(editorWidget, return false); bool success = false; - if (editor->document()->id() == CppEditor::Constants::CPPEDITOR_ID) - success = m_cppEngine->setToolTipExpression(editor, ctx); - else if (editor->document()->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) - success = m_qmlEngine->setToolTipExpression(editor, ctx); + Core::Id id = editorWidget->textDocument()->id(); + if (id == CppEditor::Constants::CPPEDITOR_ID) + success = m_cppEngine->setToolTipExpression(editorWidget, ctx); + else if (id == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) + success = m_qmlEngine->setToolTipExpression(editorWidget, ctx); return success; } diff --git a/src/plugins/debugger/qml/qmlcppengine.h b/src/plugins/debugger/qml/qmlcppengine.h index cc15899b58..ec495a3c41 100644 --- a/src/plugins/debugger/qml/qmlcppengine.h +++ b/src/plugins/debugger/qml/qmlcppengine.h @@ -46,7 +46,7 @@ public: ~QmlCppEngine(); bool canDisplayTooltip() const; - bool setToolTipExpression(TextEditor::BaseTextEditor *editor, + bool setToolTipExpression(TextEditor::BaseTextEditorWidget *editorWidget, const DebuggerToolTipContext &); void updateWatchData(const WatchData &data, const WatchUpdateFlags &flags); diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index aef5a41ee6..fead81e657 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -983,12 +983,12 @@ void QmlEngine::requestModuleSymbols(const QString &moduleName) // ////////////////////////////////////////////////////////////////////// -bool QmlEngine::setToolTipExpression(TextEditor::BaseTextEditor *editor, +bool QmlEngine::setToolTipExpression(TextEditor::BaseTextEditorWidget *editorWidget, const DebuggerToolTipContext &ctx) { // This is processed by QML inspector, which has dependencies to // the qml js editor. Makes life easier. - emit tooltipRequested(ctx.mousePosition, editor, ctx.position); + emit tooltipRequested(ctx.mousePosition, editorWidget, ctx.position); return true; } diff --git a/src/plugins/debugger/qml/qmlengine.h b/src/plugins/debugger/qml/qmlengine.h index a8a98cfaed..ca90142676 100644 --- a/src/plugins/debugger/qml/qmlengine.h +++ b/src/plugins/debugger/qml/qmlengine.h @@ -88,7 +88,7 @@ public: signals: void tooltipRequested(const QPoint &mousePos, - TextEditor::BaseTextEditor *editor, int cursorPos); + TextEditor::BaseTextEditorWidget *editorWidget, int cursorPos); void aboutToNotifyInferiorSetupOk(); private slots: @@ -127,7 +127,7 @@ private: void shutdownInferior(); void shutdownEngine(); - bool setToolTipExpression(TextEditor::BaseTextEditor *editor, + bool setToolTipExpression(TextEditor::BaseTextEditorWidget *editorWidget, const DebuggerToolTipContext &); void continueInferior(); diff --git a/src/plugins/debugger/sourceutils.cpp b/src/plugins/debugger/sourceutils.cpp index 1fb0b50ea1..ebfb5629b7 100644 --- a/src/plugins/debugger/sourceutils.cpp +++ b/src/plugins/debugger/sourceutils.cpp @@ -313,17 +313,14 @@ bool getUninitializedVariables(const CPlusPlus::Snapshot &snapshot, // Editor tooltip support -bool isCppEditor(Core::IEditor *editor) +bool isCppEditor(TextEditor::BaseTextEditorWidget *editorWidget) { - const Core::IDocument *document= editor->document(); - if (!document) - return false; - + const TextEditor::BaseTextDocument *document = editorWidget->textDocument(); return CppTools::ProjectFile::classify(document->filePath()) != CppTools::ProjectFile::Unclassified; } // Return the Cpp expression, and, if desired, the function -QString cppExpressionAt(TextEditor::BaseTextEditor *editor, int pos, +QString cppExpressionAt(TextEditor::BaseTextEditorWidget *editorWidget, int pos, int *line, int *column, QString *function /* = 0 */) { using namespace CppTools; @@ -331,18 +328,12 @@ QString cppExpressionAt(TextEditor::BaseTextEditor *editor, int pos, if (function) function->clear(); - const QPlainTextEdit *plaintext = qobject_cast<QPlainTextEdit*>(editor->widget()); - if (!plaintext) - return QString(); - - QTextCursor tc = plaintext->textCursor(); + QTextCursor tc = editorWidget->textCursor(); QString expr = tc.selectedText(); CppModelManager *modelManager = CppModelManager::instance(); if (expr.isEmpty() && modelManager) { - QTextDocument *doc = plaintext->document(); - QTC_ASSERT(doc, return QString()); tc.setPosition(pos); - const QChar ch = doc->characterAt(pos); + const QChar ch = editorWidget->characterAt(pos); if (ch.isLetterOrNumber() || ch == QLatin1Char('_')) tc.movePosition(QTextCursor::EndOfWord); @@ -357,10 +348,8 @@ QString cppExpressionAt(TextEditor::BaseTextEditor *editor, int pos, } if (function && !expr.isEmpty()) - if (const Core::IDocument *document= editor->document()) - if (modelManager) - *function = AbstractEditorSupport::functionAt(modelManager, - document->filePath(), *line, *column); + *function = AbstractEditorSupport::functionAt(modelManager, + editorWidget->textDocument()->filePath(), *line, *column); return expr; } diff --git a/src/plugins/debugger/sourceutils.h b/src/plugins/debugger/sourceutils.h index cce80ac6eb..119d35e022 100644 --- a/src/plugins/debugger/sourceutils.h +++ b/src/plugins/debugger/sourceutils.h @@ -32,16 +32,15 @@ #include <QString> -namespace TextEditor { class BaseTextEditor; } -namespace Core { class IEditor; } +namespace TextEditor { class BaseTextEditorWidget; } namespace CPlusPlus { class Snapshot; } namespace Debugger { namespace Internal { // Editor tooltip support -bool isCppEditor(Core::IEditor *editor); -QString cppExpressionAt(TextEditor::BaseTextEditor *editor, int pos, +bool isCppEditor(TextEditor::BaseTextEditorWidget *editorWidget); +QString cppExpressionAt(TextEditor::BaseTextEditorWidget *editorWidget, int pos, int *line, int *column, QString *function = 0); QString fixCppExpression(const QString &exp); QString cppFunctionAt(const QString &fileName, int line); |