aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2020-10-27 15:10:00 -0700
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2020-10-28 15:36:07 +0000
commit1c2fd68e26796f74885b0184098bf495c0a403ed (patch)
tree421d4fe7119abf41a6631932fe7804bc8b2cbd45 /ui
parent9b5d4945d0dbfe566fe69bd4019e45b52bfc9db5 (diff)
Qt: Fix saving+restoring frozen packet list rows.
Use the packet list selection model to save and restore selected rows when freezing and thawing. Fixes #16770.
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/packet_list.cpp18
-rw-r--r--ui/qt/packet_list.h2
2 files changed, 9 insertions, 11 deletions
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index d915d09922..9802bb5a23 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -229,7 +229,7 @@ PacketList::PacketList(QWidget *parent) :
rows_inserted_(false),
columns_changed_(false),
set_column_visibility_(false),
- frozen_row_(-1),
+ frozen_rows_(QModelIndexList()),
cur_history_(-1),
in_history_(false)
{
@@ -1180,11 +1180,7 @@ void PacketList::freeze()
{
column_state_ = header()->saveState();
setHeaderHidden(true);
- if (currentIndex().isValid()) {
- frozen_row_ = currentIndex().row();
- } else {
- frozen_row_ = -1;
- }
+ frozen_rows_ = selectedIndexes();
selectionModel()->clear();
setModel(Q_NULLPTR);
// It looks like GTK+ sends a cursor-changed signal at this point but Qt doesn't
@@ -1205,14 +1201,16 @@ void PacketList::thaw(bool restore_selection)
// resized the columns manually since they were initially loaded.
header()->restoreState(column_state_);
- if (restore_selection && frozen_row_ > -1 && selectionModel()) {
+ if (restore_selection && frozen_rows_.length() > 0 && selectionModel()) {
/* This updates our selection, which redissects the current packet,
* which is needed when we're called from MainWindow::layoutPanes.
* Also, this resets all ProtoTree and ByteView data */
- QModelIndex restored = packet_list_model_->index(frozen_row_, 0);
- selectionModel()->select(restored, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+ clearSelection();
+ foreach (QModelIndex idx, frozen_rows_) {
+ selectionModel()->select(idx, QItemSelectionModel::Select | QItemSelectionModel::Rows);
+ }
}
- frozen_row_ = -1;
+ frozen_rows_ = QModelIndexList();
}
void PacketList::clear() {
diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h
index c014e87236..90e619dbb1 100644
--- a/ui/qt/packet_list.h
+++ b/ui/qt/packet_list.h
@@ -134,7 +134,7 @@ private:
bool rows_inserted_;
bool columns_changed_;
bool set_column_visibility_;
- int frozen_row_;
+ QModelIndexList frozen_rows_;
QVector<int> selection_history_;
int cur_history_;
bool in_history_;