update epan/dissectors/pidl/drsuapi/drsuapi.idl from samba
[wireshark-sm.git] / ui / qt / traffic_table_dialog.cpp
blobf008bbb47bee150af677c502a19136345fada8c4
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 QPushButton *close_bt = ui->buttonBox->button(QDialogButtonBox::Close);
74 if (close_bt)
75 close_bt->setDefault(true);
77 addProgressFrame(&parent);
80 TrafficTableDialog::~TrafficTableDialog()
82 delete ui;
85 void TrafficTableDialog::addProgressFrame(QObject *parent)
87 ProgressFrame::addToButtonBox(ui->buttonBox, parent);
90 QDialogButtonBox *TrafficTableDialog::buttonBox() const
92 return ui->btnBoxSettings;
95 QVBoxLayout *TrafficTableDialog::getVerticalLayout() const
97 return ui->verticalLayout;
100 QCheckBox *TrafficTableDialog::displayFilterCheckBox() const
102 return ui->displayFilterCheckBox;
105 QCheckBox *TrafficTableDialog::absoluteTimeCheckBox() const
107 return ui->absoluteTimeCheckBox;
110 TrafficTab *TrafficTableDialog::trafficTab() const
112 return ui->trafficTab;
115 TrafficTypesList *TrafficTableDialog::trafficList() const
117 return ui->trafficList;
120 void TrafficTableDialog::currentTabChanged()
122 bool has_resolution = ui->trafficTab->hasNameResolution();
123 copy_bt_->setMenu(ui->trafficTab->createCopyMenu(copy_bt_));
125 ui->nameResolutionCheckBox->setEnabled(has_resolution);
126 if (! has_resolution) {
127 ui->nameResolutionCheckBox->setChecked(false);
128 ui->trafficTab->setNameResolution(false);
132 void TrafficTableDialog::aggregationSummaryOnlyCheckBoxToggled(bool checked)
134 if (!cap_file_.isValid()) {
135 return;
138 ATapDataModel * atdm = trafficTab()->dataModelForTabIndex(1);
139 if(atdm) {
140 atdm->updateFlags(checked);
143 cap_file_.retapPackets();
146 void TrafficTableDialog::on_nameResolutionCheckBox_toggled(bool checked)
148 ui->trafficTab->setNameResolution(checked);
151 void TrafficTableDialog::displayFilterCheckBoxToggled(bool checked)
153 if (!cap_file_.isValid()) {
154 return;
157 if (checked)
158 trafficTab()->setFilter(cap_file_.displayFilter());
159 else
160 trafficTab()->setFilter(QString());
162 cap_file_.retapPackets();
165 void TrafficTableDialog::captureEvent(CaptureEvent e)
167 if (e.captureContext() == CaptureEvent::Retap)
169 switch (e.eventType())
171 case CaptureEvent::Started:
172 ui->displayFilterCheckBox->setEnabled(false);
173 break;
174 case CaptureEvent::Finished:
175 ui->displayFilterCheckBox->setEnabled(true);
176 break;
177 default:
178 break;