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