Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
coloring_rules_model.h
1 /* coloring_rules_model.h
2  * Data model for coloring rules.
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 COLORING_RULES_MODEL_H
12 #define COLORING_RULES_MODEL_H
13 
14 #include <config.h>
15 
16 #include <glib.h>
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 
26 class ColoringRuleItem : public ModelHelperTreeItem<ColoringRuleItem>
27 {
28 public:
29  ColoringRuleItem(bool disabled, QString name, QString filter, QColor foreground, QColor background, ColoringRuleItem* parent);
30  virtual ~ColoringRuleItem();
31 
34 
35  bool disabled_;
36  QString name_;
37  QString filter_;
38  QColor foreground_;
39  QColor background_;
40 };
41 
42 class ColoringRulesModel : public QAbstractItemModel
43 {
44  Q_OBJECT
45 
46 public:
47  ColoringRulesModel(QColor defaultForeground, QColor defaultBackground, QObject *parent);
48  virtual ~ColoringRulesModel();
49 
50  enum ColoringRulesColumn {
51  colName = 0,
52  colFilter,
53  colColoringRulesMax
54  };
55 
56  void addColor(color_filter_t* colorf);
57  void addColor(bool disabled, QString filter, QColor foreground, QColor background);
58  bool importColors(QString filename, QString& err);
59  bool exportColors(QString filename, QString& err);
60  bool writeColors(QString& err);
61 
62  Qt::ItemFlags flags(const QModelIndex &index) const;
63  QVariant data(const QModelIndex &index, int role) const;
64  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
65  QVariant headerData(int section, Qt::Orientation orientation,
66  int role = Qt::DisplayRole) const;
67  QModelIndex index(int row, int column,
68  const QModelIndex & = QModelIndex()) const;
69  QModelIndex parent(const QModelIndex &) const;
70 
71  //Drag & drop functionality
72  Qt::DropActions supportedDropActions() const;
73  QStringList mimeTypes() const;
74  QMimeData* mimeData(const QModelIndexList &indexes) const;
75  bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
76 
77  int rowCount(const QModelIndex &parent = QModelIndex()) const;
78  int columnCount(const QModelIndex &parent = QModelIndex()) const;
79 
80  bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
81  bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
82  bool copyRow(int dst_row, int src_row);
83 
84 private:
85  void populate();
86  struct _GSList *createColorFilterList();
87 
88  ColoringRuleItem* root_;
89  //Save off the conversation colors, do not include in dialog
90  struct _GSList *conversation_colors_;
91 
92  QColor defaultForeground_;
93  QColor defaultBackground_;
94 
95  QList<int> dragDropRows_;
96 };
97 
98 #endif // COLORING_RULES_MODEL_H
Definition: coloring_rules_model.h:26
Definition: tree_model_helpers.h:22
Definition: color_filters.h:29
Definition: coloring_rules_model.h:42