forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -1824,15 +1824,17 @@ void WatchHandler::addTypeFormats(const QByteArray &type, const DisplayFormats &
|
|||||||
m_model->m_reportedTypeFormats.insert(QLatin1String(stripForFormat(type)), formats);
|
m_model->m_reportedTypeFormats.insert(QLatin1String(stripForFormat(type)), formats);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString WatchHandler::editorContents()
|
QString WatchHandler::editorContents(const QModelIndexList &list)
|
||||||
{
|
{
|
||||||
QString contents;
|
QString contents;
|
||||||
QTextStream ts(&contents);
|
QTextStream ts(&contents);
|
||||||
m_model->forAllItems([&ts](WatchItem *item) {
|
m_model->forAllItems([&ts, this, list](WatchItem *item) {
|
||||||
|
if (list.isEmpty() || list.contains(m_model->indexForItem(item))) {
|
||||||
const QChar tab = QLatin1Char('\t');
|
const QChar tab = QLatin1Char('\t');
|
||||||
const QChar nl = QLatin1Char('\n');
|
const QChar nl = QLatin1Char('\n');
|
||||||
ts << QString(item->level(), tab) << item->name << tab << displayValue(item) << tab
|
ts << QString(item->level(), tab) << item->name << tab << displayValue(item) << tab
|
||||||
<< item->type << nl;
|
<< item->type << nl;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public:
|
|||||||
static int unprintableBase();
|
static int unprintableBase();
|
||||||
|
|
||||||
QByteArray watcherName(const QByteArray &exp);
|
QByteArray watcherName(const QByteArray &exp);
|
||||||
QString editorContents();
|
QString editorContents(const QModelIndexList &list = QModelIndexList());
|
||||||
|
|
||||||
void scheduleResetLocation();
|
void scheduleResetLocation();
|
||||||
void resetLocation();
|
void resetLocation();
|
||||||
|
|||||||
@@ -811,8 +811,10 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
|| actSetWatchpointAtExpression.isEnabled());
|
|| actSetWatchpointAtExpression.isEnabled());
|
||||||
|
|
||||||
QAction actCopy(tr("Copy View Contents to Clipboard"), 0);
|
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());
|
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);
|
QAction actShowInEditor(tr("Open View Contents in Editor"), 0);
|
||||||
actShowInEditor.setEnabled(actionsEnabled);
|
actShowInEditor.setEnabled(actionsEnabled);
|
||||||
@@ -835,6 +837,7 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
menu.addAction(&actCloseEditorToolTips);
|
menu.addAction(&actCloseEditorToolTips);
|
||||||
menu.addAction(&actCopy);
|
menu.addAction(&actCopy);
|
||||||
menu.addAction(&actCopyValue);
|
menu.addAction(&actCopyValue);
|
||||||
|
menu.addAction(&actCopySelected);
|
||||||
menu.addAction(&actShowInEditor);
|
menu.addAction(&actShowInEditor);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
@@ -891,6 +894,9 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
} else if (act == &actCopy) {
|
} else if (act == &actCopy) {
|
||||||
QString contents = handler->editorContents();
|
QString contents = handler->editorContents();
|
||||||
copyToClipboard(contents);
|
copyToClipboard(contents);
|
||||||
|
} else if (act == &actCopySelected) {
|
||||||
|
QString contents = handler->editorContents(selectionModel()->selectedRows());
|
||||||
|
copyToClipboard(contents);
|
||||||
} else if (act == &actCopyValue) {
|
} else if (act == &actCopyValue) {
|
||||||
copyToClipboard(mi1.data().toString());
|
copyToClipboard(mi1.data().toString());
|
||||||
} else if (act == &actShowInEditor) {
|
} else if (act == &actShowInEditor) {
|
||||||
|
|||||||
Reference in New Issue
Block a user