2015-10-01 17:18:56 +00:00
|
|
|
/* supported_protocols_dialog.cpp
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2017-12-14 18:44:05 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2015-10-01 17:18:56 +00:00
|
|
|
*/
|
|
|
|
|
2017-12-14 18:44:05 +00:00
|
|
|
#include "config.h"
|
2015-10-17 02:02:29 +00:00
|
|
|
|
2015-10-01 17:18:56 +00:00
|
|
|
#include "supported_protocols_dialog.h"
|
2016-06-12 21:00:21 +00:00
|
|
|
#include <ui_supported_protocols_dialog.h>
|
2015-10-01 17:18:56 +00:00
|
|
|
|
|
|
|
#include <QElapsedTimer>
|
|
|
|
|
|
|
|
#include "wireshark_application.h"
|
|
|
|
|
|
|
|
SupportedProtocolsDialog::SupportedProtocolsDialog(QWidget *parent) :
|
2016-02-28 18:23:20 +00:00
|
|
|
GeometryStateDialog(parent),
|
2015-10-01 17:18:56 +00:00
|
|
|
ui(new Ui::SupportedProtocolsDialog),
|
2017-12-14 18:44:05 +00:00
|
|
|
supported_protocols_model_(new SupportedProtocolsModel()),
|
|
|
|
proxyModel_(new SupportedProtocolsProxyModel(this))
|
2015-10-01 17:18:56 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2017-12-14 18:44:05 +00:00
|
|
|
|
|
|
|
proxyModel_->setSourceModel(supported_protocols_model_);
|
|
|
|
ui->supportedProtocolsTreeView->setModel(proxyModel_);
|
|
|
|
|
|
|
|
//always sort by protocol/field name
|
|
|
|
proxyModel_->sort(SupportedProtocolsModel::colName);
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
loadGeometry(parent->width() * 3 / 4, parent->height());
|
2017-09-26 11:14:02 +00:00
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
2017-12-14 18:44:05 +00:00
|
|
|
|
2015-10-01 17:18:56 +00:00
|
|
|
setWindowTitle(wsApp->windowTitleString(tr("Supported Protocols")));
|
|
|
|
|
|
|
|
// Some of our names are unreasonably long.
|
|
|
|
int one_em = fontMetrics().height();
|
2017-12-14 18:44:05 +00:00
|
|
|
ui->supportedProtocolsTreeView->setColumnWidth(SupportedProtocolsModel::colName, one_em * 15);
|
|
|
|
ui->supportedProtocolsTreeView->setColumnWidth(SupportedProtocolsModel::colFilter, one_em * 10);
|
|
|
|
ui->supportedProtocolsTreeView->setColumnWidth(SupportedProtocolsModel::colType, one_em * 12);
|
|
|
|
ui->supportedProtocolsTreeView->setColumnWidth(SupportedProtocolsModel::colDescription, one_em * 30);
|
2015-10-01 17:18:56 +00:00
|
|
|
|
|
|
|
QTimer::singleShot(0, this, SLOT(fillTree()));
|
|
|
|
}
|
|
|
|
|
|
|
|
SupportedProtocolsDialog::~SupportedProtocolsDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
2017-12-14 18:44:05 +00:00
|
|
|
delete supported_protocols_model_;
|
|
|
|
delete proxyModel_;
|
2015-10-01 17:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SupportedProtocolsDialog::updateStatistics()
|
|
|
|
{
|
|
|
|
QLocale locale = QLocale::system();
|
|
|
|
QString hint = tr("%1 protocols, %2 fields.")
|
2017-12-14 18:44:05 +00:00
|
|
|
.arg(locale.toString(supported_protocols_model_->rowCount()))
|
|
|
|
.arg(locale.toString(supported_protocols_model_->fieldCount()));
|
2015-10-01 17:18:56 +00:00
|
|
|
ui->hintLabel->setText(hint);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SupportedProtocolsDialog::fillTree()
|
|
|
|
{
|
2017-12-14 18:44:05 +00:00
|
|
|
supported_protocols_model_->populate();
|
2015-10-01 17:18:56 +00:00
|
|
|
updateStatistics();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SupportedProtocolsDialog::on_searchLineEdit_textChanged(const QString &search_re)
|
|
|
|
{
|
2017-12-14 18:44:05 +00:00
|
|
|
proxyModel_->setFilter(search_re);
|
2015-10-01 17:18:56 +00:00
|
|
|
}
|