aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/memorytableview.cpp
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-15 23:08:00 +0100
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-15 23:08:00 +0100
commitfe4721d4b3e1b3cfa845bd52788f790038d34578 (patch)
treed1f7368a39ec3034d6f5a235bf27e28c99abbc9c /qtmips_gui/memorytableview.cpp
parent1b4ef2f6ce2104f0c54c124eab58c4b5f6af4327 (diff)
downloadqtmips-fe4721d4b3e1b3cfa845bd52788f790038d34578.tar.gz
qtmips-fe4721d4b3e1b3cfa845bd52788f790038d34578.tar.bz2
qtmips-fe4721d4b3e1b3cfa845bd52788f790038d34578.zip
Enable copy from memory and program views.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui/memorytableview.cpp')
-rw-r--r--qtmips_gui/memorytableview.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/qtmips_gui/memorytableview.cpp b/qtmips_gui/memorytableview.cpp
index e2386fa..aeec25e 100644
--- a/qtmips_gui/memorytableview.cpp
+++ b/qtmips_gui/memorytableview.cpp
@@ -36,6 +36,9 @@
#include <QHeaderView>
#include <QFontMetrics>
#include <QScrollBar>
+#include <QKeyEvent>
+#include <QClipboard>
+#include <QApplication>
#include "memorytableview.h"
#include "memorymodel.h"
@@ -191,3 +194,20 @@ void MemoryTableView::focus_address(std::uint32_t address) {
return;
setCurrentIndex(m->index(row, 1));
}
+
+void MemoryTableView::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);
+}