Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
timeline_delegate.h
1 /* timeline_delegate.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 TIMELINE_DELEGATE_H
11 #define TIMELINE_DELEGATE_H
12 
13 /*
14  * @file Timeline delegate.
15  *
16  * QStyledItemDelegate subclass that will draw a timeline indicator for
17  * the specified value.
18  *
19  * This is intended to be used in QTreeWidgets to show timelines, e.g. for
20  * conversations.
21  * To use it, first call setItemDelegate:
22  *
23  * myTreeWidget()->setItemDelegateForColumn(col_time_start_, new TimelineDelegate());
24  *
25  * Then, for each QTreeWidgetItem, set or return a timeline_span for the start and end
26  * of the timeline in pixels relative to the column width.
27  *
28  * setData(col_start_, Qt::UserRole, start_span);
29  * setData(col_end_, Qt::UserRole, end_span);
30  *
31  */
32 
33 #include <QStyledItemDelegate>
34 
35 // Pixels are relative to item rect and will be clipped.
36 struct timeline_span {
37  int start;
38  int width;
39 };
40 
41 Q_DECLARE_METATYPE(timeline_span)
42 
43 class TimelineDelegate : public QStyledItemDelegate
44 {
45  Q_OBJECT
46 
47 public:
48  TimelineDelegate(QWidget *parent = 0);
49 
50  // Make sure QStyledItemDelegate::paint doesn't draw any text.
51  virtual QString displayText(const QVariant &, const QLocale &) const { return QString(); }
52 
53 protected:
54  void paint(QPainter *painter, const QStyleOptionViewItem &option,
55  const QModelIndex &index) const;
56 private:
57 };
58 
59 #endif // TIMELINE_DELEGATE_H
60 
61 /*
62  * Editor modelines
63  *
64  * Local Variables:
65  * c-basic-offset: 4
66  * tab-width: 8
67  * indent-tabs-mode: nil
68  * End:
69  *
70  * ex: set shiftwidth=4 tabstop=8 expandtab:
71  * :indentSize=4:tabSize=8:noTabs=true:
72  */
Definition: timeline_delegate.h:43
Definition: pcapng.c:148
Definition: timeline_delegate.h:36