forked from qt-creator/qt-creator
debugger: provide a method to copy Locals&Watchers contents into a main editor.
Task-number: QTCREATORBUG-982
This commit is contained in:
@@ -232,6 +232,7 @@ enum ModelRoles
|
|||||||
LocalsPointerValueRole, // Pointer value (address) as quint64
|
LocalsPointerValueRole, // Pointer value (address) as quint64
|
||||||
LocalsIsWatchpointAtAddressRole,
|
LocalsIsWatchpointAtAddressRole,
|
||||||
LocalsIsWatchpointAtPointerValueRole,
|
LocalsIsWatchpointAtPointerValueRole,
|
||||||
|
RequestShowInEditorRole,
|
||||||
RequestWatchPointRole,
|
RequestWatchPointRole,
|
||||||
RequestToggleWatchRole,
|
RequestToggleWatchRole,
|
||||||
RequestToolTipByExpressionRole,
|
RequestToolTipByExpressionRole,
|
||||||
|
|||||||
@@ -743,6 +743,11 @@ bool WatchModel::setData(const QModelIndex &index, const QVariant &value, int ro
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case RequestShowInEditorRole: {
|
||||||
|
m_handler->showInEditor();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
case RequestToggleWatchRole: {
|
case RequestToggleWatchRole: {
|
||||||
BreakHandler *handler = engine()->breakHandler();
|
BreakHandler *handler = engine()->breakHandler();
|
||||||
const quint64 address = value.toULongLong();
|
const quint64 address = value.toULongLong();
|
||||||
@@ -1616,5 +1621,26 @@ void WatchHandler::addTypeFormats(const QByteArray &type, const QStringList &for
|
|||||||
m_reportedTypeFormats.insert(type, formats);
|
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 Internal
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|||||||
@@ -187,6 +187,8 @@ private:
|
|||||||
void saveTypeFormats();
|
void saveTypeFormats();
|
||||||
void setFormat(const QByteArray &type, int format);
|
void setFormat(const QByteArray &type, int format);
|
||||||
void updateWatchersWindow();
|
void updateWatchersWindow();
|
||||||
|
void showInEditor();
|
||||||
|
void showInEditorHelper(QString *contents, WatchItem *item, int level);
|
||||||
|
|
||||||
bool m_inChange;
|
bool m_inChange;
|
||||||
|
|
||||||
|
|||||||
@@ -383,6 +383,10 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
actClearCodeModelSnapshot->setEnabled(actionsEnabled
|
actClearCodeModelSnapshot->setEnabled(actionsEnabled
|
||||||
&& theDebuggerAction(UseCodeModel)->isChecked());
|
&& theDebuggerAction(UseCodeModel)->isChecked());
|
||||||
menu.addAction(actClearCodeModelSnapshot);
|
menu.addAction(actClearCodeModelSnapshot);
|
||||||
|
QAction *actShowInEditor
|
||||||
|
= new QAction(tr("Show View Contents in Editor"), &menu);
|
||||||
|
actShowInEditor->setEnabled(actionsEnabled);
|
||||||
|
menu.addAction(actShowInEditor);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.addAction(theDebuggerAction(UseToolTipsInLocalsView));
|
menu.addAction(theDebuggerAction(UseToolTipsInLocalsView));
|
||||||
|
|
||||||
@@ -435,6 +439,8 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
setModelData(LocalsTypeFormatRole, -1, mi1);
|
setModelData(LocalsTypeFormatRole, -1, mi1);
|
||||||
} else if (act == clearIndividualFormatAction) {
|
} else if (act == clearIndividualFormatAction) {
|
||||||
setModelData(LocalsIndividualFormatRole, -1, mi1);
|
setModelData(LocalsIndividualFormatRole, -1, mi1);
|
||||||
|
} else if (act == actShowInEditor) {
|
||||||
|
setModelData(RequestShowInEditorRole);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i != typeFormatActions.size(); ++i) {
|
for (int i = 0; i != typeFormatActions.size(); ++i) {
|
||||||
if (act == typeFormatActions.at(i))
|
if (act == typeFormatActions.at(i))
|
||||||
|
|||||||
Reference in New Issue
Block a user