| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
astringlist_list_model.h
Go to the documentation of this file.
1
9
10#ifndef ASTRINGLIST_LIST_MODEL_H
11#define ASTRINGLIST_LIST_MODEL_H
12
13#include <config.h>
14
15#include <QAbstractTableModel>
16#include <QModelIndex>
17#include <QList>
18#include <QStringList>
19#include <QSortFilterProxyModel>
20#include <QIdentityProxyModel>
21
27 class AStringListListModel : public QAbstractTableModel
28{
29 Q_OBJECT
30 public:
33 explicit AStringListListModel(QObject * parent = Q_NULLPTR);
34
36 virtual ~AStringListListModel();
37
41 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
42
46 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
47
53 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
54
60 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
61
75 virtual void appendRow(const QStringList &row, const QString & row_tooltip = QString(), const QModelIndex &parent = QModelIndex());
76
77
78 protected:
81 virtual QStringList headerColumns() const = 0;
82
83 private:
84 QList<QStringList> display_data_;
85 QStringList tooltip_data_;
86};
87
90 class AStringListListSortFilterProxyModel : public QSortFilterProxyModel
91{
92 Q_OBJECT
93 public:
97 enum AStringListListFilterType {
98 FilterByContains = 0,
99 FilterByStart,
100 FilterByEquivalent,
101 FilterNone
102 };
103 Q_ENUM(AStringListListFilterType)
104
105
109 explicit AStringListListSortFilterProxyModel(QObject *parent = Q_NULLPTR);
110
118 virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
119
127 virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
128
136 virtual bool filterAcceptsColumn(int column, const QModelIndex &sourceParent) const override;
137
144 void setFilterType(AStringListListFilterType type, int column = -1);
145
151 void setColumnToFilter(int column);
152
157 void setColumnsToFilter(QList<int> columns);
158
162 void clearColumnsToFilter();
163
167 void clearHiddenColumns();
168
173 void setColumnToHide(int col);
174
178 void clearNumericColumns();
179
184 void setColumnAsNumeric(int col);
185
186 public slots:
191 void setFilter(const QString &filter);
192
193 private:
194 QString filter_;
195 QMap<int, AStringListListFilterType> types_;
196 QList<int> columnsToFilter_;
197 QList<int> hiddenColumns_;
198 QList<int> numericColumns_;
199};
200
201
205 class AStringListListUrlProxyModel : public QIdentityProxyModel
206{
207 public:
212 explicit AStringListListUrlProxyModel(QObject *parent = Q_NULLPTR);
213
218 void setUrlColumn(int column);
219
225 bool isUrlColumn(int column) const;
226
234 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
235
236 private:
237 QList<int> urls_;
238};
239
240#endif // ASTRINGLIST_LIST_MODEL_H
AStringListListModel::appendRow
virtual void appendRow(const QStringList &row, const QString &row_tooltip=QString(), const QModelIndex &parent=QModelIndex())
Append a row to the model.
Definition astringlist_list_model.cpp:26
AStringListListModel::columnCount
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const override
Return the number of columns in the model.
Definition astringlist_list_model.cpp:43
AStringListListModel::headerData
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Return header data for the given section, orientation, and role.
Definition astringlist_list_model.cpp:51
AStringListListModel::AStringListListModel
AStringListListModel(QObject *parent=Q_NULLPTR)
Construct an empty model.
Definition astringlist_list_model.cpp:20
AStringListListModel::~AStringListListModel
virtual ~AStringListListModel()
Destroy the model.
Definition astringlist_list_model.cpp:24
AStringListListModel::data
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Return data for the given index and role.
Definition astringlist_list_model.cpp:63
AStringListListModel::headerColumns
virtual QStringList headerColumns() const =0
Return the list of column header strings.
AStringListListModel::rowCount
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Return the number of rows in the model.
Definition astringlist_list_model.cpp:38
AStringListListSortFilterProxyModel::setFilterType
void setFilterType(AStringListListFilterType type, int column=-1)
Set the filter match mode for a column.
Definition astringlist_list_model.cpp:181
AStringListListSortFilterProxyModel::AStringListListSortFilterProxyModel
AStringListListSortFilterProxyModel(QObject *parent=Q_NULLPTR)
Construct an AStringListListSortFilterProxyModel.
Definition astringlist_list_model.cpp:86
AStringListListSortFilterProxyModel::clearNumericColumns
void clearNumericColumns()
Clear the list of numeric columns, reverting all to string sort.
Definition astringlist_list_model.cpp:306
AStringListListSortFilterProxyModel::setFilter
void setFilter(const QString &filter)
Set the filter string and trigger re-evaluation of visible rows.
Definition astringlist_list_model.cpp:109
AStringListListSortFilterProxyModel::filterAcceptsColumn
virtual bool filterAcceptsColumn(int column, const QModelIndex &sourceParent) const override
Determine whether a source column should be visible.
Definition astringlist_list_model.cpp:293
AStringListListSortFilterProxyModel::clearHiddenColumns
void clearHiddenColumns()
Clear the list of hidden columns, making all columns visible.
Definition astringlist_list_model.cpp:264
AStringListListSortFilterProxyModel::setColumnsToFilter
void setColumnsToFilter(QList< int > columns)
Set multiple columns to include in filter evaluation.
Definition astringlist_list_model.cpp:228
AStringListListSortFilterProxyModel::clearColumnsToFilter
void clearColumnsToFilter()
Clear the list of columns included in filter evaluation.
Definition astringlist_list_model.cpp:251
AStringListListSortFilterProxyModel::setColumnToHide
void setColumnToHide(int col)
Hide a column from the view.
Definition astringlist_list_model.cpp:277
AStringListListSortFilterProxyModel::filterAcceptsRow
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
Determine whether a source row passes the current filter.
Definition astringlist_list_model.cpp:141
AStringListListSortFilterProxyModel::setColumnToFilter
void setColumnToFilter(int column)
Set a single column to include in filter evaluation.
Definition astringlist_list_model.cpp:212
AStringListListSortFilterProxyModel::AStringListListFilterType
AStringListListFilterType
Text filter match mode applied to a column.
Definition astringlist_list_model.h:97
AStringListListSortFilterProxyModel::FilterByStart
@ FilterByStart
Definition astringlist_list_model.h:99
AStringListListSortFilterProxyModel::FilterNone
@ FilterNone
Definition astringlist_list_model.h:101
AStringListListSortFilterProxyModel::FilterByContains
@ FilterByContains
Definition astringlist_list_model.h:98
AStringListListSortFilterProxyModel::FilterByEquivalent
@ FilterByEquivalent
Definition astringlist_list_model.h:100
AStringListListSortFilterProxyModel::setColumnAsNumeric
void setColumnAsNumeric(int col)
Mark a column for numeric rather than lexicographic sorting.
Definition astringlist_list_model.cpp:319
AStringListListSortFilterProxyModel::lessThan
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
Compare two rows for sorting.
Definition astringlist_list_model.cpp:93
AStringListListUrlProxyModel::data
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Return data for index, adding URL role data for URL columns.
Definition astringlist_list_model.cpp:350
AStringListListUrlProxyModel::AStringListListUrlProxyModel
AStringListListUrlProxyModel(QObject *parent=Q_NULLPTR)
Construct an AStringListListUrlProxyModel.
Definition astringlist_list_model.cpp:335
AStringListListUrlProxyModel::isUrlColumn
bool isUrlColumn(int column) const
Return whether a column is registered as a URL column.
Definition astringlist_list_model.cpp:345
AStringListListUrlProxyModel::setUrlColumn
void setUrlColumn(int column)
Register a column whose values should be treated as URLs.
Definition astringlist_list_model.cpp:339