forked from qt-creator/qt-creator
Debugger[CDB]: Show expandable tooltips.
By setting a filter model on the locals model. Prepare infrastructure for filter models for pinneable tooltips in debuggertooltips.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user