aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/programtableview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui/programtableview.cpp')
-rw-r--r--qtmips_gui/programtableview.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/qtmips_gui/programtableview.cpp b/qtmips_gui/programtableview.cpp
index e3114a6..a684692 100644
--- a/qtmips_gui/programtableview.cpp
+++ b/qtmips_gui/programtableview.cpp
@@ -44,9 +44,12 @@
ProgramTableView::ProgramTableView(QWidget *parent, QSettings *settings) : Super(parent) {
connect(verticalScrollBar() , SIGNAL(valueChanged(int)),
- this, SLOT(adjust_scroll_pos()));
+ this, SLOT(adjust_scroll_pos_check()));
+ connect(this , SIGNAL(adjust_scroll_pos_queue()),
+ this, SLOT(adjust_scroll_pos_process()), Qt::QueuedConnection);
this->settings = settings;
initial_address = settings->value("ProgramViewAddr0", 0).toULongLong();
+ adjust_scroll_pos_in_progress = false;
}
void ProgramTableView::addr0_save_change(std::uint32_t val) {
@@ -85,7 +88,15 @@ void ProgramTableView::adjustColumnCount() {
}
}
-void ProgramTableView:: adjust_scroll_pos() {
+void ProgramTableView::adjust_scroll_pos_check() {
+ if (!adjust_scroll_pos_in_progress) {
+ adjust_scroll_pos_in_progress = true;
+ emit adjust_scroll_pos_queue();
+ }
+}
+
+void ProgramTableView::adjust_scroll_pos_process() {
+ adjust_scroll_pos_in_progress = false;
std::uint32_t address;
ProgramModel *m = dynamic_cast<ProgramModel*>(model());
if (m == nullptr)
@@ -100,16 +111,16 @@ void ProgramTableView:: adjust_scroll_pos() {
int prev_row = row;
if (row < m->rowCount() / 8) {
if ((row == 0) && (index0_offset < row_bytes) && (index0_offset != 0)) {
- m->adjustRowAndOffset(row, 0, 0);
- } else if (index0_offset > row_bytes) {
+ m->adjustRowAndOffset(row, 0);
+ } else if (index0_offset >= row_bytes) {
m->get_row_address(address, row);
- m->adjustRowAndOffset(row, m->rowCount() / 7, address);
+ m->adjustRowAndOffset(row, address);
} else {
break;
}
} else if (row > m->rowCount() - m->rowCount() / 8) {
m->get_row_address(address, row);
- m->adjustRowAndOffset(row, m->rowCount() - m->rowCount() / 7, address);
+ m->adjustRowAndOffset(row, address);
} else {
break;
}
@@ -148,7 +159,7 @@ void ProgramTableView:: go_to_address(std::uint32_t address) {
int row;
if (m == nullptr)
return;
- m->adjustRowAndOffset(row, m->rowCount() / 2, address);
+ m->adjustRowAndOffset(row, address);
scrollTo(m->index(row, 0),
QAbstractItemView::PositionAtTop);
setCurrentIndex(m->index(row, 1));