diff options
author | Roland Knall <rknall@gmail.com> | 2016-10-01 08:54:57 +0200 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2016-10-01 13:18:51 +0000 |
commit | 99097dd3c65358a525e40767cc1501c4116c3a4d (patch) | |
tree | 1ad9637554aebded5ff4bf8a400a6c3fc2ed4b4e /ui/qt/capture_interfaces_dialog.cpp | |
parent | b6ad91520fd602710f5afe4a4eb8787a6bca22d4 (diff) |
Interface List: Change display to view/model
This changes the underlying model of the main interface tree.
Because of that, we can resort to a view/model approach, enlisting
the global interfaces list as only data source.
The interface list works identical to the old list, but allows
for filtering of the displayed interfaces by type. Only types, which
are present and whose interfaces are not hidden, are being displayed
for selection.
Change-Id: If8475b227daa026dc0ad3d25bc7fe050d5bf2ac3
Reviewed-on: https://code.wireshark.org/review/17940
Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui/qt/capture_interfaces_dialog.cpp')
-rw-r--r-- | ui/qt/capture_interfaces_dialog.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/ui/qt/capture_interfaces_dialog.cpp b/ui/qt/capture_interfaces_dialog.cpp index 50710e387b..1f3ba18574 100644 --- a/ui/qt/capture_interfaces_dialog.cpp +++ b/ui/qt/capture_interfaces_dialog.cpp @@ -233,9 +233,45 @@ CaptureInterfacesDialog::CaptureInterfacesDialog(QWidget *parent) : connect(ui->browseButton, SIGNAL(clicked()), this, SLOT(browseButtonClicked())); } +/* Update global device selections based on the TreeWidget selection. */ +void CaptureInterfacesDialog::updateGlobalDeviceSelections() +{ +#ifdef HAVE_LIBPCAP + QTreeWidgetItemIterator iter(ui->interfaceTree); + + global_capture_opts.num_selected = 0; + + 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.locked) { + if ((*iter)->isSelected()) { + device.selected = TRUE; + global_capture_opts.num_selected++; + } else { + device.selected = FALSE; + } + device.locked = TRUE; + global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i); + g_array_insert_val(global_capture_opts.all_ifaces, i, device); + + device.locked = FALSE; + global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i); + g_array_insert_val(global_capture_opts.all_ifaces, i, device); + } + break; + } + } + ++iter; + } +#endif +} + void CaptureInterfacesDialog::interfaceSelected() { - InterfaceTree::updateGlobalDeviceSelections(ui->interfaceTree, col_interface_); + updateGlobalDeviceSelections(); ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled((global_capture_opts.num_selected > 0) ? true: false); |