Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
coloring_rules_model.h
Go to the documentation of this file.
1
12#ifndef COLORING_RULES_MODEL_H
13#define COLORING_RULES_MODEL_H
14
15#include <config.h>
16
17#include <epan/color_filters.h>
18
20
21#include <QList>
22#include <QColor>
23#include <QAbstractTableModel>
24#include <QSortFilterProxyModel>
25
29class ColoringRuleItem : public ModelHelperTreeItem<ColoringRuleItem>
30{
31public:
41 ColoringRuleItem(bool disabled, QString name, QString filter, QColor foreground, QColor background, ColoringRuleItem* parent);
42
46 virtual ~ColoringRuleItem();
47
54
60
63
65 QString name_;
66
68 QString filter_;
69
72
75
82
83};
84
88class ColoringRulesModel : public QAbstractItemModel
89{
90 Q_OBJECT
91
92public:
99 ColoringRulesModel(QColor defaultForeground, QColor defaultBackground, QObject *parent);
100
104 virtual ~ColoringRulesModel();
105
114
119 void addColor(color_filter_t* colorf);
120
128 void addColor(bool disabled, QString filter, QColor foreground, QColor background);
129
136 bool importColors(QString filename, QString& err);
137
144 bool exportColors(QString filename, QString& err);
145
151 bool writeColors(QString& err);
152
158 Qt::ItemFlags flags(const QModelIndex &index) const;
159
166 QVariant data(const QModelIndex &index, int role) const;
167
175 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
176
184 QVariant headerData(int section, Qt::Orientation orientation,
185 int role = Qt::DisplayRole) const;
186
194 QModelIndex index(int row, int column,
195 const QModelIndex &parent = QModelIndex()) const;
196
202 QModelIndex parent(const QModelIndex &indexItem) const;
203
204 //Drag & drop functionality
209 Qt::DropActions supportedDropActions() const;
210
215 QStringList mimeTypes() const;
216
222 QMimeData* mimeData(const QModelIndexList &indexes) const;
223
233 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
234
240 int rowCount(const QModelIndex &parent = QModelIndex()) const;
241
247 int columnCount(const QModelIndex &parent = QModelIndex()) const;
248
256 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
257
265 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
266
273 bool copyRow(int dst_row, int src_row);
274
275private:
279 void populate();
280
285 struct _GSList *createColorFilterList();
286
288 ColoringRuleItem* root_;
289
290 //Save off the conversation colors, do not include in dialog
292 struct _GSList *conversation_colors_;
293
295 QColor defaultForeground_;
296
298 QColor defaultBackground_;
299
301 QList<int> dragDropRows_;
302};
303
304#endif // COLORING_RULES_MODEL_H
Represents a single coloring rule item in a tree model.
Definition coloring_rules_model.h:30
virtual ~ColoringRuleItem()
Destroys the ColoringRuleItem.
Definition coloring_rules_model.cpp:39
QString name_
The display name of the rule.
Definition coloring_rules_model.h:65
bool disabled_
Indicates if the rule is currently disabled.
Definition coloring_rules_model.h:62
ColoringRuleItem & operator=(ColoringRuleItem &rhs)
Assignment operator for ColoringRuleItem.
Definition coloring_rules_model.cpp:64
QColor background_
The background color applied by the rule.
Definition coloring_rules_model.h:74
QString filter_
The display filter string associated with the rule.
Definition coloring_rules_model.h:68
QColor foreground_
The foreground color applied by the rule.
Definition coloring_rules_model.h:71
A model managing the coloring rules for packet display.
Definition coloring_rules_model.h:89
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Retrieves header data for the given section, orientation, and role.
Definition coloring_rules_model.cpp:392
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Handles dropped MIME data.
Definition coloring_rules_model.cpp:453
QStringList mimeTypes() const
Retrieves the list of supported MIME types for drag and drop operations.
Definition coloring_rules_model.cpp:414
bool exportColors(QString filename, QString &err)
Exports the current coloring rules to a file.
Definition coloring_rules_model.cpp:162
bool writeColors(QString &err)
Writes the coloring rules to the internal configuration.
Definition coloring_rules_model.cpp:176
bool copyRow(int dst_row, int src_row)
Copies a row from one index to another.
Definition coloring_rules_model.cpp:230
ColoringRulesColumn
Defines the columns used in the coloring rules model.
Definition coloring_rules_model.h:109
@ colColoringRulesMax
Definition coloring_rules_model.h:112
@ colFilter
Definition coloring_rules_model.h:111
@ colName
Definition coloring_rules_model.h:110
bool importColors(QString filename, QString &err)
Imports coloring rules from a specified file.
Definition coloring_rules_model.cpp:150
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Sets data in the model for the given index and role.
Definition coloring_rules_model.cpp:309
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Generates an index for the specified row and column.
Definition coloring_rules_model.cpp:511
int columnCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of columns under the given parent.
Definition coloring_rules_model.cpp:569
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
Removes rows from the model.
Definition coloring_rules_model.cpp:215
int rowCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of rows under the given parent.
Definition coloring_rules_model.cpp:552
QModelIndex parent(const QModelIndex &indexItem) const
Retrieves the parent index of the specified index.
Definition coloring_rules_model.cpp:533
virtual ~ColoringRulesModel()
Destroys the ColoringRulesModel.
Definition coloring_rules_model.cpp:97
void addColor(color_filter_t *colorf)
Adds a new color rule from a core color filter.
Definition coloring_rules_model.cpp:123
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex())
Inserts rows into the model.
Definition coloring_rules_model.cpp:195
QMimeData * mimeData(const QModelIndexList &indexes) const
Generates MIME data for the specified list of indexes.
Definition coloring_rules_model.cpp:419
Qt::DropActions supportedDropActions() const
Specifies the supported drag and drop actions.
Definition coloring_rules_model.cpp:409
Base class to inherit basic tree item from.
Definition tree_model_helpers.h:25
Data for a color filter.
Definition color_filters.h:34