Kerberos: add kerberos_inject_longterm_key() helper function
[wireshark-sm.git] / ui / qt / enabled_protocols_dialog.cpp
blobe503991d0ff901ca02acb49a3f47e61108f8c60e
1 /* enabled_protocols_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 "enabled_protocols_dialog.h"
11 #include <ui_enabled_protocols_dialog.h>
13 #include <QElapsedTimer>
15 #include <epan/prefs.h>
17 #include "main_application.h"
19 EnabledProtocolsDialog::EnabledProtocolsDialog(QWidget *parent) :
20 GeometryStateDialog(parent),
21 ui(new Ui::EnabledProtocolsDialog),
22 enabled_protocols_model_(new EnabledProtocolsModel()),
23 proxyModel_(new EnabledProtocolsProxyModel(this))
25 ui->setupUi(this);
26 loadGeometry();
28 proxyModel_->setSourceModel(enabled_protocols_model_);
29 ui->protocol_tree_->setModel(proxyModel_);
31 setWindowTitle(mainApp->windowTitleString(tr("Enabled Protocols")));
33 // Some protocols have excessively long names. Instead of calling
34 // resizeColumnToContents, pick a reasonable-ish em width and apply it.
35 int one_em = ui->protocol_tree_->fontMetrics().height();
36 ui->protocol_tree_->setColumnWidth(EnabledProtocolsModel::colProtocol, one_em * 18);
38 ui->cmbSearchType->addItem(tr("Everywhere"), QVariant::fromValue(EnabledProtocolsProxyModel::EveryWhere));
39 ui->cmbSearchType->addItem(tr("Only Protocols"), QVariant::fromValue(EnabledProtocolsProxyModel::OnlyProtocol));
40 ui->cmbSearchType->addItem(tr("Only Description"), QVariant::fromValue(EnabledProtocolsProxyModel::OnlyDescription));
41 ui->cmbSearchType->addItem(tr("Only enabled protocols"), QVariant::fromValue(EnabledProtocolsProxyModel::EnabledItems));
42 ui->cmbSearchType->addItem(tr("Only disabled protocols"), QVariant::fromValue(EnabledProtocolsProxyModel::DisabledItems));
44 ui->cmbProtocolType->addItem(tr("any protocol"), QVariant::fromValue(EnabledProtocolItem::Any));
45 ui->cmbProtocolType->addItem(tr("non-heuristic protocols"), QVariant::fromValue(EnabledProtocolItem::Standard));
46 ui->cmbProtocolType->addItem(tr("heuristic protocols"), QVariant::fromValue(EnabledProtocolItem::Heuristic));
48 fillTree();
51 EnabledProtocolsDialog::~EnabledProtocolsDialog()
53 delete ui;
54 delete proxyModel_;
55 delete enabled_protocols_model_;
58 void EnabledProtocolsDialog::fillTree()
60 enabled_protocols_model_->populate();
61 //it's recommended to sort after list is populated
62 proxyModel_->sort(EnabledProtocolsModel::colProtocol);
63 ui->protocol_tree_->expandAll();
66 void EnabledProtocolsDialog::on_invert_button__clicked()
68 proxyModel_->setItemsEnable(EnabledProtocolsProxyModel::Invert);
69 ui->protocol_tree_->expandAll();
72 void EnabledProtocolsDialog::on_enable_all_button__clicked()
74 proxyModel_->setItemsEnable(EnabledProtocolsProxyModel::Enable);
75 ui->protocol_tree_->expandAll();
78 void EnabledProtocolsDialog::on_disable_all_button__clicked()
80 proxyModel_->setItemsEnable(EnabledProtocolsProxyModel::Disable);
81 ui->protocol_tree_->expandAll();
84 void EnabledProtocolsDialog::searchFilterChange()
86 EnabledProtocolsProxyModel::SearchType type = EnabledProtocolsProxyModel::EveryWhere;
87 EnabledProtocolItem::EnableProtocolType protocol = EnabledProtocolItem::Any;
88 QString search_re = ui->search_line_edit_->text();
90 if (ui->cmbSearchType->currentData().canConvert<EnabledProtocolsProxyModel::SearchType>())
91 type = ui->cmbSearchType->currentData().value<EnabledProtocolsProxyModel::SearchType>();
93 if (ui->cmbProtocolType->currentData().canConvert<EnabledProtocolItem::EnableProtocolType>())
94 protocol = ui->cmbProtocolType->currentData().value<EnabledProtocolItem::EnableProtocolType>();
96 proxyModel_->setFilter(search_re, type, protocol);
97 /* If items are filtered out, then filtered back in, the tree remains collapsed
98 Force an expansion */
99 ui->protocol_tree_->expandAll();
102 void EnabledProtocolsDialog::on_search_line_edit__textChanged(const QString &)
104 searchFilterChange();
107 void EnabledProtocolsDialog::on_cmbSearchType_currentIndexChanged(int)
109 searchFilterChange();
112 void EnabledProtocolsDialog::on_cmbProtocolType_currentIndexChanged(int)
114 searchFilterChange();
117 void EnabledProtocolsDialog::on_buttonBox_accepted()
119 enabled_protocols_model_->applyChanges();
122 void EnabledProtocolsDialog::on_buttonBox_helpRequested()
124 mainApp->helpTopicAction(HELP_ENABLED_PROTOCOLS_DIALOG);