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:
torstenandCopilot committed 2026-08-19 14:46:29 +02:00
1 parent 1881d68aef
commit d6b6ffce7c
848 files changed
+89305 -100020

No files matched your search

+53 -75
View File
@@ -1,122 +1,100 @@
#include "topic_editor_base.h"
#include "topic_preview_widget.h"
#include <LtsWidgets/lts_dialog.h>
#include <QMessageBox>
#include <QDebug>
#include <QMessageBox>
namespace TopicEditorBase
{
TopicEditor::TopicEditor(QWidget *parent)
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
, m_previewWidget(nullptr)
TopicEditor::TopicEditor(QWidget* parent)
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_previewWidget(nullptr)
{
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->hide();
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->hide();
}
void TopicEditor::setTopicData(const TopicEditorBase::TopicData &data)
void TopicEditor::setTopicData(const TopicEditorBase::TopicData& data)
{
m_topicData = data;
m_topicDuration = data.duration;
m_topicData = data;
m_topicDuration = data.duration;
if (m_previewWidget == nullptr)
{
QMessageBox::critical(
nullptr, QStringLiteral("An den Entwickler!"),
QStringLiteral("!! STOP !! - Dieser Topic Editor hatte 'init()' vorher nicht aufgerufen!")
);
return;
}
if (m_previewWidget == nullptr)
{
QMessageBox::critical(
nullptr, QStringLiteral("An den Entwickler!"),
QStringLiteral("!! STOP !! - Dieser Topic Editor hatte 'init()' vorher nicht aufgerufen!"));
m_previewWidget->setTopicData(m_topicData);
return;
}
bool isAlreadyUnchangeable = unchangeable();
if (!isAlreadyUnchangeable)
setUnchangeable(true);
m_previewWidget->setTopicData(m_topicData);
updateInternalData();
bool isAlreadyUnchangeable = unchangeable();
if (!isAlreadyUnchangeable)
setUnchangeable(true);
if (!isAlreadyUnchangeable)
setUnchangeable(false);
updateInternalData();
if (!isAlreadyUnchangeable)
setUnchangeable(false);
}
void TopicEditor::setDuration(int duration)
{
m_topicData.duration = duration;
updateInternalLength();
m_topicData.duration = duration;
updateInternalLength();
}
void TopicEditor::init(TopicPreviewWidget *widget)
void TopicEditor::init(TopicPreviewWidget* widget)
{
m_previewWidget = widget;
connect(m_previewWidget, &TopicPreviewWidget::deleteMe,
this, &TopicEditor::deleteLater);
m_previewWidget = widget;
connect(m_previewWidget, &TopicPreviewWidget::deleteMe, this, &TopicEditor::deleteLater);
m_previewWidget->setTopicEnabled(false);
connect(this, &TopicEditor::signalChangesMade, this, [this]()
{
m_previewWidget->setTopicEnabled(false);
});
connect(this, &TopicEditor::signalChangesMade, this, [this]() { m_previewWidget->setTopicEnabled(false); });
}
void TopicEditor::setTopicDataProperty(const QString &key, const QJsonValue &value)
void TopicEditor::setTopicDataProperty(const QString& key, const QJsonValue& value)
{
m_topicData.properties[key] = value;
emit signalChangesMade();
m_topicData.properties[key] = value;
emit signalChangesMade();
}
void TopicEditor::applied()
{
m_previewWidget->setTopicEnabled(true);
emit topicDataChanged();
m_previewWidget->setTopicEnabled(true);
emit topicDataChanged();
}
void TopicEditor::setIsPlaying(bool isPlaying)
{
m_isPlaying = isPlaying;
m_isPlaying = isPlaying;
}
bool TopicEditor::apply()
{
if (m_previewWidget == nullptr)
{
QMessageBox::critical(
nullptr, QStringLiteral("An den Entwickler!"),
QStringLiteral("!! STOP !! - Dieser Topic Editor hatte 'init()' vorher nicht aufgerufen!")
);
return false;
}
if (m_isPlaying)
{
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Please Stop Playback first"));
return false;
}
if (m_previewWidget == nullptr)
{
QMessageBox::critical(
nullptr, QStringLiteral("An den Entwickler!"),
QStringLiteral("!! STOP !! - Dieser Topic Editor hatte 'init()' vorher nicht aufgerufen!"));
bool result = apply2();
if (result)
applied();
return result;
return false;
}
if (m_isPlaying)
{
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Please Stop Playback first"));
return false;
}
bool result = apply2();
if (result)
applied();
return result;
}
}
} // namespace TopicEditorBase
+116 -80
View File
@@ -1,125 +1,161 @@
#pragma once
#include <QObject>
#include "topic_editor_utils.h"
#include "topiceditorbase_export.h"
#include <LtsWidgets/lts_dialog.h>
#include <LtsUtilsCore/promise.h>
#include <LtsWidgets/lts_dialog.h>
#include <QJsonArray>
#include <QJsonObject>
#include <QObject>
namespace LtsUtils { class Promise; }
namespace LtsUtils
{
class Promise;
}
namespace TopicEditorBase
{
class TopicPreviewWidget;
class TOPICEDITORBASE_EXPORT ExportNotifier : public QObject
class TOPICEDITORBASE_EXPORT ExportNotifier : public QObject
{
Q_OBJECT
Q_OBJECT
public:
ExportNotifier(QObject *parent)
: QObject(parent)
{}
public:
ExportNotifier(QObject* parent) : QObject(parent) {}
bool isSuccessful = false;
QString successMessage;
bool isSuccessful = false;
QString successMessage;
void setExportSuccessful(const QString &message)
{
isSuccessful = true;
successMessage = message;
emit exportSuccessful(message);
emit exportFinished();
}
void setExportSuccessful(const QString& message)
{
isSuccessful = true;
successMessage = message;
emit exportSuccessful(message);
emit exportFinished();
}
void setExportFailed()
{
isSuccessful = false;
successMessage = QString();
emit exportFailed();
emit exportFinished();
}
void setExportFailed()
{
isSuccessful = false;
successMessage = QString();
emit exportFailed();
emit exportFinished();
}
signals:
void stillAlive();
void exportSuccessful(const QString &);
void exportFailed();
void exportFinished();
signals:
void stillAlive();
void exportSuccessful(const QString&);
void exportFailed();
void exportFinished();
};
class TOPICEDITORBASE_EXPORT TopicEditor: public LtsWidgets::LtsDialog
class TOPICEDITORBASE_EXPORT TopicEditor : public LtsWidgets::LtsDialog
{
Q_OBJECT
Q_OBJECT
public:
explicit TopicEditor(QWidget *parent = nullptr);
virtual ~TopicEditor() = default;
public:
explicit TopicEditor(QWidget* parent = nullptr);
virtual ~TopicEditor() = default;
TopicData &topicData() { return m_topicData; }
void setTopicData(const TopicData &data);
TopicData& topicData()
{
return m_topicData;
}
int topicId() const { return m_topicData.id; }
void setTopicData(const TopicData& data);
int startTime() const { return m_topicData.startTime; }
void setStartTime(int start) { m_topicData.startTime = start; }
int topicId() const
{
return m_topicData.id;
}
int duration() const { return m_topicData.duration; }
void setDuration(int duration);
int startTime() const
{
return m_topicData.startTime;
}
QString description() const { return m_topicData.description; }
void setDescription(const QString &description) { m_topicData.description = description; }
void setStartTime(int start)
{
m_topicData.startTime = start;
}
TopicPreviewWidget *topicPreviewWidget() { return m_previewWidget; }
int duration() const
{
return m_topicData.duration;
}
protected:
void init(TopicPreviewWidget *widget);
void setDuration(int duration);
QString description() const
{
return m_topicData.description;
}
virtual void updateInternalData() = 0;
virtual void updateInternalLength() {}
void setDescription(const QString& description)
{
m_topicData.description = description;
}
TopicType topicType() const { return m_topicData.topicType; }
QJsonValue getTopicDataValue(const QString &key) const { return m_topicData.properties.value(key); }
QJsonArray getTopicVDataAsArray(const QString &key) const { return m_topicData.properties.value(key).toArray(); }
TopicPreviewWidget* topicPreviewWidget()
{
return m_previewWidget;
}
bool hasTopicDataProperties() const { return !m_topicData.properties.isEmpty(); }
void setTopicDataProperty(const QString &key, const QJsonValue &value);
protected:
void init(TopicPreviewWidget* widget);
void applied();
virtual void updateInternalData() = 0;
public slots:
virtual bool apply2() = 0;
void setIsPlaying(bool isPlaying);
virtual void updateInternalLength() {}
private slots:
bool apply() override final;
TopicType topicType() const
{
return m_topicData.topicType;
}
signals:
void topicDataChanged();
void topicEditorRequested(const TopicData &);
void durationCheckRequested(int duration, LtsUtils::Promise *promise);
void signalSetTopicPosition(QWidget *widget, int ignoreTopicForReplay);
void changesSaved(const TopicData &data);
QJsonValue getTopicDataValue(const QString& key) const
{
return m_topicData.properties.value(key);
}
protected:
TopicData m_topicData;
int m_topicDuration{-1};
bool m_isPlaying {false};
QJsonArray getTopicVDataAsArray(const QString& key) const
{
return m_topicData.properties.value(key).toArray();
}
TopicPreviewWidget *m_previewWidget{nullptr};
bool hasTopicDataProperties() const
{
return !m_topicData.properties.isEmpty();
}
void setTopicDataProperty(const QString& key, const QJsonValue& value);
void applied();
public slots:
virtual bool apply2() = 0;
void setIsPlaying(bool isPlaying);
private slots:
bool apply() override final;
signals:
void topicDataChanged();
void topicEditorRequested(const TopicData&);
void durationCheckRequested(int duration, LtsUtils::Promise* promise);
void signalSetTopicPosition(QWidget* widget, int ignoreTopicForReplay);
void changesSaved(const TopicData& data);
protected:
TopicData m_topicData;
int m_topicDuration{-1};
bool m_isPlaying{false};
TopicPreviewWidget* m_previewWidget{nullptr};
};
}
} // namespace TopicEditorBase
+10 -10
View File
@@ -1,12 +1,10 @@
#pragma once
#include "topic_editor_utils.h"
namespace TopicEditorBase
namespace TopicEditorBase
{
class TopicEditor;
@@ -14,15 +12,17 @@ class TopicEditor;
class Interface
{
public:
virtual ~Interface() = default;
public:
virtual ~Interface() = default;
virtual TopicEditor* createTopicEditor(const TopicData&) = 0;
virtual TopicEditor *createTopicEditor(const TopicData &) = 0;
virtual bool initTopicEditor() { return true; }
virtual void finishTopicEditor() {}
virtual bool initTopicEditor()
{
return true;
}
virtual void finishTopicEditor() {}
};
}
} // namespace TopicEditorBase
+241 -264
View File
@@ -8,311 +8,288 @@
#include <QLabel>
#include <QString>
namespace TopicEditorBase
{
QString topicTypeTranslation(TopicType topicType)
{
switch (topicType)
{
case TopicType::SituationMap:
return QLabel::tr("SituationMap");
case TopicType::SituationReplay:
return QLabel::tr("SituationReplay");
case TopicType::Image:
return QLabel::tr("Image");
case TopicType::Text:
return QLabel::tr("Text");
case TopicType::Pdf:
return QLabel::tr("Pdf");
case TopicType::Xml:
return QLabel::tr("Xml");
case TopicType::TacticalPlan:
return QLabel::tr("TacticalPlan");
case TopicType::MSOffice:
return QLabel::tr("MSOffice");
case TopicType::OpenOffice:
return QLabel::tr("OpenOffice");
case TopicType::Audio:
return QLabel::tr("Audio");
case TopicType::Video:
return QLabel::tr("Video");
case TopicType::Building:
return QLabel::tr("Building");
case TopicType::SituationMapFilter:
return QLabel::tr("SituationMapFilter");
case TopicType::Snapshot:
return QLabel::tr("Snapshot");
case TopicType::Evaluation:
return QLabel::tr("Evaluation");
case TopicType::Report:
return QLabel::tr("Report");
case TopicType::Situation:
return QLabel::tr("Situation");
case TopicType::Invalid:
default:
return QLabel::tr("Invalid");
}
Q_UNREACHABLE();
switch (topicType)
{
case TopicType::SituationMap:
return QLabel::tr("SituationMap");
case TopicType::SituationReplay:
return QLabel::tr("SituationReplay");
case TopicType::Image:
return QLabel::tr("Image");
case TopicType::Text:
return QLabel::tr("Text");
case TopicType::Pdf:
return QLabel::tr("Pdf");
case TopicType::Xml:
return QLabel::tr("Xml");
case TopicType::TacticalPlan:
return QLabel::tr("TacticalPlan");
case TopicType::MSOffice:
return QLabel::tr("MSOffice");
case TopicType::OpenOffice:
return QLabel::tr("OpenOffice");
case TopicType::Audio:
return QLabel::tr("Audio");
case TopicType::Video:
return QLabel::tr("Video");
case TopicType::Building:
return QLabel::tr("Building");
case TopicType::SituationMapFilter:
return QLabel::tr("SituationMapFilter");
case TopicType::Snapshot:
return QLabel::tr("Snapshot");
case TopicType::Evaluation:
return QLabel::tr("Evaluation");
case TopicType::Report:
return QLabel::tr("Report");
case TopicType::Situation:
return QLabel::tr("Situation");
case TopicType::Invalid:
default:
return QLabel::tr("Invalid");
}
Q_UNREACHABLE();
}
QString topicTypeString(TopicType topicType)
{
switch (topicType)
{
case TopicType::SituationMap:
return QStringLiteral("SituationMap");
case TopicType::SituationReplay:
return QStringLiteral("SituationReplay");
case TopicType::Image:
return QStringLiteral("Image");
case TopicType::Text:
return QStringLiteral("Text");
case TopicType::Pdf:
return QStringLiteral("Pdf");
case TopicType::Xml:
return QStringLiteral("Xml");
case TopicType::TacticalPlan:
return QStringLiteral("TacticalPlan");
case TopicType::MSOffice:
return QStringLiteral("MSOffice");
case TopicType::OpenOffice:
return QStringLiteral("OpenOffice");
case TopicType::Audio:
return QStringLiteral("Audio");
case TopicType::Video:
return QStringLiteral("Video");
case TopicType::Building:
return QStringLiteral("Building");
case TopicType::SituationMapFilter:
return QStringLiteral("SituationMapFilter");
case TopicType::Snapshot:
return QStringLiteral("Snapshot");
case TopicType::Evaluation:
return QStringLiteral("Evaluation");
case TopicType::Report:
return QStringLiteral("Report");
case TopicType::Situation:
return QStringLiteral("Situation");
case TopicType::Invalid:
default:
return QStringLiteral("Invalid");
}
Q_UNREACHABLE();
switch (topicType)
{
case TopicType::SituationMap:
return QStringLiteral("SituationMap");
case TopicType::SituationReplay:
return QStringLiteral("SituationReplay");
case TopicType::Image:
return QStringLiteral("Image");
case TopicType::Text:
return QStringLiteral("Text");
case TopicType::Pdf:
return QStringLiteral("Pdf");
case TopicType::Xml:
return QStringLiteral("Xml");
case TopicType::TacticalPlan:
return QStringLiteral("TacticalPlan");
case TopicType::MSOffice:
return QStringLiteral("MSOffice");
case TopicType::OpenOffice:
return QStringLiteral("OpenOffice");
case TopicType::Audio:
return QStringLiteral("Audio");
case TopicType::Video:
return QStringLiteral("Video");
case TopicType::Building:
return QStringLiteral("Building");
case TopicType::SituationMapFilter:
return QStringLiteral("SituationMapFilter");
case TopicType::Snapshot:
return QStringLiteral("Snapshot");
case TopicType::Evaluation:
return QStringLiteral("Evaluation");
case TopicType::Report:
return QStringLiteral("Report");
case TopicType::Situation:
return QStringLiteral("Situation");
case TopicType::Invalid:
default:
return QStringLiteral("Invalid");
}
Q_UNREACHABLE();
}
TopicType topicTypeFromString(const QString &topicName)
TopicType topicTypeFromString(const QString& topicName)
{
static const QHash<QString, TopicType> topics =
{
{ QStringLiteral("Invalid"), TopicType::Invalid },
{ QStringLiteral("SituationMap"), TopicType::SituationMap },
{ QStringLiteral("SituationReplay"), TopicType::SituationReplay },
{ QStringLiteral("Image"), TopicType::Image },
{ QStringLiteral("Text"), TopicType::Text },
{ QStringLiteral("Pdf"), TopicType::Pdf },
{ QStringLiteral("Xml"), TopicType::Xml },
{ QStringLiteral("TacticalPlan"), TopicType::TacticalPlan },
{ QStringLiteral("MSOffice"), TopicType::MSOffice },
{ QStringLiteral("OpenOffice"), TopicType::OpenOffice },
{ QStringLiteral("Audio"), TopicType::Audio },
{ QStringLiteral("Video"), TopicType::Video },
{ QStringLiteral("Building"), TopicType::Building },
{ QStringLiteral("SituationMapFilter"), TopicType::SituationMapFilter },
{ QStringLiteral("Snapshot"), TopicType::Snapshot },
{ QStringLiteral("Evaluation"), TopicType::Evaluation },
{ QStringLiteral("Report"), TopicType::Report },
{ QStringLiteral("Situation"), TopicType::Situation },
};
return topics.contains(topicName) ? topics.value(topicName) : TopicType::Invalid;
static const QHash<QString, TopicType> topics = {
{QStringLiteral("Invalid"), TopicType::Invalid},
{QStringLiteral("SituationMap"), TopicType::SituationMap},
{QStringLiteral("SituationReplay"), TopicType::SituationReplay},
{QStringLiteral("Image"), TopicType::Image},
{QStringLiteral("Text"), TopicType::Text},
{QStringLiteral("Pdf"), TopicType::Pdf},
{QStringLiteral("Xml"), TopicType::Xml},
{QStringLiteral("TacticalPlan"), TopicType::TacticalPlan},
{QStringLiteral("MSOffice"), TopicType::MSOffice},
{QStringLiteral("OpenOffice"), TopicType::OpenOffice},
{QStringLiteral("Audio"), TopicType::Audio},
{QStringLiteral("Video"), TopicType::Video},
{QStringLiteral("Building"), TopicType::Building},
{QStringLiteral("SituationMapFilter"), TopicType::SituationMapFilter},
{QStringLiteral("Snapshot"), TopicType::Snapshot},
{QStringLiteral("Evaluation"), TopicType::Evaluation},
{QStringLiteral("Report"), TopicType::Report},
{QStringLiteral("Situation"), TopicType::Situation},
};
return topics.contains(topicName) ? topics.value(topicName) : TopicType::Invalid;
}
QIcon topicIcon(const TopicType topicType)
{
switch (topicType)
{
case TopicType::SituationMap:
return QIcon(QLatin1String("icon:add_situation.svg"));
case TopicType::Situation:
return QIcon(QLatin1String("icon:add_situation_combined.svg"));
case TopicType::SituationReplay:
return QIcon(QLatin1String("icon:add_restart.svg"));
case TopicType::Image:
return QIcon(QLatin1String("icon:create_image_topic.svg"));
case TopicType::Text:
return QIcon(QLatin1String("icon:document-new-txt.svg"));
case TopicType::Pdf:
return QIcon(QLatin1String("icon:create_pdf_topic.svg"));
case TopicType::Xml:
return QIcon(QLatin1String("icon:document-new-xml.svg"));
case TopicType::TacticalPlan:
return QIcon(QLatin1String("icon:tactical_organization.svg"));
case TopicType::MSOffice:
return QIcon(QLatin1String("icon:ms_office.svg"));
case TopicType::OpenOffice:
return QIcon(QLatin1String("icon:documents.svg"));
case TopicType::Audio:
return QIcon(QLatin1String("icon:create_lecture_topic.svg"));
case TopicType::Video:
return QIcon(QLatin1String("icon:add_video_menu.svg"));
case TopicType::Building:
return QIcon(QLatin1String("icon:configure_buildings.svg"));
case TopicType::SituationMapFilter:
return QIcon(QLatin1String("icon:filter_player.svg"));
case TopicType::Snapshot:
return QIcon(QLatin1String("icon:create_snapshot.svg"));
case TopicType::Evaluation:
return QIcon(QLatin1String("icon:add_evaluation_elements.svg"));
case TopicType::Report:
return QIcon(QLatin1String("icon:add_reports_display.svg"));
case TopicType::Invalid:
default:
return QIcon();
}
Q_UNREACHABLE();
switch (topicType)
{
case TopicType::SituationMap:
return QIcon(QLatin1String("icon:add_situation.svg"));
case TopicType::Situation:
return QIcon(QLatin1String("icon:add_situation_combined.svg"));
case TopicType::SituationReplay:
return QIcon(QLatin1String("icon:add_restart.svg"));
case TopicType::Image:
return QIcon(QLatin1String("icon:create_image_topic.svg"));
case TopicType::Text:
return QIcon(QLatin1String("icon:document-new-txt.svg"));
case TopicType::Pdf:
return QIcon(QLatin1String("icon:create_pdf_topic.svg"));
case TopicType::Xml:
return QIcon(QLatin1String("icon:document-new-xml.svg"));
case TopicType::TacticalPlan:
return QIcon(QLatin1String("icon:tactical_organization.svg"));
case TopicType::MSOffice:
return QIcon(QLatin1String("icon:ms_office.svg"));
case TopicType::OpenOffice:
return QIcon(QLatin1String("icon:documents.svg"));
case TopicType::Audio:
return QIcon(QLatin1String("icon:create_lecture_topic.svg"));
case TopicType::Video:
return QIcon(QLatin1String("icon:add_video_menu.svg"));
case TopicType::Building:
return QIcon(QLatin1String("icon:configure_buildings.svg"));
case TopicType::SituationMapFilter:
return QIcon(QLatin1String("icon:filter_player.svg"));
case TopicType::Snapshot:
return QIcon(QLatin1String("icon:create_snapshot.svg"));
case TopicType::Evaluation:
return QIcon(QLatin1String("icon:add_evaluation_elements.svg"));
case TopicType::Report:
return QIcon(QLatin1String("icon:add_reports_display.svg"));
case TopicType::Invalid:
default:
return QIcon();
}
Q_UNREACHABLE();
}
QColor topicTypeColor(TopicType topicType)
{
switch (topicType)
{
case TopicType::SituationMap:
return QRgb(0xb1cbbb);
case TopicType::SituationReplay:
return QRgb(0xc94c4c);
case TopicType::Image:
return QRgb(0xfefbd8);
case TopicType::Text:
return QRgb(0x92a8d1);
case TopicType::Pdf:
return QRgb(0x80ced6);
case TopicType::Xml:
return QRgb(0xeea29a);
case TopicType::TacticalPlan:
return QRgb(0xdac292);
case TopicType::MSOffice:
return QRgb(0xf7cac9);
case TopicType::OpenOffice:
return QRgb(0xb2b2b2);
case TopicType::Audio:
return QRgb(0x034f84);
case TopicType::Video:
return QRgb(0x618685);
case TopicType::Building:
return QRgb(0xc6bcb6);
case TopicType::SituationMapFilter:
return QRgb(0x36486b);
case TopicType::Snapshot:
return QRgb(0xf18973);
case TopicType::Evaluation:
return QRgb(0xd6cbd3);
case TopicType::Report:
return QRgb(0xfeb236);
case TopicType::Situation:
return QRgb(0xb1c1cb);
case TopicType::Invalid:
default:
return Qt::black;
}
Q_UNREACHABLE();
return {};
switch (topicType)
{
case TopicType::SituationMap:
return QRgb(0xb1cbbb);
case TopicType::SituationReplay:
return QRgb(0xc94c4c);
case TopicType::Image:
return QRgb(0xfefbd8);
case TopicType::Text:
return QRgb(0x92a8d1);
case TopicType::Pdf:
return QRgb(0x80ced6);
case TopicType::Xml:
return QRgb(0xeea29a);
case TopicType::TacticalPlan:
return QRgb(0xdac292);
case TopicType::MSOffice:
return QRgb(0xf7cac9);
case TopicType::OpenOffice:
return QRgb(0xb2b2b2);
case TopicType::Audio:
return QRgb(0x034f84);
case TopicType::Video:
return QRgb(0x618685);
case TopicType::Building:
return QRgb(0xc6bcb6);
case TopicType::SituationMapFilter:
return QRgb(0x36486b);
case TopicType::Snapshot:
return QRgb(0xf18973);
case TopicType::Evaluation:
return QRgb(0xd6cbd3);
case TopicType::Report:
return QRgb(0xfeb236);
case TopicType::Situation:
return QRgb(0xb1c1cb);
case TopicType::Invalid:
default:
return Qt::black;
}
Q_UNREACHABLE();
return {};
}
std::ostream& operator<<(std::ostream& stream, TopicType topicType)
{
stream << "TopicType::" << topicTypeString(topicType).toStdString().c_str();
return stream;
stream << "TopicType::" << topicTypeString(topicType).toStdString().c_str();
return stream;
}
const QString TopicData::mime = QStringLiteral("application/rheinmetall.topiceditorbase.topicdata");
TopicData::TopicData(TopicType topicType) : topicType(topicType) {}
TopicData::TopicData(TopicType topicType)
: topicType(topicType)
{}
TopicData::TopicData(TopicType topicType, int duration) : topicType(topicType), duration(duration) {}
TopicData::TopicData(TopicType topicType, int duration)
: topicType(topicType)
, duration(duration)
{}
TopicData::TopicData(
int id, TopicType topicType, int startTime, int duration, const QString &description, const QString &channel,
const QJsonObject &properties
)
: topicType(topicType)
, id(id)
, startTime(startTime)
, duration(duration)
, properties(properties)
, description(description)
, channel(channel)
{}
void TopicData::fromJson(const QJsonObject &obj)
TopicData::TopicData(int id, TopicType topicType, int startTime, int duration, const QString& description,
const QString& channel, const QJsonObject& properties)
: topicType(topicType), id(id), startTime(startTime), duration(duration), properties(properties),
description(description), channel(channel)
{
id = obj[QStringLiteral("topicId")].toInt();
topicType = static_cast<TopicType>(obj[QStringLiteral("type")].toInt());
startTime = obj[QStringLiteral("startTime")].toInt(-1);
duration = obj[QStringLiteral("length")].toInt(-1);
state = obj[QStringLiteral("isSet")].toBool();
index = obj[QStringLiteral("index")].toInt();
properties = obj[QStringLiteral("detailData")].toObject();
description = obj[QStringLiteral("description")].toString();
channel = obj[QStringLiteral("channelName")].toString();
parentChannel = obj[QStringLiteral("filterParentChannel")].toString();
x = obj[QStringLiteral("x")].toDouble();
y = obj[QStringLiteral("y")].toDouble();
w = obj[QStringLiteral("w")].toDouble();
h = obj[QStringLiteral("h")].toDouble();
}
void TopicData::fromJson(const QJsonObject& obj)
{
id = obj[QStringLiteral("topicId")].toInt();
topicType = static_cast<TopicType>(obj[QStringLiteral("type")].toInt());
startTime = obj[QStringLiteral("startTime")].toInt(-1);
duration = obj[QStringLiteral("length")].toInt(-1);
state = obj[QStringLiteral("isSet")].toBool();
index = obj[QStringLiteral("index")].toInt();
properties = obj[QStringLiteral("detailData")].toObject();
description = obj[QStringLiteral("description")].toString();
channel = obj[QStringLiteral("channelName")].toString();
parentChannel = obj[QStringLiteral("filterParentChannel")].toString();
x = obj[QStringLiteral("x")].toDouble();
y = obj[QStringLiteral("y")].toDouble();
w = obj[QStringLiteral("w")].toDouble();
h = obj[QStringLiteral("h")].toDouble();
}
QJsonObject TopicData::toJson() const
{
return QJsonObject({
{ QStringLiteral("topicId"), id },
{ QStringLiteral("startTime"), startTime },
{ QStringLiteral("length"), duration },
{ QStringLiteral("type"), static_cast<int>(topicType) },
{ QStringLiteral("isSet"), state },
{ QStringLiteral("index"), index },
{ QStringLiteral("detailData"), properties },
{ QStringLiteral("description"), description },
{ QStringLiteral("channelName"), channel },
{ QStringLiteral("filterParentChannel"), parentChannel },
{ QStringLiteral("x"), x },
{ QStringLiteral("y"), y },
{ QStringLiteral("w"), w },
{ QStringLiteral("h"), h }
});
return QJsonObject({{QStringLiteral("topicId"), id},
{QStringLiteral("startTime"), startTime},
{QStringLiteral("length"), duration},
{QStringLiteral("type"), static_cast<int>(topicType)},
{QStringLiteral("isSet"), state},
{QStringLiteral("index"), index},
{QStringLiteral("detailData"), properties},
{QStringLiteral("description"), description},
{QStringLiteral("channelName"), channel},
{QStringLiteral("filterParentChannel"), parentChannel},
{QStringLiteral("x"), x},
{QStringLiteral("y"), y},
{QStringLiteral("w"), w},
{QStringLiteral("h"), h}});
}
QDataStream &operator<<(QDataStream &stream, const TopicData &data)
QDataStream& operator<<(QDataStream& stream, const TopicData& data)
{
const QByteArray properties = QJsonDocument(data.properties).toBinaryData();
stream << data.id << static_cast<quint8>(data.topicType) << data.startTime << data.duration << data.state << data.index
<< properties << data.description << data.channel << data.parentChannel << data.x << data.y << data.w << data.h;
return stream;
const QByteArray properties = QJsonDocument(data.properties).toBinaryData();
stream << data.id << static_cast<quint8>(data.topicType) << data.startTime << data.duration << data.state
<< data.index << properties << data.description << data.channel << data.parentChannel << data.x << data.y
<< data.w << data.h;
return stream;
}
QDataStream &operator >>(QDataStream &stream, TopicData &data)
QDataStream& operator>>(QDataStream& stream, TopicData& data)
{
QByteArray properties;
quint8 topicType;
stream >> data.id >> topicType >> data.startTime >> data.duration >> data.state >> data.index >> properties
>> data.description >> data.channel >> data.parentChannel >> data.x >> data.y >> data.w >> data.h;
data.topicType = static_cast<TopicType>(topicType);
data.properties = QJsonDocument::fromBinaryData(properties).object();
return stream;
QByteArray properties;
quint8 topicType;
stream >> data.id >> topicType >> data.startTime >> data.duration >> data.state >> data.index >> properties >>
data.description >> data.channel >> data.parentChannel >> data.x >> data.y >> data.w >> data.h;
data.topicType = static_cast<TopicType>(topicType);
data.properties = QJsonDocument::fromBinaryData(properties).object();
return stream;
}
}
} // namespace TopicEditorBase
+46 -54
View File
@@ -3,36 +3,32 @@
#include "topiceditorbase_export.h"
#include <LtsScriptTimeline/track_entry.h>
#include <QVector>
class QColor;
namespace TopicEditorBase
{
enum class TopicType
{
Invalid,
SituationMap,
SituationReplay,
Image,
Text,
Pdf,
Xml,
TacticalPlan,
MSOffice,
OpenOffice,
Audio,
Video,
Building,
SituationMapFilter,
Snapshot,
Evaluation,
Report,
Situation
enum class TopicType {
Invalid,
SituationMap,
SituationReplay,
Image,
Text,
Pdf,
Xml,
TacticalPlan,
MSOffice,
OpenOffice,
Audio,
Video,
Building,
SituationMapFilter,
Snapshot,
Evaluation,
Report,
Situation
};
typedef QVector<TopicType> TopicTypes;
@@ -40,7 +36,7 @@ TOPICEDITORBASE_EXPORT QString topicTypeTranslation(TopicType topicType);
TOPICEDITORBASE_EXPORT QString topicTypeString(TopicType topicType);
TOPICEDITORBASE_EXPORT TopicType topicTypeFromString(const QString &topicName);
TOPICEDITORBASE_EXPORT TopicType topicTypeFromString(const QString& topicName);
TOPICEDITORBASE_EXPORT QIcon topicIcon(TopicType topicType);
@@ -48,44 +44,40 @@ TOPICEDITORBASE_EXPORT QColor topicTypeColor(TopicType topicType);
TOPICEDITORBASE_EXPORT std::ostream& operator<<(std::ostream& stream, TopicType topicType);
struct TOPICEDITORBASE_EXPORT TopicData
{
static const QString mime;
static const QString mime;
TopicType topicType{TopicType::Invalid};
int id{-1};
int startTime{-1};
int duration{0};
TopicType topicType{TopicType::Invalid};
int id{-1};
int startTime{-1};
int duration{0};
bool state{false};
int index{-1};
bool state{false};
int index{-1};
QJsonObject properties;
QString description;
QString channel;
QString parentChannel;
QJsonObject properties;
QString description;
QString channel;
QString parentChannel;
double x{0.};
double y{0.};
double h{0.};
double w{0.};
double x{0.};
double y{0.};
double h{0.};
double w{0.};
TopicData() = default;
TopicData(const TopicData &data) = default;
explicit TopicData(TopicType topicType);
explicit TopicData(TopicType topicType, int duration);
explicit TopicData(
int id, TopicType topicType, int startTime, int duration, const QString &description, const QString &channel,
const QJsonObject &properties
);
TopicData() = default;
TopicData(const TopicData& data) = default;
explicit TopicData(TopicType topicType);
explicit TopicData(TopicType topicType, int duration);
explicit TopicData(int id, TopicType topicType, int startTime, int duration, const QString& description,
const QString& channel, const QJsonObject& properties);
void fromJson(const QJsonObject &obj);
QJsonObject toJson() const;
void fromJson(const QJsonObject& obj);
QJsonObject toJson() const;
};
TOPICEDITORBASE_EXPORT QDataStream &operator<<(QDataStream &stream, const TopicData &data);
TOPICEDITORBASE_EXPORT QDataStream &operator>>(QDataStream &stream, TopicData &data);
TOPICEDITORBASE_EXPORT QDataStream& operator<<(QDataStream& stream, const TopicData& data);
TOPICEDITORBASE_EXPORT QDataStream& operator>>(QDataStream& stream, TopicData& data);
}
} // namespace TopicEditorBase
+52 -75
View File
@@ -1,126 +1,103 @@
#include "topic_preview_widget.h"
#include "ui_topic_preview_widget.h"
#include "topic_previewer.h"
#include "ui_topic_preview_widget.h"
#include <LtsSession/lts_session_data.h>
#include <LtsWidgets/lts_message_dialog.h>
#include <QContextMenuEvent>
#include <QJsonDocument>
#include <QMenu>
#include <QTextEdit>
namespace TopicEditorBase
{
TopicPreviewWidget::TopicPreviewWidget(QWidget *parent)
: QWidget(parent)
, m_ui(new Ui::TopicPreviewWidget)
TopicPreviewWidget::TopicPreviewWidget(QWidget* parent) : QWidget(parent), m_ui(new Ui::TopicPreviewWidget)
{
m_ui->setupUi(this);
m_ui->setupUi(this);
#ifndef LTS_DEBUG
m_ui->lbxTopicId->hide();
m_ui->lblTopicId->hide();
m_ui->lbxTopicId->hide();
m_ui->lblTopicId->hide();
m_ui->lbxDuration->hide();
m_ui->lblDuration->hide();
m_ui->lbxDuration->hide();
m_ui->lblDuration->hide();
#endif
connect(m_ui->widget, &TopicPreviewer::deleteMe,
this, &TopicPreviewWidget::deleteMe);
connect(m_ui->widget, &TopicPreviewer::deleteMe, this, &TopicPreviewWidget::deleteMe);
connect(m_ui->widget, &TopicPreviewer::startDragMe,
this, &TopicPreviewWidget::startDragMe);
connect(m_ui->widget, &TopicPreviewer::stopDragMe,
this, &TopicPreviewWidget::stopDragMe);
connect(m_ui->widget, &TopicPreviewer::startDragMe, this, &TopicPreviewWidget::startDragMe);
connect(m_ui->widget, &TopicPreviewer::stopDragMe, this, &TopicPreviewWidget::stopDragMe);
}
TopicPreviewWidget::~TopicPreviewWidget()
{
delete m_ui;
delete m_ui;
}
void TopicPreviewWidget::setTopicEnabled(bool enabled)
{
m_ui->widget->setEnabled(enabled);
m_ui->widget->setEnabled(enabled);
}
void TopicPreviewWidget::setTopicData(const TopicData &data)
void TopicPreviewWidget::setTopicData(const TopicData& data)
{
m_ui->lbxDragAndDrop->setVisible(!data.state);
m_ui->widget->setVisible(!data.state);
m_ui->lbxDragAndDrop->setVisible(!data.state);
m_ui->widget->setVisible(!data.state);
m_ui->leDescription->setText(data.description);
m_ui->lblTopicId->setText(QString::number(data.id));
m_ui->lblDuration->setText(QString::number(data.duration));
m_ui->widget->setTopicData(data);
m_ui->leDescription->setText(data.description);
m_ui->lblTopicId->setText(QString::number(data.id));
m_ui->lblDuration->setText(QString::number(data.duration));
m_ui->widget->setTopicData(data);
}
QString TopicPreviewWidget::description() const
{
return m_ui->leDescription->text();
return m_ui->leDescription->text();
}
void TopicPreviewWidget::setDescription(const QString &description)
void TopicPreviewWidget::setDescription(const QString& description)
{
m_ui->leDescription->setText(description);
m_ui->leDescription->setText(description);
}
TopicPreviewer *TopicPreviewWidget::previewer()
TopicPreviewer* TopicPreviewWidget::previewer()
{
return m_ui->widget;
return m_ui->widget;
}
void TopicPreviewWidget::contextMenuEvent(QContextMenuEvent *event)
void TopicPreviewWidget::contextMenuEvent(QContextMenuEvent* event)
{
#ifndef LTS_DEBUG
if (LtsSessionData::LtsSessionData::getInstance()->debugFlagValue(QStringLiteral("TopicPreviewWidget.DebugMenu")) == QVariant(true))
if (LtsSessionData::LtsSessionData::getInstance()->debugFlagValue(QStringLiteral("TopicPreviewWidget.DebugMenu")) ==
QVariant(true))
#endif
{
QMenu *menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose);
QPoint p = mapToGlobal(menu->pos());
menu->setGeometry(QRect(p, QPoint(event->x(), event->y())));
menu->addAction(QStringLiteral("enable"), this, [this]()
{
setTopicEnabled(true);
});
QMenu* menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose);
menu->addAction(QStringLiteral("disable"), this, [this]()
{
setTopicEnabled(false);
});
menu->addAction(QStringLiteral("show properties"), this, [this]()
{
TopicData data = m_ui->widget->topicData();
if (data.properties.isEmpty())
{
LtsWidgets::LtsMessageDialog::showMessage(this, QStringLiteral("no properties available"));
return;
}
QPoint p = mapToGlobal(menu->pos());
menu->setGeometry(QRect(p, QPoint(event->x(), event->y())));
menu->addAction(QStringLiteral("enable"), this, [this]() { setTopicEnabled(true); });
QTextEdit *ted = new QTextEdit(nullptr);
ted->setAttribute(Qt::WA_DeleteOnClose);
ted->setWindowTitle(QStringLiteral("Track Entry #%1 - Detail Data string").arg(data.id));
ted->setText(QString::fromUtf8(QJsonDocument(data.properties).toJson()));
ted->setReadOnly(true);
ted->show();
});
menu->addAction(QStringLiteral("disable"), this, [this]() { setTopicEnabled(false); });
menu->addAction(QStringLiteral("show properties"), this, [this]() {
TopicData data = m_ui->widget->topicData();
if (data.properties.isEmpty())
{
LtsWidgets::LtsMessageDialog::showMessage(this, QStringLiteral("no properties available"));
return;
}
menu->show();
}
QTextEdit* ted = new QTextEdit(nullptr);
ted->setAttribute(Qt::WA_DeleteOnClose);
ted->setWindowTitle(QStringLiteral("Track Entry #%1 - Detail Data string").arg(data.id));
ted->setText(QString::fromUtf8(QJsonDocument(data.properties).toJson()));
ted->setReadOnly(true);
ted->show();
});
menu->show();
}
}
}
} // namespace TopicEditorBase
+23 -26
View File
@@ -1,49 +1,46 @@
#pragma once
#include <QObject>
#include "topic_editor_utils.h"
#include "topiceditorbase_export.h"
#include <QObject>
#include <QWidget>
namespace Ui { class TopicPreviewWidget; }
namespace Ui
{
class TopicPreviewWidget;
}
namespace TopicEditorBase
{
class TopicPreviewer;
class TOPICEDITORBASE_EXPORT TopicPreviewWidget : public QWidget
{
Q_OBJECT
Q_OBJECT
public:
explicit TopicPreviewWidget(QWidget *parent = nullptr);
~TopicPreviewWidget();
public:
explicit TopicPreviewWidget(QWidget* parent = nullptr);
~TopicPreviewWidget();
void setTopicData(const TopicData &data);
void setTopicEnabled(bool enabled);
void setTopicData(const TopicData& data);
void setTopicEnabled(bool enabled);
QString description() const;
void setDescription(const QString &description);
QString description() const;
void setDescription(const QString& description);
TopicPreviewer *previewer();
TopicPreviewer* previewer();
private:
void contextMenuEvent(QContextMenuEvent *event);
private:
void contextMenuEvent(QContextMenuEvent* event);
signals:
void startDragMe();
void stopDragMe();
void deleteMe();
private:
Ui::TopicPreviewWidget *m_ui{nullptr};
signals:
void startDragMe();
void stopDragMe();
void deleteMe();
private:
Ui::TopicPreviewWidget* m_ui{nullptr};
};
}
} // namespace TopicEditorBase
+41 -53
View File
@@ -6,78 +6,66 @@
#include <QMouseEvent>
#include <QPainter>
namespace TopicEditorBase
{
TopicPreviewer::TopicPreviewer(QWidget *parent)
: QWidget(parent)
TopicPreviewer::TopicPreviewer(QWidget* parent) : QWidget(parent)
{
setVisible(false);
setVisible(false);
}
TopicPreviewer::~TopicPreviewer()
{}
TopicPreviewer::~TopicPreviewer() {}
void TopicPreviewer::setTopicData(const TopicData &data)
void TopicPreviewer::setTopicData(const TopicData& data)
{
m_topicData = data;
m_topicData = data;
if (m_topicData.state)
return;
if (m_topicData.state)
return;
}
void TopicPreviewer::mousePressEvent(QMouseEvent *event)
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();
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)
void TopicPreviewer::paintEvent(QPaintEvent* event)
{
QWidget::paintEvent(event);
QWidget::paintEvent(event);
if (m_topicData.topicType == TopicType::Invalid)
return;
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)));
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
+20 -20
View File
@@ -1,39 +1,39 @@
#pragma once
#include <QObject>
#include "topic_editor_utils.h"
#include "topiceditorbase_export.h"
#include <QObject>
#include <QWidget>
namespace TopicEditorBase
{
class TOPICEDITORBASE_EXPORT TopicPreviewer : public QWidget
{
Q_OBJECT
Q_OBJECT
public:
explicit TopicPreviewer(QWidget *parent = nullptr);
~TopicPreviewer();
public:
explicit TopicPreviewer(QWidget* parent = nullptr);
~TopicPreviewer();
void setTopicData(const TopicData &data);
TopicData topicData() const { return m_topicData; }
void setTopicData(const TopicData& data);
protected:
void mousePressEvent(QMouseEvent *event) override;
void paintEvent(QPaintEvent *event) override;
TopicData topicData() const
{
return m_topicData;
}
signals:
void startDragMe();
void stopDragMe();
void deleteMe();
protected:
void mousePressEvent(QMouseEvent* event) override;
void paintEvent(QPaintEvent* event) override;
private:
TopicData m_topicData;
signals:
void startDragMe();
void stopDragMe();
void deleteMe();
private:
TopicData m_topicData;
};
}
} // namespace TopicEditorBase