debugger: provide a method to copy Locals&Watchers contents into a main editor.

Task-number: QTCREATORBUG-982
This commit is contained in:
hjk
2010-09-08 09:09:09 +02:00
parent 18d14b5367
commit 1d3606f4b9
4 changed files with 35 additions and 0 deletions

View File

@@ -743,6 +743,11 @@ bool WatchModel::setData(const QModelIndex &index, const QVariant &value, int ro
return true;
}
case RequestShowInEditorRole: {
m_handler->showInEditor();
return true;
}
case RequestToggleWatchRole: {
BreakHandler *handler = engine()->breakHandler();
const quint64 address = value.toULongLong();
@@ -1616,5 +1621,26 @@ void WatchHandler::addTypeFormats(const QByteArray &type, const QStringList &for
m_reportedTypeFormats.insert(type, formats);
}
void WatchHandler::showInEditor()
{
QString contents;
showInEditorHelper(&contents, m_locals->m_root, 0);
showInEditorHelper(&contents, m_watchers->m_root, 0);
plugin()->openTextEditor(tr("Locals & Watchers"), contents);
}
void WatchHandler::showInEditorHelper(QString *contents, WatchItem *item, int depth)
{
const QChar tab = QLatin1Char('\t');
const QChar nl = QLatin1Char('\n');
contents->append(QString(depth, tab));
contents->append(item->name);
contents->append(tab);
contents->append(item->value);
contents->append(nl);
foreach (WatchItem *child, item->children)
showInEditorHelper(contents, child, depth + 1);
}
} // namespace Internal
} // namespace Debugger