Commit bc30185b authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Debugger[CDB]: Show expandable tooltips.

By setting a filter model on the locals model.
Prepare infrastructure for filter models for pinneable
tooltips in debuggertooltips.
parent b1952160
......@@ -440,9 +440,11 @@ void CdbEngine::setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEd
if (!(exp.at(0).isLetter() || exp.at(0) == QLatin1Char('_')))
return;
const QByteArray iname = QByteArray(localsPrefixC) + exp.toAscii();
if (const WatchData *data = watchHandler()->findItem(iname)) {
QToolTip::hideText();
QToolTip::showText(mousePos, data->toToolTip());
const QModelIndex index = watchHandler()->itemIndex(iname);
if (index.isValid()) {
showDebuggerToolTip(mousePos, watchHandler()->modelForIName(iname), index.row());
} else {
hideDebuggerToolTip();
}
}
......
......@@ -33,6 +33,8 @@
#include "debuggertooltip.h"
#include <utils/qtcassert.h>
#include <QtCore/QtDebug>
#include <QtCore/QPointer>
......@@ -42,6 +44,7 @@
#include <QtGui/QKeyEvent>
#include <QtGui/QScrollBar>
#include <QtGui/QTreeView>
#include <QtGui/QSortFilterProxyModel>
namespace Debugger {
namespace Internal {
......@@ -177,6 +180,9 @@ void ToolTipWidget::run(const QPoint &point, const QModelIndex &index)
QAbstractItemModel *model = const_cast<QAbstractItemModel *>(index.model());
move(point);
setModel(model);
// Track changes in filter models.
connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(computeSize()), Qt::QueuedConnection);
computeSize();
setRootIsDecorated(model->hasChildren(index));
}
......@@ -201,6 +207,40 @@ void showDebuggerToolTip(const QPoint &point, const QModelIndex &index)
}
}
// Model for tooltips filtering a local variable using the locals model.
class ToolTipRowFilterModel : public QSortFilterProxyModel
{
public:
// Index points the variable to be filtered.
explicit ToolTipRowFilterModel(QAbstractItemModel *model, int row, QObject *parent = 0);
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
private:
const int m_row;
};
ToolTipRowFilterModel::ToolTipRowFilterModel(QAbstractItemModel *model, int row, QObject *parent) :
QSortFilterProxyModel(parent), m_row(row)
{
setSourceModel(model);
}
bool ToolTipRowFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
// Match on row for top level, else pass through.
return sourceParent.isValid() || sourceRow == m_row;
}
// Show tooltip filtering a row of a source model.
void showDebuggerToolTip(const QPoint &point, QAbstractItemModel *model, int row)
{
// Create a filter model parented on the widget to display column
ToolTipRowFilterModel *filterModel = new ToolTipRowFilterModel(model, row);
showDebuggerToolTip(point, filterModel->index(0, 0));
QTC_ASSERT(theToolTipWidget, return; )
filterModel->setParent(theToolTipWidget);
}
void hideDebuggerToolTip(int delay)
{
Q_UNUSED(delay)
......
......@@ -39,12 +39,15 @@
QT_BEGIN_NAMESPACE
class QModelIndex;
class QPoint;
class QAbstractItemModel;
QT_END_NAMESPACE
namespace Debugger {
namespace Internal {
void showDebuggerToolTip(const QPoint &point, const QModelIndex &rootIndex);
// Show tooltip filtering a row of a source model.
void showDebuggerToolTip(const QPoint &point, QAbstractItemModel *model, int row);
void hideDebuggerToolTip(int delay = 0);
} // namespace Internal
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment