| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
timeline_delegate.h
Go to the documentation of this file.
1
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 double startTime;
41 double stopTime;
42 double minRelTime;
43 double maxRelTime;
44
45 int colStart;
46 int colDuration;
47};
48
49Q_DECLARE_METATYPE(timeline_span)
50
51class TimelineDelegate : public QStyledItemDelegate
52{
53public:
54 TimelineDelegate(QWidget *parent = 0);
55
56 void setDataRole(int role);
57
58protected:
59 void paint(QPainter *painter, const QStyleOptionViewItem &option,
60 const QModelIndex &index) const;
61private:
62
63 int _dataRole;
64};
65
66#endif // TIMELINE_DELEGATE_H
TimelineDelegate
Definition timeline_delegate.h:52
timeline_span
Definition timeline_delegate.h:36