diff options
author | Michael Mann <mmann78@netscape.net> | 2017-12-19 08:32:23 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-12-19 21:00:24 +0000 |
commit | 8521dbbe67ddc7947e6e16b69c7fb4430abbc938 (patch) | |
tree | 87026fc767582cb035e6eaa9950956320080a1bc /ui/qt/models/dissector_tables_model.h | |
parent | c781cc38fd9fd76ab4b46940fd7c3f250c7bb591 (diff) |
Convert Dissector Tables dialog to use model
Now with searchability!
Change-Id: I6ab4e89d4080d3599d522807d39de80cc46e7360
Reviewed-on: https://code.wireshark.org/review/24898
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui/qt/models/dissector_tables_model.h')
-rw-r--r-- | ui/qt/models/dissector_tables_model.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/ui/qt/models/dissector_tables_model.h b/ui/qt/models/dissector_tables_model.h new file mode 100644 index 0000000000..550285025e --- /dev/null +++ b/ui/qt/models/dissector_tables_model.h @@ -0,0 +1,87 @@ +/* dissector_tables_model.h + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef DISSECTOR_TABLES_MODEL_H +#define DISSECTOR_TABLES_MODEL_H + +#include <config.h> + +#include <QAbstractItemModel> +#include <QSortFilterProxyModel> + +class DissectorTablesItem; + +class DissectorTablesModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + explicit DissectorTablesModel(QObject * parent = Q_NULLPTR); + virtual ~DissectorTablesModel(); + + enum DissectorTablesColumn { + colTableName = 0, + colShortName, + colLast + }; + + QModelIndex index(int row, int column, + const QModelIndex & = QModelIndex()) const; + QModelIndex parent(const QModelIndex &) const; + QVariant data(const QModelIndex &index, int role) const; + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + + void populate(); + +private: + DissectorTablesItem* root_; +}; + +class DissectorTablesProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT +public: + + explicit DissectorTablesProxyModel(QObject * parent = Q_NULLPTR); + + virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + + void adjustHeader(const QModelIndex ¤tIndex); + void setFilter(const QString& filter); + +protected: + bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const; + bool filterAcceptItem(DissectorTablesItem& item) const; + +private: + + QString tableName_; + QString shortName_; + QString filter_; +}; + +#endif // DISSECTOR_TABLES_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: + */ |