3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later*/
9 #ifndef TIMELINE_DELEGATE_H
10 #define TIMELINE_DELEGATE_H
13 * @file Timeline delegate.
15 * QStyledItemDelegate subclass that will draw a timeline indicator for
16 * the specified value.
18 * This is intended to be used in QTreeWidgets to show timelines, e.g. for
20 * To use it, first call setItemDelegate:
22 * myTreeWidget()->setItemDelegateForColumn(col_time_start_, new TimelineDelegate());
24 * Then, for each QTreeWidgetItem, set or return a timeline_span for the start and end
25 * of the timeline in pixels relative to the column width.
27 * setData(col_start_, Qt::UserRole, start_span);
28 * setData(col_end_, Qt::UserRole, end_span);
32 #include <QStyledItemDelegate>
34 // Pixels are relative to item rect and will be clipped.
35 struct timeline_span {
40 Q_DECLARE_METATYPE(timeline_span)
42 class TimelineDelegate : public QStyledItemDelegate
47 TimelineDelegate(QWidget *parent = 0);
49 // Make sure QStyledItemDelegate::paint doesn't draw any text.
50 virtual QString displayText(const QVariant &, const QLocale &) const { return QString(); }
53 void paint(QPainter *painter, const QStyleOptionViewItem &option,
54 const QModelIndex &index) const;
58 #endif // TIMELINE_DELEGATE_H
66 * indent-tabs-mode: nil
69 * ex: set shiftwidth=4 tabstop=8 expandtab:
70 * :indentSize=4:tabSize=8:noTabs=true: