2015-07-21 17:32:42 +00:00
|
|
|
/* enabled_protocols_dialog.cpp
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-04-30 07:47:58 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2015-07-21 17:32:42 +00:00
|
|
|
|
|
|
|
#include "enabled_protocols_dialog.h"
|
2016-06-12 21:00:21 +00:00
|
|
|
#include <ui_enabled_protocols_dialog.h>
|
2015-07-21 17:32:42 +00:00
|
|
|
|
2017-12-17 02:51:33 +00:00
|
|
|
#include <QElapsedTimer>
|
2015-07-21 17:32:42 +00:00
|
|
|
|
|
|
|
#include <epan/prefs.h>
|
|
|
|
|
|
|
|
#include "wireshark_application.h"
|
|
|
|
|
|
|
|
EnabledProtocolsDialog::EnabledProtocolsDialog(QWidget *parent) :
|
2016-02-28 18:23:20 +00:00
|
|
|
GeometryStateDialog(parent),
|
2017-12-17 02:51:33 +00:00
|
|
|
ui(new Ui::EnabledProtocolsDialog),
|
|
|
|
enabled_protocols_model_(new EnabledProtocolsModel()),
|
|
|
|
proxyModel_(new EnabledProtocolsProxyModel(this))
|
2015-07-21 17:32:42 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2016-02-28 18:23:20 +00:00
|
|
|
loadGeometry();
|
2015-07-21 17:32:42 +00:00
|
|
|
|
2017-12-17 02:51:33 +00:00
|
|
|
proxyModel_->setSourceModel(enabled_protocols_model_);
|
|
|
|
ui->protocol_tree_->setModel(proxyModel_);
|
2015-07-24 16:53:09 +00:00
|
|
|
|
2017-12-17 02:51:33 +00:00
|
|
|
setWindowTitle(wsApp->windowTitleString(tr("Enabled Protocols")));
|
2015-07-21 17:32:42 +00:00
|
|
|
|
2015-07-24 16:53:09 +00:00
|
|
|
// Some protocols have excessively long names. Instead of calling
|
|
|
|
// resizeColumnToContents, pick a reasonable-ish em width and apply it.
|
|
|
|
int one_em = ui->protocol_tree_->fontMetrics().height();
|
2017-12-17 02:51:33 +00:00
|
|
|
ui->protocol_tree_->setColumnWidth(EnabledProtocolsModel::colProtocol, one_em * 18);
|
2015-07-21 17:32:42 +00:00
|
|
|
|
2019-12-20 05:57:04 +00:00
|
|
|
ui->cmbSearchType->addItem(tr("Everywhere"), QVariant::fromValue(EnabledProtocolsProxyModel::EveryWhere));
|
|
|
|
ui->cmbSearchType->addItem(tr("Only Protocols"), QVariant::fromValue(EnabledProtocolsProxyModel::OnlyProtocol));
|
|
|
|
ui->cmbSearchType->addItem(tr("Only Description"), QVariant::fromValue(EnabledProtocolsProxyModel::OnlyDescription));
|
|
|
|
ui->cmbSearchType->addItem(tr("Only enabled protocols"), QVariant::fromValue(EnabledProtocolsProxyModel::EnabledItems));
|
|
|
|
ui->cmbSearchType->addItem(tr("Only disabled protocols"), QVariant::fromValue(EnabledProtocolsProxyModel::DisabledItems));
|
2019-08-29 09:26:34 +00:00
|
|
|
|
2019-12-20 05:57:04 +00:00
|
|
|
ui->cmbProtocolType->addItem(tr("any protocol"), QVariant::fromValue(EnabledProtocolItem::Any));
|
|
|
|
ui->cmbProtocolType->addItem(tr("non-heuristic protocols"), QVariant::fromValue(EnabledProtocolItem::Standard));
|
|
|
|
ui->cmbProtocolType->addItem(tr("heuristic protocols"), QVariant::fromValue(EnabledProtocolItem::Heuristic));
|
2019-09-03 15:11:25 +00:00
|
|
|
|
2019-10-28 16:05:41 +00:00
|
|
|
fillTree();
|
2015-07-21 17:32:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EnabledProtocolsDialog::~EnabledProtocolsDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
2017-12-17 02:51:33 +00:00
|
|
|
delete proxyModel_;
|
|
|
|
delete enabled_protocols_model_;
|
2015-07-21 17:32:42 +00:00
|
|
|
}
|
|
|
|
|
2017-12-17 02:51:33 +00:00
|
|
|
void EnabledProtocolsDialog::fillTree()
|
2015-07-21 17:32:42 +00:00
|
|
|
{
|
2017-12-17 02:51:33 +00:00
|
|
|
enabled_protocols_model_->populate();
|
|
|
|
//it's recommended to sort after list is populated
|
|
|
|
proxyModel_->sort(EnabledProtocolsModel::colProtocol);
|
|
|
|
ui->protocol_tree_->expandAll();
|
2015-07-21 17:32:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EnabledProtocolsDialog::on_invert_button__clicked()
|
|
|
|
{
|
2019-08-29 09:26:34 +00:00
|
|
|
proxyModel_->setItemsEnable(EnabledProtocolsProxyModel::Invert);
|
|
|
|
ui->protocol_tree_->expandAll();
|
2015-07-21 17:32:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EnabledProtocolsDialog::on_enable_all_button__clicked()
|
|
|
|
{
|
2019-08-29 09:26:34 +00:00
|
|
|
proxyModel_->setItemsEnable(EnabledProtocolsProxyModel::Enable);
|
|
|
|
ui->protocol_tree_->expandAll();
|
2015-07-21 17:32:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EnabledProtocolsDialog::on_disable_all_button__clicked()
|
|
|
|
{
|
2019-08-29 09:26:34 +00:00
|
|
|
proxyModel_->setItemsEnable(EnabledProtocolsProxyModel::Disable);
|
|
|
|
ui->protocol_tree_->expandAll();
|
2015-07-21 17:32:42 +00:00
|
|
|
}
|
|
|
|
|
2019-08-29 09:26:34 +00:00
|
|
|
void EnabledProtocolsDialog::searchFilterChange()
|
2015-07-21 17:32:42 +00:00
|
|
|
{
|
2019-08-29 09:26:34 +00:00
|
|
|
EnabledProtocolsProxyModel::SearchType type = EnabledProtocolsProxyModel::EveryWhere;
|
2019-09-03 15:11:25 +00:00
|
|
|
EnabledProtocolItem::EnableProtocolType protocol = EnabledProtocolItem::Any;
|
2019-08-29 09:26:34 +00:00
|
|
|
QString search_re = ui->search_line_edit_->text();
|
|
|
|
|
2019-11-17 19:02:20 +00:00
|
|
|
if (ui->cmbSearchType->currentData().canConvert<EnabledProtocolsProxyModel::SearchType>())
|
2019-08-29 09:26:34 +00:00
|
|
|
type = ui->cmbSearchType->currentData().value<EnabledProtocolsProxyModel::SearchType>();
|
|
|
|
|
2019-11-17 19:02:20 +00:00
|
|
|
if (ui->cmbProtocolType->currentData().canConvert<EnabledProtocolItem::EnableProtocolType>())
|
2019-09-03 15:11:25 +00:00
|
|
|
protocol = ui->cmbProtocolType->currentData().value<EnabledProtocolItem::EnableProtocolType>();
|
|
|
|
|
|
|
|
proxyModel_->setFilter(search_re, type, protocol);
|
2018-01-04 21:57:01 +00:00
|
|
|
/* If items are filtered out, then filtered back in, the tree remains collapsed
|
|
|
|
Force an expansion */
|
|
|
|
ui->protocol_tree_->expandAll();
|
2015-07-21 17:32:42 +00:00
|
|
|
}
|
|
|
|
|
2019-08-29 09:26:34 +00:00
|
|
|
void EnabledProtocolsDialog::on_search_line_edit__textChanged(const QString &)
|
|
|
|
{
|
|
|
|
searchFilterChange();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EnabledProtocolsDialog::on_cmbSearchType_currentIndexChanged(int)
|
|
|
|
{
|
|
|
|
searchFilterChange();
|
|
|
|
}
|
|
|
|
|
2019-09-03 15:11:25 +00:00
|
|
|
void EnabledProtocolsDialog::on_cmbProtocolType_currentIndexChanged(int)
|
|
|
|
{
|
|
|
|
searchFilterChange();
|
|
|
|
}
|
|
|
|
|
2015-07-21 17:32:42 +00:00
|
|
|
void EnabledProtocolsDialog::on_buttonBox_accepted()
|
|
|
|
{
|
2017-12-17 02:51:33 +00:00
|
|
|
enabled_protocols_model_->applyChanges();
|
2015-07-21 17:32:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EnabledProtocolsDialog::on_buttonBox_helpRequested()
|
|
|
|
{
|
|
|
|
wsApp->helpTopicAction(HELP_ENABLED_PROTOCOLS_DIALOG);
|
|
|
|
}
|