diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 955b533cf51ee58e740ad4042b6333f6f3e83c24..1b0eada5ad9a539b0cf738bd5791881bc2b8849c 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -479,9 +479,9 @@ bool CdbEngine::setToolTipExpression(const QPoint &mousePos, const WatchData *localVariable = watchHandler()->findCppLocalVariable(exp); if (!localVariable) return false; + context.iname = localVariable->iname; DebuggerToolTipWidget *tw = new DebuggerToolTipWidget; tw->setContext(context); - tw->setIname(localVariable->iname); tw->acquireEngine(this); DebuggerToolTipManager::showToolTip(mousePos, tw); return true; diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index 858ff7067e9a19d277dba06e3a8d0b0050219e92..a4c6997145650f49d4b8acd85f5c80a8dd9daae0 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -741,6 +741,7 @@ DebuggerToolTipWidget *DebuggerToolTipWidget::loadSessionDataI(QXmlStreamReader offset.setX(attributes.value(offsetXAttribute).toString().toInt()); if (attributes.hasAttribute(offsetYAttribute)) offset.setY(attributes.value(offsetYAttribute).toString().toInt()); + context.mousePosition = offset; const QStringRef className = attributes.value(QLatin1String(toolTipClassAttributeC)); const QString engineType = attributes.value(QLatin1String(engineTypeAttributeC)).toString(); @@ -762,8 +763,6 @@ DebuggerToolTipWidget *DebuggerToolTipWidget::loadSessionDataI(QXmlStreamReader rc->setEngineType(engineType); rc->doLoadSessionData(r); rc->setCreationDate(creationDate); - if (!offset.isNull()) - rc->setOffset(offset); rc->pin(); } else { qWarning("Unable to create debugger tool tip widget of class %s", qPrintable(className.toString())); @@ -949,7 +948,7 @@ void DebuggerToolTipWidget::doAcquireEngine(DebuggerEngine *engine) // Create a filter model on the debugger's model and switch to it. QAbstractItemModel *model = engine->watchModel(); TooltipFilterModel *filterModel = - new TooltipFilterModel(model, m_iname); + new TooltipFilterModel(model, m_context.iname); swapModel(filterModel); } @@ -958,7 +957,7 @@ QAbstractItemModel *DebuggerToolTipWidget::swapModel(QAbstractItemModel *newMode QAbstractItemModel *oldModel = m_treeView->swapModel(newModel); // When looking at some 'this.m_foo.x', expand all items if (newModel) { - if (const int level = m_iname.count('.')) { + if (const int level = m_context.iname.count('.')) { QModelIndex index = newModel->index(0, 0); for (int i = 0; i < level && index.isValid(); i++, index = index.child(0, 0)) m_treeView->setExpanded(index, true); @@ -1019,9 +1018,9 @@ void DebuggerToolTipWidget::doSaveSessionData(QXmlStreamWriter &w) const { w.writeStartElement(QLatin1String(treeElementC)); QXmlStreamAttributes attributes; - if (!m_expression.isEmpty()) - attributes.append(QLatin1String(treeExpressionAttributeC), m_expression); - attributes.append(QLatin1String(treeInameAttributeC), QLatin1String(m_iname)); + if (!m_context.expression.isEmpty()) + attributes.append(QLatin1String(treeExpressionAttributeC), m_context.expression); + attributes.append(QLatin1String(treeInameAttributeC), QLatin1String(m_context.iname)); w.writeAttributes(attributes); if (QAbstractItemModel *model = m_treeView->model()) { XmlWriterTreeModelVisitor v(model, w); @@ -1036,11 +1035,11 @@ void DebuggerToolTipWidget::doLoadSessionData(QXmlStreamReader &r) return; // Restore data to default model and show that. const QXmlStreamAttributes attributes = r.attributes(); - m_iname = attributes.value(QLatin1String(treeInameAttributeC)).toString().toLatin1(); - m_expression = attributes.value(QLatin1String(treeExpressionAttributeC)).toString(); + m_context.iname = attributes.value(QLatin1String(treeInameAttributeC)).toString().toLatin1(); + m_context.expression = attributes.value(QLatin1String(treeExpressionAttributeC)).toString(); if (debugToolTips) - qDebug() << "DebuggerTreeViewToolTipWidget::doLoadSessionData() " << m_debuggerModel << m_iname; - setObjectName(QLatin1String("DebuggerTreeViewToolTipWidget: ") + QLatin1String(m_iname)); + qDebug() << "DebuggerTreeViewToolTipWidget::doLoadSessionData() " << m_debuggerModel << m_context.iname; + setObjectName(QLatin1String("DebuggerTreeViewToolTipWidget: ") + QLatin1String(m_context.iname)); restoreTreeModel(r, m_defaultModel); r.readNext(); // Skip </tree> m_treeView->swapModel(m_defaultModel); @@ -1465,15 +1464,13 @@ void DebuggerToolTipManager::slotTooltipOverrideRequested(ITextEditor *editor, } -DebuggerToolTipManager::ExpressionInamePairs - DebuggerToolTipManager::treeWidgetExpressions(const QString &fileName, - const QString &engineType, - const QString &function) +DebuggerToolTipContexts DebuggerToolTipManager::treeWidgetExpressions + (const QString &fileName, const QString &engineType, const QString &function) { - ExpressionInamePairs rc; + DebuggerToolTipContexts rc; foreach (const QPointer<DebuggerToolTipWidget> &tw, d->m_tooltips) { if (!tw.isNull() && tw->matches(fileName, engineType, function)) - rc.push_back(ExpressionInamePair(tw->expression(), tw->iname())); + rc.push_back(tw->context()); } if (debugToolTips) qDebug() << "DebuggerToolTipManager::treeWidgetExpressions" diff --git a/src/plugins/debugger/debuggertooltipmanager.h b/src/plugins/debugger/debuggertooltipmanager.h index 9575353b6d22114475f72dfa4888fcd4078ba830..721778aaf14a1629493d615094ec6929ecf554b1 100644 --- a/src/plugins/debugger/debuggertooltipmanager.h +++ b/src/plugins/debugger/debuggertooltipmanager.h @@ -75,8 +75,15 @@ public: int line; int column; QString function; //!< Optional function. This must be set by the engine as it is language-specific. + + QPoint mousePosition; + QString expression; + QByteArray iname; }; +typedef QList<DebuggerToolTipContext> DebuggerToolTipContexts; + + QDebug operator<<(QDebug, const DebuggerToolTipContext &); class DebuggerToolTipTreeView; @@ -108,17 +115,8 @@ public: QDate creationDate() const { return m_creationDate; } void setCreationDate(const QDate &d) { m_creationDate = d; } - QPoint offset() const { return m_offset; } - void setOffset(const QPoint &o) { m_offset = o; } - static DebuggerToolTipWidget *loadSessionData(QXmlStreamReader &r); - QByteArray iname() const { return m_iname; } - void setIname(const QByteArray &e) { m_iname = e; } - - QString expression() const { return m_expression; } - void setExpression(const QString &e) { m_expression = e; } - static QString treeModelClipboardContents(const QAbstractItemModel *m); public slots: @@ -160,8 +158,6 @@ private: static void restoreTreeModel(QXmlStreamReader &r, QStandardItemModel *m); int m_debuggerModel; - QString m_expression; - QByteArray m_iname; DebuggerToolTipTreeView *m_treeView; QStandardItemModel *m_defaultModel; @@ -192,9 +188,6 @@ class DebuggerToolTipManager : public QObject Q_OBJECT public: - typedef QPair<QString, QByteArray> ExpressionInamePair; - typedef QList<ExpressionInamePair> ExpressionInamePairs; - explicit DebuggerToolTipManager(QObject *parent = 0); ~DebuggerToolTipManager(); @@ -202,7 +195,7 @@ public: static bool hasToolTips(); // Collect all expressions of DebuggerTreeViewToolTipWidget - static ExpressionInamePairs treeWidgetExpressions(const QString &fileName, + static DebuggerToolTipContexts treeWidgetExpressions(const QString &fileName, const QString &engineType = QString(), const QString &function= QString()); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index c64cada4344f5b02a7cfaf385a0c06146f93a9ce..bdd1c40b36a5d83d6e11f8d228a85b3bd9ac4acf 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -91,17 +91,6 @@ using namespace Utils; namespace Debugger { namespace Internal { -class GdbToolTipContext : public DebuggerToolTipContext -{ -public: - GdbToolTipContext(const DebuggerToolTipContext &c) : - DebuggerToolTipContext(c) {} - - QPoint mousePosition; - QString expression; - QByteArray iname; -}; - enum { debugPending = 0 }; #define PENDING_DEBUG(s) do { if (debugPending) qDebug() << s; } while (0) @@ -3979,8 +3968,6 @@ void GdbEngine::showToolTip() } DebuggerToolTipWidget *tw = new DebuggerToolTipWidget; - tw->setIname(m_toolTipContext->iname); - tw->setExpression(m_toolTipContext->expression); tw->setContext(*m_toolTipContext); tw->acquireEngine(this); DebuggerToolTipManager::showToolTip(m_toolTipContext->mousePosition, tw); @@ -4031,7 +4018,7 @@ bool GdbEngine::setToolTipExpression(const QPoint &mousePos, return true; } - m_toolTipContext.reset(new GdbToolTipContext(context)); + m_toolTipContext.reset(new DebuggerToolTipContext(context)); m_toolTipContext->mousePosition = mousePos; m_toolTipContext->expression = exp; m_toolTipContext->iname = iname; diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 3ef37d89ea0d819c94058db152fe90fdb982c480..fd278d51ae9d4ad807d9b7de42bb39f9ad732b50 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -50,7 +50,6 @@ class DebugInfoTask; class DebugInfoTaskHandler; class GdbResponse; class GdbMi; -class GdbToolTipContext; class WatchData; class DisassemblerAgentCookie; @@ -655,7 +654,7 @@ protected: static QByteArray tooltipIName(const QString &exp); QString tooltipExpression() const; - QScopedPointer<GdbToolTipContext> m_toolTipContext; + QScopedPointer<DebuggerToolTipContext> m_toolTipContext; // For short-circuiting stack and thread list evaluation. bool m_stackNeeded; diff --git a/src/plugins/debugger/gdb/pythongdbengine.cpp b/src/plugins/debugger/gdb/pythongdbengine.cpp index b341ec61838c5862c060c5782337d5e7085de494..1c79150c40d8a4dd9bc2eae448c663876ff9893b 100644 --- a/src/plugins/debugger/gdb/pythongdbengine.cpp +++ b/src/plugins/debugger/gdb/pythongdbengine.cpp @@ -62,34 +62,35 @@ void GdbEngine::updateLocalsPython(const UpdateParameters ¶ms) const QString fileName = stackHandler()->currentFrame().file; const QString function = stackHandler()->currentFrame().function; if (!fileName.isEmpty()) { - typedef DebuggerToolTipManager::ExpressionInamePair ExpressionInamePair; - typedef DebuggerToolTipManager::ExpressionInamePairs ExpressionInamePairs; - // Re-create tooltip items that are not filters on existing local variables in // the tooltip model. - ExpressionInamePairs toolTips = + DebuggerToolTipContexts toolTips = DebuggerToolTipManager::treeWidgetExpressions(fileName, objectName(), function); const QString currentExpression = tooltipExpression(); if (!currentExpression.isEmpty()) { int currentIndex = -1; for (int i = 0; i < toolTips.size(); ++i) { - if (toolTips.at(i).first == currentExpression) { + if (toolTips.at(i).expression == currentExpression) { currentIndex = i; break; } } - if (currentIndex < 0) - toolTips.push_back(ExpressionInamePair(currentExpression, tooltipIName(currentExpression))); + if (currentIndex < 0) { + DebuggerToolTipContext context; + context.expression = currentExpression; + context.iname = tooltipIName(currentExpression); + toolTips.push_back(context); + } } - foreach (const ExpressionInamePair &p, toolTips) { - if (p.second.startsWith("tooltip")) { + foreach (const DebuggerToolTipContext &p, toolTips) { + if (p.iname.startsWith("tooltip")) { if (!watchers.isEmpty()) watchers += "##"; - watchers += p.first.toLatin1(); + watchers += p.expression.toLatin1(); watchers += '#'; - watchers += p.second; + watchers += p.iname; } } }