summaryrefslogtreecommitdiff
path: root/ui/qt
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2017-03-10 14:37:18 +0100
committerPeter Wu <peter@lekensteyn.nl>2017-03-29 15:16:56 +0000
commit601fe5e3516b67e709628f9c4a4fa2c2f8918041 (patch)
tree3db1e0e4b0711496d6726c13e17f9b3e9c734148 /ui/qt
parent5eaa9e770533345dfc6664a5d53c6931b00fdc75 (diff)
downloadwireshark-601fe5e3516b67e709628f9c4a4fa2c2f8918041.tar.gz
Qt: propagate selection from main screen to dialog
Ensure that the selection in main screen is updated on refreshing interfaces (InterfaceFrame::interfaceListChanged). Add additional patches to ensure that selection changes from the main screen propagate to the dialog and be careful to avoid infinite recursions. Life of a signal for InterfaceFrame: ui->interfaceTree->selectionModel emits selectionChanged -> slot InterfaceFrame::interfaceTreeSelectionChanged -> emits InterfaceFrame::itemSelectionChanged -> slot MainWelcome::interfaceSelected -> emits MainWelcome::interfacesChanged -> slot CaptureInterfacesDialog::interfaceSelected (updats dialog selection) Life of a signal for CaptureInterfacesDialog: ui->interfaceTree emits itemSelectionChanged -> slot CaptureInterfacesDialog::interfaceSelected (emission of next signal because sender is ui->interfaceTree) -> emits CaptureInterfacesDialog::interfacesChanged -> slot InterfaceFrame::updateSelectedInterfaces (updates main screen selection) This should probably be updated to model/view with shared selection model in the future. Change-Id: Ibb32c201a92bd2f1310523b3e6e63b03209c9ce4 Reviewed-on: https://code.wireshark.org/review/20487 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/capture_interfaces_dialog.cpp38
-rw-r--r--ui/qt/capture_interfaces_dialog.h1
-rw-r--r--ui/qt/interface_frame.cpp2
-rw-r--r--ui/qt/main_welcome.cpp3
-rw-r--r--ui/qt/main_welcome.h1
-rw-r--r--ui/qt/main_window_slots.cpp3
6 files changed, 45 insertions, 3 deletions
diff --git a/ui/qt/capture_interfaces_dialog.cpp b/ui/qt/capture_interfaces_dialog.cpp
index 771dd40498..9a51919d2a 100644
--- a/ui/qt/capture_interfaces_dialog.cpp
+++ b/ui/qt/capture_interfaces_dialog.cpp
@@ -272,11 +272,43 @@ void CaptureInterfacesDialog::updateGlobalDeviceSelections()
#endif
}
-void CaptureInterfacesDialog::interfaceSelected()
+/* Update TreeWidget selection based on global device selections. */
+void CaptureInterfacesDialog::updateFromGlobalDeviceSelections()
{
- updateGlobalDeviceSelections();
+#ifdef HAVE_LIBPCAP
+ QTreeWidgetItemIterator iter(ui->interfaceTree);
- emit interfacesChanged();
+ // Prevent recursive interface interfaceSelected signals
+ ui->interfaceTree->blockSignals(true);
+
+ while (*iter) {
+ QString device_name = (*iter)->data(col_interface_, Qt::UserRole).value<QString>();
+ for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) {
+ interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
+ if (device_name.compare(QString().fromUtf8(device.name)) == 0) {
+ if (device.selected != (*iter)->isSelected()) {
+ (*iter)->setSelected(device.selected);
+ }
+ break;
+ }
+ }
+ ++iter;
+ }
+
+ ui->interfaceTree->blockSignals(false);
+#endif
+}
+
+void CaptureInterfacesDialog::interfaceSelected()
+{
+ if (sender() == ui->interfaceTree) {
+ // Local changes, propagate our changes
+ updateGlobalDeviceSelections();
+ emit interfacesChanged();
+ } else {
+ // Changes from the welcome screen, adjust to its state.
+ updateFromGlobalDeviceSelections();
+ }
updateSelectedFilter();
diff --git a/ui/qt/capture_interfaces_dialog.h b/ui/qt/capture_interfaces_dialog.h
index 8967c6b058..c679724e76 100644
--- a/ui/qt/capture_interfaces_dialog.h
+++ b/ui/qt/capture_interfaces_dialog.h
@@ -128,6 +128,7 @@ private:
void updateSelectedFilter();
void updateGlobalDeviceSelections();
+ void updateFromGlobalDeviceSelections();
};
#endif /* HAVE_LIBPCAP */
diff --git a/ui/qt/interface_frame.cpp b/ui/qt/interface_frame.cpp
index 8d7d188236..f382f19f99 100644
--- a/ui/qt/interface_frame.cpp
+++ b/ui/qt/interface_frame.cpp
@@ -210,6 +210,8 @@ void InterfaceFrame::triggeredIfTypeButton()
void InterfaceFrame::interfaceListChanged()
{
resetInterfaceTreeDisplay();
+ // Ensure that device selection is consistent with the displayed selection.
+ updateSelectedInterfaces();
#ifdef HAVE_LIBPCAP
if (!stat_timer_) {
diff --git a/ui/qt/main_welcome.cpp b/ui/qt/main_welcome.cpp
index 3cf1b8a52d..8832b519dc 100644
--- a/ui/qt/main_welcome.cpp
+++ b/ui/qt/main_welcome.cpp
@@ -327,6 +327,9 @@ void MainWelcome::interfaceSelected()
} else {
welcome_ui_->captureFilterComboBox->lineEdit()->setText(user_filter);
}
+
+ // Notify others (capture interfaces dialog) that the selection has changed.
+ emit interfacesChanged();
}
#ifdef HAVE_EXTCAP
diff --git a/ui/qt/main_welcome.h b/ui/qt/main_welcome.h
index 085983901e..f862154ba6 100644
--- a/ui/qt/main_welcome.h
+++ b/ui/qt/main_welcome.h
@@ -80,6 +80,7 @@ signals:
#ifdef HAVE_EXTCAP
void showExtcapOptions(QString &device_name);
#endif
+ void interfacesChanged();
public slots:
void setCaptureFilterText(const QString capture_filter);
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 2b7935dfef..555394eb16 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -3758,6 +3758,9 @@ void MainWindow::on_actionCaptureOptions_triggered()
this->main_welcome_->getInterfaceFrame(), SLOT(interfaceListChanged()));
connect(capture_interfaces_dialog_, SIGNAL(captureFilterTextEdited(QString)),
this->main_welcome_, SLOT(setCaptureFilterText(QString)));
+ // Propagate selection changes from main UI to dialog.
+ connect(this->main_welcome_, SIGNAL(interfacesChanged()),
+ capture_interfaces_dialog_, SLOT(interfaceSelected()));
connect(capture_interfaces_dialog_, SIGNAL(setFilterValid(bool, const QString)),
this, SLOT(startInterfaceCapture(bool, const QString)));