Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
astringlist_list_model.h
Go to the documentation of this file.
1
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
22class AStringListListModel : public QAbstractTableModel
23{
24 Q_OBJECT
25public:
26 explicit AStringListListModel(QObject * parent = Q_NULLPTR);
27 virtual ~AStringListListModel();
28
29 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
30 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
31 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
32 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
33
34 //
35 // This is not protected because we may need to invoke it from
36 // a wmem_map_foreach() callback implemented as an extern "C"
37 // static member function of a subclass. wmem_map_foreach() is
38 // passed, as the user data, a pointer to the class instance to
39 // which we want to append rows.
40 //
41 virtual void appendRow(const QStringList &, const QString & row_tooltip = QString(), const QModelIndex &parent = QModelIndex());
42
43protected:
44 virtual QStringList headerColumns() const = 0;
45
46private:
47 QList<QStringList> display_data_;
48 QStringList tooltip_data_;
49};
50
51class AStringListListSortFilterProxyModel : public QSortFilterProxyModel
52{
53 Q_OBJECT
54public:
55
56 enum AStringListListFilterType
57 {
58 FilterByContains = 0,
59 FilterByStart,
60 FilterByEquivalent,
61 FilterNone
62 };
63 Q_ENUM(AStringListListFilterType)
64
65 explicit AStringListListSortFilterProxyModel(QObject * parent = Q_NULLPTR);
66
67 virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
68 virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
69 virtual bool filterAcceptsColumn(int column, const QModelIndex &sourceParent) const;
70
71 void setFilterType(AStringListListFilterType type, int column = -1);
72
73 void setColumnToFilter(int);
74 void setColumnsToFilter(QList<int>);
75 void clearColumnsToFilter();
76
77 void clearHiddenColumns();
78 void setColumnToHide(int col);
79
80 void clearNumericColumns();
81 void setColumnAsNumeric(int col);
82
83public slots:
84 void setFilter(const QString&);
85
86private:
87 QString filter_;
88 QMap<int, AStringListListFilterType> types_;
89 QList<int> columnsToFilter_;
90 QList<int> hiddenColumns_;
91 QList<int> numericColumns_;
92};
93
94class AStringListListUrlProxyModel : public QIdentityProxyModel
95{
96public:
97 explicit AStringListListUrlProxyModel(QObject * parent = Q_NULLPTR);
98
99 void setUrlColumn(int);
100 bool isUrlColumn(int) const;
101
102 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
103
104private:
105 QList<int> urls_;
106};
107
108#endif // ASTRINGLIST_LIST_MODEL_H
Definition astringlist_list_model.h:23
Definition astringlist_list_model.h:52
Definition astringlist_list_model.h:95