Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Plugins/Timeline/Gui/EventTimelineClassic/detail_data.h
T
Berrux Kana 3f7beb3c7e Qt6 migration: build fixes for Groups 10/11 + missing plugin modules
Continue the Qt5->Qt6 migration so the LTS Projects (Group 10) and LTS
Application (Group 11) compile, link, and ctest runs.

Qt5->Qt6 API migration (resolves removed/deprecated Qt6 APIs) across Lts
Tools and Apps, e.g. QAction->QActionGroup, QAbstractSocket::errorOccurred,
Qt::SkipEmptyParts, QRandomGenerator, QInputDevice::DeviceType,
QRegularExpression, QLatin1Literal->QStringLiteral, and the SampleModel
m_description->description rename.

CMake build fixes:
- CMakeLists.txt: add Lts/Common to CMAKE_AUTOMOC_INCLUDE_DIRECTORIES so moc
  resolves Q_INTERFACES(ProjectPlugin::Plugin) for the migrated Projects.
- cmake/NGLMacros.cmake: NGL_COMPILE_RESOURCES - replace return() (which aborts
  the calling CMakeLists.txt) with an if/else/endif.
- OpApp/THP: guard the ArcGISQt5Hack link with $<IF:$<TARGET_EXISTS:...>> (the
  target is absent when the SituationMap viewer is stubbed); matches
  CentralEffectSimulation.
- LtsSession: prefer the in-tree svcCoreClient target over a FIND_LIBRARY in
  /usr/local/lib.
- CnrProxyTester/DotMatrixDisplay: set AUTOUIC_SEARCH_PATHS for the ui/ subdir.
- TopicDiscover: link NGLLogger.

Export-header visibility stubs (expand the empty *_EXPORT macro to
__attribute__((visibility("default"))); the build sets -fvisibility=hidden and
these stubs shadow the CMake-generated header):
- include/LtsProjectionWorkstation/ltsprojectionworkstation_export.h (fixes
  undefined reference to LtsProjectionWorkstation::getInstance /
  setProjectionOperatorPreset)
- include/LtsSession/ltssession_export.h, include/LtsUtilsGuiDds/ltsutilsguidds_export.h (same pattern)

New plugin modules (copied from legacy) so LtsAppDescriptorChecker finds the
gui:3 IIDs referenced by the Projects' apps.json:
- TakeHomePackageManager/OldTHP              gui:3:tpm.man, gui:3:tpm.usb
- PresentationManagement/.../ScriptEditor   gui:3:pre.script.edit
- Timeline/Gui/EventTimelineClassic         gui:3:tln.view

new_docker_build.sh: correct group targets to the actual CMake target names,
guard LtsReportDisplay on BUILD_CODIFICATION, and skip modules unavailable in
the prebuilt image (AsmWorkstationCertifier/botan2, TrajectoryWidget,
VideoImport, thp_viewer/VLC).
2026-10-05 10:49:34 +02:00

344 lines
11 KiB
C++
Executable File

/**
* @RDE_HEADER@
* Model to handle datail data for the different event types
* $Id$
* $HeadURL$
* $Author$
*
* Created by Mike Wille, SLSE, 2017-09-04
*/
#pragma once
#include "logger.h"
#include <LtsUtilsCore/data_modification_enum.h>
#include <LtsSession/lts_session.h>
#include <Services/ProjectDataManagement/pdm_enums.hpp> // needed for this header
#include <QHash>
#include <QMap>
#include <QObject>
#include "attribute_value_lookup.h"
namespace LtsSession
{
class LtsSession;
}
namespace LtsTimelineClassic
{
class Event;
}
namespace LtsWidgets
{
class LtsDateTimeEdit;
}
namespace Timeline
{
constexpr int markerTypeId = 999999; // HACK: there is no marker type
class DetailData : public QObject
{
Q_OBJECT
public:
enum class RequestResult
{
Error = 0,
Okay = 1,
InvalidAttributeType,
NoValueTranslationForAttribute,
NoUiTypeForAttribute,
InvalidAttributeTypeJson,
JsonCorrupted
};
struct GetDetailDataForAttributeResult
{
QString attributeType; // translated! "Friendly Fire" instead of the key "FriendlyFire"
QString attributeValue; // also translated! "No" instead of the key "0"
QString attributeTypeId; // "FriendlyFire" instead of the translated version "Friendly Fire"
int attributeValueId = 0;
RequestResult requestResult = RequestResult::Error;
};
using GetDetailDataResultList = QVector<GetDetailDataForAttributeResult>;
enum AttributeUITypes // attribute ui types
{
ATTRIBUTE_UI_TYPE_TIME_RANGE_WIDGET = 0,
ATTRIBUTE_UI_TYPE_DEFAULT_RANGE_WIDGET,
ATTRIBUTE_UI_TYPE_AREA_RANGE_WIDGET,
ATTRIBUTE_UI_TYPE_COMBO_BOX, // most attributes use this
ATTRIBUTE_UI_TYPE_CHECKBOX,
ATTRIBUTE_UI_TYPE_RAD_RANGE_WIDGET
};
enum UIParameterType
{
UI_PARAM_TYPE_N1,
UI_PARAM_TYPE_N2,
UI_PARAM_TYPE_O1,
UI_PARAM_TYPE_O2,
UI_PARAM_TYPE_RAD,
UI_PARAM_TYPE_MIN,
UI_PARAM_TYPE_MAX,
UI_PARAM_TYPE_PREFIX,
UI_PARAM_TYPE_SUFFIX
};
enum InterpreterTypes
{
INTERPRETER_TYPE_NONE = 0, // ERROR VALUE
//INTERPRETER_TYPE_TOINT,
INTERPRETER_TYPE_RANGE,
INTERPRETER_TYPE_AREA, // for filter interpreter
INTERPRETER_TYPE_ID_COMPARE, // or key compare
INTERPRETER_TYPE_STR_COMPARE, // or value compare [deprecated - do not use]
INTERPRETER_TYPE_POSITION, // for event info windows line edits !
INTERPRETER_TYPE_TIME, // for event info windows line edits !
INTERPRETER_TYPE_DURATION, // for event info windows line edits !
INTERPRETER_TYPE_RAD
};
explicit DetailData(LtsSession::LtsSession *session, QObject *parent = nullptr);
void populate();
GetDetailDataResultList getDetailData(const LtsTimelineClassic::Event *event);
GetDetailDataForAttributeResult getDetailDataForAttribute(const LtsTimelineClassic::Event *event, const QString &attributeType);
void createRetrieveCurrentTimeCallback(LtsWidgets::LtsDateTimeEdit *dateTimeEdit);
LtsSession::LtsSession *session() { return m_session; }
private:
/**
* @brief addRedirectedAttributeType just like "addAttributeType", but automatically redirects to "redirectionAttributeTypeId" (note that redirected attributes do not need to have ui types or interpreter types)
* @param attributeTypeId
* @param attributeText
* @param redirectionAttributeTypeId
*/
void addRedirectedAttributeType(const QString &newAttributeTypeId, const QString &attributeText, const QString &redirectToAttributeTypeId);
void addAttributeType(const QString &attributeTypeId, const QString &attributeText, const int uiTypeId = ATTRIBUTE_UI_TYPE_COMBO_BOX, const int interpreterTypeId = INTERPRETER_TYPE_ID_COMPARE);
void addAttributeTypeWithYesAndNo(const QString &attributeTypeId, const QString &attributeText)
{
addAttributeType(attributeTypeId, attributeText, ATTRIBUTE_UI_TYPE_CHECKBOX);
attributeValueLookup.addValueToAttributeValueMap(attributeTypeId, 0, tr("No"));
attributeValueLookup.addValueToAttributeValueMap(attributeTypeId, 1, tr("Yes"));
}
template <typename AttributeEnumType>
void addAttributeValue(const QString &attributeTypeId, const AttributeEnumType &attributeEnum)
{
//qWarning() << "<<<" << attributeTypeId << ":" << (int)attributeEnum << "=>" << toString(attributeEnum);
attributeValueLookup.addValueToAttributeValueMap(attributeTypeId, (int)attributeEnum, toString(attributeEnum));
}
void addEventType(int eventTypeId, const QString &eventTypeString);
void addEventType(const ProjectDataManagement::EventType &eventType);
GetDetailDataForAttributeResult getDetailDataForAttribute(const QString &attributeType, const QJsonValue &attributeValueJson);
LtsSession::LtsSession *m_session;
bool __already_populated__; // do not allow secondary population, this would take to much time to develop atm
NGL::INGLLogger &m_logger;
public:
class LookupBase
{
public:
explicit LookupBase(const QString &lookupClassName);
protected:
QString m_lookupClassName;
NGL::INGLLogger &m_logger;
};
class EventTypeLookup : public LookupBase
{
public:
using EventTypeMap = QMap<int /* eventTypeId */, QString /* Event Name */>; // example: 3, 'Hit'
EventTypeLookup();
void addEventType(const int key, const QString &value);
int getEventType(const QString &eventText) const;
QString getEventText(const int eventType) const;
QStringList getEventTexts() const; // all texts
bool isEventExists(const int eventType) const;
private:
EventTypeMap m_eventTypeMap;
};
EventTypeLookup eventTypeLookup;
class AttributeTypeLookup : public LookupBase
{
public:
using AttributeTypeLookupMap = QMap<QString /* attributeTypeId */, QString /* name */>;
using AttributeTypeList = QList<QString>;
using AttributeTextList = QStringList;
AttributeTypeLookup();
void addAttributeText(const QString &attributeType, const QString &attributeText);
QString getAttributeType(const QString &attributeText) const;
AttributeTypeList getAttributeTypes() const;
QString getAttributeText(const QString &attributeType, const QString &defaultReturnValue = QString()) const;
AttributeTextList getAttributeTexts() const;
private:
AttributeTypeLookupMap m_attributeTypeLookupMap;
};
AttributeTypeLookup attributeTypeLookup;
class AttributeEventLookup : public LookupBase
{
public:
using AttributeEventLookupMap = QMap<int /* eventTypeId */, QList<QString> /* attributeTypeId List */>;
using AttributeList = QList<QString>;
AttributeEventLookup();
void addAttributesToEvent(const int eventType, const AttributeList &attributeTypeList);
void addAttributesToEvent(const ProjectDataManagement::EventType &eventType, const AttributeList &attributeTypeList);
bool isAttributeInEvent(const int eventType, const QString &attributeType);
AttributeList getEventsAttributeList(const int eventType) const; // get all attribute types from the event
private:
AttributeEventLookupMap m_attributeEventLookupMap;
};
AttributeEventLookup attributeEventLookup;
class AttributeParameterLookup : public LookupBase // as ui type is fixed for attribute type, it is perfectly okay to request parameters (min, max, etc.) by attribute type
{
public:
using ParameterMap = QMap<int, QVariant>; // Parameter Type => Parameter String
using AttributeParameterMap = QHash<QString, ParameterMap>;
AttributeParameterLookup();
void addParameter(const QString &attributeType, const ParameterMap &parameterMap); // add a parameter map to the lookup
ParameterMap getParameterMap(const QString &attributeType) const;
QVariant getParameterValue(const QString &attributeType, const int parameterType) const;
private:
AttributeParameterMap m_attributeParameterMap;
};
AttributeParameterLookup attributeParameterLookup;
class AttributeUITypeLookup : public LookupBase
{
public:
using AttributeUITypeLookupMap = QHash<QString, int>;
AttributeUITypeLookup();
void addUITypeToAttribute(const QString &attributeType, const int uiType);
int getUIType(const QString &attributeType) const;
private:
AttributeUITypeLookupMap m_attributeUITypeLookupMap;
};
AttributeUITypeLookup attributeUITypeLookup;
class AttributeInterpreterLookup : public LookupBase
{
public:
using AttributeInterpreterLookupMap = QHash<QString, int>;
AttributeInterpreterLookup();
void addInterpreterTypeToAttribute(const QString &attributeType, const int interpreterType);
int getInterpreterType(const QString &attributeType) const;
private:
AttributeInterpreterLookupMap m_attributeInterpreterLookupMap;
};
AttributeInterpreterLookup attributeInterpreterLookup;
class AttributeValueLookup : public LookupBase
{
public:
AttributeValueLookup();
void addValueToAttributeValueMap(const QString &attributeType, const int valueKey, const QString &valueValue /* ^^ */);
void removeValueFromAttributeValueMap(const QString &attributeType, const int valueKey);
void addValuesToAttributeValueMap(const QString &attributeType, const AttributeValueMap &avm); // add a VALUE (consisting of id & string) to the map coresponding to the attribute type
void clear(); // clears map for updating map and sets to uninitialized
AttributeValueMap getAttributeValueMap(const QString &attributeType) const;
QString getValueStringFromValueId(const QString &attributeType, const int attributeValueId, const QString &defaultValue = QString()) const;
private:
AtributeValueLookupMap m_attributeTypeValueMap; // contains a map for each attribute type, that contain a map for their keys & values
};
AttributeValueLookup attributeValueLookup;
class AttributeValueLookupDtc : public LookupBase
{
public:
AttributeValueLookupDtc() : LookupBase(QStringLiteral("AttributeValueLookupDtc")) {}
~AttributeValueLookupDtc() { qDeleteAll(m_provider); }
// takes ownership on provider
void addHandlerForDtc(const QString &attributeType, AttributeValueLookupProvider *provider)
{
auto &p = m_provider[attributeType];
delete p;
p = provider;
}
AttributeValueMap getAttributeValueMap(int eventType, const QString &attributeType) const
{
const auto provider = m_provider.value(attributeType);
if (!provider)
return {};
return provider->getAttributeValueMap(eventType);
}
QString getValueStringFromValueId(const QString &attributeType, int attributeValueId) const
{
const auto provider = m_provider.value(attributeType);
if (!provider)
return {};
return provider->getValueStringFromValueId(attributeValueId);
}
private:
QHash<QString, AttributeValueLookupProvider*> m_provider;
};
AttributeValueLookupDtc m_attributeValueLookupDtc;
AttributeValueMap operatorsForEventType(int eventType) const;
QString operatorNameFromId(int id) const;
class AttributeRedirectionLookup : public LookupBase
{
public:
using AttributeRedirectionMap = QHash<QString, QString>;
explicit AttributeRedirectionLookup();
void addRedirection(const QString &attributeType, const QString &redirectTo);
QString getRedirection(const QString &attributeType) const; // returns redirection, or if no redirection for attribute type, then returns original attribute type
private:
AttributeRedirectionMap m_attributeRedirectionMap;
};
AttributeRedirectionLookup attributeRedirectionLookup;
};
} // namespace Timeline