diff options
author | hjk <[email protected]> | 2011-11-07 20:07:14 +0100 |
---|---|---|
committer | hjk <[email protected]> | 2011-11-08 11:51:49 +0100 |
commit | 4f522b92efa14ef995b4b4d8257e91bdda97e31c (patch) | |
tree | 82ee9c8044e234b717feb96f42b6702def3173f3 /src/plugins/debugger/watchhandler.cpp | |
parent | 9e13fa077e2dbf71d8fe25c441ae0e23e998ed42 (diff) |
debugger: add dialog to edit display types
Change-Id: If1ea8cdab359bcad80e37dd4a932e4b586527264
Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src/plugins/debugger/watchhandler.cpp')
-rw-r--r-- | src/plugins/debugger/watchhandler.cpp | 104 |
1 files changed, 69 insertions, 35 deletions
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 81ea6173f13..6424bfa63c0 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -37,6 +37,7 @@ #include "debuggeractions.h" #include "debuggercore.h" #include "debuggerengine.h" +#include "debuggerdialogs.h" #include "watchutils.h" #if USE_WATCH_MODEL_TEST @@ -758,43 +759,15 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const case LocalsExpandedRole: return m_handler->m_expandedINames.contains(data.iname); - case LocalsTypeFormatListRole: { - if (data.referencingAddress || isPointerType(data.type)) - return QStringList() - << tr("Raw pointer") - << tr("Latin1 string") - << tr("UTF8 string") - << tr("Local 8bit string") - << tr("UTF16 string") - << tr("UCS4 string"); - if (data.type.contains("char[") || data.type.contains("char [")) - return QStringList() - << tr("Latin1 string") - << tr("UTF8 string") - << tr("Local 8bit string"); - bool ok = false; - (void)data.value.toULongLong(&ok, 0); - if ((isIntType(data.type) && data.type != "bool") || ok) - return QStringList() - << tr("Decimal") - << tr("Hexadecimal") - << tr("Binary") - << tr("Octal"); - // Hack: Compensate for namespaces. - QString type = stripTemplate(data.type); - int pos = type.indexOf("::Q"); - if (pos >= 0 && type.count(':') == 2) - type = type.mid(pos + 2); - pos = type.indexOf('<'); - if (pos >= 0) - type = type.left(pos); - type.replace(':', '_'); - return m_handler->m_reportedTypeFormats.value(type); - } + case LocalsTypeFormatListRole: + return m_handler->typeFormatList(data); + case LocalsTypeRole: - return removeNamespaces(displayType(data)); + return removeNamespaces(displayType(data)); + case LocalsRawTypeRole: - return QString::fromLatin1(data.type); + return QString::fromLatin1(data.type); + case LocalsTypeFormatRole: return m_handler->m_typeFormats.value(stripTemplate(data.type), -1); @@ -933,6 +906,41 @@ QVariant WatchModel::headerData(int section, Qt::Orientation orientation, int ro return QVariant(); } +QStringList WatchHandler::typeFormatList(const WatchData &data) const +{ + if (data.referencingAddress || isPointerType(data.type)) + return QStringList() + << tr("Raw pointer") + << tr("Latin1 string") + << tr("UTF8 string") + << tr("Local 8bit string") + << tr("UTF16 string") + << tr("UCS4 string"); + if (data.type.contains("char[") || data.type.contains("char [")) + return QStringList() + << tr("Latin1 string") + << tr("UTF8 string") + << tr("Local 8bit string"); + bool ok = false; + (void)data.value.toULongLong(&ok, 0); + if ((isIntType(data.type) && data.type != "bool") || ok) + return QStringList() + << tr("Decimal") + << tr("Hexadecimal") + << tr("Binary") + << tr("Octal"); + // Hack: Compensate for namespaces. + QString type = stripTemplate(data.type); + int pos = type.indexOf("::Q"); + if (pos >= 0 && type.count(':') == 2) + type = type.mid(pos + 2); + pos = type.indexOf('<'); + if (pos >= 0) + type = type.left(pos); + type.replace(':', '_'); + return m_reportedTypeFormats.value(type); +} + // Determine sort order of watch items by sort order or alphabetical inames // according to setting 'SortStructMembers'. We need a map key for bulkInsert // and a predicate for finding the insertion position of a single item. @@ -1759,5 +1767,31 @@ void WatchHandler::rebuildModel() endCycle(); } +void WatchHandler::setTypeFormats(const TypeFormats &typeFormats) +{ + m_reportedTypeFormats = typeFormats; +} + +TypeFormats WatchHandler::typeFormats() const +{ + return m_reportedTypeFormats; +} + +void WatchHandler::editTypeFormats(bool includeLocals, const QByteArray &iname) +{ + Q_UNUSED(includeLocals); + TypeFormatsDialog dlg(0); + + //QHashIterator<QString, QStringList> it(m_reportedTypeFormats); + QList<QString> l = m_reportedTypeFormats.keys(); + qSort(l.begin(), l.end()); + foreach (const QString &ba, l) { + int f = iname.isEmpty() ? -1 : format(iname); + dlg.addTypeFormats(ba, m_reportedTypeFormats.value(ba), f); + } + if (dlg.exec()) + setTypeFormats(dlg.typeFormats()); +} + } // namespace Internal } // namespace Debugger |