Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
export_objects_model.h
Go to the documentation of this file.
1
11
12#ifndef EXPORT_OBJECTS_MODEL_H
13#define EXPORT_OBJECTS_MODEL_H
14
15#include <config.h>
16
17#include <epan/tap.h>
18#include <epan/export_object.h>
19
20#include <QAbstractTableModel>
21#include <QSortFilterProxyModel>
22#include <QList>
23#include <QSet>
24
32
37{
38public:
43 explicit ExportObjectEntry(export_object_entry_t *entry = nullptr) : entry(entry) {}
44
50 bool operator==(const ExportObjectEntry &other) const {
51 return eo_entry_equal(entry, other.entry);
52 }
53
57 QByteArrayView Data() const { return entry ? QByteArrayView(entry->payload_data, entry->payload_len) : QByteArrayView(); }
62 uint32_t PacketNum() const { return entry ? entry->pkt_num : 0; }
63
64private:
67};
68
75size_t qHash(const ExportObjectEntry& entry, size_t seed = 0);
76
80class ExportObjectModel : public QAbstractTableModel
81{
82 Q_OBJECT
83
84public:
90 ExportObjectModel(register_eo_t* eo, QObject *parent);
91
95 virtual ~ExportObjectModel();
96
108
114
121
125 void resetObjects();
126
133 bool saveEntry(const QModelIndex &index, QString filename);
134
140 void saveEntries(const QModelIndexList &indices, QString path);
141
146 void saveAllEntries(QString path);
147
152 const char* getTapListenerName();
153
158 void* getTapData();
159
164 tap_packet_cb getTapPacketFunc();
165
170 static void resetTap(void *tapdata);
171
175 void removeTap();
176
183 QVariant data(const QModelIndex &index, int role) const override;
184
192 QVariant headerData(int section, Qt::Orientation orientation,
193 int role = Qt::DisplayRole) const override;
194
200 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
201
207 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
208
209private:
211 QList<QVariant> objects_;
212
214 QSet<ExportObjectEntry> object_set_;
215
217 export_object_list_t export_object_list_;
218
220 export_object_list_gui_t eo_gui_data_;
221
223 register_eo_t* eo_;
224};
225
229class ExportObjectProxyModel : public QSortFilterProxyModel
230{
231public:
232
237 explicit ExportObjectProxyModel(QObject * parent = Q_NULLPTR);
238
243 void setContentFilterString(QString contentFilter);
244
249 void setTextFilterString(QString textFilter);
250
255 void setUniqueFilter(bool unique);
256
257protected:
264 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
265
272 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
273
274private:
276 QString contentFilter_;
277
279 QString textFilter_;
280
282 bool uniqueFilter_;
283
284};
285
286#endif // EXPORT_OBJECTS_MODEL_H
A wrapper class for an export object entry.
Definition export_objects_model.h:37
bool operator==(const ExportObjectEntry &other) const
Compares two ExportObjectEntry instances for equality.
Definition export_objects_model.h:50
QByteArrayView Data() const
Retrieves the payload data view for the entry.
Definition export_objects_model.h:57
ExportObjectEntry(export_object_entry_t *entry=nullptr)
Constructs a new ExportObjectEntry.
Definition export_objects_model.h:43
uint32_t PacketNum() const
Retrieves the packet number associated with the entry.
Definition export_objects_model.h:62
A table model managing a list of exportable objects extracted from network traffic.
Definition export_objects_model.h:81
void resetObjects()
Resets and clears all object entries from the model.
Definition export_objects_model.cpp:263
QVariant data(const QModelIndex &index, int role) const override
Retrieves data from the model for a given index and role.
Definition export_objects_model.cpp:66
void addObjectEntry(export_object_entry_t *entry)
Adds a new export object entry to the model.
Definition export_objects_model.cpp:148
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Retrieves the header data for a specific section and role.
Definition export_objects_model.cpp:112
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns under a given parent.
Definition export_objects_model.cpp:143
static void resetTap(void *tapdata)
Static callback used to reset the tap data.
Definition export_objects_model.cpp:281
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under a given parent.
Definition export_objects_model.cpp:133
tap_packet_cb getTapPacketFunc()
Retrieves the callback function used for processing tap packets.
Definition export_objects_model.cpp:299
virtual ~ExportObjectModel()
Destroys the ExportObjectModel.
Definition export_objects_model.cpp:59
ExportObjectModel(register_eo_t *eo, QObject *parent)
Constructs a new ExportObjectModel.
Definition export_objects_model.cpp:48
void saveAllEntries(QString path)
Saves all entries in the model to a directory.
Definition export_objects_model.cpp:222
export_object_entry_t * objectEntry(int row)
Retrieves the export object entry at a specific row.
Definition export_objects_model.cpp:160
void saveEntries(const QModelIndexList &indices, QString path)
Saves multiple entries to a directory.
Definition export_objects_model.cpp:181
ExportObjectColumn
Enumerates the columns for the export object model.
Definition export_objects_model.h:100
@ colFilename
Definition export_objects_model.h:105
@ colHostname
Definition export_objects_model.h:102
@ colExportObjectMax
Definition export_objects_model.h:106
@ colPacket
Definition export_objects_model.h:101
@ colSize
Definition export_objects_model.h:104
@ colContent
Definition export_objects_model.h:103
const char * getTapListenerName()
Retrieves the name of the tap listener.
Definition export_objects_model.cpp:289
void removeTap()
Removes the associated tap listener.
Definition export_objects_model.cpp:304
void * getTapData()
Retrieves the tap data pointer.
Definition export_objects_model.cpp:294
bool saveEntry(const QModelIndex &index, QString filename)
Saves a specific entry to a file.
Definition export_objects_model.cpp:165
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Determines whether a row from the source model matches the active filters and should be displayed.
Definition export_objects_model.cpp:378
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
Compares two source indices to determine their sort order.
Definition export_objects_model.cpp:318
void setUniqueFilter(bool unique)
Sets the filter to determine whether to show only unique items.
Definition export_objects_model.cpp:365
void setTextFilterString(QString textFilter)
Sets the text filter string used for general searching.
Definition export_objects_model.cpp:352
ExportObjectProxyModel(QObject *parent=Q_NULLPTR)
Constructs a new ExportObjectProxyModel.
Definition export_objects_model.cpp:311
void setContentFilterString(QString contentFilter)
Sets the filter string used for matching content types.
Definition export_objects_model.cpp:339
struct register_eo register_eo_t
Definition export_object.h:61
struct _export_object_list_t export_object_list_t
Abstracts the GUI-specific operations needed to manage a list of exported objects during dissection.
struct _export_object_entry_t export_object_entry_t
Represents a single object extracted from a packet capture for export.
size_t qHash(const ExportObjectEntry &entry, size_t seed=0)
Computes the hash for an ExportObjectEntry.
Definition export_objects_model.cpp:43
GUI context data for the export object list.
Definition export_objects_model.h:28
class ExportObjectModel * model
Pointer to the export object model.
Definition export_objects_model.h:30