Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Common/LtsTimelineClassic/PassiveEventContainer.cpp
T
torstenandCopilot d6b6ffce7c Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files)
- Formatted LtsAppDescriptor module files
- Formatted LtsAppManager/AppChooser files
- Applied clang-format to all DTC and enum headers across modules
- Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/)

Cosmetic changes only, no functional modifications.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-19 14:46:29 +02:00

100 lines
2.6 KiB
C++

#include "PassiveEventContainer.h"
#include "EventGraphic.h"
#include "EventTools.h"
#include <QBrush>
#include <QDebug>
#include <QGuiApplication>
#include <QPainter>
#include <QPen>
#include <QStyleOptionViewItem>
#include <math.h>
#include <time.h>
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());
}
} // namespace LtsTimelineClassic