forked from qt-creator/qt-creator
Debugger: Fix up titles/tooltips of memory views.
This commit is contained in:
@@ -211,6 +211,8 @@ enum ModelRoles
|
||||
LocalsExpressionRole,
|
||||
LocalsRawExpressionRole,
|
||||
LocalsExpandedRole, // The preferred expanded state to the view
|
||||
LocalsRawTypeRole, // Raw type name
|
||||
LocalsTypeRole, // Display type name
|
||||
LocalsTypeFormatListRole,
|
||||
LocalsTypeFormatRole, // Used to communicate alternative formats to the view
|
||||
LocalsIndividualFormatRole,
|
||||
|
||||
@@ -626,7 +626,7 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
|
||||
}
|
||||
|
||||
case Qt::DisplayRole: {
|
||||
const QByteArray ns = engine()->qtNamespace();
|
||||
const QByteArray qtNameSpace = engine()->qtNamespace();
|
||||
QString result;
|
||||
switch (idx.column()) {
|
||||
case 0:
|
||||
@@ -635,18 +635,18 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
|
||||
else if (data.name == QLatin1String("*") && item->parent)
|
||||
result = QLatin1Char('*') + item->parent->name;
|
||||
else
|
||||
result = removeInitialNamespace(data.name, ns);
|
||||
result = removeInitialNamespace(data.name, qtNameSpace);
|
||||
break;
|
||||
case 1:
|
||||
result = removeInitialNamespace(truncateValue(
|
||||
formattedValue(data, itemFormat(data))), ns);
|
||||
formattedValue(data, itemFormat(data))), qtNameSpace);
|
||||
if (data.referencingAddress) {
|
||||
result += QLatin1String(" @");
|
||||
result += QString::fromLatin1(data.hexAddress());
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
result = removeNamespaces(displayType(data), ns);
|
||||
result = removeNamespaces(displayType(data), qtNameSpace);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -722,7 +722,10 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
|
||||
type = type.left(pos);
|
||||
return m_handler->m_reportedTypeFormats.value(type);
|
||||
}
|
||||
|
||||
case LocalsTypeRole:
|
||||
return removeNamespaces(displayType(data), engine()->qtNamespace());
|
||||
case LocalsRawTypeRole:
|
||||
return QString::fromLatin1(data.type);
|
||||
case LocalsTypeFormatRole:
|
||||
return m_handler->m_typeFormats.value(data.type, -1);
|
||||
|
||||
|
||||
@@ -148,6 +148,8 @@ static inline quint64 pointerValueOf(const QModelIndex &m)
|
||||
{ return m.data(LocalsPointerValueRole).toULongLong(); }
|
||||
static inline QString nameOf(const QModelIndex &m)
|
||||
{ return m.data().toString(); }
|
||||
static inline QString typeOf(const QModelIndex &m)
|
||||
{ return m.data(LocalsTypeRole).toString(); }
|
||||
static inline uint sizeOf(const QModelIndex &m)
|
||||
{ return m.data(LocalsSizeRole).toUInt(); }
|
||||
|
||||
@@ -159,6 +161,18 @@ static inline uint sizeOf(const QModelIndex &m)
|
||||
typedef QPair<int, QString> ColorNumberToolTipPair;
|
||||
typedef QVector<ColorNumberToolTipPair> ColorNumberToolTipVector;
|
||||
|
||||
static inline QString variableToolTip(const QString &name,
|
||||
const QString &type,
|
||||
quint64 offset)
|
||||
{
|
||||
return offset ?
|
||||
//: HTML tooltip of a variable in the memory editor
|
||||
WatchWindow::tr("<i>%1</i> %2 at #%3").
|
||||
arg(type, name).arg(offset) :
|
||||
//: HTML tooltip of a variable in the memory editor
|
||||
WatchWindow::tr("<i>%1</i> %2").arg(type, name);
|
||||
}
|
||||
|
||||
static int memberVariableRecursion(const QModelIndex &m,
|
||||
const QString &name,
|
||||
quint64 start, quint64 end,
|
||||
@@ -178,7 +192,8 @@ static int memberVariableRecursion(const QModelIndex &m,
|
||||
&& (childAddress + childSize) <= end) { // Non-static, within area?
|
||||
const QString childName = nameRoot + nameOf(childIndex);
|
||||
const quint64 childOffset = childAddress - start;
|
||||
const QString toolTip = WatchWindow::tr("%1 at #%2").arg(childName).arg(childOffset);
|
||||
const QString toolTip
|
||||
= variableToolTip(childName, typeOf(childIndex), childOffset);
|
||||
const ColorNumberToolTipPair colorNumberNamePair((*colorNumberIn)++, toolTip);
|
||||
const ColorNumberToolTipVector::iterator begin = cnmv->begin() + childOffset;
|
||||
qFill(begin, begin + childSize, colorNumberNamePair);
|
||||
@@ -240,7 +255,8 @@ static inline MemoryMarkupList
|
||||
MemoryMarkupList result;
|
||||
const QString name = nameOf(m);
|
||||
int colorNumber = 0;
|
||||
ColorNumberToolTipVector ranges(size, ColorNumberToolTipPair(colorNumber, name));
|
||||
const QString rootToolTip = variableToolTip(name, typeOf(m), 0);
|
||||
ColorNumberToolTipVector ranges(size, ColorNumberToolTipPair(colorNumber, rootToolTip));
|
||||
const int childCount = memberVariableRecursion(m, name, address, address + size, &colorNumber, &ranges);
|
||||
if (sizeIsEstimate && !childCount)
|
||||
return result; // Fixme: Exact size not known, no point in filling if no children.
|
||||
@@ -319,7 +335,9 @@ static void addVariableMemoryView(DebuggerEngine *engine,
|
||||
const QList<MemoryMarkup> markup =
|
||||
variableMemoryMarkup(m, address, size, sizeIsEstimate, background);
|
||||
const unsigned flags = separateView ? (DebuggerEngine::MemoryView|DebuggerEngine::MemoryReadOnly) : 0;
|
||||
const QString title = WatchWindow::tr("Memory at Variable '%1' (0x%2)").arg(nameOf(m)).arg(address, 0, 16);
|
||||
const QString title = deferencePointer ?
|
||||
WatchWindow::tr("Memory Referenced by Pointer '%1' (0x%2)").arg(nameOf(m)).arg(address, 0, 16) :
|
||||
WatchWindow::tr("Memory at Variable '%1' (0x%2)").arg(nameOf(m)).arg(address, 0, 16);
|
||||
engine->openMemoryView(address, flags, markup, p, title, parent);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user