aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2016-12-12 11:34:03 -0800
committerGerald Combs <gerald@wireshark.org>2016-12-13 22:01:59 +0000
commite150235ef14cf6a9ada7d74c534e4aee469f3ac5 (patch)
tree213d19faeb8b4965d309c6bb2a23bc1c08c975bc /ui
parent6f3fed904d0ceee39b086408117d7fc1f79ef63f (diff)
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')
-rw-r--r--ui/qt/main_window_slots.cpp4
-rw-r--r--ui/qt/packet_list.cpp19
-rw-r--r--ui/qt/packet_list.h15
3 files changed, 31 insertions, 7 deletions
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index dfdc8ac433..79e8a25433 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -320,7 +320,6 @@ void MainWindow::layoutPanes()
if (cur_layout_ == new_layout) return;
QSplitter *parents[3];
- int current_row = capture_file_.currentRow();
// Reparent all widgets and add them back in the proper order below.
// This hides each widget as well.
@@ -397,8 +396,7 @@ void MainWindow::layoutPanes()
proto_tree_->setVisible(ms_children.contains(proto_tree_) && recent.tree_view_show);
byte_view_tab_->setVisible(ms_children.contains(byte_view_tab_) && recent.byte_view_show);
- packet_list_->thaw();
- cf_select_packet(capture_file_.capFile(), current_row); // XXX Doesn't work for row 0?
+ packet_list_->thaw(true);
cur_layout_ = new_layout;
}
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;
diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h
index 446d13a6b5..4f3d072831 100644
--- a/ui/qt/packet_list.h
+++ b/ui/qt/packet_list.h
@@ -61,8 +61,20 @@ public:
QMenu *colorizeMenu() { return &colorize_menu_; }
void setProtoTree(ProtoTree *proto_tree);
void setByteViewTab(ByteViewTab *byteViewTab);
+ /** Disable and clear the packet list.
+ *
+ * Disable packet list widget updates, clear the detail and byte views,
+ * and disconnect the model.
+ */
void freeze();
- void thaw();
+ /** Enable and restore the packet list.
+ *
+ * Enable packet list widget updates and reconnect the model.
+ *
+ * @param restore_selection If true, redissect the previously selected
+ * packet. This includes filling in the detail and byte views.
+ */
+ void thaw(bool restore_selection = false);
void clear();
void writeRecent(FILE *rf);
bool contextMenuActive();
@@ -120,6 +132,7 @@ private:
bool rows_inserted_;
bool columns_changed_;
bool set_column_visibility_;
+ int frozen_row_;
void setFrameReftime(gboolean set, frame_data *fdata);
void setColumnVisibility();