![Michael Mann](/assets/img/avatar_default.png)
Also have search file search name, filter and description columns Change-Id: Id519c5b1deb4a80e3b95437cf2e6d3e9510e4b11 Reviewed-on: https://code.wireshark.org/review/24857 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
120 lines
2.9 KiB
C++
120 lines
2.9 KiB
C++
/* supported_protocols_model.h
|
|
*
|
|
* Wireshark - Network traffic analyzer
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
* Copyright 1998 Gerald Combs
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
*/
|
|
|
|
#ifndef SUPPORTED_PROTOCOLS_MODEL_H
|
|
#define SUPPORTED_PROTOCOLS_MODEL_H
|
|
|
|
#include <config.h>
|
|
|
|
#include <epan/proto.h>
|
|
|
|
#include <QAbstractItemModel>
|
|
#include <QSortFilterProxyModel>
|
|
|
|
class SupportedProtocolsItem
|
|
{
|
|
public:
|
|
SupportedProtocolsItem(protocol_t* proto, const char *name, const char* filter, ftenum_t ftype, const char* descr, SupportedProtocolsItem* parent);
|
|
virtual ~SupportedProtocolsItem();
|
|
|
|
protocol_t* protocol() const {return proto_; }
|
|
QString name() const { return name_; }
|
|
ftenum_t type() const {return ftype_; }
|
|
QString filter() const { return filter_; }
|
|
QString description() const { return descr_; }
|
|
|
|
void appendChild(SupportedProtocolsItem* child);
|
|
SupportedProtocolsItem* child(int row);
|
|
int childCount() const;
|
|
int row() const;
|
|
SupportedProtocolsItem* parentItem() {return parent_; }
|
|
|
|
private:
|
|
SupportedProtocolsItem* parent_;
|
|
QList<SupportedProtocolsItem*> childItems_;
|
|
|
|
protocol_t* proto_;
|
|
QString name_;
|
|
QString filter_;
|
|
ftenum_t ftype_;
|
|
QString descr_;
|
|
};
|
|
|
|
|
|
class SupportedProtocolsModel : public QAbstractItemModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit SupportedProtocolsModel(QObject * parent = Q_NULLPTR);
|
|
virtual ~SupportedProtocolsModel();
|
|
|
|
enum SupportedProtocolsColumn {
|
|
colName = 0,
|
|
colFilter,
|
|
colType,
|
|
colDescription,
|
|
colLast
|
|
};
|
|
|
|
int fieldCount() {return field_count_;}
|
|
|
|
QModelIndex index(int row, int column,
|
|
const QModelIndex & = QModelIndex()) const;
|
|
QModelIndex parent(const QModelIndex &) const;
|
|
QVariant data(const QModelIndex &index, int role) const;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation,
|
|
int role = Qt::DisplayRole) const;
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
void populate();
|
|
|
|
private:
|
|
SupportedProtocolsItem* root_;
|
|
int field_count_;
|
|
};
|
|
|
|
class SupportedProtocolsProxyModel : public QSortFilterProxyModel
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
|
|
explicit SupportedProtocolsProxyModel(QObject * parent = Q_NULLPTR);
|
|
|
|
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
|
|
|
void setFilter(const QString& filter);
|
|
|
|
protected:
|
|
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
|
|
bool filterAcceptItem(SupportedProtocolsItem& item) const;
|
|
|
|
private:
|
|
|
|
QString filter_;
|
|
};
|
|
|
|
#endif // SUPPORTED_PROTOCOLS_MODEL_H
|
|
|
|
/*
|
|
* Editor modelines
|
|
*
|
|
* Local Variables:
|
|
* c-basic-offset: 4
|
|
* tab-width: 8
|
|
* indent-tabs-mode: nil
|
|
* End:
|
|
*
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
*/
|