diff options
Diffstat (limited to 'qtmips_gui/programtableview.cpp')
-rw-r--r-- | qtmips_gui/programtableview.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/qtmips_gui/programtableview.cpp b/qtmips_gui/programtableview.cpp index 005b518..e3114a6 100644 --- a/qtmips_gui/programtableview.cpp +++ b/qtmips_gui/programtableview.cpp @@ -36,6 +36,9 @@ #include <QHeaderView> #include <QFontMetrics> #include <QScrollBar> +#include <QKeyEvent> +#include <QClipboard> +#include <QApplication> #include "programtableview.h" #include "programmodel.h" @@ -82,7 +85,6 @@ void ProgramTableView::adjustColumnCount() { } } - void ProgramTableView:: adjust_scroll_pos() { std::uint32_t address; ProgramModel *m = dynamic_cast<ProgramModel*>(model()); @@ -165,3 +167,20 @@ void ProgramTableView::focus_address(std::uint32_t address) { return; setCurrentIndex(m->index(row, 3)); } + +void ProgramTableView::keyPressEvent(QKeyEvent *event) { + if(event->matches(QKeySequence::Copy)) { + QString text; + QItemSelectionRange range = selectionModel()->selection().first(); + for (auto i = range.top(); i <= range.bottom(); ++i) + { + QStringList rowContents; + for (auto j = range.left(); j <= range.right(); ++j) + rowContents << model()->index(i,j).data().toString(); + text += rowContents.join("\t"); + text += "\n"; + } + QApplication::clipboard()->setText(text); + } else + Super::keyPressEvent(event); +} |