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