Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
packet_list_model.h
1 /* packet_list_model.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 PACKET_LIST_MODEL_H
11 #define PACKET_LIST_MODEL_H
12 
13 #include <config.h>
14 
15 #include <stdio.h>
16 
17 #include <glib.h>
18 
19 #include <epan/packet.h>
20 
21 #include <QAbstractItemModel>
22 #include <QFont>
23 #include <QVector>
24 
25 #include "packet_list_record.h"
26 
27 #include "cfile.h"
28 
29 class QElapsedTimer;
30 
31 class PacketListModel : public QAbstractItemModel
32 {
33  Q_OBJECT
34 public:
35  explicit PacketListModel(QObject *parent = 0, capture_file *cf = NULL);
36  ~PacketListModel();
37  void setCaptureFile(capture_file *cf);
38  QModelIndex index(int row, int column,
39  const QModelIndex & = QModelIndex()) const;
40  QModelIndex parent(const QModelIndex &) const;
41  int packetNumberToRow(int packet_num) const;
42  guint recreateVisibleRows();
43  void clear();
44 
45  int rowCount(const QModelIndex &parent = QModelIndex()) const;
46  int columnCount(const QModelIndex & = QModelIndex()) const;
47  QVariant data(const QModelIndex &d_index, int role) const;
48  QVariant headerData(int section, Qt::Orientation orientation,
49  int role = Qt::DisplayRole | Qt::ToolTipRole) const;
50 
51  gint appendPacket(frame_data *fdata);
52  frame_data *getRowFdata(int row);
53  void ensureRowColorized(int row);
54  int visibleIndexOf(frame_data *fdata) const;
62  void resetColumns();
63  void resetColorized();
64  void toggleFrameMark(const QModelIndex &fm_index);
65  void setDisplayedFrameMark(gboolean set);
66  void toggleFrameIgnore(const QModelIndex &i_index);
67  void setDisplayedFrameIgnore(gboolean set);
68  void toggleFrameRefTime(const QModelIndex &rt_index);
69  void unsetAllFrameRefTime();
70  void applyTimeShift();
71 
72  void setMaximiumRowHeight(int height);
73 
74 signals:
75  void goToPacket(int);
76  void maxLineCountChanged(const QModelIndex &ih_index) const;
77  void itemHeightChanged(const QModelIndex &ih_index);
78  void pushBusyStatus(const QString &status);
79  void popBusyStatus();
80 
81  void pushProgressStatus(const QString &status, bool animate, bool terminate_is_stop, gboolean *stop_flag);
82  void updateProgressStatus(int value);
83  void popProgressStatus();
84 
85  void bgColorizationProgress(int first, int last);
86 
87 public slots:
88  void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
89  void flushVisibleRows();
90  void dissectIdle(bool reset = false);
91 
92 private:
93  capture_file *cap_file_;
94  QList<QString> col_names_;
95  QVector<PacketListRecord *> physical_rows_;
96  QVector<PacketListRecord *> visible_rows_;
97  QVector<PacketListRecord *> new_visible_rows_;
98  QVector<int> number_to_row_;
99 
100  int max_row_height_; // px
101  int max_line_count_;
102 
103  static int sort_column_;
104  static int sort_column_is_numeric_;
105  static int text_sort_column_;
106  static Qt::SortOrder sort_order_;
107  static capture_file *sort_cap_file_;
108  static bool recordLessThan(PacketListRecord *r1, PacketListRecord *r2);
109  static double parseNumericColumn(const QString &val, bool *ok);
110 
111  QElapsedTimer *idle_dissection_timer_;
112  int idle_dissection_row_;
113 
114  bool isNumericColumn(int column);
115 
116 private slots:
117  void emitItemHeightChanged(const QModelIndex &ih_index);
118 };
119 
120 #endif // PACKET_LIST_MODEL_H
121 
122 /*
123  * Editor modelines
124  *
125  * Local Variables:
126  * c-basic-offset: 4
127  * tab-width: 8
128  * indent-tabs-mode: nil
129  * End:
130  *
131  * ex: set shiftwidth=4 tabstop=8 expandtab:
132  * :indentSize=4:tabSize=8:noTabs=true:
133  */
void invalidateAllColumnStrings()
Invalidate any cached column strings.
Definition: packet_list_model.cpp:140
Definition: packet_list_record.h:31
Definition: packet_list_model.h:31
Definition: frame_data.h:53
void resetColumns()
Rebuild columns from settings.
Definition: packet_list_model.cpp:147
Definition: cfile.h:58