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>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+104
-137
@@ -1,191 +1,158 @@
|
||||
#include "track_header.h"
|
||||
|
||||
#include "tools.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
#include <QBrush>
|
||||
#include <QPen>
|
||||
#include <QColor>
|
||||
#include <QCursor>
|
||||
#include <QMouseEvent>
|
||||
#include <QFontMetrics>
|
||||
#include <QFont>
|
||||
#include <QTime>
|
||||
#include <QApplication>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <QFont>
|
||||
#include <QFontMetrics>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
#include <QTime>
|
||||
|
||||
namespace LtsScriptTimeline
|
||||
{
|
||||
|
||||
TrackHeader::TrackHeader(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_indicatorTime(-1)
|
||||
, m_textMargin(12)
|
||||
, m_textSpacing(10)
|
||||
, m_indicatorLock(false)
|
||||
, m_tools(nullptr)
|
||||
TrackHeader::TrackHeader(QWidget* parent)
|
||||
: QWidget(parent), m_indicatorTime(-1), m_textMargin(12), m_textSpacing(10), m_indicatorLock(false),
|
||||
m_tools(nullptr)
|
||||
{
|
||||
setCursor(Qt::IBeamCursor);
|
||||
setCursor(Qt::IBeamCursor);
|
||||
|
||||
m_timeFormat = QStringLiteral("HH:mm:ss");
|
||||
m_timeFormat = QStringLiteral("HH:mm:ss");
|
||||
}
|
||||
|
||||
|
||||
void TrackHeader::setTools(Tools *tools)
|
||||
void TrackHeader::setTools(Tools* tools)
|
||||
{
|
||||
m_tools = tools;
|
||||
m_tools = tools;
|
||||
}
|
||||
|
||||
|
||||
void TrackHeader::mousePressEvent(QMouseEvent *event)
|
||||
void TrackHeader::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->buttons() != Qt::LeftButton)
|
||||
return;
|
||||
if (!m_indicatorLock)
|
||||
{
|
||||
setIndicatorTime(m_tools->getTime(event->localPos().x()));
|
||||
emit signalHeaderIndicatorTimeUserChanged(m_indicatorTime);
|
||||
}
|
||||
if (event->buttons() != Qt::LeftButton)
|
||||
return;
|
||||
if (!m_indicatorLock)
|
||||
{
|
||||
setIndicatorTime(m_tools->getTime(event->localPos().x()));
|
||||
emit signalHeaderIndicatorTimeUserChanged(m_indicatorTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TrackHeader::setIndicatorTime(int time)
|
||||
{
|
||||
m_indicatorTime = time;
|
||||
emit signalHeaderIndicatorTimeChanged(m_indicatorTime);
|
||||
update();
|
||||
m_indicatorTime = time;
|
||||
emit signalHeaderIndicatorTimeChanged(m_indicatorTime);
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void TrackHeader::recreatePositionLabels()
|
||||
{
|
||||
|
||||
QTime t;
|
||||
t.setHMS(23, 59, 59);
|
||||
|
||||
QFontMetrics fm(QApplication::font());
|
||||
|
||||
QTime t;
|
||||
t.setHMS(23, 59, 59);
|
||||
|
||||
QFontMetrics fm(QApplication::font());
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
|
||||
int currentTextWidth = fm.width(t.toString());
|
||||
int currentTextWidth = fm.width(t.toString());
|
||||
#else
|
||||
int currentTextWidth = fm.horizontalAdvance(t.toString());
|
||||
int currentTextWidth = fm.horizontalAdvance(t.toString());
|
||||
#endif
|
||||
|
||||
if (currentTextWidth < 1 )
|
||||
{
|
||||
qCritical() << "TrackHeader::recreatePositionLabels: invalid text size";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int currentTextWidthTime = m_tools->getDuration(currentTextWidth);
|
||||
|
||||
int time = m_tools->getDuration(m_textMargin);
|
||||
int end = (m_tools->m_timelineLength * 2) + currentTextWidthTime;
|
||||
|
||||
int paintStartTime = m_tools->getTime(0) - currentTextWidthTime;
|
||||
int paintEndTime = m_tools->getTime(width() * 2);
|
||||
int count = 0;
|
||||
|
||||
m_positionMarkers.clear();
|
||||
|
||||
|
||||
|
||||
int textSpacingTime = m_tools->getDuration(m_textSpacing);
|
||||
while (time < end && count < 5000)
|
||||
{
|
||||
|
||||
|
||||
if (time >= paintStartTime && time <= paintEndTime)
|
||||
if (currentTextWidth < 1)
|
||||
{
|
||||
|
||||
m_positionMarkers.append(m_tools->getPos(time));
|
||||
qCritical() << "TrackHeader::recreatePositionLabels: invalid text size";
|
||||
return;
|
||||
}
|
||||
|
||||
time += currentTextWidthTime + textSpacingTime;
|
||||
count++;
|
||||
}
|
||||
int currentTextWidthTime = m_tools->getDuration(currentTextWidth);
|
||||
|
||||
|
||||
int time = m_tools->getDuration(m_textMargin);
|
||||
int end = (m_tools->m_timelineLength * 2) + currentTextWidthTime;
|
||||
|
||||
update();
|
||||
int paintStartTime = m_tools->getTime(0) - currentTextWidthTime;
|
||||
int paintEndTime = m_tools->getTime(width() * 2);
|
||||
int count = 0;
|
||||
|
||||
m_positionMarkers.clear();
|
||||
|
||||
int textSpacingTime = m_tools->getDuration(m_textSpacing);
|
||||
while (time < end && count < 5000)
|
||||
{
|
||||
|
||||
if (time >= paintStartTime && time <= paintEndTime)
|
||||
{
|
||||
|
||||
m_positionMarkers.append(m_tools->getPos(time));
|
||||
}
|
||||
|
||||
time += currentTextWidthTime + textSpacingTime;
|
||||
count++;
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void TrackHeader::resizeEvent(QResizeEvent *event)
|
||||
void TrackHeader::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
recreatePositionLabels();
|
||||
recreatePositionLabels();
|
||||
|
||||
QWidget::resizeEvent(event);
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void TrackHeader::updateMe()
|
||||
{
|
||||
recreatePositionLabels();
|
||||
update();
|
||||
recreatePositionLabels();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void TrackHeader::paintEvent(QPaintEvent *event)
|
||||
void TrackHeader::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
QPainter painter(this);
|
||||
|
||||
QWidget::paintEvent(event);
|
||||
|
||||
painter.save();
|
||||
|
||||
|
||||
|
||||
painter.setPen(QGuiApplication::palette().windowText().color());
|
||||
painter.setBrush(QGuiApplication::palette().window().color());
|
||||
|
||||
painter.drawRect(rect().adjusted(0, 0, -1, -1));
|
||||
|
||||
int h = height();
|
||||
|
||||
|
||||
if (m_indicatorTime > -1 && m_indicatorTime <= m_tools->getTime(width()))
|
||||
{
|
||||
painter.setPen(QColor("cyan"));
|
||||
int indicatorPos = m_tools->getPos(m_indicatorTime);
|
||||
painter.drawLine(indicatorPos, h - (h / 4), indicatorPos, h);
|
||||
}
|
||||
|
||||
|
||||
|
||||
painter.setPen(QGuiApplication::palette().windowText().color());
|
||||
|
||||
|
||||
|
||||
for (auto i = m_positionMarkers.constBegin(); i != m_positionMarkers.constEnd(); ++i)
|
||||
{
|
||||
int pos = *i;
|
||||
|
||||
|
||||
int time = m_tools->getTime(pos);
|
||||
|
||||
|
||||
QTime t = QTime::fromMSecsSinceStartOfDay(time * 1000);
|
||||
|
||||
|
||||
QString x = t.toString(m_timeFormat);
|
||||
|
||||
|
||||
painter.drawText(pos, h / 2 , x);
|
||||
QWidget::paintEvent(event);
|
||||
|
||||
painter.save();
|
||||
painter.setPen(QGuiApplication::palette().link().color());
|
||||
painter.drawLine(pos, (h / 2) + 2, pos, h);
|
||||
|
||||
painter.setPen(QGuiApplication::palette().windowText().color());
|
||||
painter.setBrush(QGuiApplication::palette().window().color());
|
||||
|
||||
painter.drawRect(rect().adjusted(0, 0, -1, -1));
|
||||
|
||||
int h = height();
|
||||
|
||||
if (m_indicatorTime > -1 && m_indicatorTime <= m_tools->getTime(width()))
|
||||
{
|
||||
painter.setPen(QColor("cyan"));
|
||||
int indicatorPos = m_tools->getPos(m_indicatorTime);
|
||||
painter.drawLine(indicatorPos, h - (h / 4), indicatorPos, h);
|
||||
}
|
||||
|
||||
painter.setPen(QGuiApplication::palette().windowText().color());
|
||||
|
||||
for (auto i = m_positionMarkers.constBegin(); i != m_positionMarkers.constEnd(); ++i)
|
||||
{
|
||||
int pos = *i;
|
||||
|
||||
int time = m_tools->getTime(pos);
|
||||
|
||||
QTime t = QTime::fromMSecsSinceStartOfDay(time * 1000);
|
||||
|
||||
QString x = t.toString(m_timeFormat);
|
||||
|
||||
painter.drawText(pos, h / 2, x);
|
||||
|
||||
painter.save();
|
||||
painter.setPen(QGuiApplication::palette().link().color());
|
||||
painter.drawLine(pos, (h / 2) + 2, pos, h);
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
painter.restore();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LtsScriptTimeline
|
||||
Reference in new issue
Block a user