Debugger: Use TypedTreeItem's typed parent ability for WatchItems

Less "user code".

Change-Id: Idf4e0a950761bd0184f2844c45415d5bdb8cd51a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2018-03-08 15:13:42 +01:00
parent 2626e1629f
commit c050d916ce
3 changed files with 7 additions and 14 deletions

View File

@@ -463,11 +463,6 @@ void WatchItem::parse(const GdbMi &data, bool maySort)
exp = name; exp = name;
} }
WatchItem *WatchItem::parentItem() const
{
return static_cast<WatchItem *>(parent());
}
// Format a tooltip row with aligned colon. // Format a tooltip row with aligned colon.
static void formatToolTipRow(QTextStream &str, const QString &category, const QString &value) static void formatToolTipRow(QTextStream &str, const QString &category, const QString &value)
{ {
@@ -519,7 +514,7 @@ QString WatchItem::toToolTip() const
bool WatchItem::isLocal() const bool WatchItem::isLocal() const
{ {
if (arrayIndex >= 0) if (arrayIndex >= 0)
if (const WatchItem *p = parentItem()) if (const WatchItem *p = parent())
return p->isLocal(); return p->isLocal();
return iname.startsWith("local."); return iname.startsWith("local.");
} }
@@ -527,7 +522,7 @@ bool WatchItem::isLocal() const
bool WatchItem::isWatcher() const bool WatchItem::isWatcher() const
{ {
if (arrayIndex >= 0) if (arrayIndex >= 0)
if (const WatchItem *p = parentItem()) if (const WatchItem *p = parent())
return p->isWatcher(); return p->isWatcher();
return iname.startsWith("watch."); return iname.startsWith("watch.");
} }
@@ -535,7 +530,7 @@ bool WatchItem::isWatcher() const
bool WatchItem::isInspect() const bool WatchItem::isInspect() const
{ {
if (arrayIndex >= 0) if (arrayIndex >= 0)
if (const WatchItem *p = parentItem()) if (const WatchItem *p = parent())
return p->isInspect(); return p->isInspect();
return iname.startsWith("inspect."); return iname.startsWith("inspect.");
} }
@@ -543,7 +538,7 @@ bool WatchItem::isInspect() const
QString WatchItem::internalName() const QString WatchItem::internalName() const
{ {
if (arrayIndex >= 0) { if (arrayIndex >= 0) {
if (const WatchItem *p = parentItem()) if (const WatchItem *p = parent())
return p->iname + '.' + QString::number(arrayIndex); return p->iname + '.' + QString::number(arrayIndex);
} }
return iname; return iname;
@@ -564,7 +559,7 @@ QString WatchItem::expression() const
if (!type.isEmpty()) if (!type.isEmpty())
return QString("*(%1*)0x%2").arg(type).arg(addr, 0, 16); return QString("*(%1*)0x%2").arg(type).arg(addr, 0, 16);
} }
const WatchItem *p = parentItem(); const WatchItem *p = parent();
if (p && !p->exp.isEmpty()) if (p && !p->exp.isEmpty())
return QString("(%1).%2").arg(p->exp, name); return QString("(%1).%2").arg(p->exp, name);
return name; return name;

View File

@@ -39,7 +39,7 @@ namespace Internal {
class GdbMi; class GdbMi;
class WatchItem : public Utils::TypedTreeItem<WatchItem> class WatchItem : public Utils::TypedTreeItem<WatchItem, WatchItem>
{ {
public: public:
WatchItem(); WatchItem();
@@ -58,8 +58,6 @@ public:
QVariant editValue() const; QVariant editValue() const;
int editType() const; int editType() const;
WatchItem *parentItem() const;
static const qint64 InvalidId = -1; static const qint64 InvalidId = -1;
void setHasChildren(bool c) { wantsChildren = c; } void setHasChildren(bool c) { wantsChildren = c; }

View File

@@ -829,7 +829,7 @@ static QString displayName(const WatchItem *item)
{ {
QString result; QString result;
const WatchItem *p = item->parentItem(); const WatchItem *p = item->parent();
if (!p) if (!p)
return result; return result;
if (item->arrayIndex >= 0) { if (item->arrayIndex >= 0) {