diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 4eb5501de2d..a1f3b8eb150 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 d6afbf661d5..6fd7e515f0f 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 2327690ea20..dd86e84230f 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) {