forked from qt-creator/qt-creator
Debugger: Simplify tooltip interface
Change-Id: I7ce688e56fb516ef6e77ee2e4f56d9b56379918b Reviewed-by: David Schulz <david.schulz@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -447,8 +447,7 @@ void CdbEngine::syncVerboseLog(bool verboseLog)
|
|||||||
postCommand(m_verboseLog ? QByteArray("!sym noisy") : QByteArray("!sym quiet"), 0);
|
postCommand(m_verboseLog ? QByteArray("!sym noisy") : QByteArray("!sym quiet"), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CdbEngine::setToolTipExpression(const QPoint &mousePos,
|
bool CdbEngine::setToolTipExpression(TextEditor::ITextEditor *editor,
|
||||||
TextEditor::ITextEditor *editor,
|
|
||||||
const DebuggerToolTipContext &contextIn)
|
const DebuggerToolTipContext &contextIn)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
@@ -469,10 +468,7 @@ bool CdbEngine::setToolTipExpression(const QPoint &mousePos,
|
|||||||
if (!localVariable)
|
if (!localVariable)
|
||||||
return false;
|
return false;
|
||||||
context.iname = localVariable->iname;
|
context.iname = localVariable->iname;
|
||||||
DebuggerToolTipWidget *tw = new DebuggerToolTipWidget;
|
DebuggerToolTipManager::showToolTip(context, this);
|
||||||
tw->setContext(context);
|
|
||||||
tw->acquireEngine(this);
|
|
||||||
DebuggerToolTipManager::showToolTip(mousePos, tw);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
|
|
||||||
// Factory function that returns 0 if the debug engine library cannot be found.
|
// Factory function that returns 0 if the debug engine library cannot be found.
|
||||||
|
|
||||||
virtual bool setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor,
|
virtual bool setToolTipExpression(TextEditor::ITextEditor *editor,
|
||||||
const DebuggerToolTipContext &ctx);
|
const DebuggerToolTipContext &ctx);
|
||||||
virtual void setupEngine();
|
virtual void setupEngine();
|
||||||
virtual void setupInferior();
|
virtual void setupInferior();
|
||||||
|
|||||||
@@ -1355,8 +1355,8 @@ DebuggerRunControl *DebuggerEngine::runControl() const
|
|||||||
return d->runControl();
|
return d->runControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebuggerEngine::setToolTipExpression
|
bool DebuggerEngine::setToolTipExpression(TextEditor::ITextEditor *,
|
||||||
(const QPoint &, TextEditor::ITextEditor *, const DebuggerToolTipContext &)
|
const DebuggerToolTipContext &)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,8 +143,8 @@ public:
|
|||||||
const DebuggerStartParameters &startParameters() const;
|
const DebuggerStartParameters &startParameters() const;
|
||||||
DebuggerStartParameters &startParameters();
|
DebuggerStartParameters &startParameters();
|
||||||
|
|
||||||
virtual bool setToolTipExpression(const QPoint & mousePos,
|
virtual bool setToolTipExpression(TextEditor::ITextEditor *editor,
|
||||||
TextEditor::ITextEditor *editor, const Internal::DebuggerToolTipContext &);
|
const Internal::DebuggerToolTipContext &);
|
||||||
|
|
||||||
virtual void updateWatchData(const Internal::WatchData &data,
|
virtual void updateWatchData(const Internal::WatchData &data,
|
||||||
const Internal::WatchUpdateFlags & flags = Internal::WatchUpdateFlags());
|
const Internal::WatchUpdateFlags & flags = Internal::WatchUpdateFlags());
|
||||||
|
|||||||
@@ -43,19 +43,20 @@
|
|||||||
#include <utils/tooltip/tipcontents.h>
|
#include <utils/tooltip/tipcontents.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QToolButton>
|
|
||||||
#include <QToolBar>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QDebug>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
#include <QLabel>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QStandardItemModel>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QClipboard>
|
|
||||||
|
|
||||||
#include <QStack>
|
#include <QStack>
|
||||||
#include <QDebug>
|
#include <QStandardItemModel>
|
||||||
|
#include <QToolBar>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
@@ -430,9 +431,6 @@ void DumpTreeModelVisitor::rowEnded()
|
|||||||
m_level--;
|
m_level--;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Debugger
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
static QDebug operator<<(QDebug d, const QAbstractItemModel &model)
|
static QDebug operator<<(QDebug d, const QAbstractItemModel &model)
|
||||||
{
|
{
|
||||||
@@ -445,10 +443,54 @@ static QDebug operator<<(QDebug d, const QAbstractItemModel &model)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Debugger {
|
/*!
|
||||||
namespace Internal {
|
\class Debugger::Internal::TooltipFilterModel
|
||||||
|
|
||||||
|
\brief The TooltipFilterModel class is a model for tooltips filtering an
|
||||||
|
item on the watchhandler matching its tree on the iname.
|
||||||
|
|
||||||
|
In addition, suppress the model's tooltip data to avoid a tooltip on a tooltip.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TooltipFilterModel : public QSortFilterProxyModel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TooltipFilterModel(QAbstractItemModel *model, const QByteArray &iname)
|
||||||
|
: m_iname(iname)
|
||||||
|
{
|
||||||
|
setSourceModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const
|
||||||
|
{
|
||||||
|
return role == Qt::ToolTipRole
|
||||||
|
? QVariant() : QSortFilterProxyModel::data(index, role);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isSubIname(const QByteArray &haystack, const QByteArray &needle)
|
||||||
|
{
|
||||||
|
return haystack.size() > needle.size()
|
||||||
|
&& haystack.startsWith(needle)
|
||||||
|
&& haystack.at(needle.size()) == '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||||
|
{
|
||||||
|
const QModelIndex nameIndex = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||||
|
const QByteArray iname = nameIndex.data(LocalsINameRole).toByteArray();
|
||||||
|
return iname == m_iname || isSubIname(iname, m_iname) || isSubIname(m_iname, iname);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const QByteArray m_iname;
|
||||||
|
};
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TreeModelCopyVisitor builds a QStandardItem from a tree model (copy).
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Visitor building a QStandardItem from a tree model (copy).
|
|
||||||
class TreeModelCopyVisitor : public TreeModelVisitor
|
class TreeModelCopyVisitor : public TreeModelVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -466,6 +508,72 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// DebuggerToolTipWidget
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class DebuggerToolTipWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool isPinned() const { return m_isPinned; }
|
||||||
|
|
||||||
|
explicit DebuggerToolTipWidget(QWidget *parent = 0);
|
||||||
|
bool engineAcquired() const { return m_engineAcquired; }
|
||||||
|
|
||||||
|
QString fileName() const { return m_context.fileName; }
|
||||||
|
QString function() const { return m_context.function; }
|
||||||
|
int position() const { return m_context.position; }
|
||||||
|
// Check for a match at position.
|
||||||
|
bool matches(const QString &fileName,
|
||||||
|
const QString &engineType = QString(),
|
||||||
|
const QString &function= QString()) const;
|
||||||
|
|
||||||
|
const DebuggerToolTipContext &context() const { return m_context; }
|
||||||
|
void setContext(const DebuggerToolTipContext &c) { m_context = c; }
|
||||||
|
|
||||||
|
QString engineType() const { return m_engineType; }
|
||||||
|
void setEngineType(const QString &e) { m_engineType = e; }
|
||||||
|
|
||||||
|
QDate creationDate() const { return m_creationDate; }
|
||||||
|
void setCreationDate(const QDate &d) { m_creationDate = d; }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void saveSessionData(QXmlStreamWriter &w) const;
|
||||||
|
|
||||||
|
void acquireEngine(Debugger::DebuggerEngine *engine);
|
||||||
|
void releaseEngine();
|
||||||
|
void copy();
|
||||||
|
bool positionShow(const DebuggerToolTipEditor &pe);
|
||||||
|
void pin();
|
||||||
|
void doLoadSessionData(QXmlStreamReader &r);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotDragged(const QPoint &p);
|
||||||
|
void toolButtonClicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void doReleaseEngine();
|
||||||
|
void doSaveSessionData(QXmlStreamWriter &w) const;
|
||||||
|
QString clipboardContents() const;
|
||||||
|
QAbstractItemModel *swapModel(QAbstractItemModel *newModel);
|
||||||
|
|
||||||
|
bool m_isPinned;
|
||||||
|
QToolButton *m_toolButton;
|
||||||
|
DraggableLabel *m_titleLabel;
|
||||||
|
bool m_engineAcquired;
|
||||||
|
QString m_engineType;
|
||||||
|
DebuggerToolTipContext m_context;
|
||||||
|
QDate m_creationDate;
|
||||||
|
QPoint m_offset; //!< Offset to text cursor position (user dragging).
|
||||||
|
int m_debuggerModel;
|
||||||
|
DebuggerToolTipTreeView *m_treeView;
|
||||||
|
QStandardItemModel *m_defaultModel;
|
||||||
|
};
|
||||||
|
|
||||||
void DebuggerToolTipWidget::pin()
|
void DebuggerToolTipWidget::pin()
|
||||||
{
|
{
|
||||||
if (m_isPinned)
|
if (m_isPinned)
|
||||||
@@ -633,10 +741,15 @@ void DebuggerToolTipWidget::acquireEngine(DebuggerEngine *engine)
|
|||||||
qDebug() << this << " acquiring" << engine << m_engineAcquired;
|
qDebug() << this << " acquiring" << engine << m_engineAcquired;
|
||||||
if (m_engineAcquired)
|
if (m_engineAcquired)
|
||||||
return;
|
return;
|
||||||
doAcquireEngine(engine);
|
|
||||||
m_engineType = engine->objectName();
|
m_engineType = engine->objectName();
|
||||||
m_engineAcquired = true;
|
m_engineAcquired = true;
|
||||||
m_titleLabel->setText(QString());
|
m_titleLabel->setText(QString());
|
||||||
|
|
||||||
|
// Create a filter model on the debugger's model and switch to it.
|
||||||
|
QAbstractItemModel *model = engine->watchModel();
|
||||||
|
TooltipFilterModel *filterModel = new TooltipFilterModel(model, m_context.iname);
|
||||||
|
swapModel(filterModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerToolTipWidget::releaseEngine()
|
void DebuggerToolTipWidget::releaseEngine()
|
||||||
@@ -712,17 +825,7 @@ static QDate dateFromString(const QString &date)
|
|||||||
QDate();
|
QDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
DebuggerToolTipWidget *DebuggerToolTipWidget::loadSessionData(QXmlStreamReader &r)
|
static DebuggerToolTipWidget *loadSessionDataI(QXmlStreamReader &r)
|
||||||
{
|
|
||||||
if (debugToolTips)
|
|
||||||
qDebug() << ">DebuggerToolTipWidget::loadSessionData" << r.tokenString() << r.name();
|
|
||||||
DebuggerToolTipWidget *rc = DebuggerToolTipWidget::loadSessionDataI(r);
|
|
||||||
if (debugToolTips)
|
|
||||||
qDebug() << "<DebuggerToolTipWidget::loadSessionData" << r.tokenString() << r.name() << " returns " << rc;
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
DebuggerToolTipWidget *DebuggerToolTipWidget::loadSessionDataI(QXmlStreamReader &r)
|
|
||||||
{
|
{
|
||||||
if (!readStartElement(r, toolTipElementC))
|
if (!readStartElement(r, toolTipElementC))
|
||||||
return 0;
|
return 0;
|
||||||
@@ -793,50 +896,6 @@ void DebuggerToolTipWidget::saveSessionData(QXmlStreamWriter &w) const
|
|||||||
w.writeEndElement();
|
w.writeEndElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\class Debugger::Internal::TooltipFilterModel
|
|
||||||
|
|
||||||
\brief The TooltipFilterModel class is a model for tooltips filtering an
|
|
||||||
item on the watchhandler matching its tree on the iname.
|
|
||||||
|
|
||||||
In addition, suppress the model's tooltip data to avoid a tooltip on a tooltip.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class TooltipFilterModel : public QSortFilterProxyModel
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TooltipFilterModel(QAbstractItemModel *model, const QByteArray &iname)
|
|
||||||
: m_iname(iname)
|
|
||||||
{
|
|
||||||
setSourceModel(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const
|
|
||||||
{
|
|
||||||
return role == Qt::ToolTipRole
|
|
||||||
? QVariant() : QSortFilterProxyModel::data(index, role);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const QByteArray m_iname;
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool isSubIname(const QByteArray &haystack, const QByteArray &needle)
|
|
||||||
{
|
|
||||||
return haystack.size() > needle.size()
|
|
||||||
&& haystack.startsWith(needle)
|
|
||||||
&& haystack.at(needle.size()) == '.';
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TooltipFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
|
||||||
{
|
|
||||||
const QModelIndex nameIndex = sourceModel()->index(sourceRow, 0, sourceParent);
|
|
||||||
const QByteArray iname = nameIndex.data(LocalsINameRole).toByteArray();
|
|
||||||
return iname == m_iname || isSubIname(iname, m_iname) || isSubIname(m_iname, iname);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Debugger::Internal::DebuggerToolTipTreeView
|
\class Debugger::Internal::DebuggerToolTipTreeView
|
||||||
|
|
||||||
@@ -967,15 +1026,6 @@ void DebuggerToolTipTreeView::computeSize()
|
|||||||
viewport()->update();
|
viewport()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
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_context.iname);
|
|
||||||
swapModel(filterModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
QAbstractItemModel *DebuggerToolTipWidget::swapModel(QAbstractItemModel *newModel)
|
QAbstractItemModel *DebuggerToolTipWidget::swapModel(QAbstractItemModel *newModel)
|
||||||
{
|
{
|
||||||
QAbstractItemModel *oldModel = m_treeView->swapModel(newModel);
|
QAbstractItemModel *oldModel = m_treeView->swapModel(newModel);
|
||||||
@@ -1001,7 +1051,7 @@ void DebuggerToolTipWidget::doReleaseEngine()
|
|||||||
delete swapModel(m_defaultModel);
|
delete swapModel(m_defaultModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerToolTipWidget::restoreTreeModel(QXmlStreamReader &r, QStandardItemModel *m)
|
static void restoreTreeModel(QXmlStreamReader &r, QStandardItemModel *m)
|
||||||
{
|
{
|
||||||
StandardItemTreeModelBuilder builder(m);
|
StandardItemTreeModelBuilder builder(m);
|
||||||
int columnCount = 1;
|
int columnCount = 1;
|
||||||
@@ -1069,7 +1119,7 @@ void DebuggerToolTipWidget::doLoadSessionData(QXmlStreamReader &r)
|
|||||||
m_treeView->swapModel(m_defaultModel);
|
m_treeView->swapModel(m_defaultModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DebuggerToolTipWidget::treeModelClipboardContents(const QAbstractItemModel *m)
|
QString DebuggerToolTipManager::treeModelClipboardContents(const QAbstractItemModel *m)
|
||||||
{
|
{
|
||||||
QString rc;
|
QString rc;
|
||||||
QTextStream str(&rc);
|
QTextStream str(&rc);
|
||||||
@@ -1081,7 +1131,7 @@ QString DebuggerToolTipWidget::treeModelClipboardContents(const QAbstractItemMod
|
|||||||
QString DebuggerToolTipWidget::clipboardContents() const
|
QString DebuggerToolTipWidget::clipboardContents() const
|
||||||
{
|
{
|
||||||
if (const QAbstractItemModel *model = m_treeView->model())
|
if (const QAbstractItemModel *model = m_treeView->model())
|
||||||
return DebuggerToolTipWidget::treeModelClipboardContents(model);
|
return DebuggerToolTipManager::treeModelClipboardContents(model);
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1149,13 +1199,15 @@ bool DebuggerToolTipManager::hasToolTips()
|
|||||||
return !d->m_tooltips.isEmpty();
|
return !d->m_tooltips.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerToolTipManager::showToolTip(const QPoint &p, DebuggerToolTipWidget *toolTipWidget)
|
void DebuggerToolTipManager::showToolTip(const DebuggerToolTipContext &context,
|
||||||
|
DebuggerEngine *engine)
|
||||||
{
|
{
|
||||||
if (debugToolTipPositioning)
|
DebuggerToolTipWidget *tw = new DebuggerToolTipWidget;
|
||||||
qDebug() << "DebuggerToolTipManager::showToolTip" << p << " Mouse at " << QCursor::pos();
|
tw->setContext(context);
|
||||||
const Utils::WidgetContent widgetContent(toolTipWidget, true);
|
tw->acquireEngine(engine);
|
||||||
Utils::ToolTip::show(p, widgetContent, debuggerCore()->mainWindow());
|
const Utils::WidgetContent widgetContent(tw, true);
|
||||||
d->registerToolTip(toolTipWidget);
|
Utils::ToolTip::show(context.mousePosition, widgetContent, debuggerCore()->mainWindow());
|
||||||
|
d->registerToolTip(tw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerToolTipManagerData::registerToolTip(DebuggerToolTipWidget *toolTipWidget)
|
void DebuggerToolTipManagerData::registerToolTip(DebuggerToolTipWidget *toolTipWidget)
|
||||||
@@ -1214,6 +1266,16 @@ void DebuggerToolTipManager::sessionAboutToChange()
|
|||||||
closeAllToolTips();
|
closeAllToolTips();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DebuggerToolTipWidget *loadSessionDataX(QXmlStreamReader &r)
|
||||||
|
{
|
||||||
|
if (debugToolTips)
|
||||||
|
qDebug() << ">DebuggerToolTipWidget::loadSessionData" << r.tokenString() << r.name();
|
||||||
|
DebuggerToolTipWidget *rc = loadSessionDataI(r);
|
||||||
|
if (debugToolTips)
|
||||||
|
qDebug() << "<DebuggerToolTipWidget::loadSessionData" << r.tokenString() << r.name() << " returns " << rc;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
void DebuggerToolTipManager::loadSessionData()
|
void DebuggerToolTipManager::loadSessionData()
|
||||||
{
|
{
|
||||||
const QString data = DebuggerCore::sessionValue(sessionSettingsKeyC).toString();
|
const QString data = DebuggerCore::sessionValue(sessionSettingsKeyC).toString();
|
||||||
@@ -1225,7 +1287,7 @@ void DebuggerToolTipManager::loadSessionData()
|
|||||||
return;
|
return;
|
||||||
const double version = r.attributes().value(QLatin1String(sessionVersionAttributeC)).toString().toDouble();
|
const double version = r.attributes().value(QLatin1String(sessionVersionAttributeC)).toString().toDouble();
|
||||||
while (!r.atEnd())
|
while (!r.atEnd())
|
||||||
if (DebuggerToolTipWidget *tw = DebuggerToolTipWidget::loadSessionData(r))
|
if (DebuggerToolTipWidget *tw = loadSessionDataX(r))
|
||||||
d->registerToolTip(tw);
|
d->registerToolTip(tw);
|
||||||
|
|
||||||
if (debugToolTips)
|
if (debugToolTips)
|
||||||
@@ -1466,8 +1528,9 @@ void DebuggerToolTipManager::slotTooltipOverrideRequested(ITextEditor *editor,
|
|||||||
if (!currentEngine || !currentEngine->canDisplayTooltip())
|
if (!currentEngine || !currentEngine->canDisplayTooltip())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const DebuggerToolTipContext context = DebuggerToolTipContext::fromEditor(editor, pos);
|
DebuggerToolTipContext context = DebuggerToolTipContext::fromEditor(editor, pos);
|
||||||
if (context.isValid() && currentEngine->setToolTipExpression(point, editor, context)) {
|
context.mousePosition = point;
|
||||||
|
if (context.isValid() && currentEngine->setToolTipExpression(editor, context)) {
|
||||||
*handled = true;
|
*handled = true;
|
||||||
d->m_lastToolTipEditor = editor;
|
d->m_lastToolTipEditor = editor;
|
||||||
d->m_lastToolTipPoint = point;
|
d->m_lastToolTipPoint = point;
|
||||||
|
|||||||
@@ -32,34 +32,21 @@
|
|||||||
|
|
||||||
#include "debuggerconstants.h"
|
#include "debuggerconstants.h"
|
||||||
|
|
||||||
|
#include <QDate>
|
||||||
|
#include <QPointer>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
|
||||||
#include <QPointer>
|
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
#include <QXmlStreamReader>
|
|
||||||
#include <QDate>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QVBoxLayout;
|
|
||||||
class QToolButton;
|
|
||||||
class QStandardItemModel;
|
|
||||||
class QToolBar;
|
|
||||||
class QDebug;
|
class QDebug;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core { class IEditor; }
|
||||||
class IEditor;
|
|
||||||
class IMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace TextEditor { class ITextEditor; }
|
namespace TextEditor { class ITextEditor; }
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
class DebuggerEngine;
|
class DebuggerEngine;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class DraggableLabel;
|
|
||||||
class DebuggerToolTipEditor;
|
|
||||||
|
|
||||||
class DebuggerToolTipContext
|
class DebuggerToolTipContext
|
||||||
{
|
{
|
||||||
@@ -84,81 +71,6 @@ typedef QList<DebuggerToolTipContext> DebuggerToolTipContexts;
|
|||||||
|
|
||||||
QDebug operator<<(QDebug, const DebuggerToolTipContext &);
|
QDebug operator<<(QDebug, const DebuggerToolTipContext &);
|
||||||
|
|
||||||
class DebuggerToolTipTreeView;
|
|
||||||
|
|
||||||
class DebuggerToolTipWidget : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool isPinned() const { return m_isPinned; }
|
|
||||||
|
|
||||||
explicit DebuggerToolTipWidget(QWidget *parent = 0);
|
|
||||||
bool engineAcquired() const { return m_engineAcquired; }
|
|
||||||
|
|
||||||
QString fileName() const { return m_context.fileName; }
|
|
||||||
QString function() const { return m_context.function; }
|
|
||||||
int position() const { return m_context.position; }
|
|
||||||
// Check for a match at position.
|
|
||||||
bool matches(const QString &fileName,
|
|
||||||
const QString &engineType = QString(),
|
|
||||||
const QString &function= QString()) const;
|
|
||||||
|
|
||||||
const DebuggerToolTipContext &context() const { return m_context; }
|
|
||||||
void setContext(const DebuggerToolTipContext &c) { m_context = c; }
|
|
||||||
|
|
||||||
QString engineType() const { return m_engineType; }
|
|
||||||
void setEngineType(const QString &e) { m_engineType = e; }
|
|
||||||
|
|
||||||
QDate creationDate() const { return m_creationDate; }
|
|
||||||
void setCreationDate(const QDate &d) { m_creationDate = d; }
|
|
||||||
|
|
||||||
static DebuggerToolTipWidget *loadSessionData(QXmlStreamReader &r);
|
|
||||||
|
|
||||||
static QString treeModelClipboardContents(const QAbstractItemModel *m);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void saveSessionData(QXmlStreamWriter &w) const;
|
|
||||||
|
|
||||||
void acquireEngine(Debugger::DebuggerEngine *engine);
|
|
||||||
void releaseEngine();
|
|
||||||
void copy();
|
|
||||||
bool positionShow(const DebuggerToolTipEditor &pe);
|
|
||||||
void pin();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void slotDragged(const QPoint &p);
|
|
||||||
void toolButtonClicked();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_isPinned;
|
|
||||||
QToolButton *m_toolButton;
|
|
||||||
|
|
||||||
private:
|
|
||||||
static DebuggerToolTipWidget *loadSessionDataI(QXmlStreamReader &r);
|
|
||||||
void doAcquireEngine(Debugger::DebuggerEngine *engine);
|
|
||||||
void doReleaseEngine();
|
|
||||||
void doSaveSessionData(QXmlStreamWriter &w) const;
|
|
||||||
void doLoadSessionData(QXmlStreamReader &r);
|
|
||||||
QString clipboardContents() const;
|
|
||||||
|
|
||||||
DraggableLabel *m_titleLabel;
|
|
||||||
bool m_engineAcquired;
|
|
||||||
QString m_engineType;
|
|
||||||
DebuggerToolTipContext m_context;
|
|
||||||
QDate m_creationDate;
|
|
||||||
QPoint m_offset; //!< Offset to text cursor position (user dragging).
|
|
||||||
|
|
||||||
private:
|
|
||||||
QAbstractItemModel *swapModel(QAbstractItemModel *newModel);
|
|
||||||
static void restoreTreeModel(QXmlStreamReader &r, QStandardItemModel *m);
|
|
||||||
|
|
||||||
int m_debuggerModel;
|
|
||||||
|
|
||||||
DebuggerToolTipTreeView *m_treeView;
|
|
||||||
QStandardItemModel *m_defaultModel;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DebuggerToolTipTreeView : public QTreeView
|
class DebuggerToolTipTreeView : public QTreeView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -168,16 +80,15 @@ public:
|
|||||||
|
|
||||||
QAbstractItemModel *swapModel(QAbstractItemModel *model);
|
QAbstractItemModel *swapModel(QAbstractItemModel *model);
|
||||||
QSize sizeHint() const { return m_size; }
|
QSize sizeHint() const { return m_size; }
|
||||||
int computeHeight(const QModelIndex &index) const;
|
|
||||||
|
|
||||||
public slots:
|
private slots:
|
||||||
void computeSize();
|
void computeSize();
|
||||||
void expandNode(const QModelIndex &idx);
|
void expandNode(const QModelIndex &idx);
|
||||||
void collapseNode(const QModelIndex &idx);
|
void collapseNode(const QModelIndex &idx);
|
||||||
void handleItemIsExpanded(const QModelIndex &sourceIdx);
|
void handleItemIsExpanded(const QModelIndex &sourceIdx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init(QAbstractItemModel *model);
|
int computeHeight(const QModelIndex &index) const;
|
||||||
|
|
||||||
QSize m_size;
|
QSize m_size;
|
||||||
};
|
};
|
||||||
@@ -198,11 +109,13 @@ public:
|
|||||||
const QString &engineType = QString(),
|
const QString &engineType = QString(),
|
||||||
const QString &function= QString());
|
const QString &function= QString());
|
||||||
|
|
||||||
static void showToolTip(const QPoint &p, DebuggerToolTipWidget *);
|
static void showToolTip(const DebuggerToolTipContext &context,
|
||||||
|
DebuggerEngine *engine);
|
||||||
|
|
||||||
virtual bool eventFilter(QObject *, QEvent *);
|
virtual bool eventFilter(QObject *, QEvent *);
|
||||||
|
|
||||||
static bool debug();
|
static bool debug();
|
||||||
|
static QString treeModelClipboardContents(const QAbstractItemModel *m);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void debugModeEntered();
|
void debugModeEntered();
|
||||||
|
|||||||
@@ -3644,10 +3644,7 @@ void GdbEngine::showToolTip()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DebuggerToolTipWidget *tw = new DebuggerToolTipWidget;
|
DebuggerToolTipManager::showToolTip(*m_toolTipContext, this);
|
||||||
tw->setContext(*m_toolTipContext);
|
|
||||||
tw->acquireEngine(this);
|
|
||||||
DebuggerToolTipManager::showToolTip(m_toolTipContext->mousePosition, tw);
|
|
||||||
// Prevent tooltip from re-occurring (classic GDB, QTCREATORBUG-4711).
|
// Prevent tooltip from re-occurring (classic GDB, QTCREATORBUG-4711).
|
||||||
m_toolTipContext.reset();
|
m_toolTipContext.reset();
|
||||||
}
|
}
|
||||||
@@ -3663,8 +3660,8 @@ void GdbEngine::resetLocation()
|
|||||||
DebuggerEngine::resetLocation();
|
DebuggerEngine::resetLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GdbEngine::setToolTipExpression(const QPoint &mousePos,
|
bool GdbEngine::setToolTipExpression(TextEditor::ITextEditor *editor,
|
||||||
TextEditor::ITextEditor *editor, const DebuggerToolTipContext &contextIn)
|
const DebuggerToolTipContext &contextIn)
|
||||||
{
|
{
|
||||||
if (state() != InferiorStopOk || !isCppEditor(editor)) {
|
if (state() != InferiorStopOk || !isCppEditor(editor)) {
|
||||||
//qDebug() << "SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED "
|
//qDebug() << "SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED "
|
||||||
@@ -3696,7 +3693,6 @@ bool GdbEngine::setToolTipExpression(const QPoint &mousePos,
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_toolTipContext.reset(new DebuggerToolTipContext(context));
|
m_toolTipContext.reset(new DebuggerToolTipContext(context));
|
||||||
m_toolTipContext->mousePosition = mousePos;
|
|
||||||
m_toolTipContext->expression = exp;
|
m_toolTipContext->expression = exp;
|
||||||
m_toolTipContext->iname = iname;
|
m_toolTipContext->iname = iname;
|
||||||
// Local variable: Display synchronously.
|
// Local variable: Display synchronously.
|
||||||
|
|||||||
@@ -406,8 +406,8 @@ protected:
|
|||||||
//
|
//
|
||||||
// Watch specific stuff
|
// Watch specific stuff
|
||||||
//
|
//
|
||||||
virtual bool setToolTipExpression(const QPoint &mousePos,
|
virtual bool setToolTipExpression(TextEditor::ITextEditor *editor,
|
||||||
TextEditor::ITextEditor *editor, const DebuggerToolTipContext &);
|
const DebuggerToolTipContext &);
|
||||||
virtual void assignValueInDebugger(const WatchData *data,
|
virtual void assignValueInDebugger(const WatchData *data,
|
||||||
const QString &expr, const QVariant &value);
|
const QString &expr, const QVariant &value);
|
||||||
|
|
||||||
|
|||||||
@@ -834,10 +834,7 @@ void LldbEngine::showToolTip()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DebuggerToolTipWidget *tw = new DebuggerToolTipWidget;
|
DebuggerToolTipManager::showToolTip(*m_toolTipContext, this);
|
||||||
tw->setContext(*m_toolTipContext);
|
|
||||||
tw->acquireEngine(this);
|
|
||||||
DebuggerToolTipManager::showToolTip(m_toolTipContext->mousePosition, tw);
|
|
||||||
// Prevent tooltip from re-occurring (classic GDB, QTCREATORBUG-4711).
|
// Prevent tooltip from re-occurring (classic GDB, QTCREATORBUG-4711).
|
||||||
m_toolTipContext.reset();
|
m_toolTipContext.reset();
|
||||||
}
|
}
|
||||||
@@ -848,8 +845,7 @@ void LldbEngine::resetLocation()
|
|||||||
DebuggerEngine::resetLocation();
|
DebuggerEngine::resetLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LldbEngine::setToolTipExpression(const QPoint &mousePos,
|
bool LldbEngine::setToolTipExpression(TextEditor::ITextEditor *editor, const DebuggerToolTipContext &contextIn)
|
||||||
TextEditor::ITextEditor *editor, const DebuggerToolTipContext &contextIn)
|
|
||||||
{
|
{
|
||||||
if (state() != InferiorStopOk || !isCppEditor(editor)) {
|
if (state() != InferiorStopOk || !isCppEditor(editor)) {
|
||||||
//qDebug() << "SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED "
|
//qDebug() << "SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED "
|
||||||
@@ -881,7 +877,6 @@ bool LldbEngine::setToolTipExpression(const QPoint &mousePos,
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_toolTipContext.reset(new DebuggerToolTipContext(context));
|
m_toolTipContext.reset(new DebuggerToolTipContext(context));
|
||||||
m_toolTipContext->mousePosition = mousePos;
|
|
||||||
m_toolTipContext->expression = exp;
|
m_toolTipContext->expression = exp;
|
||||||
m_toolTipContext->iname = iname;
|
m_toolTipContext->iname = iname;
|
||||||
// Local variable: Display synchronously.
|
// Local variable: Display synchronously.
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ private:
|
|||||||
void abortDebugger();
|
void abortDebugger();
|
||||||
void resetLocation();
|
void resetLocation();
|
||||||
|
|
||||||
bool setToolTipExpression(const QPoint &mousePos,
|
bool setToolTipExpression(TextEditor::ITextEditor *editor,
|
||||||
TextEditor::ITextEditor *editor, const DebuggerToolTipContext &);
|
const DebuggerToolTipContext &);
|
||||||
|
|
||||||
void continueInferior();
|
void continueInferior();
|
||||||
void interruptInferior();
|
void interruptInferior();
|
||||||
|
|||||||
@@ -452,10 +452,9 @@ static WatchData m_toolTip;
|
|||||||
static QPoint m_toolTipPos;
|
static QPoint m_toolTipPos;
|
||||||
static QHash<QString, WatchData> m_toolTipCache;
|
static QHash<QString, WatchData> m_toolTipCache;
|
||||||
|
|
||||||
bool PdbEngine::setToolTipExpression(const QPoint &mousePos,
|
bool PdbEngine::setToolTipExpression(TextEditor::ITextEditor *editor,
|
||||||
TextEditor::ITextEditor *editor, const DebuggerToolTipContext &ctx)
|
const DebuggerToolTipContext &ctx)
|
||||||
{
|
{
|
||||||
Q_UNUSED(mousePos)
|
|
||||||
Q_UNUSED(editor)
|
Q_UNUSED(editor)
|
||||||
|
|
||||||
if (state() != InferiorStopOk) {
|
if (state() != InferiorStopOk) {
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ private:
|
|||||||
void shutdownInferior();
|
void shutdownInferior();
|
||||||
void shutdownEngine();
|
void shutdownEngine();
|
||||||
|
|
||||||
bool setToolTipExpression(const QPoint &mousePos,
|
bool setToolTipExpression(TextEditor::ITextEditor *editor,
|
||||||
TextEditor::ITextEditor *editor, const DebuggerToolTipContext &);
|
const DebuggerToolTipContext &);
|
||||||
|
|
||||||
void continueInferior();
|
void continueInferior();
|
||||||
void interruptInferior();
|
void interruptInferior();
|
||||||
|
|||||||
@@ -89,15 +89,14 @@ bool QmlCppEngine::canDisplayTooltip() const
|
|||||||
return m_cppEngine->canDisplayTooltip() || m_qmlEngine->canDisplayTooltip();
|
return m_cppEngine->canDisplayTooltip() || m_qmlEngine->canDisplayTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlCppEngine::setToolTipExpression(const QPoint & mousePos,
|
bool QmlCppEngine::setToolTipExpression(TextEditor::ITextEditor *editor, const DebuggerToolTipContext &ctx)
|
||||||
TextEditor::ITextEditor *editor, const DebuggerToolTipContext &ctx)
|
|
||||||
{
|
{
|
||||||
QTC_ASSERT(editor, return false);
|
QTC_ASSERT(editor, return false);
|
||||||
bool success = false;
|
bool success = false;
|
||||||
if (editor->document()->id() == CppEditor::Constants::CPPEDITOR_ID)
|
if (editor->document()->id() == CppEditor::Constants::CPPEDITOR_ID)
|
||||||
success = m_cppEngine->setToolTipExpression(mousePos, editor, ctx);
|
success = m_cppEngine->setToolTipExpression(editor, ctx);
|
||||||
else if (editor->document()->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID)
|
else if (editor->document()->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID)
|
||||||
success = m_qmlEngine->setToolTipExpression(mousePos, editor, ctx);
|
success = m_qmlEngine->setToolTipExpression(editor, ctx);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ public:
|
|||||||
~QmlCppEngine();
|
~QmlCppEngine();
|
||||||
|
|
||||||
bool canDisplayTooltip() const;
|
bool canDisplayTooltip() const;
|
||||||
bool setToolTipExpression(const QPoint &mousePos,
|
bool setToolTipExpression(TextEditor::ITextEditor *editor,
|
||||||
TextEditor::ITextEditor * editor, const DebuggerToolTipContext &);
|
const DebuggerToolTipContext &);
|
||||||
void updateWatchData(const WatchData &data,
|
void updateWatchData(const WatchData &data,
|
||||||
const WatchUpdateFlags &flags);
|
const WatchUpdateFlags &flags);
|
||||||
void watchDataSelected(const QByteArray &iname);
|
void watchDataSelected(const QByteArray &iname);
|
||||||
|
|||||||
@@ -983,12 +983,12 @@ void QmlEngine::requestModuleSymbols(const QString &moduleName)
|
|||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool QmlEngine::setToolTipExpression(const QPoint &mousePos,
|
bool QmlEngine::setToolTipExpression(TextEditor::ITextEditor *editor,
|
||||||
TextEditor::ITextEditor *editor, const DebuggerToolTipContext &ctx)
|
const DebuggerToolTipContext &ctx)
|
||||||
{
|
{
|
||||||
// This is processed by QML inspector, which has dependencies to
|
// This is processed by QML inspector, which has dependencies to
|
||||||
// the qml js editor. Makes life easier.
|
// the qml js editor. Makes life easier.
|
||||||
emit tooltipRequested(mousePos, editor, ctx.position);
|
emit tooltipRequested(ctx.mousePosition, editor, ctx.position);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,8 +128,8 @@ private:
|
|||||||
void shutdownInferior();
|
void shutdownInferior();
|
||||||
void shutdownEngine();
|
void shutdownEngine();
|
||||||
|
|
||||||
bool setToolTipExpression(const QPoint &mousePos,
|
bool setToolTipExpression(TextEditor::ITextEditor *editor,
|
||||||
TextEditor::ITextEditor *editor, const DebuggerToolTipContext &);
|
const DebuggerToolTipContext &);
|
||||||
|
|
||||||
void continueInferior();
|
void continueInferior();
|
||||||
void interruptInferior();
|
void interruptInferior();
|
||||||
|
|||||||
@@ -958,7 +958,7 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
} else if (act == &actRemoveWatchExpression) {
|
} else if (act == &actRemoveWatchExpression) {
|
||||||
handler->removeData(p.data(LocalsINameRole).toByteArray());
|
handler->removeData(p.data(LocalsINameRole).toByteArray());
|
||||||
} else if (act == &actCopy) {
|
} else if (act == &actCopy) {
|
||||||
copyToClipboard(DebuggerToolTipWidget::treeModelClipboardContents(model()));
|
copyToClipboard(DebuggerToolTipManager::treeModelClipboardContents(model()));
|
||||||
} else if (act == &actCopyValue) {
|
} else if (act == &actCopyValue) {
|
||||||
copyToClipboard(mi1.data().toString());
|
copyToClipboard(mi1.data().toString());
|
||||||
} else if (act == &actShowInEditor) {
|
} else if (act == &actShowInEditor) {
|
||||||
|
|||||||
Reference in New Issue
Block a user