summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk@theqtcompany.com>2016-06-03 17:02:23 +0200
committerhjk <hjk@theqtcompany.com>2016-06-06 06:54:59 +0000
commit6df0a34e99f57954c40fbd352cef5559bd3f96dc (patch)
treef260971a755058c7913974f2375fb34c12bd9ae1
parent797dc11937c6ae91c3fcec5b686f4c315e62a8e1 (diff)
downloadqt-creator-6df0a34e99f57954c40fbd352cef5559bd3f96dc.tar.gz
Debugger: Add a way to copy selected values from Locals and Expressions
Task-number: QTCREATORBUG-14956 Change-Id: I2700820adf716afb784ec686297c15c48f3592f7 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--src/plugins/debugger/watchhandler.cpp14
-rw-r--r--src/plugins/debugger/watchhandler.h2
-rw-r--r--src/plugins/debugger/watchwindow.cpp8
3 files changed, 16 insertions, 8 deletions
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp
index 4eb5501de2..a1f3b8eb15 100644
--- a/src/plugins/debugger/watchhandler.cpp
+++ b/src/plugins/debugger/watchhandler.cpp
@@ -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;
}
diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h
index d6afbf661d..6fd7e515f0 100644
--- a/src/plugins/debugger/watchhandler.h
+++ b/src/plugins/debugger/watchhandler.h
@@ -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();
diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp
index 2327690ea2..dd86e84230 100644
--- a/src/plugins/debugger/watchwindow.cpp
+++ b/src/plugins/debugger/watchwindow.cpp
@@ -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) {