diff options
author | Roland Knall <rknall@gmail.com> | 2019-11-21 10:50:41 +0100 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2019-11-21 10:59:05 +0000 |
commit | cfee0f8082578810cbc88213edde3562f2a7bf73 (patch) | |
tree | a7faa696f466c3fc004709a602474af79361910d | |
parent | ecb90a4e25ac9aad866c76a9d65839dc27c77519 (diff) |
Qt: Remove frameSelect signal
As all frameSelect signals now transport a QList<int> of selected
frames, use this instead
Change-Id: I1888e45a4df997920aebde9706ca0ae803bdba03
Reviewed-on: https://code.wireshark.org/review/35176
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
-rw-r--r-- | ui/qt/byte_view_tab.cpp | 11 | ||||
-rw-r--r-- | ui/qt/byte_view_tab.h | 2 | ||||
-rw-r--r-- | ui/qt/main_status_bar.cpp | 10 | ||||
-rw-r--r-- | ui/qt/main_status_bar.h | 3 | ||||
-rw-r--r-- | ui/qt/main_window.cpp | 14 | ||||
-rw-r--r-- | ui/qt/main_window.h | 5 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 5 | ||||
-rw-r--r-- | ui/qt/packet_dialog.cpp | 2 | ||||
-rw-r--r-- | ui/qt/packet_list.cpp | 20 | ||||
-rw-r--r-- | ui/qt/packet_list.h | 1 | ||||
-rw-r--r-- | ui/qt/proto_tree.cpp | 15 | ||||
-rw-r--r-- | ui/qt/proto_tree.h | 2 | ||||
-rw-r--r-- | ui/qt/widgets/wireless_timeline.cpp | 6 | ||||
-rw-r--r-- | ui/qt/widgets/wireless_timeline.h | 4 |
14 files changed, 51 insertions, 49 deletions
diff --git a/ui/qt/byte_view_tab.cpp b/ui/qt/byte_view_tab.cpp index a5279afc4e..d007f1a95a 100644 --- a/ui/qt/byte_view_tab.cpp +++ b/ui/qt/byte_view_tab.cpp @@ -59,7 +59,7 @@ void ByteViewTab::connectToMainWindow() wsApp->mainWindow(), SIGNAL(fieldHighlight(FieldInformation *))); /* Connect change of packet selection */ - connect(wsApp->mainWindow(), SIGNAL(frameSelected(int)), this, SLOT(selectedFrameChanged(int))); + connect(wsApp->mainWindow(), SIGNAL(framesSelected(QList<int>)), this, SLOT(selectedFrameChanged(QList<int>))); connect(wsApp->mainWindow(), SIGNAL(setCaptureFile(capture_file*)), this, SLOT(setCaptureFile(capture_file*))); connect(wsApp->mainWindow(), SIGNAL(fieldSelected(FieldInformation *)), this, SLOT(selectedFieldChanged(FieldInformation *))); @@ -77,7 +77,7 @@ void ByteViewTab::captureActive(int cap) tvbuff_t * stored = VariantPointer<tvbuff_t>::asPtr(bvt->property(tvb_data_property)); if (! stored) - selectedFrameChanged(-1); + selectedFrameChanged(QList<int>()); } } } @@ -227,7 +227,7 @@ void ByteViewTab::setTabsVisible() { tabBar()->hide(); } -void ByteViewTab::selectedFrameChanged(int frameNum) +void ByteViewTab::selectedFrameChanged(QList<int> frames) { clear(); qDeleteAll(findChildren<ByteViewText *>()); @@ -246,7 +246,8 @@ void ByteViewTab::selectedFrameChanged(int frameNum) } } - if (frameNum >= 0) + /* only show the bytes for single selections */ + if (frames.count() == 1) { if (! cap_file_ || ! cap_file_->edt) return; @@ -340,7 +341,7 @@ void ByteViewTab::highlightedFieldChanged(FieldInformation *highlighted) void ByteViewTab::setCaptureFile(capture_file *cf) { - selectedFrameChanged(-1); + selectedFrameChanged(QList<int>()); cap_file_ = cf; } diff --git a/ui/qt/byte_view_tab.h b/ui/qt/byte_view_tab.h index 95eeaf9745..f1aa93a700 100644 --- a/ui/qt/byte_view_tab.h +++ b/ui/qt/byte_view_tab.h @@ -36,7 +36,7 @@ public slots: /* Set the capture file */ void setCaptureFile(capture_file *cf); /* Creates the tabs and data, depends on an dissection which has already run */ - void selectedFrameChanged(int); + void selectedFrameChanged(QList<int>); /* Selects or marks a field */ void selectedFieldChanged(FieldInformation *); /* Highlights field */ diff --git a/ui/qt/main_status_bar.cpp b/ui/qt/main_status_bar.cpp index 95144b4639..d921d20884 100644 --- a/ui/qt/main_status_bar.cpp +++ b/ui/qt/main_status_bar.cpp @@ -167,7 +167,7 @@ MainStatusBar::MainStatusBar(QWidget *parent) : #endif connect(wsApp, SIGNAL(appInitialized()), splitter, SLOT(show())); - connect(wsApp, SIGNAL(appInitialized()), this, SLOT(setProfileName())); + connect(wsApp, SIGNAL(appInitialized()), this, SLOT(appInitialized())); connect(&info_status_, SIGNAL(toggleTemporaryFlash(bool)), this, SLOT(toggleBackground(bool))); connect(wsApp, SIGNAL(profileNameChanged(const gchar *)), @@ -348,7 +348,13 @@ void MainStatusBar::setProfileName() profile_status_.setText(tr("Profile: %1").arg(get_profile_name())); } -void MainStatusBar::selectedFrameChanged(int) +void MainStatusBar::appInitialized() +{ + setProfileName(); + connect(wsApp->mainWindow(), SIGNAL(framesSelected(QList<int>)), this, SLOT(selectedFrameChanged(QList<int>))); +} + +void MainStatusBar::selectedFrameChanged(QList<int>) { showCaptureStatistics(); } diff --git a/ui/qt/main_status_bar.h b/ui/qt/main_status_bar.h index 95d3db18bd..277c04efe5 100644 --- a/ui/qt/main_status_bar.h +++ b/ui/qt/main_status_bar.h @@ -81,7 +81,7 @@ public slots: void setCaptureFile(capture_file *cf); void selectedFieldChanged(FieldInformation *); void highlightedFieldChanged(FieldInformation *); - void selectedFrameChanged(int); + void selectedFrameChanged(QList<int>); void updateCaptureStatistics(capture_session * cap_session); void updateCaptureFixedStatistics(capture_session * cap_session); @@ -89,6 +89,7 @@ public slots: void captureEventHandler(CaptureEvent ev); private slots: + void appInitialized(); void toggleBackground(bool enabled); void setProfileName(); void switchToProfile(); diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 3dbd5a59bd..c945f28998 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -464,12 +464,8 @@ MainWindow::MainWindow(QWidget *parent) : packet_list_ = new PacketList(&master_split_); main_ui_->wirelessTimelineWidget->setPacketList(packet_list_); - connect(packet_list_, SIGNAL(frameSelected(int)), - this, SIGNAL(frameSelected(int))); - connect(packet_list_, SIGNAL(framesSelected(QList<int>)), - this, SLOT(framesSelected(QList<int>))); - connect(this, SIGNAL(frameSelected(int)), - this, SLOT(setMenusForSelectedPacket())); + connect(packet_list_, SIGNAL(framesSelected(QList<int>)), this, SLOT(setMenusForSelectedPacket())); + connect(packet_list_, SIGNAL(framesSelected(QList<int>)), this, SIGNAL(framesSelected(QList<int>))); proto_tree_ = new ProtoTree(&master_split_); proto_tree_->installEventFilter(this); @@ -562,10 +558,6 @@ MainWindow::MainWindow(QWidget *parent) : packet_list_, SLOT(setCaptureFile(capture_file*))); connect(this, SIGNAL(setCaptureFile(capture_file*)), proto_tree_, SLOT(setCaptureFile(capture_file*))); - connect(this, SIGNAL(frameSelected(int)), - main_ui_->wirelessTimelineWidget, SLOT(selectedFrameChanged(int))); - connect(this, SIGNAL(frameSelected(int)), - main_ui_->statusBar, SLOT(selectedFrameChanged(int))); connect(wsApp, SIGNAL(zoomMonospaceFont(QFont)), packet_list_, SLOT(setMonospaceFont(QFont))); @@ -594,8 +586,6 @@ MainWindow::MainWindow(QWidget *parent) : connect(main_ui_->actionViewCollapseAll, SIGNAL(triggered()), proto_tree_, SLOT(collapseAll())); - connect(packet_list_, SIGNAL(frameSelected(int)), - this, SIGNAL(frameSelected(int))); connect(packet_list_, SIGNAL(packetDissectionChanged()), this, SLOT(redissectPackets())); connect(packet_list_, SIGNAL(showColumnPreferences(QString)), diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index 82f51ae58e..db75a90f41 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -298,7 +298,8 @@ signals: void fieldSelected(FieldInformation *); void fieldHighlight(FieldInformation *); - void frameSelected(int); + void framesSelected(QList<int>); + void captureActive(int); public slots: @@ -326,8 +327,6 @@ public slots: void showWelcome(); void showCapture(); - void framesSelected(QList<int>); - void setTitlebarForCaptureFile(); void setWSWindowTitle(QString title = QString()); diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 8c9e44b179..4d8cd8368b 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -3946,11 +3946,6 @@ void MainWindow::activatePluginIFToolbar(bool) } } -void MainWindow::framesSelected(QList<int> /* frames */) -{ - setMenusForSelectedPacket(); -} - #ifdef _MSC_VER #pragma warning(pop) #endif diff --git a/ui/qt/packet_dialog.cpp b/ui/qt/packet_dialog.cpp index 428fc5fb16..019548eaa3 100644 --- a/ui/qt/packet_dialog.cpp +++ b/ui/qt/packet_dialog.cpp @@ -72,7 +72,7 @@ PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata) byte_view_tab_ = new ByteViewTab(ui->packetSplitter, &edt_); byte_view_tab_->setCaptureFile(cap_file_.capFile()); - byte_view_tab_->selectedFrameChanged(0); + byte_view_tab_->selectedFrameChanged(QList<int>() << 0); ui->packetSplitter->setStretchFactor(1, 0); diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index ce2e0202f8..b9f587a9bb 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -475,7 +475,6 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS rows << idx.row(); } - emit frameSelected(-1); emit framesSelected(rows); emit fieldSelected(0); cf_unselect_packet(cap_file_); @@ -531,9 +530,7 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS in_history_ = false; related_packet_delegate_.clear(); - if (proto_tree_) proto_tree_->clear(); - emit frameSelected(row); emit framesSelected(QList<int>() << row); if (!cap_file_->edt) { @@ -542,10 +539,9 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS return; } - if (proto_tree_ && cap_file_->edt->tree) { + if (cap_file_->edt->tree) { packet_info *pi = &cap_file_->edt->pi; related_packet_delegate_.setCurrentFrame(pi->num); - proto_tree_->setRootNode(cap_file_->edt->tree); conversation_t *conv = find_conversation_pinfo(pi, 0); if (conv) { related_packet_delegate_.setConversation(conv); @@ -1172,7 +1168,9 @@ void PacketList::freeze() // It looks like GTK+ sends a cursor-changed signal at this point but Qt doesn't // call selectionChanged. related_packet_delegate_.clear(); - proto_tree_->clear(); + + /* Clears packet list as well as byteview */ + emit framesSelected(QList<int>()); } void PacketList::thaw(bool restore_selection) @@ -1185,10 +1183,12 @@ 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) { - // 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)); + if (restore_selection && frozen_row_ > -1 && 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); } frozen_row_ = -1; } diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h index f3cc4a7507..ff1873b915 100644 --- a/ui/qt/packet_list.h +++ b/ui/qt/packet_list.h @@ -157,7 +157,6 @@ signals: void showProtocolPreferences(const QString module_name); void editProtocolPreference(struct preference *pref, struct pref_module *module); - void frameSelected(int frameNum); void framesSelected(QList<int>); void fieldSelected(FieldInformation *); diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp index 6cb4645307..7217950b77 100644 --- a/ui/qt/proto_tree.cpp +++ b/ui/qt/proto_tree.cpp @@ -14,6 +14,9 @@ #include <epan/ftypes/ftypes.h> #include <epan/prefs.h> +#include <epan/epan.h> +#include <epan/epan_dissect.h> +#include <cfile.h> #include <ui/qt/utils/color_utils.h> #include <ui/qt/utils/variant_pointer.h> @@ -111,8 +114,8 @@ void ProtoTree::connectToMainWindow() { connect(wsApp->mainWindow(), SIGNAL(fieldSelected(FieldInformation *)), this, SLOT(selectedFieldChanged(FieldInformation *))); - connect(wsApp->mainWindow(), SIGNAL(frameSelected(int)), - this, SLOT(selectedFrameChanged(int))); + connect(wsApp->mainWindow(), SIGNAL(framesSelected(QList<int>)), + this, SLOT(selectedFrameChanged(QList<int>))); } } @@ -603,10 +606,14 @@ void ProtoTree::itemDoubleClicked(const QModelIndex &index) { } } -void ProtoTree::selectedFrameChanged(int frameNum) +void ProtoTree::selectedFrameChanged(QList<int> frames) { - if (frameNum < 0) + clear(); + + if (frames.count() != 1) proto_tree_model_->setRootNode(Q_NULLPTR); + else if (cap_file_ && cap_file_->edt && cap_file_->edt->tree) + proto_tree_model_->setRootNode(cap_file_->edt->tree); } // Select a field and bring it into view. Intended to be called by external diff --git a/ui/qt/proto_tree.h b/ui/qt/proto_tree.h index 608ddcb7cb..773a6e3bb5 100644 --- a/ui/qt/proto_tree.h +++ b/ui/qt/proto_tree.h @@ -95,7 +95,7 @@ public slots: void collapseAll(); void itemDoubleClicked(const QModelIndex & index); void selectedFieldChanged(FieldInformation *); - void selectedFrameChanged(int); + void selectedFrameChanged(QList<int>); protected slots: void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); diff --git a/ui/qt/widgets/wireless_timeline.cpp b/ui/qt/widgets/wireless_timeline.cpp index 3f31e6351a..b57ff672d4 100644 --- a/ui/qt/widgets/wireless_timeline.cpp +++ b/ui/qt/widgets/wireless_timeline.cpp @@ -175,7 +175,7 @@ void WirelessTimeline::clip_tsf() } -void WirelessTimeline::selectedFrameChanged(int) +void WirelessTimeline::selectedFrameChanged(QList<int>) { if (isHidden()) return; @@ -278,13 +278,15 @@ void WirelessTimeline::captureFileReadFinished() zoom_level = 0; show(); - selectedFrameChanged(0); + selectedFrameChanged(QList<int>()); // TODO: show or ungrey the toolbar controls update(); } void WirelessTimeline::appInitialized() { + connect(wsApp->mainWindow(), SIGNAL(framesSelected(QList<int>)), this, SLOT(selectedFrameChanged(QList<int>))); + GString *error_string; error_string = register_tap_listener("wlan_radio_timeline", this, NULL, TL_REQUIRES_NOTHING, tap_timeline_reset, tap_timeline_packet, NULL/*tap_draw_cb tap_draw*/, NULL); if (error_string) { diff --git a/ui/qt/widgets/wireless_timeline.h b/ui/qt/widgets/wireless_timeline.h index 9a2972f067..00af02db99 100644 --- a/ui/qt/widgets/wireless_timeline.h +++ b/ui/qt/widgets/wireless_timeline.h @@ -67,7 +67,6 @@ protected: public slots: void bgColorizationProgress(int first, int last); - void selectedFrameChanged(int frameNum); void appInitialized(); protected: @@ -94,6 +93,9 @@ protected: capture_file *capfile; GHashTable* radio_packet_list; + +protected slots: + void selectedFrameChanged(QList<int>); }; #endif // WIRELESS_TIMELINE_H |