Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / ui / qt / traffic_table_dialog.cpp
blob205e3e7373bb733a0b0c9e018b177bb55d01a87e
1 /* traffic_table_dialog.cpp
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
10 #include "traffic_table_dialog.h"
11 #include <ui_traffic_table_dialog.h>
13 #include <epan/addr_resolv.h>
14 #include <epan/prefs.h>
16 #include "ui/recent.h"
18 #include "progress_frame.h"
19 #include "main_application.h"
21 #include <ui/qt/widgets/traffic_tab.h>
22 #include <ui/qt/widgets/traffic_types_list.h>
24 #include <QCheckBox>
25 #include <QClipboard>
26 #include <QContextMenuEvent>
27 #include <QDialogButtonBox>
28 #include <QList>
29 #include <QMap>
30 #include <QMessageBox>
31 #include <QPushButton>
32 #include <QTabWidget>
33 #include <QTreeWidget>
34 #include <QTextStream>
35 #include <QToolButton>
36 #include <QTreeView>
38 TrafficTableDialog::TrafficTableDialog(QWidget &parent, CaptureFile &cf, const QString &table_name) :
39 WiresharkDialog(parent, cf),
40 ui(new Ui::TrafficTableDialog)
42 ui->setupUi(this);
43 loadGeometry(parent.width(), parent.height() * 3 / 4);
45 ui->absoluteTimeCheckBox->hide();
46 setWindowSubtitle(QStringLiteral("%1s").arg(table_name));
47 ui->grpSettings->setTitle(QStringLiteral("%1 Settings").arg(table_name));
49 copy_bt_ = buttonBox()->addButton(tr("Copy"), QDialogButtonBox::ActionRole);
50 copy_bt_->setMenu(ui->trafficTab->createCopyMenu(copy_bt_));
52 if (cf.displayFilter().length() > 0) {
53 ui->displayFilterCheckBox->setChecked(true);
54 ui->trafficTab->setFilter(cf.displayFilter());
57 ui->trafficTab->setFocus();
58 ui->trafficTab->useNanosecondTimestamps(cf.timestampPrecision() == WTAP_TSPREC_NSEC);
59 connect(ui->displayFilterCheckBox, &QCheckBox::toggled, this, &TrafficTableDialog::displayFilterCheckBoxToggled);
60 connect(ui->trafficList, &TrafficTypesList::protocolsChanged, ui->trafficTab, &TrafficTab::setOpenTabs);
61 connect(ui->trafficTab, &TrafficTab::tabsChanged, ui->trafficList, &TrafficTypesList::selectProtocols);
63 connect(mainApp, SIGNAL(addressResolutionChanged()), this, SLOT(currentTabChanged()));
64 connect(ui->trafficTab, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged()));
65 connect(&cap_file_, SIGNAL(captureEvent(CaptureEvent)), this, SLOT(captureEvent(CaptureEvent)));
67 connect(ui->absoluteTimeCheckBox, &QCheckBox::toggled, ui->trafficTab, &TrafficTab::useAbsoluteTime);
68 connect(ui->trafficTab, &TrafficTab::retapRequired, &cap_file_, &CaptureFile::delayedRetapPackets);
70 connect(ui->trafficListSearch, &QLineEdit::textChanged, ui->trafficList, &TrafficTypesList::filterList);
71 connect(ui->trafficList, &TrafficTypesList::clearFilterList, ui->trafficListSearch, &QLineEdit::clear);
73 connect(mainApp->mainWindow(), SIGNAL(displayFilterSuccess(bool)), this, SLOT(displayFilterSuccess(bool)));
75 QPushButton *close_bt = ui->buttonBox->button(QDialogButtonBox::Close);
76 if (close_bt)
77 close_bt->setDefault(true);
79 addProgressFrame(&parent);
82 TrafficTableDialog::~TrafficTableDialog()
84 delete ui;
87 void TrafficTableDialog::addProgressFrame(QObject *parent)
89 ProgressFrame::addToButtonBox(ui->buttonBox, parent);
92 QDialogButtonBox *TrafficTableDialog::buttonBox() const
94 return ui->btnBoxSettings;
97 QVBoxLayout *TrafficTableDialog::getVerticalLayout() const
99 return ui->verticalLayout;
102 QCheckBox *TrafficTableDialog::displayFilterCheckBox() const
104 return ui->displayFilterCheckBox;
107 QCheckBox *TrafficTableDialog::absoluteTimeCheckBox() const
109 return ui->absoluteTimeCheckBox;
112 TrafficTab *TrafficTableDialog::trafficTab() const
114 return ui->trafficTab;
117 TrafficTypesList *TrafficTableDialog::trafficList() const
119 return ui->trafficList;
122 void TrafficTableDialog::currentTabChanged()
124 bool has_resolution = ui->trafficTab->hasNameResolution();
125 copy_bt_->setMenu(ui->trafficTab->createCopyMenu(copy_bt_));
127 ui->nameResolutionCheckBox->setEnabled(has_resolution);
128 if (! has_resolution) {
129 ui->nameResolutionCheckBox->setChecked(false);
130 ui->trafficTab->setNameResolution(false);
134 void TrafficTableDialog::aggregationSummaryOnlyCheckBoxToggled(bool checked)
136 if (!cap_file_.isValid()) {
137 return;
140 ATapDataModel * atdm = trafficTab()->dataModelForTabIndex(1);
141 if(atdm) {
142 atdm->updateFlags(checked);
145 cap_file_.retapPackets();
148 void TrafficTableDialog::on_nameResolutionCheckBox_toggled(bool checked)
150 ui->trafficTab->setNameResolution(checked);
153 void TrafficTableDialog::displayFilterCheckBoxToggled(bool checked)
155 displayFilterUpdate(checked);
158 void TrafficTableDialog::displayFilterUpdate(bool set_filter)
160 if (!cap_file_.isValid()) {
161 return;
164 if (set_filter)
165 trafficTab()->setFilter(cap_file_.displayFilter());
166 else
167 trafficTab()->setFilter(QString());
169 cap_file_.retapPackets();
172 void TrafficTableDialog::displayFilterSuccess(bool success)
174 if (success && ui->displayFilterCheckBox->isEnabled() && ui->displayFilterCheckBox->isChecked()) {
175 displayFilterUpdate(true);
179 void TrafficTableDialog::captureEvent(CaptureEvent e)
181 if (e.captureContext() == CaptureEvent::Retap)
183 switch (e.eventType())
185 case CaptureEvent::Started:
186 ui->displayFilterCheckBox->setEnabled(false);
187 break;
188 case CaptureEvent::Finished:
189 ui->displayFilterCheckBox->setEnabled(true);
190 break;
191 default:
192 break;