Files
qt-migration-legatus/qt5-before/dlbo/Lts/Tools/DBUpdate/main.cpp
T
torstenandCopilot 7173785915 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>
2026-09-15 18:20:26 +00:00

152 lines
4.5 KiB
C++

/**
* @RDE_HEADER@
* DBUpdate
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, 2021-02-17
*/
#include "db_update.h"
#include <NGLLogger/INGLLogger.h>
#include <nglapplication/nglapplication.h>
#include <nglapplication/nglcoreapplication.h>
#include <ngltranslator/ngltranslator.h>
#include <LtsCommandLineParser/LtsCommandLineParser.h>
#include <QInputDialog>
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
{
public:
CmdLineParser()
: LtsCommandLineParser(ProvideCommandLineParameterOptions::None)
{
addOption({{QStringLiteral("l"), QStringLiteral("lang")},
QStringLiteral("Language iso code to use (de_DE, en_GB, en_US)"),
QStringLiteral("<locale iso code>")
});
addOption({{QStringLiteral("u"), QStringLiteral("update")},
QStringLiteral("Update file (*.upd)"),
QStringLiteral("<update file>")
});
addOption({{QStringLiteral("p"), QStringLiteral("pass")},
QStringLiteral("Password"),
QStringLiteral("<password>")
});
addOption({{QStringLiteral("g"), QStringLiteral("only generate sql")},
QStringLiteral("Only generate sql (do no execute)")
});
addOption({{QStringLiteral("b"), QStringLiteral("Backup first")},
QStringLiteral("Make a database backup first")
});
}
bool onlyGenerate() const
{
return isSet(QStringLiteral("g"));
}
bool withBackup() const
{
return isSet(QStringLiteral("b"));
}
QString langIsoCode() const { return value(QStringLiteral("l")); }
QString updateFile() const { return value(QStringLiteral("u")); }
QString pass() const { return value(QStringLiteral("p")); }
};
int main(int argc, char *argv[])
{
int retval = -1;
bool bHeadless = false;
for (int i = 1; i < argc; ++i)
{
if (strcmp(argv[i], "-u") == 0) // given the update file on commando line
{
bHeadless = true;
break;
}
}
QScopedPointer<QCoreApplication> app;
app.reset(bHeadless ? dynamic_cast<QCoreApplication*>(new NGLCoreApplication(argc, argv))
: dynamic_cast<QCoreApplication*>(new NGLApplication(argc, argv)));
QCoreApplication::setApplicationName(QLatin1String("DBUpdate"));
QCoreApplication::setOrganizationName(QLatin1String("RME"));
if (!bHeadless)
app->setAttribute(Qt::AA_UseHighDpiPixmaps);
NGL::LoggerHandler *lh = dynamic_cast<NGL::LoggerHandler*>(app.data());
lh->createLogger("dbu", "log4cxx_dbu.props");
NGL::INGLLogger &logger = lh->baseLogger();
// Parse Options
CmdLineParser options;
if (!options.init())
return retval;
// Set Translation
QString langIsoCode = options.langIsoCode();
if (langIsoCode.isEmpty())
langIsoCode = QLocale::system().name();
NGL::setTranslationLocale(langIsoCode.toLatin1());
STARTUP_LOG(logger);
if (bHeadless)
{
QString pwd = options.pass();
if (pwd.isEmpty() || pwd != QStringLiteral("geheim"))
{
ERROR_LOG(logger) << "Incorrect password !!!";
return -3;
}
DEBUG_LOG(logger) << "Running headless, update file: " << options.updateFile() << ", Generate only: " << options.onlyGenerate();
DBUpdate::DBUpdateRun *up = new DBUpdate::DBUpdateRun(options.updateFile(), options.onlyGenerate(), options.withBackup());
if (!up->init())
{
ERROR_LOG(logger) << "Failed to init DBUpdateHeadless";
return -2;
}
if (!up->runUpdate())
{
ERROR_LOG(logger) << "Failed to run update: " << options.updateFile();
return -1;
}
retval = 0;
}
else
{
bool ok;
QString pass = QInputDialog::getText(nullptr,
QCoreApplication::tr("Password"),
QCoreApplication::tr("Please enter the password:"), QLineEdit::Password,
QString(), &ok); // blocking, no event loop needed
if (!ok || pass.isEmpty() || pass.toLower() != QStringLiteral("geheim"))
{
ERROR_LOG(logger) << "Incorrect password !!!";
return -3;
}
QScopedPointer<DBUpdate::DBUpdate> mainWindow(new DBUpdate::DBUpdate);
if (!mainWindow->init())
{
ERROR_LOG(logger) << "Failed to init DBUpdate";
return -2;
}
mainWindow->show();
QGuiApplication::setQuitOnLastWindowClosed(true);
retval = QCoreApplication::exec();
if (retval < 0)
ERROR_LOG(logger) << "Failed: " << retval;
}
SHUTDOWN_LOG(logger);
return retval;
}