diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-12-12 11:34:03 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2016-12-13 22:01:59 +0000 |
commit | e150235ef14cf6a9ada7d74c534e4aee469f3ac5 (patch) | |
tree | 213d19faeb8b4965d309c6bb2a23bc1c08c975bc /ui/qt/packet_list.cpp | |
parent | 6f3fed904d0ceee39b086408117d7fc1f79ef63f (diff) | |
download | wireshark-e150235ef14cf6a9ada7d74c534e4aee469f3ac5.tar.gz |
Qt: Optionally restore our selected packet when thawing.
Stash the current row when we freeze the packet list. Make it possible
to restore it when thawing. Do so when the layout changes and when we
move a column.
Change-Id: I44cfb8bafcd4d49a46e1c89bf47aecf5ac139773
Reviewed-on: https://code.wireshark.org/review/19222
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/packet_list.cpp')
-rw-r--r-- | ui/qt/packet_list.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index b5f5493a77..74049d084f 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -246,7 +246,8 @@ PacketList::PacketList(QWidget *parent) : tail_timer_id_(0), rows_inserted_(false), columns_changed_(false), - set_column_visibility_(false) + set_column_visibility_(false), + frozen_row_(-1) { QMenu *main_menu_item, *submenu; QAction *action; @@ -882,6 +883,11 @@ void PacketList::freeze() { setUpdatesEnabled(false); column_state_ = header()->saveState(); + if (currentIndex().isValid()) { + frozen_row_ = currentIndex().row(); + } else { + frozen_row_ = -1; + } selectionModel()->clear(); setModel(NULL); // It looks like GTK+ sends a cursor-changed signal at this point but Qt doesn't @@ -891,7 +897,7 @@ void PacketList::freeze() byte_view_tab_->clear(); } -void PacketList::thaw() +void PacketList::thaw(bool restore_selection) { setUpdatesEnabled(true); setModel(packet_list_model_); @@ -900,6 +906,13 @@ void PacketList::thaw() // We don't reapply the recent settings because the user could have // resized the columns manually since they were initially loaded. header()->restoreState(column_state_); + + if (restore_selection && frozen_row_ > -1) { + // This updates our selection, which redissects the current packet, + // which is needed when we're called from MainWindow::layoutPanes. + setCurrentIndex(packet_list_model_->index(frozen_row_, 0)); + } + frozen_row_ = -1; } void PacketList::clear() { @@ -1388,7 +1401,7 @@ void PacketList::sectionMoved(int, int, int) g_list_free(prefs.col_list); prefs.col_list = new_col_list; - thaw(); + thaw(true); for (int i = 0; i < saved_sizes.length(); i++) { if (saved_sizes[i] < 1) continue; |