| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
column_list_model.h
Go to the documentation of this file.
1
9
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
22 class ColumnProxyModel : public QSortFilterProxyModel
23{
24 public:
29 ColumnProxyModel(QObject *parent = Q_NULLPTR);
30
35 void setShowDisplayedOnly(bool set);
36
37 protected:
44 virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
45
46 private:
48 bool showDisplayedOnly_;
49};
50
54 class ColumnTypeDelegate : public QStyledItemDelegate
55{
56 public:
61 ColumnTypeDelegate(QObject * parent = Q_NULLPTR);
62
68 static QString displayDesc(char display);
69
75 static QString alignDesc(char xalign);
76
84 QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option,
85 const QModelIndex &index) const override;
86
92 void setEditorData(QWidget *editor, const QModelIndex &index) const override;
93
100 void setModelData(QWidget *editor, QAbstractItemModel *model,
101 const QModelIndex &index) const override;
102
109 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
110 const QModelIndex &index) const override;
111};
112
116 class ColumnListModel : public QAbstractTableModel
117{
118 Q_OBJECT
119
120 public:
125 ColumnListModel(QObject * parent = Q_NULLPTR);
126
130 enum {
131 COL_DISPLAYED,
132 COL_TITLE,
133 COL_TYPE,
134 COL_FIELDS,
135 COL_OCCURRENCE,
136 COL_DISPLAY,
137 COL_WIDTH,
138 COL_XALIGN
139 };
140
144 enum {
145 OriginalType = Qt::UserRole,
146 DisplayedState
147 };
148
156 static bool displayEnabled(const QModelIndex &index, bool &displayStrings, bool &displayDetails);
157
161 void saveColumns();
162
166 void addEntry();
167
172 void deleteEntry(int row);
173
177 void reset();
178
186 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
187
194 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
195
201 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
202
208 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
209
215 virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
216
221 virtual QStringList mimeTypes() const override;
222
228 virtual QMimeData *mimeData(const QModelIndexList &indexes) const override;
229
234 virtual Qt::DropActions supportedDropActions() const override;
235
245 virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
246
256 virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
257
265 virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
266
267 private:
273 QString headerTitle(int section) const;
274
278 void populate();
279};
280
281#endif // COLUMN_LIST_MODELS_H
ColumnListModel::mimeData
virtual QMimeData * mimeData(const QModelIndexList &indexes) const override
Generates MIME data for the specified list of indexes.
Definition column_list_model.cpp:478
ColumnListModel::rowCount
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Retrieves the number of rows in the model.
Definition column_list_model.cpp:334
ColumnListModel::supportedDropActions
virtual Qt::DropActions supportedDropActions() const override
Specifies the supported drag and drop actions.
Definition column_list_model.cpp:533
ColumnListModel::setData
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Sets data in the model for the given index and role.
Definition column_list_model.cpp:538
ColumnListModel::COL_DISPLAYED
@ COL_DISPLAYED
Definition column_list_model.h:131
ColumnListModel::COL_WIDTH
@ COL_WIDTH
Definition column_list_model.h:137
ColumnListModel::COL_TYPE
@ COL_TYPE
Definition column_list_model.h:133
ColumnListModel::COL_XALIGN
@ COL_XALIGN
Definition column_list_model.h:138
ColumnListModel::COL_OCCURRENCE
@ COL_OCCURRENCE
Definition column_list_model.h:135
ColumnListModel::COL_TITLE
@ COL_TITLE
Definition column_list_model.h:132
ColumnListModel::COL_FIELDS
@ COL_FIELDS
Definition column_list_model.h:134
ColumnListModel::COL_DISPLAY
@ COL_DISPLAY
Definition column_list_model.h:136
ColumnListModel::headerData
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Retrieves header data for the table model.
Definition column_list_model.cpp:325
ColumnListModel::mimeTypes
virtual QStringList mimeTypes() const override
Retrieves the supported MIME types for drag and drop operations.
Definition column_list_model.cpp:473
ColumnListModel::data
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Retrieves data from the model.
Definition column_list_model.cpp:394
ColumnListModel::deleteEntry
void deleteEntry(int row)
Deletes a specific entry from the column list.
Definition column_list_model.cpp:673
ColumnListModel::DisplayedState
@ DisplayedState
Definition column_list_model.h:146
ColumnListModel::OriginalType
@ OriginalType
Definition column_list_model.h:145
ColumnListModel::canDropMimeData
virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
Checks if MIME data can be dropped at a specific location.
Definition column_list_model.cpp:490
ColumnListModel::flags
virtual Qt::ItemFlags flags(const QModelIndex &index) const override
Retrieves the item flags for a given index.
Definition column_list_model.cpp:452
ColumnListModel::saveColumns
void saveColumns()
Saves the current column list to the global configuration.
Definition column_list_model.cpp:599
ColumnListModel::columnCount
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const override
Retrieves the number of columns in the model.
Definition column_list_model.cpp:339
ColumnListModel::displayEnabled
static bool displayEnabled(const QModelIndex &index, bool &displayStrings, bool &displayDetails)
Checks whether the display options are enabled for the given index.
Definition column_list_model.cpp:313
ColumnListModel::reset
void reset()
Resets the column list to the default configuration.
Definition column_list_model.cpp:680
ColumnListModel::ColumnListModel
ColumnListModel(QObject *parent=Q_NULLPTR)
Constructs a new ColumnListModel.
Definition column_list_model.cpp:307
ColumnListModel::addEntry
void addEntry()
Adds a new default entry to the end of the column list.
Definition column_list_model.cpp:656
ColumnListModel::dropMimeData
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Handles dropped MIME data to rearrange rows.
Definition column_list_model.cpp:499
ColumnProxyModel::ColumnProxyModel
ColumnProxyModel(QObject *parent=Q_NULLPTR)
Constructs a new ColumnProxyModel.
Definition column_list_model.cpp:42
ColumnProxyModel::setShowDisplayedOnly
void setShowDisplayedOnly(bool set)
Sets whether to show only the displayed columns.
Definition column_list_model.cpp:60
ColumnProxyModel::filterAcceptsRow
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Determines whether a specific row is accepted by the filter.
Definition column_list_model.cpp:47
ColumnTypeDelegate::setEditorData
void setEditorData(QWidget *editor, const QModelIndex &index) const override
Sets the data for the editor from the model.
Definition column_list_model.cpp:183
ColumnTypeDelegate::ColumnTypeDelegate
ColumnTypeDelegate(QObject *parent=Q_NULLPTR)
Constructs a new ColumnTypeDelegate.
Definition column_list_model.cpp:73
ColumnTypeDelegate::createEditor
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Creates an editor widget for a given index.
Definition column_list_model.cpp:108
ColumnTypeDelegate::setModelData
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Sets the data in the model from the editor.
Definition column_list_model.cpp:214
ColumnTypeDelegate::alignDesc
static QString alignDesc(char xalign)
Retrieves the alignment description for a given alignment character.
Definition column_list_model.cpp:77
ColumnTypeDelegate::displayDesc
static QString displayDesc(char display)
Retrieves the display description for a given display format character.
Definition column_list_model.cpp:93
ColumnTypeDelegate::updateEditorGeometry
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Updates the geometry of the editor widget based on available space.
Definition column_list_model.cpp:300