Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Tools/VapixConfig/config.cpp
T
torsten d5c13033e2 Session 022: Migrate Lts/Tools (72 submodules) to Qt6
- Copied complete Lts/Tools directory from qt5-before to qt6-after
- Updated 32 CMakeLists.txt files (Qt5:: → Qt6::)
- Tools subdirectory already included in parent Lts/CMakeLists.txt
- All 72 tool submodules now present in qt6-migrated-legatus
- Includes: Adler, ArAssets, ConfigX, DBAdministration, DBUpdate,
  DdsView, InfrastructureManagement, and 67 more tools
- C++17 standard (RTI 7.7.0 compatibility maintained)
- Tests deferred until final validation phase

Migration progress:
✅ Lts/Application (68 files)
✅ Lts/DDS (verified Qt6-ready)
✅ Lts/Plugins (60 submodules, verified)
✅ Lts/Projects (5 submodules, verified)
✅ Lts/Proxies (13 submodules, verified)
✅ Lts/Services (47 submodules, verified)
✅ Lts/Tools (72 submodules, copied + CMake updated)
✅ Lts/Viewer (LtsFileDialog, LtsReportDisplay, SituationMap)
🟡 TetraIF (partial)
🟡 Z (partial: nglwidgets, QtSingleApplication, qsql_informix, WMS_Interface)
2026-08-25 14:07:20 +02:00

164 lines
4.7 KiB
C++
Executable File

/**
* @RDE_HEADER@
* Config class to parse XML-Files for Axis Camera Configuration
* $Id$
* $HeadURL$
* $Author$
* Created by Terrell Scharfenberg, SLSE, 2016-05-27
*/
#include "config.h"
#include <QtCore/QDebug>
#include <QFile>
using namespace VapixConfig;
Config::Config()
{
}
// init is needed to clear the DomDocument for saving purpose
void Config::init()
{
m_domDocument.clear();
m_root = m_domDocument.createElement(QLatin1String("Camera"));
m_domDocument.appendChild(m_root);
}
// Reads XML and put created maps in maplists
bool Config::processConfig(const QString &xmlConfig)
{
QFile f(xmlConfig);
if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
return 0;
m_domDocument.setContent(&f);
m_root = m_domDocument.documentElement();
if (m_root.tagName() != QLatin1String("Camera"))
return false;
const QDomNodeList image = m_root.elementsByTagName(QLatin1String("Image"));
const QDomNodeList window = m_root.elementsByTagName(QLatin1String("Motion"));
const QDomNodeList server = m_root.elementsByTagName(QLatin1String("EventServer"));
const QDomNodeList event = m_root.elementsByTagName(QLatin1String("Event"));
const QDomNodeList action = m_root.elementsByTagName(QLatin1String("Action"));
for (int i = 0; i <= image.size(); ++i)
{
const QDomElement tempElement = image.at(i).toElement();
QDomElement tempChild = tempElement.firstChild().toElement();
QMap<QString, QString> imageMap;
while (!tempChild.isNull())
{
imageMap[tempChild.tagName()] = tempChild.firstChild().toText().data();
tempChild = tempChild.nextSibling().toElement();
}
if (!imageMap.isEmpty())
{
m_imageList.append(imageMap);
}
}
for (int i = 0; i <= window.size(); ++i)
{
const QDomElement tempElement = window.at(i).toElement();
QDomElement tempChild = tempElement.firstChild().toElement();
QMap<QString, QString> windowMap;
while (!tempChild.isNull())
{
windowMap[tempChild.tagName()] = tempChild.firstChild().toText().data();
tempChild = tempChild.nextSibling().toElement();
}
if (!windowMap.isEmpty())
{
m_windowList.append(windowMap);
}
}
for (int i = 0; i <= server.size(); ++i)
{
const QDomElement tempElement = server.at(i).toElement();
QDomElement tempChild = tempElement.firstChild().toElement();
QMap<QString, QString> serverMap;
while (!tempChild.isNull())
{
serverMap[tempChild.tagName()] = tempChild.firstChild().toText().data();
tempChild = tempChild.nextSibling().toElement();
}
if (!serverMap.isEmpty())
{
m_serverList.append(serverMap);
}
}
for (int i = 0; i <= event.size(); ++i)
{
const QDomElement tempElement = event.at(i).toElement();
QDomElement tempChild = tempElement.firstChild().toElement();
QMap<QString, QString> eventMap;
while (!tempChild.isNull())
{
eventMap[tempChild.tagName()] = tempChild.firstChild().toText().data();
tempChild = tempChild.nextSibling().toElement();
}
if (!eventMap.isEmpty())
{
m_eventList.append(eventMap);
}
}
for (int i = 0; i <= action.size(); ++i)
{
const QDomElement tempElement = action.at(i).toElement();
QDomElement tempChild = tempElement.firstChild().toElement();
QMap<QString, QString> actionMap;
while (!tempChild.isNull())
{
actionMap[tempChild.tagName()] = tempChild.firstChild().toText().data();
tempChild = tempChild.nextSibling().toElement();
}
if (!actionMap.isEmpty())
{
m_actionList.append(actionMap);
}
}
f.close();
return true;
}
//Saves configuration from camera to XML file
void Config::saveConfig(const QString &savePath)
{
QFile saveFile;
saveFile.setFileName(savePath);
if (saveFile.open(QIODevice::WriteOnly))
{
QTextStream stream(&saveFile);
stream << m_domDocument.toString();
saveFile.close();
}
else
qDebug("Failed to write data!");
}
// used to fill XML
void Config::addElementToXml(const QMap<QString, QString> &givenMap, const QString &groupName)
{
QString tempName = groupName;
if (!tempName.compare(QLatin1String("Event.*.Actions")))
tempName = QLatin1String("Action");
if (!tempName.compare(QLatin1String("EventServers")))
tempName = QLatin1String("EventServer");
QDomElement tempElem = m_domDocument.createElement(tempName);
m_root.appendChild(tempElem);
QDomElement tempChild;
QDomText tempText;
for (auto iterator = givenMap.begin(); iterator != givenMap.end(); ++iterator)
{
tempChild = m_domDocument.createElement(iterator.key());
tempElem.appendChild(tempChild);
tempText = m_domDocument.createTextNode(iterator.value());
tempChild.appendChild(tempText);
}
}