From f30621943190e821da636013899c2dc86ab96290 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 3 Mar 2009 18:05:23 +0100 Subject: Fixes: debugger: make stack contents availaible in the clipboard Details: missing some more information, though.. --- src/plugins/debugger/stackwindow.cpp | 51 +++++++++++++++++++++++++++++------- src/plugins/debugger/stackwindow.h | 1 + 2 files changed, 43 insertions(+), 9 deletions(-) (limited to 'src/plugins/debugger') diff --git a/src/plugins/debugger/stackwindow.cpp b/src/plugins/debugger/stackwindow.cpp index 88fbeb2a7e..e238dfdf75 100644 --- a/src/plugins/debugger/stackwindow.cpp +++ b/src/plugins/debugger/stackwindow.cpp @@ -33,14 +33,18 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + using Debugger::Internal::StackWindow; @@ -81,22 +85,51 @@ void StackWindow::rowActivated(const QModelIndex &index) void StackWindow::contextMenuEvent(QContextMenuEvent *ev) { QMenu menu; + + QAction *act0 = new QAction(tr("Copy contents to clipboard"), &menu); + act0->setEnabled(model() != 0); + QAction *act1 = new QAction(tr("Adjust column widths to contents"), &menu); + QAction *act2 = new QAction(tr("Always adjust column widths to contents"), &menu); act2->setCheckable(true); act2->setChecked(m_alwaysResizeColumnsToContents); + menu.addAction(act0); + menu.addSeparator(); menu.addAction(act1); menu.addAction(act2); QAction *act = menu.exec(ev->globalPos()); - if (act == act1) + if (act == act0) + copyContentsToClipboard(); + else if (act == act1) resizeColumnsToContents(); else if (act == act2) setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents); } +void StackWindow::copyContentsToClipboard() +{ + QString str; + int n = model()->rowCount(); + int m = model()->columnCount(); + for (int i = 0; i != n; ++i) { + for (int j = 0; j != m; ++j) { + QModelIndex index = model()->index(i, j); + str += model()->data(index).toString(); + str += '\t'; + } + str += '\n'; + } + QClipboard *clipboard = QApplication::clipboard(); + #ifdef Q_OS_LINUX + clipboard->setText(str, QClipboard::Selection); + #endif + clipboard->setText(str, QClipboard::Clipboard); +} + void StackWindow::resizeColumnsToContents() { resizeColumnToContents(0); diff --git a/src/plugins/debugger/stackwindow.h b/src/plugins/debugger/stackwindow.h index 2891aaff6d..5bb2390755 100644 --- a/src/plugins/debugger/stackwindow.h +++ b/src/plugins/debugger/stackwindow.h @@ -61,6 +61,7 @@ private slots: private: void resizeEvent(QResizeEvent *ev); void contextMenuEvent(QContextMenuEvent *ev); + void copyContentsToClipboard(); bool m_alwaysResizeColumnsToContents; }; -- cgit v1.2.1