diff options
author | hjk <qtc-committer@nokia.com> | 2009-03-03 18:05:23 +0100 |
---|---|---|
committer | hjk <qtc-committer@nokia.com> | 2009-03-03 18:05:23 +0100 |
commit | f30621943190e821da636013899c2dc86ab96290 (patch) | |
tree | 5c08b8a8de2e7638968bba777535c91c6829983b /src/plugins/debugger | |
parent | bd96ebf749d7a56d9769531c0e72e0994a796d6d (diff) | |
download | qt-creator-f30621943190e821da636013899c2dc86ab96290.tar.gz |
Fixes: debugger: make stack contents availaible in the clipboard
Details: missing some more information, though..
Diffstat (limited to 'src/plugins/debugger')
-rw-r--r-- | src/plugins/debugger/stackwindow.cpp | 51 | ||||
-rw-r--r-- | src/plugins/debugger/stackwindow.h | 1 |
2 files changed, 43 insertions, 9 deletions
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 <utils/qtcassert.h> -#include <QAction> -#include <QComboBox> -#include <QDebug> -#include <QHeaderView> -#include <QMenu> -#include <QResizeEvent> -#include <QTreeView> -#include <QVBoxLayout> +#include <QtCore/QDebug> + +#include <QtGui/QAction> +#include <QtGui/QApplication> +#include <QtGui/QClipboard> +#include <QtGui/QComboBox> +#include <QtGui/QHeaderView> +#include <QtGui/QMenu> +#include <QtGui/QResizeEvent> +#include <QtGui/QTreeView> +#include <QtGui/QVBoxLayout> + 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; }; |