Continues migration with DDS, Common
This commit is contained in:
1 parent
9b15cee841
commit
fa48db111e
668 files changed
+111841
-2
No files matched your search
+133
@@ -0,0 +1,133 @@
|
||||
|
||||
|
||||
|
||||
#include "PassiveEventContainer.h"
|
||||
#include "EventGraphic.h"
|
||||
#include "EventTools.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
#include <QStyleOptionViewItem>
|
||||
#include <QBrush>
|
||||
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace LtsTimelineClassic
|
||||
{
|
||||
|
||||
PassiveEventContainer::PassiveEventContainer(bool ignoreKnownRanges, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_ignoreKnownRanges(ignoreKnownRanges)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
PassiveEventContainer::~PassiveEventContainer()
|
||||
{
|
||||
qDeleteAll(m_eventGraphicList);
|
||||
}
|
||||
|
||||
|
||||
EventGraphicList PassiveEventContainer::getEventGraphicList() const
|
||||
{
|
||||
return m_eventGraphicList;
|
||||
}
|
||||
|
||||
|
||||
void PassiveEventContainer::setEventList(const EventGraphicList &eventGraphicList)
|
||||
{
|
||||
qDeleteAll(m_eventGraphicList);
|
||||
|
||||
m_eventGraphicList = eventGraphicList;
|
||||
}
|
||||
|
||||
|
||||
void PassiveEventContainer::paint(QPainter *painter, const QStyleOptionViewItem &option, const LineMap &lineMap,
|
||||
const QVector<Range> &knownRanges) const
|
||||
{
|
||||
EventTools::s_test++;
|
||||
|
||||
bool alternate = option.features.testFlag(QStyleOptionViewItem::ViewItemFeature::Alternate);
|
||||
const QColor bg = QColor(alternate ? QRgb(0xF6D8CE) : QRgb(0xFBF2EF));
|
||||
|
||||
QColor cachedBg(Qt::white);
|
||||
if (alternate)
|
||||
cachedBg = cachedBg.darker(110);
|
||||
|
||||
|
||||
painter->fillRect(option.rect, QBrush(bg));
|
||||
|
||||
int posX1 = option.rect.x();
|
||||
int posX2 = option.rect.right();
|
||||
int posY1 = option.rect.y();
|
||||
int posY2 = option.rect.bottom();
|
||||
int h = posY2 - posY1 + 1;
|
||||
|
||||
painter->save();
|
||||
painter->setClipping(true);
|
||||
painter->setClipRect(option.rect.adjusted(0, 0, 1, 1));
|
||||
|
||||
int eventWidth = EventTools::eventWidth();
|
||||
|
||||
|
||||
if (m_ignoreKnownRanges)
|
||||
{
|
||||
painter->fillRect(QRect(posX1, posY1, posX2 - posX1, h), cachedBg);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto &range : knownRanges)
|
||||
{
|
||||
int rangeStart = EventTools::getEventPosition(range.start);
|
||||
int rangeEnd = EventTools::getEventPosition(range.end);
|
||||
|
||||
|
||||
if (rangeEnd >= posX1 && rangeStart <= posX2)
|
||||
painter->fillRect(QRect(rangeStart, posY1, rangeEnd - rangeStart + eventWidth + 1, h), cachedBg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
painter->restore();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (auto i = lineMap.constBegin(); i != lineMap.constEnd(); ++i)
|
||||
{
|
||||
int posX = i.key();
|
||||
|
||||
painter->setPen(QPen(QBrush(QGuiApplication::palette().shadow()), 1.0));
|
||||
|
||||
if (posX > option.rect.x() &&
|
||||
posX < (option.rect.x() + option.rect.width()))
|
||||
painter->drawLine(posX, posY1, posX, posY2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
EventTools::drawEvents(painter, m_eventGraphicList, option.rect.y());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user