Commit 19936183 authored by hjk's avatar hjk

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

parent d4ee5af7
......@@ -211,6 +211,10 @@ GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters,
SLOT(reloadLocals()));
connect(debuggerCore()->action(SortStructMembers), SIGNAL(valueChanged(QVariant)),
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()),
SLOT(createFullBacktrace()));
}
......
......@@ -315,17 +315,6 @@ static void formatToolTipRow(QTextStream &str,
<< 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
{
if (!valuetooltip.isEmpty())
......@@ -335,7 +324,8 @@ QString WatchData::toToolTip() const
str << "<html><body><table>";
formatToolTipRow(str, tr("Name"), name);
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;
if (value.size() > 1000) {
val.truncate(1000);
......
......@@ -260,19 +260,36 @@ static QString niceTypeHelper(const QByteArray &typeIn)
return simplified;
}
QString WatchModel::displayType(const WatchData &data) const
static QString removeNamespaces(QString str, const QByteArray &ns)
{
if (!data.displayedType.isEmpty())
return data.displayedType;
QString type = niceTypeHelper(data.type);
if (!debuggerCore()->boolSetting(ShowStdNamespace))
type.remove(QLatin1String("std::"));
str.remove(QLatin1String("std::"));
if (!debuggerCore()->boolSetting(ShowQtNamespace)) {
const QString qtNamespace = QString::fromLatin1(engine()->qtNamespace());
const QString qtNamespace = QString::fromLatin1(ns);
if (!qtNamespace.isEmpty())
type.remove(qtNamespace);
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 type;
return str;
}
QString WatchModel::displayType(const WatchData &data) const
{
return data.displayedType.isEmpty()
? niceTypeHelper(data.type)
: data.displayedType;
}
static inline int formatToIntegerBase(int format)
......@@ -600,25 +617,30 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
case 1:
return editValue(data);
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 QString::fromUtf8(data.type);
default: break;
} // switch editrole column
case Qt::DisplayRole:
case Qt::DisplayRole: {
const QByteArray ns = engine()->qtNamespace();
switch (idx.column()) {
case 0:
if (data.name.isEmpty())
return tr("<Edit>");
if (data.name == QLatin1String("*") && item->parent)
return QVariant(QLatin1Char('*') + item->parent->name);
return data.name;
return removeInitialNamespace(data.name, ns);
case 1:
return truncateValue(formattedValue(data, itemFormat(data)));
return removeInitialNamespace(truncateValue(
formattedValue(data, itemFormat(data))), ns);
case 2:
return displayType(data);
default: break;
return removeNamespaces(displayType(data), ns);
default:
break;
} // switch editrole column
}
case Qt::ToolTipRole:
return debuggerCore()->boolSetting(UseToolTipsInLocalsView)
? data.toToolTip() : QVariant();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment