Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
uat_model.h
Go to the documentation of this file.
1
13
14#ifndef UAT_MODEL_H
15#define UAT_MODEL_H
16
17#include <config.h>
18
19#include <QAbstractItemModel>
20#include <QList>
21#include <QMap>
22#include <epan/uat.h>
23
27class UatModel : public QAbstractTableModel
28{
29 Q_OBJECT
30public:
36 UatModel(QObject *parent, uat_t *uat = 0);
37
43 UatModel(QObject *parent, QString tableName);
44
50 Qt::ItemFlags flags(const QModelIndex &index) const override;
51
58 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
59
67 QVariant headerData(int section, Qt::Orientation orientation,
68 int role = Qt::DisplayRole) const override;
69
75 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
76
82 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
83
91 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
92
100 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
101
109 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
110
116 QModelIndex appendEntry(QVariantList row);
117
123 QModelIndex copyRow(QModelIndex original);
124
131 bool moveRow(int src_row, int dst_row);
132
142 bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
143
144 //Drag & drop functionality
149 Qt::DropActions supportedDropActions() const override;
150
160 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
161
165 void reloadUat();
166
171 bool hasErrors() const;
172
176 void clearAll();
177
185 bool applyChanges(QString &error);
186
193 bool revertChanges(QString &error);
194
202 QModelIndex findRowForColumnContent(QVariant columnContent, int columnToCheckAgainst, int role = Qt::DisplayRole);
203
204private:
212 bool checkField(int row, int col, char **error) const;
213
219 QList<int> checkRow(int row);
220
225 void loadUat(uat_t * uat = 0);
226
233 bool moveRowPrivate(int src_row, int dst_row);
234
236 uat_t *uat_;
237
239 bool applying_;
240
242 QVector<bool> dirty_records;
243
245 QVector<QMap<int, QString> > record_errors;
246};
247#endif // UAT_MODEL_H
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Retrieves header data for the table.
Definition uat_model.cpp:277
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override
Moves multiple rows from one position to another.
Definition uat_model.cpp:577
UatModel(QObject *parent, uat_t *uat=0)
Constructs a new UatModel object using a UAT structure.
Definition uat_model.cpp:31
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
Inserts a specified number of rows into the model.
Definition uat_model.cpp:444
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
Removes a specified number of rows from the model.
Definition uat_model.cpp:475
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under a given parent.
Definition uat_model.cpp:294
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns under a given parent.
Definition uat_model.cpp:304
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags for a given index.
Definition uat_model.cpp:118
bool revertChanges(QString &error)
Definition uat_model.cpp:100
bool applyChanges(QString &error)
Definition uat_model.cpp:75
QModelIndex appendEntry(QVariantList row)
Appends a new entry to the end of the table.
Definition uat_model.cpp:314
void clearAll()
Clears all entries from the model.
Definition uat_model.cpp:492
bool moveRow(int src_row, int dst_row)
Moves a row from one position to another.
Definition uat_model.cpp:572
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Sets the data for a specific index.
Definition uat_model.cpp:367
Qt::DropActions supportedDropActions() const override
Returns the supported drag and drop actions for the model.
Definition uat_model.cpp:661
QModelIndex copyRow(QModelIndex original)
Copies an existing row and inserts the copy.
Definition uat_model.cpp:505
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Handles dropped MIME data to perform drag and drop operations.
Definition uat_model.cpp:666
QModelIndex findRowForColumnContent(QVariant columnContent, int columnToCheckAgainst, int role=Qt::DisplayRole)
Finds the first row containing specific content in a given column.
Definition uat_model.cpp:262
void reloadUat()
Reloads the UAT data from the underlying structure.
Definition uat_model.cpp:61
bool hasErrors() const
Checks if any records in the model currently have validation errors.
Definition uat_model.cpp:608
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Retrieves data for a given index and role.
Definition uat_model.cpp:172