aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/qt/byte_view_tab.cpp4
-rw-r--r--ui/qt/capture_file.cpp7
-rw-r--r--ui/qt/capture_file.h7
-rw-r--r--ui/qt/main_window_slots.cpp7
-rw-r--r--ui/qt/packet_list.cpp4
5 files changed, 24 insertions, 5 deletions
diff --git a/ui/qt/byte_view_tab.cpp b/ui/qt/byte_view_tab.cpp
index 4df8cb39a7..3b2c138cfd 100644
--- a/ui/qt/byte_view_tab.cpp
+++ b/ui/qt/byte_view_tab.cpp
@@ -24,6 +24,10 @@
#include <QTabBar>
#include <QTreeWidgetItem>
+// To do:
+// - We might want to add a callback to free_data_sources in so that we
+// don't have to blindly call clear().
+
ByteViewTab::ByteViewTab(QWidget *parent) :
QTabWidget(parent)
{
diff --git a/ui/qt/capture_file.cpp b/ui/qt/capture_file.cpp
index ed05ea9b04..a32f225f15 100644
--- a/ui/qt/capture_file.cpp
+++ b/ui/qt/capture_file.cpp
@@ -68,6 +68,13 @@ bool CaptureFile::isValid() const
return false;
}
+int CaptureFile::currentRow()
+{
+ if (isValid())
+ return cap_file_->current_row;
+ return -1;
+}
+
void CaptureFile::retapPackets()
{
if (cap_file_) {
diff --git a/ui/qt/capture_file.h b/ui/qt/capture_file.h
index 3a4742e312..ace854d0d8 100644
--- a/ui/qt/capture_file.h
+++ b/ui/qt/capture_file.h
@@ -47,6 +47,13 @@ public:
*/
bool isValid() const;
+ /** Get the current selected row
+ *
+ * @return the current selected index of the packet list if the capture
+ * file is open and a packet is selected, otherwise -1.
+ */
+ int currentRow();
+
/** Return a filename suitable for use in a window title.
*
* @return One of: the basename of the capture file without an extension,
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 2b09f2facf..b7ccae4cd4 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -255,9 +255,11 @@ 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.
+ packet_list_->freeze(); // Clears tree and byte view tab.
packet_list_->setParent(main_ui_->mainStack);
proto_tree_->setParent(main_ui_->mainStack);
byte_view_tab_->setParent(main_ui_->mainStack);
@@ -341,9 +343,8 @@ void MainWindow::layoutPanes()
}
widget->setVisible(show);
}
- if (capture_file_.isValid() && capture_file_.capFile()->current_row >= 0) {
- cf_select_packet(capture_file_.capFile(), capture_file_.capFile()->current_row);
- }
+ packet_list_->thaw();
+ cf_select_packet(capture_file_.capFile(), current_row); // XXX Doesn't work for row 0?
cur_layout_ = new_layout;
}
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index d2a9e7ef80..6b5a70b11c 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -639,7 +639,7 @@ void PacketList::redrawVisiblePackets() {
build_column_format_array(&cap_file_->cinfo, prefs.num_cols, FALSE);
packet_list_model_->resetColumns();
- if (row > 0) {
+ if (row >= 0) {
setCurrentIndex(packet_list_model_->index(row, 0));
}
@@ -880,7 +880,7 @@ void PacketList::goLastPacket(void) {
// XXX We can jump to the wrong packet if a display filter is applied
void PacketList::goToPacket(int packet) {
int row = packet_list_model_->packetNumberToRow(packet);
- if (row > 0) {
+ if (row >= 0) {
setCurrentIndex(packet_list_model_->index(row, 0));
}
}