1 /* export_objects_model.h 2 * Data model for Export Objects. 3 * 4 * Wireshark - Network traffic analyzer 5 * By Gerald Combs <gerald@wireshark.org> 6 * Copyright 1998 Gerald Combs 7 * 8 * SPDX-License-Identifier: GPL-2.0-or-later 9 */ 10 11 #ifndef EXPORT_OBJECTS_MODEL_H 12 #define EXPORT_OBJECTS_MODEL_H 13 14 #include <config.h> 15 16 #include <epan/tap.h> 17 #include <epan/export_object.h> 18 19 #include <QAbstractTableModel> 20 #include <QSortFilterProxyModel> 21 #include <QList> 22 23 typedef struct export_object_list_gui_t { 24 class ExportObjectModel *model; 25 } export_object_list_gui_t; 26 27 class ExportObjectModel : public QAbstractTableModel 28 { 29 Q_OBJECT 30 31 public: 32 ExportObjectModel(register_eo_t* eo, QObject *parent); 33 34 enum ExportObjectColumn { 35 colPacket = 0, 36 colHostname, 37 colContent, 38 colSize, 39 colFilename, 40 colExportObjectMax 41 }; 42 43 void addObjectEntry(export_object_entry_t *entry); 44 export_object_entry_t *objectEntry(int row); 45 void resetObjects(); 46 47 bool saveEntry(QModelIndex &index, QString filename); 48 void saveAllEntries(QString path); 49 50 const char* getTapListenerName(); 51 void* getTapData(); 52 tap_packet_cb getTapPacketFunc(); 53 static void resetTap(void *tapdata); 54 void removeTap(); 55 56 QVariant data(const QModelIndex &index, int role) const; 57 QVariant headerData(int section, Qt::Orientation orientation, 58 int role = Qt::DisplayRole) const; 59 int rowCount(const QModelIndex &parent = QModelIndex()) const; 60 int columnCount(const QModelIndex &parent = QModelIndex()) const; 61 62 private: 63 QList<QVariant> objects_; 64 65 export_object_list_t export_object_list_; 66 export_object_list_gui_t eo_gui_data_; 67 register_eo_t* eo_; 68 }; 69 70 class ExportObjectProxyModel : public QSortFilterProxyModel 71 { 72 public: 73 74 explicit ExportObjectProxyModel(QObject * parent = Q_NULLPTR); 75 76 void setContentFilterString(QString contentFilter); 77 void setTextFilterString(QString textFilter); 78 79 protected: 80 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const; 81 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; 82 83 private: 84 QString contentFilter_; 85 QString textFilter_; 86 87 }; 88 89 #endif // EXPORT_OBJECTS_MODEL_H 90