From 36747de2c73d3c11e30abd7b371cc5a5cf91a331 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Thu, 14 Mar 2019 21:43:34 +0100 Subject: Fix nested calls of setCurrentIndex which caused breakage. ProgramTableView::focus_address() calls QAbstractItemView::setCurrentIndex(). verticalScrollBar() value is updated as result of current row change. This emits signal valueChanged which is connected to ProgramTableView::adjust_scroll_pos(). It checks if the limit of range covered by actual model and row to address offset is reached. If the top or bottom 1/8 of range is reached then model needs to be adjusted to cover continuation area. Model shift requires update of the current row to stay on the same address even that row 0 address offset is changed. This model shifting is required because range of scroll is only signed integer and QTableView is even more limited in row count to work reliably. Signed-off-by: Pavel Pisa --- qtmips_gui/programtableview.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'qtmips_gui/programtableview.h') diff --git a/qtmips_gui/programtableview.h b/qtmips_gui/programtableview.h index 5a67f51..6298d89 100644 --- a/qtmips_gui/programtableview.h +++ b/qtmips_gui/programtableview.h @@ -53,19 +53,22 @@ public: void resizeEvent(QResizeEvent *event) override; signals: void address_changed(std::uint32_t address); + void adjust_scroll_pos_queue(); public slots: void go_to_address(std::uint32_t address); void focus_address(std::uint32_t address); protected: - void keyPressEvent(QKeyEvent *event); + void keyPressEvent(QKeyEvent *event); private slots: - void adjust_scroll_pos(); + void adjust_scroll_pos_check(); + void adjust_scroll_pos_process(); private: void addr0_save_change(std::uint32_t val); void adjustColumnCount(); QSettings *settings; std::uint32_t initial_address; + bool adjust_scroll_pos_in_progress; }; #endif // PROGRAMTABLEVIEW_H -- cgit v1.2.3