Changeset View
Changeset View
Standalone View
Standalone View
src/analyze/gui/stackstreeview.cpp
- This file was added.
1 | #include "stackstreeview.hpp" | ||||
---|---|---|---|---|---|
2 | | ||||
3 | #include <QApplication> | ||||
4 | #include <QClipboard> | ||||
5 | #include <QKeyEvent> | ||||
6 | | ||||
7 | StacksTreeView::StacksTreeView(QWidget* parent) | ||||
8 | : QTreeView(parent) { | ||||
9 | | ||||
10 | } | ||||
11 | | ||||
12 | void StacksTreeView::keyPressEvent(QKeyEvent* event) { | ||||
13 | if(!selectedIndexes().isEmpty() && event->matches(QKeySequence::Copy)) { | ||||
14 | QString text; | ||||
15 | QItemSelectionRange range = selectionModel()->selection().first(); | ||||
16 | for (auto i = range.top(); i <= range.bottom(); ++i) | ||||
17 | { | ||||
18 | QStringList rowContents; | ||||
19 | for (auto j = range.left(); j <= range.right(); ++j) | ||||
20 | rowContents << model()->index(i,j).data().toString(); | ||||
21 | text += rowContents.join(QString::fromUtf8("\t")); | ||||
22 | text += QString::fromUtf8("\n"); | ||||
23 | } | ||||
24 | QApplication::clipboard()->setText(text); | ||||
25 | } else { | ||||
26 | QTreeView::keyPressEvent(event); | ||||
27 | } | ||||
28 | } |