#include "EventDelegate.h" #include "PassiveEventContainer.h" #include #include namespace LtsTimelineClassic { EventDelegate::EventDelegate(QWidget *parent) : QStyledItemDelegate(parent) , m_liveTime(0) { } QSize EventDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { (void)option; (void)index; return QSize(50, 20); } void EventDelegate::setKnownRanges(const QVector &knownRanges) { m_knownRanges = knownRanges; } void EventDelegate::setLiveTime(qint64 liveTime) { m_liveTime = liveTime; } void EventDelegate::slotAddLine(int posX, qint64 time) { m_lineMap.insert(posX, time); } void EventDelegate::slotResetLineList() { m_lineMap.clear(); } void EventDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (index.data().canConvert()) { PassiveEventContainer *passiveEventContainer = qvariant_cast(index.data()); passiveEventContainer->paint(painter, option, m_lineMap, m_knownRanges); } else QStyledItemDelegate::paint(painter, option, index); } }