| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
coloring_rules_model.h
Go to the documentation of this file.
1
11
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
19#include <ui/qt/models/tree_model_helpers.h>
20
21#include <QList>
22#include <QColor>
23#include <QAbstractTableModel>
24#include <QSortFilterProxyModel>
25
29 class ColoringRuleItem : public ModelHelperTreeItem<ColoringRuleItem>
30{
31 public:
41 ColoringRuleItem(bool disabled, QString name, QString filter, QColor foreground, QColor background, ColoringRuleItem* parent);
42
46 virtual ~ColoringRuleItem();
47
53 ColoringRuleItem(color_filter_t *colorf, ColoringRuleItem* parent);
54
59 ColoringRuleItem(const ColoringRuleItem& item);
60
62 bool disabled_;
63
65 QString name_;
66
68 QString filter_;
69
71 QColor foreground_;
72
74 QColor background_;
75
81 ColoringRuleItem& operator=(ColoringRuleItem& rhs);
82
83};
84
88 class ColoringRulesModel : public QAbstractItemModel
89{
90 Q_OBJECT
91
92 public:
99 ColoringRulesModel(QColor defaultForeground, QColor defaultBackground, QObject *parent);
100
104 virtual ~ColoringRulesModel();
105
109 enum ColoringRulesColumn {
110 colName = 0,
111 colFilter,
112 colColoringRulesMax
113 };
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 override;
159
166 QVariant data(const QModelIndex &index, int role) const override;
167
175 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
176
184 QVariant headerData(int section, Qt::Orientation orientation,
185 int role = Qt::DisplayRole) const override;
186
194 QModelIndex index(int row, int column,
195 const QModelIndex &parent = QModelIndex()) const override;
196
202 QModelIndex parent(const QModelIndex &indexItem) const override;
203
204 //Drag & drop functionality
209 Qt::DropActions supportedDropActions() const override;
210
215 QStringList mimeTypes() const override;
216
222 QMimeData* mimeData(const QModelIndexList &indexes) const override;
223
233 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
234
240 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
241
247 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
248
256 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
257
265 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
266
273 bool copyRow(int dst_row, int src_row);
274
275 private:
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
ColoringRuleItem
Represents a single coloring rule item in a tree model.
Definition coloring_rules_model.h:30
ColoringRuleItem::~ColoringRuleItem
virtual ~ColoringRuleItem()
Destroys the ColoringRuleItem.
Definition coloring_rules_model.cpp:39
ColoringRuleItem::name_
QString name_
The display name of the rule.
Definition coloring_rules_model.h:65
ColoringRuleItem::disabled_
bool disabled_
Indicates if the rule is currently disabled.
Definition coloring_rules_model.h:62
ColoringRuleItem::operator=
ColoringRuleItem & operator=(ColoringRuleItem &rhs)
Assignment operator for ColoringRuleItem.
Definition coloring_rules_model.cpp:64
ColoringRuleItem::ColoringRuleItem
ColoringRuleItem(bool disabled, QString name, QString filter, QColor foreground, QColor background, ColoringRuleItem *parent)
Constructs a new ColoringRuleItem.
Definition coloring_rules_model.cpp:29
ColoringRuleItem::background_
QColor background_
The background color applied by the rule.
Definition coloring_rules_model.h:74
ColoringRuleItem::filter_
QString filter_
The display filter string associated with the rule.
Definition coloring_rules_model.h:68
ColoringRuleItem::foreground_
QColor foreground_
The foreground color applied by the rule.
Definition coloring_rules_model.h:71
ColoringRulesModel::setData
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 coloring_rules_model.cpp:309
ColoringRulesModel::mimeTypes
QStringList mimeTypes() const override
Retrieves the list of supported MIME types for drag and drop operations.
Definition coloring_rules_model.cpp:406
ColoringRulesModel::dropMimeData
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Handles dropped MIME data.
Definition coloring_rules_model.cpp:445
ColoringRulesModel::data
QVariant data(const QModelIndex &index, int role) const override
Retrieves data from the model for the given index and role.
Definition coloring_rules_model.cpp:273
ColoringRulesModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Generates an index for the specified row and column.
Definition coloring_rules_model.cpp:503
ColoringRulesModel::ColoringRulesModel
ColoringRulesModel(QColor defaultForeground, QColor defaultBackground, QObject *parent)
Constructs a new ColoringRulesModel.
Definition coloring_rules_model.cpp:86
ColoringRulesModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns under the given parent.
Definition coloring_rules_model.cpp:561
ColoringRulesModel::exportColors
bool exportColors(QString filename, QString &err)
Exports the current coloring rules to a file.
Definition coloring_rules_model.cpp:162
ColoringRulesModel::supportedDropActions
Qt::DropActions supportedDropActions() const override
Specifies the supported drag and drop actions.
Definition coloring_rules_model.cpp:401
ColoringRulesModel::writeColors
bool writeColors(QString &err)
Writes the coloring rules to the internal configuration.
Definition coloring_rules_model.cpp:176
ColoringRulesModel::copyRow
bool copyRow(int dst_row, int src_row)
Copies a row from one index to another.
Definition coloring_rules_model.cpp:230
ColoringRulesModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under the given parent.
Definition coloring_rules_model.cpp:544
ColoringRulesModel::ColoringRulesColumn
ColoringRulesColumn
Defines the columns used in the coloring rules model.
Definition coloring_rules_model.h:109
ColoringRulesModel::colColoringRulesMax
@ colColoringRulesMax
Definition coloring_rules_model.h:112
ColoringRulesModel::colFilter
@ colFilter
Definition coloring_rules_model.h:111
ColoringRulesModel::colName
@ colName
Definition coloring_rules_model.h:110
ColoringRulesModel::importColors
bool importColors(QString filename, QString &err)
Imports coloring rules from a specified file.
Definition coloring_rules_model.cpp:150
ColoringRulesModel::mimeData
QMimeData * mimeData(const QModelIndexList &indexes) const override
Generates MIME data for the specified list of indexes.
Definition coloring_rules_model.cpp:411
ColoringRulesModel::removeRows
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
Removes rows from the model.
Definition coloring_rules_model.cpp:215
ColoringRulesModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
Retrieves the item flags for a given index.
Definition coloring_rules_model.cpp:251
ColoringRulesModel::insertRows
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
Inserts rows into the model.
Definition coloring_rules_model.cpp:195
ColoringRulesModel::~ColoringRulesModel
virtual ~ColoringRulesModel()
Destroys the ColoringRulesModel.
Definition coloring_rules_model.cpp:97
ColoringRulesModel::addColor
void addColor(color_filter_t *colorf)
Adds a new color rule from a core color filter.
Definition coloring_rules_model.cpp:123
ColoringRulesModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Retrieves header data for the given section, orientation, and role.
Definition coloring_rules_model.cpp:384
ColoringRulesModel::parent
QModelIndex parent(const QModelIndex &indexItem) const override
Retrieves the parent index of the specified index.
Definition coloring_rules_model.cpp:525
ModelHelperTreeItem< ColoringRuleItem >::ModelHelperTreeItem
ModelHelperTreeItem(ColoringRuleItem *parent)
Definition tree_model_helpers.h:31
color_filters.h
color_filter_t
struct _color_filter color_filter_t
Data for a color filter.
tree_model_helpers.h