summaryrefslogtreecommitdiffstats
path: root/ui/qt/traffic_table_dialog.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:34:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:34:10 +0000
commite4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc (patch)
tree68cb5ef9081156392f1dd62a00c6ccc1451b93df /ui/qt/traffic_table_dialog.cpp
parentInitial commit. (diff)
downloadwireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.tar.xz
wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.zip
Adding upstream version 4.2.2.upstream/4.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ui/qt/traffic_table_dialog.cpp')
-rw-r--r--ui/qt/traffic_table_dialog.cpp163
1 files changed, 163 insertions, 0 deletions
diff --git a/ui/qt/traffic_table_dialog.cpp b/ui/qt/traffic_table_dialog.cpp
new file mode 100644
index 00000000..2040eedf
--- /dev/null
+++ b/ui/qt/traffic_table_dialog.cpp
@@ -0,0 +1,163 @@
+/* traffic_table_dialog.cpp
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "traffic_table_dialog.h"
+#include <ui_traffic_table_dialog.h>
+
+#include <epan/addr_resolv.h>
+#include <epan/prefs.h>
+
+#include "ui/recent.h"
+
+#include "progress_frame.h"
+#include "main_application.h"
+
+#include <ui/qt/widgets/traffic_tab.h>
+#include <ui/qt/widgets/traffic_types_list.h>
+
+#include <QCheckBox>
+#include <QClipboard>
+#include <QContextMenuEvent>
+#include <QDialogButtonBox>
+#include <QList>
+#include <QMap>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QTabWidget>
+#include <QTreeWidget>
+#include <QTextStream>
+#include <QToolButton>
+#include <QTreeView>
+
+TrafficTableDialog::TrafficTableDialog(QWidget &parent, CaptureFile &cf, const QString &table_name) :
+ WiresharkDialog(parent, cf),
+ ui(new Ui::TrafficTableDialog)
+{
+ ui->setupUi(this);
+ loadGeometry(parent.width(), parent.height() * 3 / 4);
+
+ ui->absoluteTimeCheckBox->hide();
+ setWindowSubtitle(QString("%1s").arg(table_name));
+ ui->grpSettings->setTitle(QString("%1 Settings").arg(table_name));
+
+ copy_bt_ = buttonBox()->addButton(tr("Copy"), QDialogButtonBox::ActionRole);
+ copy_bt_->setMenu(ui->trafficTab->createCopyMenu(copy_bt_));
+
+ if (cf.displayFilter().length() > 0) {
+ ui->displayFilterCheckBox->setChecked(true);
+ ui->trafficTab->setFilter(cf.displayFilter());
+ }
+
+ ui->trafficTab->setFocus();
+ ui->trafficTab->useNanosecondTimestamps(cf.timestampPrecision() == WTAP_TSPREC_NSEC);
+ connect(ui->displayFilterCheckBox, &QCheckBox::toggled, this, &TrafficTableDialog::displayFilterCheckBoxToggled);
+ connect(ui->trafficList, &TrafficTypesList::protocolsChanged, ui->trafficTab, &TrafficTab::setOpenTabs);
+ connect(ui->trafficTab, &TrafficTab::tabsChanged, ui->trafficList, &TrafficTypesList::selectProtocols);
+
+ connect(mainApp, SIGNAL(addressResolutionChanged()), this, SLOT(currentTabChanged()));
+ connect(ui->trafficTab, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged()));
+ connect(&cap_file_, SIGNAL(captureEvent(CaptureEvent)), this, SLOT(captureEvent(CaptureEvent)));
+
+ connect(ui->absoluteTimeCheckBox, &QCheckBox::toggled, ui->trafficTab, &TrafficTab::useAbsoluteTime);
+ connect(ui->trafficTab, &TrafficTab::retapRequired, &cap_file_, &CaptureFile::delayedRetapPackets);
+
+ connect(ui->trafficListSearch, &QLineEdit::textChanged, ui->trafficList, &TrafficTypesList::filterList);
+ connect(ui->trafficList, &TrafficTypesList::clearFilterList, ui->trafficListSearch, &QLineEdit::clear);
+
+ QPushButton *close_bt = ui->buttonBox->button(QDialogButtonBox::Close);
+ if (close_bt)
+ close_bt->setDefault(true);
+
+ addProgressFrame(&parent);
+}
+
+TrafficTableDialog::~TrafficTableDialog()
+{
+ delete ui;
+}
+
+void TrafficTableDialog::addProgressFrame(QObject *parent)
+{
+ ProgressFrame::addToButtonBox(ui->buttonBox, parent);
+}
+
+QDialogButtonBox *TrafficTableDialog::buttonBox() const
+{
+ return ui->btnBoxSettings;
+}
+
+QCheckBox *TrafficTableDialog::displayFilterCheckBox() const
+{
+ return ui->displayFilterCheckBox;
+}
+
+QCheckBox *TrafficTableDialog::absoluteTimeCheckBox() const
+{
+ return ui->absoluteTimeCheckBox;
+}
+
+TrafficTab *TrafficTableDialog::trafficTab() const
+{
+ return ui->trafficTab;
+}
+
+TrafficTypesList *TrafficTableDialog::trafficList() const
+{
+ return ui->trafficList;
+}
+
+void TrafficTableDialog::currentTabChanged()
+{
+ bool has_resolution = ui->trafficTab->hasNameResolution();
+ copy_bt_->setMenu(ui->trafficTab->createCopyMenu(copy_bt_));
+
+ ui->nameResolutionCheckBox->setEnabled(has_resolution);
+ if (! has_resolution) {
+ ui->nameResolutionCheckBox->setChecked(false);
+ ui->trafficTab->setNameResolution(false);
+ }
+}
+
+void TrafficTableDialog::on_nameResolutionCheckBox_toggled(bool checked)
+{
+ ui->trafficTab->setNameResolution(checked);
+}
+
+void TrafficTableDialog::displayFilterCheckBoxToggled(bool checked)
+{
+ if (!cap_file_.isValid()) {
+ return;
+ }
+
+ if (checked)
+ trafficTab()->setFilter(cap_file_.displayFilter());
+ else
+ trafficTab()->setFilter(QString());
+
+ cap_file_.retapPackets();
+}
+
+void TrafficTableDialog::captureEvent(CaptureEvent e)
+{
+ if (e.captureContext() == CaptureEvent::Retap)
+ {
+ switch (e.eventType())
+ {
+ case CaptureEvent::Started:
+ ui->displayFilterCheckBox->setEnabled(false);
+ break;
+ case CaptureEvent::Finished:
+ ui->displayFilterCheckBox->setEnabled(true);
+ break;
+ default:
+ break;
+ }
+ }
+
+}