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();
}
}
#include "debuggertooltip.h"
+#include <utils/qtcassert.h>
+
#include <QtCore/QtDebug>
#include <QtCore/QPointer>
#include <QtGui/QKeyEvent>
#include <QtGui/QScrollBar>
#include <QtGui/QTreeView>
+#include <QtGui/QSortFilterProxyModel>
namespace Debugger {
namespace Internal {
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));
}
}
}
+// 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)