debugger: fix the ShowQtNamespace option in the Locals & Watchers window

This commit is contained in:
hjk
2011-01-17 15:23:22 +01:00
parent d4ee5af764
commit 199361834b
3 changed files with 45 additions and 29 deletions

View File

@@ -211,6 +211,10 @@ GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters,
SLOT(reloadLocals())); SLOT(reloadLocals()));
connect(debuggerCore()->action(SortStructMembers), SIGNAL(valueChanged(QVariant)), connect(debuggerCore()->action(SortStructMembers), SIGNAL(valueChanged(QVariant)),
SLOT(reloadLocals())); SLOT(reloadLocals()));
connect(debuggerCore()->action(ShowStdNamespace), SIGNAL(valueChanged(QVariant)),
SLOT(reloadLocals()));
connect(debuggerCore()->action(ShowQtNamespace), SIGNAL(valueChanged(QVariant)),
SLOT(reloadLocals()));
connect(debuggerCore()->action(CreateFullBacktrace), SIGNAL(triggered()), connect(debuggerCore()->action(CreateFullBacktrace), SIGNAL(triggered()),
SLOT(createFullBacktrace())); SLOT(createFullBacktrace()));
} }

View File

@@ -315,17 +315,6 @@ static void formatToolTipRow(QTextStream &str,
<< htmlEscape(value) << "</td></tr>"; << htmlEscape(value) << "</td></tr>";
} }
static QString typeToolTip(const WatchData &wd)
{
if (wd.displayedType.isEmpty())
return wd.type;
QString rc = wd.displayedType;
rc += QLatin1String(" (");
rc += wd.type;
rc += QLatin1Char(')');
return rc;
}
QString WatchData::toToolTip() const QString WatchData::toToolTip() const
{ {
if (!valuetooltip.isEmpty()) if (!valuetooltip.isEmpty())
@@ -335,7 +324,8 @@ QString WatchData::toToolTip() const
str << "<html><body><table>"; str << "<html><body><table>";
formatToolTipRow(str, tr("Name"), name); formatToolTipRow(str, tr("Name"), name);
formatToolTipRow(str, tr("Expression"), exp); formatToolTipRow(str, tr("Expression"), exp);
formatToolTipRow(str, tr("Type"), typeToolTip(*this)); formatToolTipRow(str, tr("Internal Type"), type);
formatToolTipRow(str, tr("Displayed Type"), displayedType);
QString val = value; QString val = value;
if (value.size() > 1000) { if (value.size() > 1000) {
val.truncate(1000); val.truncate(1000);

View File

@@ -260,19 +260,36 @@ static QString niceTypeHelper(const QByteArray &typeIn)
return simplified; return simplified;
} }
static QString removeNamespaces(QString str, const QByteArray &ns)
{
if (!debuggerCore()->boolSetting(ShowStdNamespace))
str.remove(QLatin1String("std::"));
if (!debuggerCore()->boolSetting(ShowQtNamespace)) {
const QString qtNamespace = QString::fromLatin1(ns);
if (!qtNamespace.isEmpty())
str.remove(qtNamespace);
}
return str;
}
static QString removeInitialNamespace(QString str, const QByteArray &ns)
{
if (str.startsWith(QLatin1String("std::"))
&& debuggerCore()->boolSetting(ShowStdNamespace))
str = str.mid(5);
if (!debuggerCore()->boolSetting(ShowQtNamespace)) {
const QString qtNamespace = QString::fromLatin1(ns);
if (!qtNamespace.isEmpty() && str.startsWith(qtNamespace))
str = str.mid(qtNamespace.size());
}
return str;
}
QString WatchModel::displayType(const WatchData &data) const QString WatchModel::displayType(const WatchData &data) const
{ {
if (!data.displayedType.isEmpty()) return data.displayedType.isEmpty()
return data.displayedType; ? niceTypeHelper(data.type)
QString type = niceTypeHelper(data.type); : data.displayedType;
if (!debuggerCore()->boolSetting(ShowStdNamespace))
type.remove(QLatin1String("std::"));
if (!debuggerCore()->boolSetting(ShowQtNamespace)) {
const QString qtNamespace = QString::fromLatin1(engine()->qtNamespace());
if (!qtNamespace.isEmpty())
type.remove(qtNamespace);
}
return type;
} }
static inline int formatToIntegerBase(int format) static inline int formatToIntegerBase(int format)
@@ -600,25 +617,30 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
case 1: case 1:
return editValue(data); return editValue(data);
case 2: case 2:
if (!data.displayedType.isEmpty()) // To be tested: Can debuggers handle those? // FIXME:: To be tested: Can debuggers handle those?
if (!data.displayedType.isEmpty())
return data.displayedType; return data.displayedType;
return QString::fromUtf8(data.type); return QString::fromUtf8(data.type);
default: break; default: break;
} // switch editrole column } // switch editrole column
case Qt::DisplayRole: case Qt::DisplayRole: {
const QByteArray ns = engine()->qtNamespace();
switch (idx.column()) { switch (idx.column()) {
case 0: case 0:
if (data.name.isEmpty()) if (data.name.isEmpty())
return tr("<Edit>"); return tr("<Edit>");
if (data.name == QLatin1String("*") && item->parent) if (data.name == QLatin1String("*") && item->parent)
return QVariant(QLatin1Char('*') + item->parent->name); return QVariant(QLatin1Char('*') + item->parent->name);
return data.name; return removeInitialNamespace(data.name, ns);
case 1: case 1:
return truncateValue(formattedValue(data, itemFormat(data))); return removeInitialNamespace(truncateValue(
formattedValue(data, itemFormat(data))), ns);
case 2: case 2:
return displayType(data); return removeNamespaces(displayType(data), ns);
default: break; default:
break;
} // switch editrole column } // switch editrole column
}
case Qt::ToolTipRole: case Qt::ToolTipRole:
return debuggerCore()->boolSetting(UseToolTipsInLocalsView) return debuggerCore()->boolSetting(UseToolTipsInLocalsView)
? data.toToolTip() : QVariant(); ? data.toToolTip() : QVariant();