Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
proto_tree.h
1 /* proto_tree.h
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 1998 Gerald Combs
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9 
10 #ifndef PROTO_TREE_H
11 #define PROTO_TREE_H
12 
13 #include <config.h>
14 
15 #include <epan/proto.h>
16 
17 #include "cfile.h"
18 
19 #include "protocol_preferences_menu.h"
20 
21 #include <ui/qt/utils/field_information.h>
22 #include <QTreeView>
23 #include <QMenu>
24 
25 class ProtoTreeModel;
26 class ProtoNode;
27 
28 class ProtoTree : public QTreeView
29 {
30  Q_OBJECT
31 public:
32  explicit ProtoTree(QWidget *parent = 0, epan_dissect_t *edt_fixed = 0);
33  QMenu *colorizeMenu() { return &colorize_menu_; }
34  void setRootNode(proto_node *root_node);
35  void emitRelatedFrame(int related_frame, ft_framenum_type_t framenum_type = FT_FRAMENUM_NONE);
36  void autoScrollTo(const QModelIndex &index);
37  void goToHfid(int hfid);
38  void clear();
39  void closeContextMenu();
40  void restoreSelectedField();
41  const QString toString(const QModelIndex &start_idx = QModelIndex()) const;
42 
43 protected:
44  virtual void contextMenuEvent(QContextMenuEvent *event);
45  virtual void timerEvent(QTimerEvent *event);
46  virtual void keyReleaseEvent(QKeyEvent *event);
47  virtual bool eventFilter(QObject * obj, QEvent * ev);
48  virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
49 
50 private:
51  ProtoTreeModel *proto_tree_model_;
52  QMenu ctx_menu_;
53  QMenu conv_menu_;
54  QMenu colorize_menu_;
55  ProtocolPreferencesMenu proto_prefs_menu_;
56  QAction *decode_as_;
57  QList<QAction *> copy_actions_;
58  QFont mono_font_;
59  int column_resize_timer_;
60  QList<QPair<int,int> > selected_hfid_path_; // row, hfinfo
61 
62  QPoint drag_start_position_;
63 
64  capture_file *cap_file_;
65  epan_dissect_t *edt_;
66 
67  void saveSelectedField(QModelIndex &index);
68  static void foreachTreeNode(proto_node *node, gpointer proto_tree_ptr);
69 
70 signals:
71  void fieldSelected(FieldInformation *);
72  void openPacketInNewWindow(bool);
73  void goToPacket(int);
74  void relatedFrame(int, ft_framenum_type_t);
75  void showProtocolPreferences(const QString module_name);
76  void editProtocolPreference(struct preference *pref, struct pref_module *module);
77 
78 public slots:
79 
80  /* Set the capture file */
81  void setCaptureFile(capture_file *cf);
82  void setMonospaceFont(const QFont &mono_font);
83  void syncExpanded(const QModelIndex & index);
84  void syncCollapsed(const QModelIndex & index);
85  void expandSubtrees();
86  void collapseSubtrees();
87  void expandAll();
88  void collapseAll();
89  void itemDoubleClicked(const QModelIndex & index);
90  void selectedFieldChanged(FieldInformation *);
91 
92 protected slots:
93  void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
94 
95 private slots:
96  void updateContentWidth();
97 };
98 
99 #endif // PROTO_TREE_H
100 
101 /*
102  * Editor modelines
103  *
104  * Local Variables:
105  * c-basic-offset: 4
106  * tab-width: 8
107  * indent-tabs-mode: nil
108  * End:
109  *
110  * ex: set shiftwidth=4 tabstop=8 expandtab:
111  * :indentSize=4:tabSize=8:noTabs=true:
112  */
Definition: field_information.h:21
Definition: proto_tree_model.h:18
Definition: prefs-int.h:27
Definition: proto_tree.h:28
Definition: proto_node.h:17
Definition: prefs.c:192
Definition: protocol_preferences_menu.h:19
Definition: epan_dissect.h:28
Definition: proto.h:759
Definition: cfile.h:58