| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
column_list_model.h
Go to the documentation of this file.
1
10#ifndef COLUMN_LIST_MODELS_H
11#define COLUMN_LIST_MODELS_H
12
13#include <QAbstractListModel>
14#include <QSortFilterProxyModel>
15#include <QStyledItemDelegate>
16#include <QSortFilterProxyModel>
17#include <QMimeData>
18
19 class ColumnProxyModel : public QSortFilterProxyModel
20{
21public:
22 ColumnProxyModel(QObject *parent = Q_NULLPTR);
23
24 void setShowDisplayedOnly(bool set);
25
26protected:
27 virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
28
29private:
30 bool showDisplayedOnly_;
31};
32
33 class ColumnTypeDelegate : public QStyledItemDelegate
34{
35public:
36 ColumnTypeDelegate(QObject * parent = Q_NULLPTR);
37
38 static QString displayDesc(char display);
39 static QString alignDesc(char xalign);
40
41 QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option,
42 const QModelIndex &index) const override;
43
44 void setEditorData(QWidget *editor, const QModelIndex &index) const override;
45 void setModelData(QWidget *editor, QAbstractItemModel *model,
46 const QModelIndex &index) const override;
47
48 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
49 const QModelIndex &index) const override;
50};
51
52 class ColumnListModel : public QAbstractTableModel
53{
54 Q_OBJECT
55
56public:
57 ColumnListModel(QObject * parent = Q_NULLPTR);
58
59 enum {
60 COL_DISPLAYED,
61 COL_TITLE,
62 COL_TYPE,
63 COL_FIELDS,
64 COL_OCCURRENCE,
65 COL_DISPLAY,
66 COL_WIDTH,
67 COL_XALIGN
68 };
69
70 enum {
71 OriginalType = Qt::UserRole,
72 DisplayedState
73 };
74
75 static bool displayEnabled(const QModelIndex &index, bool &displayStrings, bool &displayDetails);
76
77 void saveColumns();
78
79 void addEntry();
80 void deleteEntry(int row);
81 void reset();
82
83 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
84 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
85 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
86 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
87 virtual Qt::ItemFlags flags(const QModelIndex &index) const;
88
89 virtual QStringList mimeTypes() const;
90 virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
91 virtual Qt::DropActions supportedDropActions() const;
92 virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const;
93 virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
94
95 virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
96
97private:
98 QString headerTitle(int section) const;
99
100 void populate();
101};
102
103#endif // COLUMN_LIST_MODELS_H
ColumnListModel
Definition column_list_model.h:53
ColumnProxyModel
Definition column_list_model.h:20
ColumnTypeDelegate
Definition column_list_model.h:34