Commit 6df0a34e authored by hjk's avatar hjk

Debugger: Add a way to copy selected values from Locals and Expressions

Task-number: QTCREATORBUG-14956
Change-Id: I2700820adf716afb784ec686297c15c48f3592f7
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent 797dc119
......@@ -1824,15 +1824,17 @@ void WatchHandler::addTypeFormats(const QByteArray &type, const DisplayFormats &
m_model->m_reportedTypeFormats.insert(QLatin1String(stripForFormat(type)), formats);
}
QString WatchHandler::editorContents()
QString WatchHandler::editorContents(const QModelIndexList &list)
{
QString contents;
QTextStream ts(&contents);
m_model->forAllItems([&ts](WatchItem *item) {
const QChar tab = QLatin1Char('\t');
const QChar nl = QLatin1Char('\n');
ts << QString(item->level(), tab) << item->name << tab << displayValue(item) << tab
<< item->type << nl;
m_model->forAllItems([&ts, this, list](WatchItem *item) {
if (list.isEmpty() || list.contains(m_model->indexForItem(item))) {
const QChar tab = QLatin1Char('\t');
const QChar nl = QLatin1Char('\n');
ts << QString(item->level(), tab) << item->name << tab << displayValue(item) << tab
<< item->type << nl;
}
});
return contents;
}
......
......@@ -100,7 +100,7 @@ public:
static int unprintableBase();
QByteArray watcherName(const QByteArray &exp);
QString editorContents();
QString editorContents(const QModelIndexList &list = QModelIndexList());
void scheduleResetLocation();
void resetLocation();
......
......@@ -811,8 +811,10 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
|| actSetWatchpointAtExpression.isEnabled());
QAction actCopy(tr("Copy View Contents to Clipboard"), 0);
QAction actCopyValue(tr("Copy Value to Clipboard"), 0);
QAction actCopyValue(tr("Copy Current Value to Clipboard"), 0);
actCopyValue.setEnabled(idx.isValid());
QAction actCopySelected(tr("Copy Selected Rows to Clipboard"), 0);
actCopySelected.setEnabled(selectionModel()->hasSelection());
QAction actShowInEditor(tr("Open View Contents in Editor"), 0);
actShowInEditor.setEnabled(actionsEnabled);
......@@ -835,6 +837,7 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
menu.addAction(&actCloseEditorToolTips);
menu.addAction(&actCopy);
menu.addAction(&actCopyValue);
menu.addAction(&actCopySelected);
menu.addAction(&actShowInEditor);
menu.addSeparator();
......@@ -891,6 +894,9 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
} else if (act == &actCopy) {
QString contents = handler->editorContents();
copyToClipboard(contents);
} else if (act == &actCopySelected) {
QString contents = handler->editorContents(selectionModel()->selectedRows());
copyToClipboard(contents);
} else if (act == &actCopyValue) {
copyToClipboard(mi1.data().toString());
} else if (act == &actShowInEditor) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment