Wireshark  4.3.0
The Wireshark network protocol analyzer
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 {
21 public:
22  ColumnProxyModel(QObject *parent = Q_NULLPTR);
23 
24  void setShowDisplayedOnly(bool set);
25 
26 protected:
27  virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
28 
29 private:
30  bool showDisplayedOnly_;
31 };
32 
33 class ColumnTypeDelegate : public QStyledItemDelegate
34 {
35 public:
36  ColumnTypeDelegate(QObject * parent = Q_NULLPTR);
37 
38  static QString alignDesc(char xalign);
39 
40  QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option,
41  const QModelIndex &index) const override;
42 
43  void setEditorData(QWidget *editor, const QModelIndex &index) const override;
44  void setModelData(QWidget *editor, QAbstractItemModel *model,
45  const QModelIndex &index) const override;
46 
47  void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
48  const QModelIndex &index) const override;
49 };
50 
51 class ColumnListModel : public QAbstractTableModel
52 {
53  Q_OBJECT
54 
55 public:
56  ColumnListModel(QObject * parent = Q_NULLPTR);
57 
58  enum {
59  COL_DISPLAYED,
60  COL_TITLE,
61  COL_TYPE,
62  COL_FIELDS,
63  COL_OCCURRENCE,
64  COL_RESOLVED,
65  COL_WIDTH,
66  COL_XALIGN
67  };
68 
69  enum {
70  OriginalType = Qt::UserRole,
71  DisplayedState
72  };
73 
74  void saveColumns();
75 
76  void addEntry();
77  void deleteEntry(int row);
78  void reset();
79 
80  virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
81  virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
82  virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
83  virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
84  virtual Qt::ItemFlags flags(const QModelIndex &index) const;
85 
86  virtual QStringList mimeTypes() const;
87  virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
88  virtual Qt::DropActions supportedDropActions() const;
89  virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const;
90  virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
91 
92  virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
93 
94 private:
95  QString headerTitle(int section) const;
96 
97  void populate();
98 };
99 
100 #endif // COLUMN_LIST_MODELS_H
Definition: column_list_model.h:52
Definition: column_list_model.h:20
Definition: column_list_model.h:34