Qt6 Migration: Complete migration with DDS/RTI support and build validation
Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list
Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF
Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
- Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
- Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)
Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified
Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
18662 files changed
+4115092
-5435
No files matched your search
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* Load/Publish db-translations
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "translation.h"
|
||||
#include "dds_handler.h"
|
||||
#include <QTimer>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QCryptographicHash>
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
|
||||
namespace ProjectDataManagement
|
||||
{
|
||||
static const int s_translationBlobId = 1;
|
||||
|
||||
Translation::Translation(const std::shared_ptr<DdsHandler> &dds, const std::shared_ptr<DatabaseInterface> &db)
|
||||
: Interface::Fts::InsertUpdateTranslationRequestHandler(dds->fts())
|
||||
, m_dds(dds)
|
||||
, m_db(db)
|
||||
, m_logger(getLogger("Translation"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Translation ctor";
|
||||
m_publishTimer.setInterval(1000);
|
||||
m_publishTimer.setSingleShot(true);
|
||||
m_publishTimer.setTimerType(Qt::VeryCoarseTimer);
|
||||
connect(&m_publishTimer, &QTimer::timeout, this, &Translation::publishData);
|
||||
|
||||
QTimer::singleShot(1000, this, &Translation::collectAndPublishData);
|
||||
}
|
||||
|
||||
Translation::~Translation()
|
||||
{
|
||||
m_dds->dts()->removeTranslationBlobByKey(s_translationBlobId);
|
||||
}
|
||||
|
||||
void Translation::collectAndPublishData()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Collecting translation data";
|
||||
m_jsonData.clear();
|
||||
const auto cb = [this](const Database::PdmTranslation &data)
|
||||
{
|
||||
this->addToJson(data);
|
||||
};
|
||||
|
||||
if (!m_db->select(cb))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Error fetching translations from db";
|
||||
return;
|
||||
}
|
||||
|
||||
publishData();
|
||||
|
||||
DEBUG_LOG(m_logger) << "Collecting translation data - finished";
|
||||
}
|
||||
|
||||
void Translation::publishData()
|
||||
{
|
||||
QJsonArray arr;
|
||||
for (const QJsonObject &obj : qAsConst(m_jsonData))
|
||||
arr += obj;
|
||||
|
||||
const QJsonObject jObj{ {QStringLiteral("translations"), arr} };
|
||||
const QByteArray data = QJsonDocument(jObj).toBinaryData();
|
||||
const QByteArray compressed = qCompress(data, 9);
|
||||
const QByteArray md5Sum = QCryptographicHash::hash(compressed, QCryptographicHash::Md5).toHex();
|
||||
|
||||
INFO_LOG(m_logger) << "Created translation blob with " << arr.size() << " elements, size: " << compressed.size()
|
||||
<< " (uncompressed: " << data.size() << "), md5Sum: " << md5Sum;
|
||||
m_dds->dts()->publish(ProjectDataManagement::TranslationBlob(s_translationBlobId,
|
||||
LtsUtils::convert<std::vector<uint8_t>>(compressed),
|
||||
md5Sum.data()));
|
||||
}
|
||||
|
||||
static inline QJsonObject toJsonObject(const Database::PdmTranslation &data)
|
||||
{
|
||||
return QJsonObject({{QStringLiteral("isoCode"), data.isoCode},
|
||||
{QStringLiteral("context"), data.context},
|
||||
{QStringLiteral("key"), data.key},
|
||||
{QStringLiteral("disambiguation"), data.disambiguation},
|
||||
{QStringLiteral("translation"), data.translation}
|
||||
});
|
||||
}
|
||||
|
||||
void Translation::addToJson(const Database::PdmTranslation &data)
|
||||
{
|
||||
m_jsonData[data.id] = toJsonObject(data);
|
||||
}
|
||||
|
||||
void Translation::onInsertUpdateTranslationRequest(const rti::core::SampleIdentity &cookie,
|
||||
const InsertUpdateTranslationRequest &request)
|
||||
{
|
||||
Database::PdmTranslation te;
|
||||
te.isoCode = QString::fromStdString(request.isoCode());
|
||||
te.context = QString::fromStdString(request.ctx());
|
||||
te.key = QString::fromStdString(request.key());
|
||||
te.disambiguation = QString::fromStdString(request.disambiguation());
|
||||
te.translation = QString::fromStdString(request.translation());
|
||||
|
||||
// not fast but also not really needed ...
|
||||
te.id = -1;
|
||||
auto end = m_jsonData.end();
|
||||
for (auto it = m_jsonData.begin(); it != end; ++it)
|
||||
{
|
||||
const QJsonObject &obj = it.value();
|
||||
if (obj.value(QStringLiteral("isoCode")).toString() == te.isoCode &&
|
||||
obj.value(QStringLiteral("context")).toString() == te.context &&
|
||||
obj.value(QStringLiteral("key")).toString() == te.key &&
|
||||
obj.value(QStringLiteral("disambiguation")).toString() == te.disambiguation)
|
||||
{
|
||||
te.id = it.key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const bool bRet = (te.id > 0) ? m_db->insert(te) : m_db->update(te);
|
||||
Core::FunctionReplyObject fro(te.id);
|
||||
if (bRet)
|
||||
{
|
||||
addToJson(te);
|
||||
m_publishTimer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
fro = Core::FunctionReplyObject(te.id, tr_lts("dds", "Can not insert/update translation element"));
|
||||
WARNING_LOG(m_logger) << fro();
|
||||
}
|
||||
m_dds->fts()->insertUpdateTranslationReply(cookie, fro);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user