aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/memorymodel.cpp
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-10 23:55:53 +0100
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-10 23:55:53 +0100
commit1c608f4cd1c5a1102442679b9d6608a254cc7420 (patch)
treef0a3e150e4756a801d02c149a0ab7455bf388200 /qtmips_gui/memorymodel.cpp
parent53605cd996338dafc507d4126a2a49b865b04db1 (diff)
downloadqtmips-1c608f4cd1c5a1102442679b9d6608a254cc7420.tar.gz
qtmips-1c608f4cd1c5a1102442679b9d6608a254cc7420.tar.bz2
qtmips-1c608f4cd1c5a1102442679b9d6608a254cc7420.zip
Implemented workaround QTableView limits workaround which mostly works.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui/memorymodel.cpp')
-rw-r--r--qtmips_gui/memorymodel.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/qtmips_gui/memorymodel.cpp b/qtmips_gui/memorymodel.cpp
index 13ae1c7..69a412d 100644
--- a/qtmips_gui/memorymodel.cpp
+++ b/qtmips_gui/memorymodel.cpp
@@ -47,8 +47,8 @@ MemoryModel::MemoryModel(QObject *parent)
}
int MemoryModel::rowCount(const QModelIndex & /*parent*/) const {
- std::uint64_t rows = (0x2000 + cells_per_row - 1) / cells_per_row;
- return rows;
+ // std::uint64_t rows = (0x2000 + cells_per_row - 1) / cells_per_row;
+ return 2000;
}
int MemoryModel::columnCount(const QModelIndex & /*parent*/) const {
@@ -143,6 +143,10 @@ void MemoryModel::set_cell_size(int index) {
emit cell_size_changed();
}
+void MemoryModel::update_all() {
+ emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
+}
+
void MemoryModel::check_for_updates() {
bool need_update = false;
if (machine == nullptr)
@@ -158,5 +162,27 @@ void MemoryModel::check_for_updates() {
}
if (!need_update)
return;
- emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
+ update_all();
+}
+
+bool MemoryModel::adjustRowAndOffset(int &row, int optimal_row, std::uint32_t address) {
+ if (optimal_row < rowCount() / 8)
+ optimal_row = rowCount() / 8;
+ if (optimal_row >= rowCount() - rowCount() / 8)
+ optimal_row = rowCount() - rowCount() / 8;
+ row = rowCount() / 2;
+ address -= address % cellSizeBytes();
+ std::uint32_t row_bytes = cells_per_row * cellSizeBytes();
+ std::uint32_t diff = row * row_bytes;
+ if (diff > address) {
+ row = address / row_bytes;
+ if (row == 0) {
+ index0_offset = 0;
+ } else {
+ index0_offset = address - row * row_bytes;
+ }
+ } else {
+ index0_offset = address - diff;
+ }
+ return get_row_for_address(row, address);
}