- training_area_telegrams.cpp: Fixed QJsonObject initializer syntax (Qt6 requires {{}} not ({}))
- training_area_telegrams.cpp: Fixed fromJson() methods to access m_* members directly
- training_area_telegrams.cpp: Fixed brace mismatches in multiple toJson() methods
- training_area_telegrams.h: Changed Header struct to public members for consistency
- tx_mixin.cpp: Fixed getEquipmentNumber() template for direct member access
- lts_coordinate.cpp: Added missing #include <iomanip>
- MIGRATION_STATUS.md: Added migration progress tracking document
C++17 constraint enforced due to RTI Connext DDS 7.7.0 incompatibility with C++20+
Build status: BUILD_RTI=OFF successful (0 errors, warnings only)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
72 lines
1.8 KiB
C++
72 lines
1.8 KiB
C++
#include "topic_previewer.h"
|
|
|
|
#include <QtCore/QDebug>
|
|
#include <QDrag>
|
|
#include <QMimeData>
|
|
#include <QtGui/QMouseEvent>
|
|
#include <QtGui/QPainter>
|
|
|
|
namespace TopicEditorBase
|
|
{
|
|
|
|
TopicPreviewer::TopicPreviewer(QWidget* parent) : QWidget(parent)
|
|
{
|
|
|
|
setVisible(false);
|
|
}
|
|
|
|
TopicPreviewer::~TopicPreviewer() {}
|
|
|
|
void TopicPreviewer::setTopicData(const TopicData& data)
|
|
{
|
|
m_topicData = data;
|
|
|
|
if (m_topicData.state)
|
|
return;
|
|
}
|
|
|
|
void TopicPreviewer::mousePressEvent(QMouseEvent* event)
|
|
{
|
|
|
|
if (m_topicData.topicType == TopicType::Invalid || m_topicData.duration < 1 || event->buttons() != Qt::LeftButton)
|
|
return;
|
|
|
|
m_topicData.state = true;
|
|
QByteArray byteArray;
|
|
QDataStream dataStream(&byteArray, QIODevice::WriteOnly);
|
|
dataStream << m_topicData;
|
|
m_topicData.state = false;
|
|
QMimeData* mimeData = new QMimeData;
|
|
mimeData->setData(TopicData::mime, byteArray);
|
|
QDrag* drag = new QDrag(this);
|
|
drag->setDragCursor(QPixmap(), Qt::CopyAction);
|
|
drag->setMimeData(mimeData);
|
|
emit startDragMe();
|
|
if (drag->exec(Qt::CopyAction) == Qt::CopyAction)
|
|
emit deleteMe();
|
|
emit stopDragMe();
|
|
}
|
|
|
|
void TopicPreviewer::paintEvent(QPaintEvent* event)
|
|
{
|
|
QWidget::paintEvent(event);
|
|
|
|
if (m_topicData.topicType == TopicType::Invalid)
|
|
return;
|
|
|
|
QPainter painter(this);
|
|
painter.setClipping(true);
|
|
painter.setClipRect(rect(), Qt::ReplaceClip);
|
|
painter.setPen(isEnabled() ? Qt::black : Qt::lightGray);
|
|
painter.setBrush(QBrush(topicTypeColor(m_topicData.topicType)));
|
|
painter.drawRect(rect().adjusted(0, 0, -1, -1));
|
|
painter.drawText(rect().adjusted(3, 16, -1, -1), m_topicData.description);
|
|
if (!isEnabled())
|
|
{
|
|
painter.setBrush(QBrush(QColor(255, 255, 255, 204)));
|
|
painter.drawRect(rect().adjusted(0, 0, -1, -1));
|
|
}
|
|
}
|
|
|
|
} // namespace TopicEditorBase
|