forked from qt-creator/qt-creator
debugger: simplify code for inserting new watchitems
This commit is contained in:
@@ -1169,7 +1169,7 @@ class Dumper:
|
|||||||
self.put('name="%s",' % escapedExp)
|
self.put('name="%s",' % escapedExp)
|
||||||
self.put('exp="%s",' % escapedExp)
|
self.put('exp="%s",' % escapedExp)
|
||||||
handled = False
|
handled = False
|
||||||
if exp == "<Edit>" or len(exp) == 0:
|
if len(exp) == 0: # The <Edit> case
|
||||||
self.putValue(" ")
|
self.putValue(" ")
|
||||||
self.putType(" ")
|
self.putType(" ")
|
||||||
self.putNumChild(0)
|
self.putNumChild(0)
|
||||||
|
|||||||
@@ -214,7 +214,6 @@ enum ModelRoles
|
|||||||
LocalsPointerValueRole, // Pointer value (address) as quint64
|
LocalsPointerValueRole, // Pointer value (address) as quint64
|
||||||
LocalsIsWatchpointAtAddressRole,
|
LocalsIsWatchpointAtAddressRole,
|
||||||
LocalsIsWatchpointAtPointerValueRole,
|
LocalsIsWatchpointAtPointerValueRole,
|
||||||
WatcherEditPlaceHolderRole,
|
|
||||||
RequestWatchPointRole,
|
RequestWatchPointRole,
|
||||||
RequestToggleWatchRole,
|
RequestToggleWatchRole,
|
||||||
RequestToolTipByExpressionRole,
|
RequestToolTipByExpressionRole,
|
||||||
|
|||||||
@@ -72,9 +72,6 @@ void GdbEngine::updateLocalsPython(const QByteArray &varList)
|
|||||||
it.next();
|
it.next();
|
||||||
if (!watchers.isEmpty())
|
if (!watchers.isEmpty())
|
||||||
watchers += "##";
|
watchers += "##";
|
||||||
if (it.key() == WatchHandler::watcherEditPlaceHolder().toLatin1())
|
|
||||||
watchers += "<Edit>#watch." + QByteArray::number(it.value());
|
|
||||||
else
|
|
||||||
watchers += it.key() + "#watch." + QByteArray::number(it.value());
|
watchers += it.key() + "#watch." + QByteArray::number(it.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -735,9 +735,6 @@ void PdbEngine::updateLocals()
|
|||||||
it.next();
|
it.next();
|
||||||
if (!watchers.isEmpty())
|
if (!watchers.isEmpty())
|
||||||
watchers += "##";
|
watchers += "##";
|
||||||
if (it.key() == WatchHandler::watcherEditPlaceHolder().toLatin1())
|
|
||||||
watchers += "<Edit>#watch." + QByteArray::number(it.value());
|
|
||||||
else
|
|
||||||
watchers += it.key() + "#watch." + QByteArray::number(it.value());
|
watchers += it.key() + "#watch." + QByteArray::number(it.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -599,26 +599,18 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
|
|||||||
|
|
||||||
case EngineActionsEnabledRole:
|
case EngineActionsEnabledRole:
|
||||||
return engine()->debuggerActionsEnabled();
|
return engine()->debuggerActionsEnabled();
|
||||||
|
|
||||||
case WatcherEditPlaceHolderRole:
|
|
||||||
return m_handler->watcherEditPlaceHolder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const WatchItem *item = watchItem(idx);
|
const WatchItem *item = watchItem(idx);
|
||||||
const WatchItem &data = *item;
|
const WatchItem &data = *item;
|
||||||
|
|
||||||
if (data.name == m_handler->watcherEditPlaceHolder()) {
|
|
||||||
if (idx.column() == 0 &&
|
|
||||||
(role == Qt::EditRole || role == Qt::DisplayRole))
|
|
||||||
return data.name;
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
case Qt::DisplayRole: {
|
case Qt::DisplayRole: {
|
||||||
switch (idx.column()) {
|
switch (idx.column()) {
|
||||||
case 0:
|
case 0:
|
||||||
|
if (data.name.isEmpty() && role == Qt::DisplayRole)
|
||||||
|
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 data.name;
|
||||||
@@ -836,7 +828,7 @@ Qt::ItemFlags WatchModel::flags(const QModelIndex &idx) const
|
|||||||
return editable; // Watcher names are editable.
|
return editable; // Watcher names are editable.
|
||||||
|
|
||||||
if (data.isWatcher()) {
|
if (data.isWatcher()) {
|
||||||
if (data.name != m_handler->watcherEditPlaceHolder()) {
|
if (!data.name.isEmpty()) {
|
||||||
// FIXME: Forcing types is not implemented yet.
|
// FIXME: Forcing types is not implemented yet.
|
||||||
//if (idx.column() == 2)
|
//if (idx.column() == 2)
|
||||||
// return editable; // Watcher types can be set by force.
|
// return editable; // Watcher types can be set by force.
|
||||||
@@ -1249,7 +1241,7 @@ QByteArray WatchHandler::watcherName(const QByteArray &exp)
|
|||||||
void WatchHandler::watchExpression(const QString &exp)
|
void WatchHandler::watchExpression(const QString &exp)
|
||||||
{
|
{
|
||||||
// Do not insert multiple placeholders.
|
// Do not insert multiple placeholders.
|
||||||
if (exp == watcherEditPlaceHolder() && m_watcherNames.contains(exp.toLatin1()))
|
if (exp.isEmpty() && m_watcherNames.contains(QByteArray()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: 'exp' can contain illegal characters
|
// FIXME: 'exp' can contain illegal characters
|
||||||
@@ -1257,7 +1249,7 @@ void WatchHandler::watchExpression(const QString &exp)
|
|||||||
data.exp = exp.toLatin1();
|
data.exp = exp.toLatin1();
|
||||||
data.name = exp;
|
data.name = exp;
|
||||||
m_watcherNames[data.exp] = watcherCounter++;
|
m_watcherNames[data.exp] = watcherCounter++;
|
||||||
if (exp.isEmpty() || exp == watcherEditPlaceHolder())
|
if (exp.isEmpty())
|
||||||
data.setAllUnneeded();
|
data.setAllUnneeded();
|
||||||
data.iname = watcherName(data.exp);
|
data.iname = watcherName(data.exp);
|
||||||
if (m_engine->isSynchroneous() && !m_engine->isSessionEngine())
|
if (m_engine->isSynchroneous() && !m_engine->isSessionEngine())
|
||||||
@@ -1416,7 +1408,7 @@ QStringList WatchHandler::watchedExpressions() const
|
|||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
const QString &watcherName = it.key();
|
const QString &watcherName = it.key();
|
||||||
if (!watcherName.isEmpty() && watcherName != watcherEditPlaceHolder())
|
if (!watcherName.isEmpty())
|
||||||
watcherNames.push_back(watcherName);
|
watcherNames.push_back(watcherName);
|
||||||
}
|
}
|
||||||
return watcherNames;
|
return watcherNames;
|
||||||
@@ -1528,12 +1520,6 @@ WatchData *WatchHandler::findItem(const QByteArray &iname) const
|
|||||||
return model->findItem(iname, model->m_root);
|
return model->findItem(iname, model->m_root);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString WatchHandler::watcherEditPlaceHolder()
|
|
||||||
{
|
|
||||||
static const QString rc = tr("<Edit>");
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WatchHandler::setFormat(const QString &type, int format)
|
void WatchHandler::setFormat(const QString &type, int format)
|
||||||
{
|
{
|
||||||
if (format == -1)
|
if (format == -1)
|
||||||
|
|||||||
@@ -171,7 +171,6 @@ public:
|
|||||||
QByteArray typeFormatRequests() const;
|
QByteArray typeFormatRequests() const;
|
||||||
QByteArray individualFormatRequests() const;
|
QByteArray individualFormatRequests() const;
|
||||||
|
|
||||||
static QString watcherEditPlaceHolder();
|
|
||||||
int format(const QByteArray &iname) const;
|
int format(const QByteArray &iname) const;
|
||||||
|
|
||||||
void addTypeFormats(const QString &type, const QStringList &formats);
|
void addTypeFormats(const QString &type, const QStringList &formats);
|
||||||
|
|||||||
@@ -206,9 +206,8 @@ void WatchWindow::mouseDoubleClickEvent(QMouseEvent *ev)
|
|||||||
{
|
{
|
||||||
const QModelIndex idx = indexAt(ev->pos());
|
const QModelIndex idx = indexAt(ev->pos());
|
||||||
if (!idx.isValid()) {
|
if (!idx.isValid()) {
|
||||||
// The "<Edit>" string.
|
// The "<Edit>" case.
|
||||||
QVariant placeHolder = model()->data(idx, WatcherEditPlaceHolderRole);
|
watchExpression(QString());
|
||||||
setModelData(RequestWatchExpressionRole, placeHolder);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QTreeView::mouseDoubleClickEvent(ev);
|
QTreeView::mouseDoubleClickEvent(ev);
|
||||||
@@ -410,7 +409,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
} else if (act == actAlwaysAdjustColumnWidth) {
|
} else if (act == actAlwaysAdjustColumnWidth) {
|
||||||
setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents);
|
setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents);
|
||||||
} else if (act == actInsertNewWatchItem) {
|
} else if (act == actInsertNewWatchItem) {
|
||||||
watchExpression(WatchHandler::watcherEditPlaceHolder());
|
watchExpression(QString());
|
||||||
} else if (act == actOpenMemoryEditAtVariableAddress) {
|
} else if (act == actOpenMemoryEditAtVariableAddress) {
|
||||||
setModelData(RequestShowMemoryRole, address);
|
setModelData(RequestShowMemoryRole, address);
|
||||||
} else if (act == actOpenMemoryEditAtPointerValue) {
|
} else if (act == actOpenMemoryEditAtPointerValue) {
|
||||||
|
|||||||
Reference in New Issue
Block a user