Remove unused code from the Release 2 scope modules

Trim mostly-deletion changes (~700 lines) across the modules the Release
2 build compiles: unused telegrams and receiver/handler code in
TrainingAreaBase (telegrams, recv_from_dds_aes/fts, ism/main/pdm/position
handlers), dead members in SqlBrowser and ProjectDataManagement,
unused LtsPluginManager loader paths, LtsSession unit-test, WlsTetra and
DdsView cleanups, plus the stale include_directories removal in
Lts/CMakeLists.txt. Continues the Release 2 source prune (keep only what
the build compiles).

Excluded from this commit by design: the machine-specific .envrc
(MIGRATE_PIPELINE_ROOT path fix stays uncommitted) and the untracked
qt5-before/ reference tree.
This commit is contained in:
berrux-dev committed 2026-11-17 17:28:48 +01:00
1 parent e60a860283
commit 84f8cfb41f
45 files changed
+12 -706

No files matched your search

@@ -16,8 +16,6 @@ else()
endif()
# Add only existing subdirectories to allow partial checkouts / incremental migration
# Release 2 scope: Tools, DDS, Common, Services (minimal), Proxies (TrainingAreaBase only), Plugins (Styles only for LtsWidgets dependency)
# Excluded: Application, Viewer, Projects, most Plugins (not in Release 2)
set(LTS_SUBDIRS Tools DDS Common Services Proxies Plugins)
foreach(dir IN LISTS LTS_SUBDIRS)
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${dir}")
@@ -46,13 +44,10 @@ ENDIF()
INCLUDE(MacroCodeGenIdl)
# Add stub headers for non-RTI/non-FilterManagement builds
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include/AudioVideoManagement/)
# (AudioVideoManagement, TopicEditorBase, OperatorManagement, LtsScriptTimeline and
# Services/PresentationManagement entries removed: pruned in Release 2, paths gone.)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include/NGLLogger/)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include/LtsSession/)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include/TopicEditorBase/)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include/OperatorManagement/)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include/LtsScriptTimeline/)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include/LtsUtilsGuiDds/)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include/Services/PresentationManagement/)
CODEGEN_WRITE_SERVICEFILE_INFO()
@@ -5,7 +5,6 @@
# Created by Mike Wille, SLSE, 2016-01-13
#
# Make ${Qt6_Widgets} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::Widgets)
set(Qt6_Widgets ${Qt6_Widgets})
@@ -13,7 +12,6 @@ else()
set(Qt6_Widgets "")
endif()
SET(LtsNoti_SRCS
lts_notification.h
lts_notification.cpp
@@ -22,7 +20,6 @@ SET(LtsNoti_SRCS
)
NGL_ADD_LIBRARY2(WS LtsNotification SHARED ${LtsNoti_SRCS})
NGL_TARGET_INCLUDE_DIRECTORIES(LtsNotification
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
@@ -11,20 +11,16 @@
#include "lts_plugin_loader.h"
#include <memory>
#include <utility>
#include <NGLLogger/NGLLoggerBootstrap.h>
#include <LtsAppDescriptor/lts_app_descriptor.h>
#include <QCoreApplication>
#include <QDirIterator>
#include <QFileInfo>
#include <QJsonObject>
#include <QPluginLoader>
#include <QMutableListIterator>
#include <QDebug>
namespace LtsPluginManager
{
@@ -42,7 +38,6 @@ void LtsPluginLoaderHandler::cleanupPluginLoader()
s_ltsPluginLoader->ltsPluginLoader.unloadAllPlugins();
}
LtsPluginLoader *LtsPluginLoader::getInstance()
{
if (!s_ltsPluginLoader.exists())
@@ -50,7 +45,6 @@ LtsPluginLoader *LtsPluginLoader::getInstance()
return &s_ltsPluginLoader->ltsPluginLoader;
}
LtsPluginLoader::~LtsPluginLoader()
{
unloadAllPlugins();
@@ -72,7 +66,6 @@ void LtsPluginLoader::unloadAllPlugins()
m_loadedPlugins.clear();
}
void LtsPluginLoader::checkPlugins(const QVector<LtsAppDescriptor::AppDescription> &appVector,
QStringList &errors /* out */)
{
@@ -84,7 +77,6 @@ void LtsPluginLoader::checkPlugins(const QVector<LtsAppDescriptor::AppDescriptio
return;
}
QVector<PluginInstance> dataPlugins;
QVector<PluginInstance> guiPlugins;
auto addDataPluginFn = [&](const PluginInstance &pi)
@@ -110,8 +102,6 @@ void LtsPluginLoader::checkPlugins(const QVector<LtsAppDescriptor::AppDescriptio
return;
}
// check for duplicate iids per plugin type
auto checkDuplicateIidsFn = [&](const QVector<PluginInstance> &plugins, const QString &pluginType)
{
@@ -133,18 +123,13 @@ void LtsPluginLoader::checkPlugins(const QVector<LtsAppDescriptor::AppDescriptio
checkDuplicateIidsFn(dataPlugins, QStringLiteral("data"));
checkDuplicateIidsFn(guiPlugins, QStringLiteral("gui"));
QVector<PluginInstance> plugins(dataPlugins + guiPlugins);
// check if all in apps.json requested plugins are available
for (auto i1 = appVector.constBegin(); i1 != appVector.constEnd(); ++i1) // Apps
{
const LtsAppDescriptor::AppDescription &app = *i1;
//WARNING_LOG(logger) << "Checking app '"<<app.appName<<"'";
const QVector<LtsAppDescriptor::PluginInfo> &piVector = app.pluginInfos;
for (auto i2 = piVector.constBegin(); i2 != piVector.constEnd(); i2++) // App's Required Plugins
@@ -174,7 +159,6 @@ void LtsPluginLoader::checkPlugins(const QVector<LtsAppDescriptor::AppDescriptio
return;
}
bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
const std::function<bool(const PluginInstance &)> &loadPlugin,
const QStringList &requiredPlugins,
@@ -211,30 +195,25 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
}
}
{
QMutableListIterator<QString> i1(optionalPluginsList); // delete all plugins from the to-load list that were cached
while (i1.hasNext())
{
const QString pluginName = i1.next().toLower();
QMap<PluginKey, PluginInstance>::iterator i2 = m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
if (i2 != m_loadedPlugins.end())
{
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance";
if (loadPlugin)
loadPlugin(i2.value());
i1.remove();
}
}
}
}
QFileInfo libPathInfo(QCoreApplication::applicationDirPath() + QStringLiteral("/../lib/"));
QString libPath(libPathInfo.absolutePath());
if (!libPathInfo.exists())
@@ -272,7 +251,6 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
continue;
const QString absoluteFilePath = pluginDir.filePath();
DEBUG_LOG(logger) << "File Path: " << absoluteFilePath;
// if (!filename.contains(type))
@@ -284,7 +262,6 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
std::unique_ptr<QPluginLoader> pluginLoader(new QPluginLoader);
pluginLoader->setFileName(absoluteFilePath);
const QJsonObject jObj = pluginLoader->metaData();
QJsonObject::const_iterator iid = jObj.find(QStringLiteral("IID"));
@@ -297,7 +274,6 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
const QString jsonIid = iid.value().toString().toLower(); // LOWERCASE ! (pun intended)
// Use QStringView for efficient string operations
const QList<QStringView> iidParameters = QStringView{jsonIid}.split(QLatin1Char(':'));
DEBUG_LOG(logger) << "Plugin " << absoluteFilePath << " provides iid '" << jsonIid;
if (iidParameters.count() != 3)
@@ -316,7 +292,6 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
}
PluginType pluginType = PluginType::UNKNOWN;
const QString pluginName = iidParameters.at(2).toString();
const QString pluginTypeString = iidParameters.at(0).toString();
switch (pluginTypes.indexOf(pluginTypeString))
@@ -367,11 +342,9 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
{
QMutableListIterator<QString> i (requiredPluginsList);
while (i.hasNext())
{
const QString requiredPlugin = i.next().toLower();
if (pluginName == requiredPlugin)
{
found = true;
@@ -381,13 +354,11 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
}
}
if (!found)
{
for (auto i = optionalPluginsList.constBegin(); i != optionalPluginsList.constEnd(); i++)
{
const QString optionalPlugin = (*i).toLower();
if (pluginName == optionalPlugin)
{
found = true;
@@ -396,25 +367,19 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
}
}
if (!found)
{
DEBUG_LOG(logger) << "Plugin " << pluginName << " was not requested";
continue; // plugin was not requested to be loaded
}
}
// before we create a new instance of a plugin, which is not needed as one instance is perfectly fine to use for many apps, look it up in the loaded plugins list
if (loadPlugin && !m_loadedPlugins.isEmpty()) // only lookup if there is something to lookup TODO: faster to NOT do that check?
{
QMap<PluginKey, PluginInstance>::iterator i = m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
if (i != m_loadedPlugins.end())
{
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance ("<<i.value().plugin->metaObject()->className()<<")";
loadPlugin(i.value());
continue; // found, next plugin!
}
@@ -422,7 +387,6 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
// plugin not already loaded:
QObject *plugin = pluginLoader->instance();
if (!plugin)
{
ERROR_LOG(logger) << "Failed to load " << filename << " - " << pluginLoader->errorString();
@@ -435,7 +399,6 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
pi.fullFileName = absoluteFilePath;
pi.plugin = plugin;
pi.pluginLoader = pluginLoader.get();
if (loadPlugin && !loadPlugin(pi)) // does the dev want this plugin? if no, unload it! TODO: really unload? or still cache it??
{
DEBUG_LOG(logger) << "Plugin " << pluginName << " unloaded";
@@ -444,7 +407,6 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
continue; // next plugin
}
pi.pluginLoader = pluginLoader.release();
// the dev decided to use that plugin, so cache it
m_loadedPlugins.insert(PluginKey(requestedPluginType, pluginName), pi);
@@ -454,13 +416,11 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
DEBUG_LOG(logger) << "Loaded " << jsonIid << " - File: " << filename;
} // end of >> pluginDir.hasNext();
if (checkPluginsLists && !requiredPluginsList.isEmpty())
{
WARNING_LOG(logger) << "These plugins could not be found for Plugin Type " << (int)requestedPluginType << ": " << requiredPluginsList.join(QStringLiteral(", "));
return false;
}
return true;
}
@@ -53,7 +53,6 @@ enum class PluginType
};
struct PluginInstance // one instance for one plugin
{
QString pluginName;
@@ -63,23 +62,18 @@ struct PluginInstance // one instance for one plugin
QPluginLoader *pluginLoader = nullptr;
};
class LTSPLUGINLOADER_EXPORT LtsPluginLoader
{
public:
static LtsPluginLoader *getInstance();
void unloadAllPlugins();
void checkPlugins(const QVector<LtsAppDescriptor::AppDescription> &appVector,
QStringList &errors /* out */);
bool loadPlugins(PluginType requestedPluginType,
const std::function<bool(const PluginInstance &pluginInstance)> &loadPlugin,
const QStringList &requiredPlugins = QStringList(), /* leave empty to get all plugins of the given type */
const QString &specialTopicTypeFilter = QString(),
const QStringList &optionalPlugins = QStringList());
typedef QPair<PluginType, QString> PluginKey;
private:
@@ -52,7 +52,6 @@ LtsPluginManager::LtsPluginManager()
LtsPluginManager::~LtsPluginManager()
{
delete m_sessionManager;
}
@@ -100,9 +99,7 @@ bool LtsPluginManager::startApp(const LtsAppDescriptor::AppDescription& app, boo
const LtsSession::DdsConnectionParams& connParams, const QString& workspaceId,
bool hidden)
{
LtsWidgets::LtsWaitDialogContainer wait;
m_app = app;
LtsPluginLoader* pluginLoader = LtsPluginLoader::getInstance();
@@ -134,12 +131,10 @@ bool LtsPluginManager::startApp(const LtsAppDescriptor::AppDescription& app, boo
for (auto i = dataPlugins.constBegin(); i != dataPlugins.constEnd(); ++i)
{
const PluginInstance& pi = *i;
AppPluginInstance api;
api.pluginInstance = pi;
api.m_appName = m_app.appName;
api.m_appId = m_app.id;
dataApiList.append(api);
}
@@ -147,7 +142,6 @@ bool LtsPluginManager::startApp(const LtsAppDescriptor::AppDescription& app, boo
for (auto i = guiPlugins.constBegin(); i != guiPlugins.constEnd(); ++i)
{
const PluginInstance& pi = *i;
AppPluginInstance api;
api.pluginInstance = pi;
api.m_appName = m_app.appName;
@@ -156,17 +150,13 @@ bool LtsPluginManager::startApp(const LtsAppDescriptor::AppDescription& app, boo
for (auto i2 = app.pluginInfos.constBegin(); i2 != app.pluginInfos.constEnd(); ++i2)
{
const LtsAppDescriptor::PluginInfo& rp = *i2;
if (rp.type == LtsAppDescriptor::PluginInfo::PluginType::GUI && rp.iid == pi.pluginName)
{
api.m_flags = rp.flags;
api.m_options = rp.options;
break;
}
}
guiApiList.append(api);
}
@@ -174,12 +164,10 @@ bool LtsPluginManager::startApp(const LtsAppDescriptor::AppDescription& app, boo
if (!connParamsNew.isValid())
{
INFO_LOG(m_logger) << "Invalid connection params given - using default parameter";
connParamsNew.domainId = LtsSessionData::LtsSessionData::getInstance()->getDomainIdPreset();
connParamsNew.partitionId = 0;
connParamsNew.exerciseId = 0;
connParamsNew.partitionType = IDL::PartitionType::Global;
connParamsNew.tcpConnectionUrl = LtsSessionData::LtsSessionData::getInstance()->getTcpConnectionUrl();
}
if (LtsSessionData::LtsSessionData::getInstance()->getQosFile().size() > 0 &&
@@ -192,7 +180,6 @@ bool LtsPluginManager::startApp(const LtsAppDescriptor::AppDescription& app, boo
ERROR_LOG(m_logger) << "Could not create Global Session - abort.";
return false;
}
return true;
}
@@ -58,7 +58,6 @@ namespace LtsPluginManager
struct AppPluginInstance
{
PluginInstance pluginInstance;
QFlags<LtsAppDescriptor::PluginInfo::Flag> m_flags;
QStringList m_options;
QString m_appName;
@@ -77,7 +76,6 @@ class LTSPLUGINMANAGER_EXPORT LtsPluginManager : public QObject
const LtsSession::DdsConnectionParams& connParams, const QString& workspaceId = QString(),
bool hidden = false);
LtsSession::LtsSession* getSession(IDL::PartitionType partitionType, int partitionId);
bool isInitialized() const
{
return m_initialized;
@@ -31,9 +31,6 @@ private slots:
void clearScope();
private:
// LtsSessionData is a process-wide singleton and clear() only resets the
// preset + operator state. Bring it back to a known baseline before each
// slot so the slots do not depend on execution order.
void resetSessionData();
};
@@ -12,7 +12,6 @@ else()
set(Qt6_WebSockets "")
endif()
SET(SRCS
logger.cpp
logger.h
@@ -8,7 +8,6 @@
*/
#include "logger.h"
#include <NGLLogger/NGLLoggerBootstrap.h>
namespace WlsTetra
@@ -44,17 +44,12 @@ LtsWebSocket::AbstractClientMessage *ClientMessageFactory::createMessage(LtsWebS
return checkResult(client, message, result);
}
ClientMessage::ClientMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
: LtsWebSocket::AbstractClientMessage(client, type, typeId, uuid, data)
, m_dataManager(dataManager)
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger())
{}
SendBiteRequest::SendBiteRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
: ClientMessage(dataManager, client, type, typeId, uuid, data)
{}
@@ -24,15 +24,10 @@ class DataManager;
namespace ClientMessages
{
class ClientMessageFactory final : public LtsWebSocket::AbstractClientMessageFactory
{
public:
explicit ClientMessageFactory(DataManager *dataManager);
LtsWebSocket::AbstractClientMessage *createMessage(LtsWebSocket::ReplyHandler *client,
const QString &message);
@@ -41,8 +36,6 @@ private:
};
class ClientMessage : public LtsWebSocket::AbstractClientMessage
{
protected:
@@ -22,8 +22,6 @@ using namespace JsonKeys;
namespace Messages
{
QString ReplyMessage::toJsonString() const
{
return QString::fromUtf8(QJsonDocument(m_jsonRepresentation).toJson(QJsonDocument::Compact));
@@ -35,8 +33,6 @@ ReplyMessage::ReplyMessage(const QString &type, const int typeId, const QString
}
OkMessage::OkMessage(const OkMessage::OkData &data)
: ReplyMessage(OK(), 1, data.uuid)
{
@@ -47,8 +43,6 @@ OkMessage::OkMessage(const OkMessage::OkData &data)
}));
}
ErrorMessage::ErrorMessage(const ErrorMessage::ErrorData &data)
: ReplyMessage(ERROR_(), -1, data.uuid)
{
@@ -59,9 +53,6 @@ ErrorMessage::ErrorMessage(const ErrorMessage::ErrorData &data)
}));
}
QJsonObject BiteDataMessage::ErrorText::toJson() const
{
return QJsonObject({{LANG(), lang},
@@ -81,7 +72,6 @@ QJsonObject BiteDataMessage::BasicError::toJson() const
return QJsonObject({{ERROR_TEXT(), text}});
}
QJsonObject BiteDataMessage::BiteError::toJson() const
{
return QJsonObject({{ERROR_TEXT(), vecToPath(errorTexts)},
@@ -92,7 +82,6 @@ QJsonObject BiteDataMessage::BiteError::toJson() const
});
}
BiteDataMessage::BiteDataMessage(const BiteDataMessage::BiteData &data, const QString &uuid)
: ReplyMessage(BITE_DATA(), 2, uuid)
{
@@ -108,7 +97,6 @@ BiteDataMessage::BiteDataMessage(const BiteDataMessage::BiteData &data, const QS
}));
}
PositionMessage::PositionMessage(const PositionMessage::PositionData &data, const QString &uuid)
: ReplyMessage(POSITION_DATA(), 3, uuid)
{
@@ -120,9 +108,6 @@ PositionMessage::PositionMessage(const PositionMessage::PositionData &data, cons
{LAST_POSITION_UPDATE(), data.gpsTime}
}));
}
}
}
}
@@ -27,11 +27,8 @@ namespace Messages
class ReplyMessage : public LtsWebSocket::ReplyMessage
{
public:
ReplyMessage() = default;
virtual ~ReplyMessage() = default;
virtual QString toJsonString() const;
protected:
@@ -73,7 +70,6 @@ public:
{}
};
class OkMessage final
: public ReplyMessage
{
@@ -7,7 +7,6 @@
*/
#include "dds_handler.h"
#include <DDS/DDSConnector/publisher.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <DDS/Core/pacemaker.h>
@@ -1,6 +1,3 @@
#include "exm_handler.h"
#include "main_handler.h"
#include <NGLLogger/NGLLoggerBootstrap.h>
@@ -34,7 +31,6 @@ ExerciseManagement::Exercise ExmHandler::exercise(int exerciseId)
return m_exmDtc->exercise(exerciseId);
}
void ExmHandler::onExerciseChanged(const ExerciseManagement::Exercise &data, DataModification modType)
{
if (!data.radioGroupId.has_value() || data.radioGroupId.get() == 0)
@@ -68,6 +64,4 @@ void ExmHandler::onExerciseChanged(const ExerciseManagement::Exercise &data, Dat
if (bExercise2RadioGroupChanged)
emit exercise2RadioGroupChanged();
}
}
@@ -1,6 +1,3 @@
#pragma once
#include <ExerciseManagement/exm_dtc.h>
#include <unordered_map>
@@ -15,9 +12,7 @@ class ExmHandler final : public QObject
Q_OBJECT
public:
explicit ExmHandler(MainHandler *mainHandler);
bool init();
std::unordered_map<int, int> exercise2RadioGroup() const { return m_exercise2RadioGroup; }
ExerciseManagement::Exercise exercise(int exerciseId);
@@ -1,6 +1,4 @@
#include "ism_handler.h"
#include <utility>
#include "main_handler.h"
@@ -42,20 +40,6 @@ bool IsmHandler::init()
ERROR_LOG(m_logger) << "Can not read data from ISM";
return false;
}
return true;
}
@@ -77,8 +61,6 @@ IsmHandler::OpsData IsmHandler::dataFromOpsCode(int ipsCode)
int assetId = m_dtcIsm->getAssetIdFromOpticalCode(ipsCode);
OpsData opsData;
if ( assetId < 0)
{
WARNING_LOG(m_logger) << "No asset for ops code=" << ipsCode << " found";
@@ -87,14 +69,6 @@ IsmHandler::OpsData IsmHandler::dataFromOpsCode(int ipsCode)
opsData.opsCode = ipsCode;
opsData.assetId = assetId;
DEBUG_LOG(m_logger) << "OpsData.structureElementId=" << opsData.structureElementId
<< " assetId=" << opsData.assetId
<< " mountingPointTypeId=" << opsData.mountingPointTypeId
@@ -103,13 +77,10 @@ IsmHandler::OpsData IsmHandler::dataFromOpsCode(int ipsCode)
<< " roomId=" << opsData.roomId;
{
DEBUG_LOG(m_logger) <<"---------------- UPDATE OPS-Data ------------------";
updateOpsData(opsData, true);
opsData= m_opsData[opsData.opsCode] ;
}
return opsData;
}
@@ -171,10 +142,8 @@ void IsmHandler::onMountingPointAssetChanged(const InfrastructureManagement::Mou
case DataModification::eModified:
{
OpsData opsData;
opsData.opsCode = m_dtcIsm->getOpticalCodeFromAssetId(data.assetId);
opsData.assetId = data.assetId;
updateOpsData(opsData, true);
break;
}
@@ -189,8 +158,6 @@ void IsmHandler::onMountingPointAssetChanged(const InfrastructureManagement::Mou
void IsmHandler::rotateBuildingFootprint(int mseId)
{
if ( m_relBuildingFootprintsRotated.contains(mseId))
{
DEBUG_LOG(m_logger) << " mainStructureElements.Rotate already done id=" << mseId;
@@ -225,7 +192,6 @@ void IsmHandler::rotateBuildingFootprint(int mseId)
void IsmHandler::onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &data, DataModification modType)
{
switch (modType)
{
case DataModification::eAdded:
@@ -235,8 +201,6 @@ void IsmHandler::onMainStructureElementChanged(const InfrastructureManagement::M
if ( !m_dtcIsm->isElementAssignedToExercise(data, exerciseId))
{
INFO_LOG(m_logger) << "HandlerBuildingData::onMainStructureElementChanged() id=" << data.id << " remove";
m_buildingBoundingBoxes.remove(data.id);
m_relBuildingFootprints.remove(data.id);
m_relBuildingFootprintsRotated.remove((data.id));
@@ -251,7 +215,6 @@ void IsmHandler::onMainStructureElementChanged(const InfrastructureManagement::M
removeOpsDataByStructureElementId(se.id);
}
QMutableHashIterator<int, OpsData> iter(m_opsData);
while (iter.hasNext())
{
@@ -267,10 +230,6 @@ void IsmHandler::onMainStructureElementChanged(const InfrastructureManagement::M
return;
}
for (const InfrastructureManagement::StructureElement &se : data.elements)
{
if (se.mountingPointTypeId != InfrastructureManagement::MountingPointType::IndoorIPS &&
@@ -285,8 +244,6 @@ void IsmHandler::onMainStructureElementChanged(const InfrastructureManagement::M
}
DEBUG_LOG(m_logger) << " mainStructureElements Vor Rotate id=" << data.id;
QMap<int, InfrastructureManagement::MainFootprint> mainFootprints = m_dtcIsm->getFootprintsByExerciseId(exerciseId);
if (mainFootprints.contains(data.id))
{
rotateBuildingFootprint(data.id);
@@ -316,8 +273,6 @@ void IsmHandler::onMainFootprintChanged(const InfrastructureManagement::MainFoot
case DataModification::eAdded:
case DataModification::eModified:
{
DEBUG_LOG(m_logger) << "mainStructureElements onMainFootprintChanged id=" << data.id;
double minX = 0;
double maxX = 0;
@@ -445,11 +400,8 @@ void IsmHandler::updateOpsData(OpsData &data, bool force)
const auto &mainStructureElements = m_dtcIsm->mainStructureElements();
for (const auto &mse : std::as_const(mainStructureElements))
{
if (!force && !m_dtcIsm->isElementAssignedToExercise(mse, exerciseId))
continue;
for (const InfrastructureManagement::StructureElement &se : mse.elements)
@@ -500,13 +452,9 @@ bool IsmHandler::posInExtendedBuildingFootprint(int mainStructureElementId, cons
return false;
}
DEBUG_LOG(m_logger) << "mainStructureElementId=" << mainStructureElementId
<< " position=" << position;
int exerciseId = m_mainHandler->ddsHandler()->getExerciseId();
InfrastructureManagement::MainStructureElement mse = m_dtcIsm->mainStructureElement(mainStructureElementId);
@@ -516,29 +464,21 @@ bool IsmHandler::posInExtendedBuildingFootprint(int mainStructureElementId, cons
if (!m_buildingBoundingBoxes.contains(mainStructureElementId))
return false;
TetraIcd::RelativePosition relBldgPosition = m_mainHandler->posHandler()->geographicToRelative(mse.geoPosition);
TetraIcd::RelativePosition relPosition = m_mainHandler->posHandler()->geographicToRelative(position);
DEBUG_LOG(m_logger) << "relBldgPosition=" << relBldgPosition.offsetX << "/" << relBldgPosition.offsetY
<< ", relPosition=" << relPosition.offsetX << "/" << relPosition.offsetY;
QPointF relPositionMgrs(relPosition.offsetX, relPosition.offsetY);
QPolygonF relBuildingFootprint = m_relBuildingFootprintsRotated[mainStructureElementId];
QPointF relPositionF(relPosition.offsetX - relBldgPosition.offsetX, relPosition.offsetY - relBldgPosition.offsetY);
if (relBuildingFootprint.containsPoint(relPositionF, Qt::OddEvenFill))
{
DEBUG_LOG(m_logger) << "Position is inside Building-Footprint";
return true;
}
DEBUG_LOG(m_logger) << "relBuildingFootprint.size=" << relBuildingFootprint.size();
for (int i = 0; i < relBuildingFootprint.size() ; i++)
{
@@ -613,6 +553,4 @@ double IsmHandler::squareLen(const QPointF &p1, const QPointF &p2)
double vy = p2.y() - p1.y();
return vx * vx + vy * vy;
}
}
@@ -1,5 +1,4 @@
#pragma once
#include <QtCore/QObject>
#include <QtCore/QMap>
@@ -42,9 +41,6 @@ public:
OpsData dataFromOpsCode(int ipsCode) ;
int getAssetTypeIdFromStructureElementId (int structureElementId) {return m_structure_ElementId2AssetTypeId.value(structureElementId);}
bool posInExtendedBuildingFootprint(int mainStructureElementId, const Core::GeoPosition &position, const int mountPointTypeId) const;
private Q_SLOTS:
@@ -67,24 +63,16 @@ private:
NGL::INGLLogger &m_logger;
MainHandler *m_mainHandler;
QHash<int, OpsData> m_opsData;
QMap<int, int> m_structure_ElementId2AssetTypeId;
QMap<int, int> m_structureElementId2AssetId;
QMap<int, int> m_assetId2StructureElementId;
QMap<int, QRectF> m_buildingBoundingBoxes;
QMap<int, QPolygonF> m_relBuildingFootprints;
QMap<int, QPolygonF> m_relBuildingFootprintsRotated;
QMap<int, QRectF> m_buildingBoundingBoxesMgrs;
QMap<int, QPolygonF> m_relBuildingFootprintsRotatedMgrs;
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_dtcIsm;
int m_distanceIpsToGps;
int m_distanceOpsToGps;
};
@@ -1,8 +1,5 @@
#include "logger.h"
#include <NGLLogger/NGLLoggerBootstrap.h>
namespace TrainingAreaBase
@@ -27,5 +24,4 @@ namespace TrainingAreaBase
abort();
}
}
}
@@ -1,6 +1,4 @@
#pragma once
#include <NGLLogger/INGLLogger.h>
@@ -19,10 +19,8 @@
#include <LtsPluginManager/lts_plugin_loader.h>
#include <TrainingAreaBase/tab_record_replay_plugin.h>
#include <TrainingAreaBase/tab_record_replay_plugin_custom.h>
#include <nglsettings/nglsettings_connections.h>
#include <ngldb/nsqlquery.h>
#include <QUuid>
#include <QJsonDocument>
#include <QSqlDatabase>
@@ -42,18 +40,15 @@ MainHandler::~MainHandler()
LtsPluginManager::LtsPluginLoader::getInstance()->unloadAllPlugins();
m_interfaces.clear();
m_ifcConnectionState.clear();
m_rxHandler.reset();
m_txHandler.reset();
m_ftsHandler.reset();
m_posHandler.reset();
m_ppmHandler.reset();
m_pdmHandler.reset();
m_exmHandler.reset();
m_ismHandler.reset();
m_aesHandler.reset();
m_ddsHandler.reset();
m_dbHandler.reset();
}
@@ -168,8 +163,6 @@ bool MainHandler::init(int domainId, int exerciseId)
for (const std::shared_ptr<Plugin::Interface> &ifc : m_interfaces)
m_txHandler->addTxHandler(ifc->sendToTab());
// WebSocketServer
m_handlerWebSocket = std::make_shared<WebSocketInterface::WebSocketInterfaceHandler>(this);
DEBUG_LOG(m_logger) << "Reset WebSocketInterfaceHandler successful.";
@@ -181,8 +174,6 @@ bool MainHandler::init(int domainId, int exerciseId)
}
m_ddsHandler->pacemaker()->addPort(m_handlerWebSocket->serverWebSocketPort(), Core::CorePortType::WebSocketServer, QStringLiteral("{\"id\":\"TAB\"}"));
DEBUG_LOG(m_logger) << "Initialisation WebSocketInterfaceHandler successful.";
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::Running);
return true;
}
@@ -234,7 +225,6 @@ bool MainHandler::loadPlugin(const LtsPluginManager::PluginInstance &pi)
connect(ifc.get(), &Plugin::Interface::directMessage, this, &MainHandler::onDirectMessage);
m_interfaces.push_back(ifc);
m_ccsMap = m_pdmHandler->dtc()->canComponentStrings();
m_bctMap = m_pdmHandler->dtc()->biteComponentTexts();
@@ -356,7 +346,6 @@ void MainHandler::onConnectionState(const QString &name, bool connectionState)
{
m_ifcConnectionState.insert(name, connectionState);
}
DEBUG_LOG(m_logger) << "Publishing connection states: " << m_ifcConnectionState.size();
TrainingAreaBase::Connections connections;
@@ -371,17 +360,13 @@ void MainHandler::onDirectMessage(const QByteArray &jsonMessage)
{
DEBUG_LOG(m_logger) << "Got direct message " << jsonMessage;
WebSocketInterface::Messages::BiteDataMessage::BiteData biteData;
QJsonObject obj = QJsonDocument::fromJson(jsonMessage).object();
biteData.equipNo = obj.value(WebSocketInterface::JsonKeys::EQUIP_NO()).toInt();
biteData.isLicensed = obj.value(QStringLiteral("doLicence")).toBool();
qint64 biteState = obj.value(QStringLiteral("biteState")).toInt();
qint64 configState = obj.value(QStringLiteral("configState")).toInt();
qint64 batteryState = obj.value(QStringLiteral("batteryState")).toInt();
qint64 configError = obj.value(QStringLiteral("configError")).toInt();
QJsonArray biteError = obj.value(QStringLiteral("biteError")).toArray();
if (biteData.equipNo <= 0)
@@ -515,7 +500,6 @@ void MainHandler::onPositionChanged(int equipNo, const ParticipantManagement::Pa
positionData.equipNo = equipNo;
positionData.pos = pos.pos;
positionData.gpsTime = pos.sampleTime;
WebSocketInterface::Messages::PositionMessage *msg = new WebSocketInterface::Messages::PositionMessage(positionData, QUuid::createUuid().toString());
if (m_handlerWebSocket != nullptr)
@@ -1,5 +1,4 @@
#pragma once
#include <QtCore/QObject>
@@ -24,9 +23,6 @@
#include "tab_plugin_interface.h"
#include "WebSocketInterface/websocket_interface_handler.h"
#include <ngldb/db_service_handler.h>
#include "logger.h"
namespace NGLDB
@@ -65,7 +61,6 @@ public:
std::shared_ptr<PpmHandler> ppmHandler() const { return m_ppmHandler; }
std::shared_ptr<PositionHandler> posHandler() const { return m_posHandler; }
int exerciseId() const override { return m_ddsHandler->ddsConnector()->getPartitionId(); }
bool useTetraScrambling() const override;
ProjectDataManagement::RadioGroup exerciseRadioGroup() const override;
@@ -108,7 +103,6 @@ private:
std::vector<std::shared_ptr<Plugin::Interface>> m_interfaces;
std::shared_ptr<WebSocketInterface::WebSocketInterfaceHandler> m_handlerWebSocket;
ExerciseManagement::Exercise m_exerciseData;
QMap<int, ProjectDataManagement::CanComponentString> m_ccsMap;
QMap<int, ProjectDataManagement::BiteComponentText> m_bctMap;
@@ -1,10 +1,7 @@
#include "pdm_handler.h"
#include <utility>
#include "main_handler.h"
#include <ProjectDataManagement/pdm_dtc.h>
#include <NGLLogger/NGLLoggerBootstrap.h>
@@ -39,8 +36,6 @@ bool PdmHandler::init()
bool PdmHandler::initializePdm()
{
if (!m_dtcPdm->waitForHistoricalDataChargeType(20000) ||
!m_dtcPdm->waitForHistoricalDataGearType(20000) ||
!m_dtcPdm->waitForHistoricalDataGearTypeChargeType(20000) ||
@@ -176,32 +171,11 @@ int PdmHandler::vulnerabilityKindId(int tasVulnerabilityKindId, int equipmentNum
return it.value().taVulnerabilityKind;
}
QMap<int, ProjectDataManagement::RadioGroup> PdmHandler::radioGroups()
{
initializePdm();
return m_radioGroups;
}
static const int s_unknownMarker = 0x80000000;
int PdmHandler::chargeTypeIdFromGearAndChargeTasCode(int gearTasCode, int chargeTasCode)
@@ -1,6 +1,4 @@
#include "position_handler.h"
#include "exm_handler.h"
#include "logger.h"
@@ -51,13 +49,8 @@ bool PositionHandler::initCoordinateConversion() const
const LtsCoordTrans::UtmCoordinate bottomLeft(LtsCoordTrans::UtmCoordinate::fromGeographic(ta.bottomLeft.lon, ta.bottomLeft.lat));
const QPointF mid(bottomLeft.geographic(ta.width / 2, ta.height / 2));
QString mgrs = LtsCoordTrans::mgrsFromGeographic(mid.x(), mid.y(), -1);
mgrs += QStringLiteral("00000000000000");
m_utm2Geographic = LtsCoordTrans::UtmCoordinate::fromMgrs(mgrs);
LtsCoordTrans::UtmCoordinate topRight(bottomLeft);
@@ -116,10 +109,7 @@ QPointF PositionHandler::geographicToRelativePointF(const Core::GeoPosition2D &p
QPointF PositionHandler::geographicToRelativePointF(const Core::GeoPosition &p) const
{
initCoordinateConversion();
const LtsCoordTrans::UtmCoordinate point(LtsCoordTrans::UtmCoordinate::fromGeographic(p.lon, p.lat, m_utm2Geographic.zone));
return QPointF(point.x - m_utm2Geographic.x, point.y - m_utm2Geographic.y);
}
@@ -140,7 +130,6 @@ TetraIcd::RelativePosition PositionHandler::geographicToRelative(const Core::Geo
const LtsCoordTrans::UtmCoordinate &PositionHandler::baseCoordinate() const
{
initCoordinateConversion();
return m_utm2Geographic;
}
@@ -165,8 +154,6 @@ double PositionHandler::speed (const TetraIcd::RelativePosition &relPos, const i
<< " timeStamp=" << timeStamp
<< " lastParticipantPosition=" << lastParticipantPosition.time
<< " deltaTime=" << deltaTime;
double speed = line.length() / (deltaTime / 1000);
return speed;
}
@@ -37,7 +37,6 @@ public:
TetraIcd::RelativePosition geographicToRelative(const Core::GeoPosition2D &p, double z) const;
const LtsCoordTrans::UtmCoordinate &baseCoordinate() const;
static bool isPositionMarkedInvalid(const TetraIcd::RelativePosition &p)
{
static_assert(std::is_integral<decltype(p.offsetX)>::value, "RelativePosition.offsetX must be an integer!");
@@ -48,10 +47,8 @@ public:
(invalidPos == (p.offsetY & threeBytes)));
}
double speed(const TetraIcd::RelativePosition &relPos, const int equipNo, const qint64 timeStamp) const;
bool isTimeToPerformSpeedCheckExceeded(const int equipNo, const qint64 timeStamp, const int maxTime) const;
void setLastPosition(int equipNo, const TrainingAreaBase::TabPosition &pos);
void setLastMountPointTypeId(int equipNo, const int lastMountPointTypeId);
void setLastBuildingId(int equipNo, const int lastBuildingId);
@@ -61,7 +58,6 @@ public:
int lastMountPointTypeId(const int equipNo) const;
int lastBuildingId(const int equipNo) const;
int lastRoomId(const int equipNo) const;
bool isInTrainingArea(const TetraIcd::RelativePosition &relPos) const;
private:
@@ -73,7 +69,6 @@ private:
mutable std::shared_ptr<AssetManagement::Interface::Dtc> m_dtcAsm;
mutable LtsCoordTrans::UtmCoordinate m_utm2Geographic;
QHash<int, ParticipantPosition> m_lastPosition;
mutable QPointF m_relPosBottomLeft;
mutable QPointF m_relPosTopRight;
};
@@ -1,6 +1,4 @@
#include "ppm_handler.h"
#include "main_handler.h"
#include "send_to_tab.h"
@@ -20,9 +20,7 @@ class PpmHandler final : public QObject
Q_OBJECT
public:
explicit PpmHandler(MainHandler *mainHandler);
bool init();
std::shared_ptr<ParticipantManagement::Interface::Dtc> getDtc() { return m_ppmDtc; }
std::unordered_map<int, std::unordered_set<int>> exerciseEquipmentAssignment() const { return m_exerciseEquipmentAssignments; }
@@ -1,6 +1,4 @@
#include "recv_from_dds_aes.h"
#include <utility>
#include "main_handler.h"
@@ -15,15 +13,11 @@
namespace TrainingAreaBase
{
AesStateHandler::AesStateHandler(MainHandler *mainHandler)
: m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger())
, m_dbInterface(mainHandler->dbHandler()->db())
, m_exerciseId(mainHandler->exerciseId()) {}
template<>
void RecvFromDdsAes::txData(const TrainingAreaBase::TetraIcd::DusMineReactivation &tele)
{
@@ -38,8 +32,6 @@ bool AesStateHandler::init()
{
const auto cb = [this](const Database::AesId2TaId & item)
{
m_tetraId2ddsId[item.aesTetraId] = item.aesDdsId;
m_ddsId2TetraId[item.aesDdsId] = item.aesTetraId;
DEBUG_LOG(m_logger) << "AES internal DDS id: " << item.aesDdsId << " - tetra id: " << item.aesTetraId;
@@ -59,7 +51,6 @@ bool AesStateHandler::init()
int AesStateHandler::createAesTetraId(int aesDdsId, bool &alreadyExists)
{
alreadyExists = false;
Database::AesId2TaId aes2Ta;
aes2Ta.aesTetraId = getAesTetraId(aesDdsId);
if (aes2Ta.aesTetraId != 0)
@@ -107,9 +98,6 @@ bool AesStateHandler::update(int aesDdsId, int aesTetraId, bool bSentToTetra)
return true;
}
RecvFromDdsAes::RecvFromDdsAes(MainHandler *mainHandler,
const std::shared_ptr<SendToTab> &txCallback,
QObject *parent)
@@ -128,7 +116,6 @@ RecvFromDdsAes::RecvFromDdsAes(MainHandler *mainHandler,
connect(m_checkOutdatedTelegramsTimer, &QTimer::timeout,
this, &RecvFromDdsAes::onCheckOutdatedTelegrams);
m_sendDusMineReactivtionTimer->setSingleShot(true);
m_sendDusMineReactivtionTimer->setInterval(200);
connect(m_sendDusMineReactivtionTimer, &QTimer::timeout,
@@ -372,9 +359,6 @@ bool RecvFromDdsAes::sendSingleFireSMArt(const SendCesHitRequest &request)
return true;
}
template <typename T>
void RecvFromDdsAes::handleEffectSimulation(const T &data, DataModification modType, TetraIcd::AreaEffectSimulationType aesType)
{
@@ -442,8 +426,6 @@ void RecvFromDdsAes::handleEffectSimulation(const T &data, DataModification modT
}
else
{
if (!(std::is_same<T, AreaEffectSimulation::FunctionalArea>::value) ||
(data.effectStateId == AreaEffectSimulation::AesEffectState::EsActivated))
handleSendToTetra(data, aesType);
@@ -545,12 +527,9 @@ void RecvFromDdsAes::onTriggeredImpactsChanged(const AreaEffectSimulation::Trigg
return;
if (data.aesTypeId != AreaEffectSimulation::AesType::AtMineAreaSingleMines)
return;
if (data.aesItemId == 0)
return;
bool completeUntriggered = true;
for (size_t i = 0; i < data.bitfield.size() && completeUntriggered; ++i)
{
@@ -572,7 +551,6 @@ void RecvFromDdsAes::onTriggeredImpactsChanged(const AreaEffectSimulation::Trigg
if (completeUntriggered)
return;
auto it = m_currentMineArea.find(data.aesItemId);
if (it != m_currentMineArea.end())
{
@@ -605,9 +583,7 @@ void RecvFromDdsAes::onTriggeredImpactsChanged(const AreaEffectSimulation::Trigg
}
TetraIcd::MineAreaSingleMineState out;
out.aesDdsId = data.aesItemId;
out.mineCount = data.impactCount;
out.mineState.reserve(data.bitfield.size());
for (const auto &c : data.bitfield)
@@ -625,23 +601,16 @@ void RecvFromDdsAes::onDusMineStateChanged(const AreaEffectSimulation::DusMineSt
if (vec.size() == 0)
return;
for (const auto &mine : vec)
{
if (!m_mainHandler->pdmHandler()->isReactivatableChargeType({mine.chargeTypeId, 0,0}))
continue;
if (mine != m_allReactivatableDusMines.value(mine.eqId))
{
if (!mine.triggered &&
m_allReactivatableDusMines.contains(mine.eqId) && m_allReactivatableDusMines.value(mine.eqId).triggered
)
m_minesToSend << mine.eqId;
m_allReactivatableDusMines.insert(mine.eqId, mine);
}
}
@@ -711,16 +680,11 @@ void setCommonCombatParams(T &out, const S &in, const int aesTetraId)
out.effectDuration = in.effectDuration;
}
void RecvFromDdsAes::onEffectsChanged(const AreaEffectSimulation::Effects &data, DataModification modType)
{
if (modType == DataModification::eRemoved)
return;
if (data.aesTypeId != AreaEffectSimulation::AesType::AtExplosionClusterSingleExplosions)
return;
@@ -728,32 +692,23 @@ void RecvFromDdsAes::onEffectsChanged(const AreaEffectSimulation::Effects &data,
if (aesItemId <= 0)
return;
const AreaEffectSimulation::ExplosionCluster &aes = m_dtcAes->explosionCluster(aesItemId);
if (aes.id != aesItemId)
return;
const bool bIsLaserGuidable = m_mainHandler->pdmHandler()->isLaserGuidable(aes.chargeStruct);
if (!bIsLaserGuidable)
return;
const std::vector<AreaEffectSimulation::SingleEffect> &singleEffectsRef = data.singleEffects;
if (!singleEffectsRef.empty())
{
bool bAlreadyExists = false;
const int aesTetraId = m_aesStateHandler->createAesTetraId(aesItemId, bAlreadyExists);
DEBUG_LOG(m_logger) << "RecvFromDdsAes::onEffectsChanged(Effects, "
<< aesTetraId << ")";
TetraIcd::CreateAreaExplosion cAes;
setCommonCombatParams(cAes, aes, aesTetraId);
if(cAes.effectStart > 0)
{
@@ -763,11 +718,9 @@ void RecvFromDdsAes::onEffectsChanged(const AreaEffectSimulation::Effects &data,
cAes.effectStart += (delayMSec);
}
const AreaEffectSimulation::SingleEffect &firstSingleEffect = singleEffectsRef.front();
const Core::GeoPosition &fsePosition = firstSingleEffect.position;
cAes.relCorner = m_posHandler->geographicToRelative(fsePosition);
cAes.width = qRound(aes.area.width);
cAes.height = qRound(aes.area.height);
cAes.rotationAngle = aes.area.rotation;
@@ -784,14 +737,7 @@ void RecvFromDdsAes::onEffectsChanged(const AreaEffectSimulation::Effects &data,
for (const Core::GeoPosition2D &pos : std::as_const(aes.mhPoints))
mhPointsRef.emplace_back(m_posHandler->geographicToRelative(pos, 0));
cAes.chargeTypeId = 254;
txData(cAes);
}
}
@@ -811,8 +757,6 @@ void RecvFromDdsAes::sendCreateEffectSimulation(const AreaEffectSimulation::AirS
cAes.header.equipmentNumber = 0;
cAes.relEffectPosition = m_posHandler->geographicToRelative(aes.impactPosition, 0);
const auto chargeType(pdm()->chargeTypeFromId(aes.chargeStruct.chargeTypeId));
cAes.chargeTypeId = chargeType.legacyId > 0 ? chargeType.legacyId : chargeType.id;
@@ -846,7 +790,6 @@ void RecvFromDdsAes::sendCreateEffectSimulation(const AreaEffectSimulation::BCCo
cAes.validityTimeWind = aes.weatherTimestamp;
cAes.relPositionValidityTimeWind = m_posHandler->geographicToRelative(aes.weatherPosition, 0);
const auto chargeType(pdm()->chargeTypeFromId(aes.chargeStruct.chargeTypeId));
cAes.chargeTypeId = chargeType.legacyId > 0 ? chargeType.legacyId : chargeType.id;
@@ -890,8 +833,6 @@ void RecvFromDdsAes::sendCreateEffectSimulation(const AreaEffectSimulation::Expl
cAes.impactCount = aes.cannonCount * aes.cannonRounds;
cAes.impactEdgeLength = qRound(pdm()->impactEdgeLength(aes.chargeStruct));
cAes.hazardDistance = m_mainHandler->pdmHandler()->hazardDistance(aes.chargeStruct);
const auto chargeType(pdm()->chargeTypeFromId(aes.chargeStruct.chargeTypeId));
cAes.chargeTypeId = chargeType.legacyId > 0 ? chargeType.legacyId : chargeType.id;
@@ -903,17 +844,13 @@ void RecvFromDdsAes::sendCreateEffectSimulation(const AreaEffectSimulation::Expl
void RecvFromDdsAes::sendCreateEffectSimulation(const AreaEffectSimulation::ExplosionCluster &aes, int aesTetraId)
{
const bool bIsLaserGuidable = m_mainHandler->pdmHandler()->isLaserGuidable(aes.chargeStruct);
DEBUG_LOG(m_logger) << "RecvFromDdsAes::sendCreateEffectSimulation "
<< ", aes " << aes
<< ", bIsLaserGuidable " << bIsLaserGuidable;
if (bIsLaserGuidable)
{
return;
}
@@ -925,10 +862,7 @@ void RecvFromDdsAes::sendCreateEffectSimulation(const AreaEffectSimulation::Expl
DEBUG_LOG(m_logger) << "RecvFromDdsAes::sendCreateEffectSimulation(ExplosionArea, "
<< aesTetraId << ")";
TetraIcd::CreateAreaExplosion cAes;
setCommonCombatParams(cAes, aes, aesTetraId);
cAes.relCorner = m_posHandler->geographicToRelative(aes.area.cornerBottomLeft, 0);
cAes.width = qRound(aes.area.width);
cAes.height = qRound(aes.area.height);
@@ -948,9 +882,6 @@ void RecvFromDdsAes::sendCreateEffectSimulation(const AreaEffectSimulation::Expl
int chargeTypeId = 0;
const auto chargeType(pdm()->chargeTypeFromId(aes.chargeStruct.chargeTypeId));
chargeTypeId = pdm()->legacyChargeTypeIgniterType(aes.chargeStruct.chargeTypeId, aes.chargeStruct.igniterTypeId, aes.chargeStruct.igniterFunctionId);
if (chargeTypeId > 0)
cAes.chargeTypeId = chargeTypeId;
else
@@ -960,7 +891,6 @@ void RecvFromDdsAes::sendCreateEffectSimulation(const AreaEffectSimulation::Expl
if (cAes.chargeTypeId <= 0)
return;
txData(cAes);
}
@@ -979,8 +909,6 @@ void RecvFromDdsAes::sendCreateEffectSimulation(const AreaEffectSimulation::Expl
cAes.header.equipmentNumber = equipmentNumber;
cAes.relEffectPosition = m_posHandler->geographicToRelative(aes.impactPosition, 0);
cAes.effectDiameter = qRound(2 * pdm()->impactRadius(aes.chargeStruct));
const auto chargeType(pdm()->chargeTypeFromId(aes.chargeStruct.chargeTypeId));
cAes.chargeTypeId = chargeType.legacyId > 0 ? chargeType.legacyId : chargeType.id;
@@ -1002,13 +930,8 @@ void RecvFromDdsAes::sendCreateEffectSimulation(const AreaEffectSimulation::Mine
TetraIcd::CreateMineArea cAes;
setCommonCombatParams(cAes, aes, aesTetraId);
cAes.layingDepth = aes.width;
cAes.layingDensity = aes.density;
const auto chargeType(pdm()->chargeTypeFromId(aes.chargeStruct.chargeTypeId));
cAes.chargeTypeId = chargeType.legacyId > 0 ? chargeType.legacyId : chargeType.id;
@@ -1069,9 +992,7 @@ void RecvFromDdsAes::sendCreateEffectSimulation(const AreaEffectSimulation::NCon
cAes.borderLengthOuter = qRound(aes.borderLengthOuter);
cAes.spanAngle = aes.spanAngle;
cAes.rotationAngle = aes.rotationAngle;
cAes.chargeTypeId = aes.chargeStruct.chargeTypeId;
txData(cAes);
}
@@ -1111,9 +1032,7 @@ void RecvFromDdsAes::sendCreateEffectSimulation(const AreaEffectSimulation::Tech
DEBUG_LOG(m_logger) << "RecvFromDdsAes::sendCreateEffectSimulation(TechnicalArea, "
<< aesTetraId << ")";
TetraIcd::TechnicalArea fAes;
fAes.aesDdsId = aes.id;
fAes.name = aes.name;
fAes.taType = static_cast<TetraIcd::TechnicalArea::Type>(aes.type);
fAes.relCorner = m_posHandler->geographicToRelative(aes.area.cornerBottomLeft, 0);
@@ -1148,15 +1067,12 @@ void RecvFromDdsAes::sendCreateEffectSimulation(const AreaEffectSimulation::DusS
void RecvFromDdsAes::sendCreateEffectSimulation(const AreaEffectSimulation::GasPipe &aes, int aesTetraId)
{
Q_UNUSED(aes);
Q_UNUSED(aesTetraId);
}
void RecvFromDdsAes::sendModifyEffectSimulationName(TetraIcd::AreaEffectSimulationType aesType, int aesTetraId, const std::string &name, int aesId)
{
if (aesTetraId == 0)
{
WARNING_LOG(m_logger) << "Trying to modify an effect simulation name but have no aes identification: " << name;
@@ -1168,9 +1084,7 @@ void RecvFromDdsAes::sendModifyEffectSimulationName(TetraIcd::AreaEffectSimulati
TetraIcd::ModifyAreaEffectSimulationName mAes;
mAes.aesType = aesType;
mAes.aesDdsId = aesId;
mAes.name = name;
txData(mAes);
}
@@ -1181,8 +1095,6 @@ void RecvFromDdsAes::sendRemoveEffectSimulation(TetraIcd::AreaEffectSimulationTy
if (aesType == TetraIcd::AreaEffectSimulationType::GasPipeDetonation)
return;
const int aesTetraId = m_aesStateHandler->getAesTetraId(aesDdsId);
if (aesTetraId == 0)
{
@@ -1237,8 +1149,6 @@ void RecvFromDdsAes::sendPauseEffectSimulation(int aesDdsId)
TetraIcd::PauseEffectSimulation dAes;
dAes.aesDdsId = aesDdsId;
txData(dAes);
}
@@ -1269,7 +1179,6 @@ void RecvFromDdsAes::sendResumeEffectSimulation(const AreaEffectSimulation::Expl
TetraIcd::ResumeEffectSimulation dAes;
dAes.aesDdsId = aes.id;
dAes.sequelNumber = AreaEffectSimulation::Polygons::getSequelNumber(aes.id,
aes.cannonCount * aes.cannonRounds,
aes.originalEffectDuration,
@@ -1281,7 +1190,6 @@ void RecvFromDdsAes::sendResumeEffectSimulation(const AreaEffectSimulation::Expl
txData(dAes);
}
template<>
void RecvFromDdsAes::sendResumeEffectSimulation(const AreaEffectSimulation::ExplosionCluster &aes)
{
@@ -1370,6 +1278,5 @@ void RecvFromDdsAes::fillCentralChangesTable(const T &data)
{
dataChanged(data);
}
}
@@ -1,6 +1,4 @@
#pragma once
#include <QtCore/QObject>
@@ -60,8 +58,6 @@ private:
int m_exerciseId;
};
class RecvFromDdsAes : public QObject
{
Q_OBJECT
@@ -95,21 +91,15 @@ public:
}
void resetAllDusMines();
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> dtcAes() const { return m_dtcAes;}
private:
template<typename T>
void handleEffectSimulation(const T &data, DataModification modType, TetraIcd::AreaEffectSimulationType aesType);
template<typename T>
void fillCentralChangesTable(const T &data);
template <typename T>
void handleSendToTetra(const T &data, TetraIcd::AreaEffectSimulationType aesType);
void onAirSupportImpactChanged(const AreaEffectSimulation::AirSupportImpact &data, DataModification modType);
void onBcContaminationChanged(const AreaEffectSimulation::BCContamination &data, DataModification modType);
void onExplosionAreaChanged(const AreaEffectSimulation::ExplosionArea &data, DataModification modType);
@@ -147,7 +137,6 @@ private:
static_assert(std::is_base_of<AreaEffectSimulation::AesItem, T>::value, "Given type for sendResumeEffectSimulation is not an aes item!");
}
void doSpecialization(const AreaEffectSimulation::ExplosionArea &data, std::unordered_map<int, AreaEffectSimulation::ExplosionArea> &cont)
{
cont[data.id].remainExplosionNumber = data.remainExplosionNumber; }
@@ -170,8 +159,6 @@ private:
DEBUG_LOG(m_logger) << "new AES Item: " << data;
return true;
}
it->second.effectStateId = data.effectStateId;
doSpecialization(data, cont);
@@ -182,12 +169,11 @@ private:
return false;
}
T tmp(it->second);
tmp.name = data.name; tmp.sampleTime = data.sampleTime; onlyNameChanged = (tmp == data);
tmp.name = data.name;
tmp.sampleTime = data.sampleTime;
onlyNameChanged = (tmp == data);
std::swap(it->second, dataTmp);
DEBUG_LOG(m_logger) << "changed AES Item: " << data;
return true;
}
@@ -202,14 +188,14 @@ private:
bool dataChanged(const AreaEffectSimulation::ExplosionArea &current, bool &onlyNameChanged)
{
AreaEffectSimulation::ExplosionArea copy(current);
copy.remainExplosionNumber = 0; return dataChanged(copy, m_currentExplosionArea, onlyNameChanged);
copy.remainExplosionNumber = 0;
return dataChanged(copy, m_currentExplosionArea, onlyNameChanged);
}
bool dataChanged(const AreaEffectSimulation::ExplosionCluster &current, bool &onlyNameChanged)
{
AreaEffectSimulation::ExplosionCluster copy(current);
copy.remainExplosionNumber = 0; return dataChanged(copy, m_currentExplosionCluster, onlyNameChanged);
copy.remainExplosionNumber = 0;
return dataChanged(copy, m_currentExplosionCluster, onlyNameChanged);
}
bool dataChanged(const AreaEffectSimulation::ExplosionSingle &current, bool &onlyNameChanged)
@@ -241,16 +227,13 @@ private:
return dataChanged(current, m_currentGasPipes, onlyNameChanged);
}
bool dataChanged(const AreaEffectSimulation::BoobyTrap &current)
{
bool placeholder;
Q_UNUSED(placeholder);
return dataChanged(current, m_currentBoobyTraps, placeholder);
}
bool dataChanged(const AreaEffectSimulation::OffRouteMine &current)
{
bool placeholder;
@@ -320,7 +303,6 @@ private:
}
std::shared_ptr<PdmHandler> pdm();
template<typename T>
void txData(const T &tele)
{
@@ -348,19 +330,12 @@ private:
std::unordered_map<int, AreaEffectSimulation::TechnicalArea> m_currentTechnicalArea;
std::unordered_map<int, AreaEffectSimulation::DusSingleMine> m_currentDusSingleMine;
std::unordered_map<int, AreaEffectSimulation::GasPipe> m_currentGasPipes;
std::unordered_map<int, AreaEffectSimulation::BoobyTrap> m_currentBoobyTraps;
std::unordered_map<int, AreaEffectSimulation::OffRouteMine> m_currentOffRouteMines;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<SendToTab> m_txCallback;
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_dtcAes;
std::shared_ptr<AesStateHandler> m_aesStateHandler;
QMap<int, AreaEffectSimulation::AesEffectState> m_currentEffectState;
QMap<int, AreaEffectSimulation::DusMine> m_allReactivatableDusMines;
QVector<int> m_minesToSend;
@@ -368,7 +343,6 @@ private:
MainHandler *m_mainHandler;
QTimer *m_checkOutdatedTelegramsTimer;
QTimer *m_sendDusMineReactivtionTimer;
QVector<TetraIcd::TrainingAreaTelegram*> m_sentAesTelegrams;
QVector<int> m_sentAesTelegramsAesIds;
};
@@ -11,14 +11,10 @@
#include "main_handler.h"
#include "ism_handler.h"
#include "settings.h"
#include <LtsUtilsCore/json.h>
namespace TrainingAreaBase
{
RecvFromDdsFts::RecvFromDdsFts(MainHandler *mainHandler, const std::shared_ptr<Interface::Fts> &ftsTab,
const std::shared_ptr<SendToTab> &txCallback)
: Interface::Fts::DemandBiteRequestHandler(ftsTab)
@@ -222,7 +218,6 @@ void RecvFromDdsFts::onSendGeopairingDataRequest(const rti::core::SampleIdentity
data.payloadType = TetraIcd::OpaquePayloadDataBase::Type::Geopairing;
data.header.equipmentNumber = request.equipmentNumber;
data.payload = request.payload;
m_ftsTab->sendGeopairingDataReply(cookie, fillFro(request.participantId, m_txCallback->txData(data)));
}
@@ -232,7 +227,6 @@ void RecvFromDdsFts::onSendTargetDataRequest(const rti::core::SampleIdentity &co
data.payloadType = TetraIcd::OpaquePayloadDataBase::Type::Target;
data.header.equipmentNumber = request.equipmentNumber;
data.payload = request.payload;
m_ftsTab->sendTargetDataReply(cookie, fillFro(request.participantId, m_txCallback->txData(data)));
}
@@ -6,10 +6,8 @@
* $Author$
*/
#include "tab_record_replay_plugin_custom.h"
namespace TrainingAreaBase
{
@@ -68,7 +66,6 @@ bool RecordReplayPluginCustom::ppmDdsTopicsFromDatabase(NSqlQuery &q, qint64 fro
if (!readEquipmentState(q, fromTime, toTime)) return false;
if (!readSpecialSensorData(q, fromTime, toTime)) return false;
return true;
}
@@ -1,9 +1,6 @@
#include "training_area_telegrams.h"
#include <utility>
#include <QtCore/QJsonArray>
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonObject>
@@ -12,7 +9,6 @@ namespace TrainingAreaBase
{
namespace TetraIcd
{
JsonException::JsonException(const QJsonObject &obj, const QString &key)
: m_obj(obj)
, m_key(key)
@@ -3063,10 +3059,8 @@ namespace TrainingAreaBase
UAVAction UAVAction::fromJson(const QJsonObject &obj)
{
UAVAction ret;
get(obj, TASK(), ret.task);
get(obj, POSITION(), ret.absPosition);
return ret;
}
@@ -3075,16 +3069,13 @@ namespace TrainingAreaBase
return QJsonObject{{TASK(), enumToJson(task)}, {POSITION(), absPosition.toJson()}};
}
UAVPerformMission UAVPerformMission::fromJson(const QJsonObject &obj)
{
UAVPerformMission ret;
get(obj, HEADER(), ret.header);
get(obj, ACTIONS(), ret.actions);
get(obj, MISSION_NAME(), ret.missionName);
get(obj, MISSION_ID(), ret.missionId);
return ret;
}
@@ -3093,14 +3084,11 @@ namespace TrainingAreaBase
return QJsonObject{{HEADER(), header.toJson()}, {ACTIONS(), arrayToJson(actions)}, {MISSION_NAME(), missionName}, {MISSION_ID(), missionId}};
}
UAVStatus UAVStatus::fromJson(const QJsonObject &obj)
{
UAVStatus ret;
get(obj, HEADER(), ret.header);
get(obj, UAVSTATE(), ret.uavState);
return ret;
}
@@ -3109,14 +3097,11 @@ namespace TrainingAreaBase
return QJsonObject{{HEADER(), header.toJson()}, {UAVSTATE(), enumToJson(uavState)}};
}
UAVRadioLinkConnectionStatus UAVRadioLinkConnectionStatus::fromJson(const QJsonObject &obj)
{
UAVRadioLinkConnectionStatus ret;
get(obj, HEADER(), ret.header);
get(obj, UAVCONNECTIONSTATE(), ret.uavConnectionState);
return ret;
}
@@ -3125,16 +3110,13 @@ namespace TrainingAreaBase
return QJsonObject{{HEADER(), header.toJson()}, {UAVCONNECTIONSTATE(), enumToJson(uavConnectionState)}};
}
UAVMissionStatus UAVMissionStatus::fromJson(const QJsonObject &obj)
{
UAVMissionStatus ret;
get(obj, HEADER(), ret.header);
get(obj, CURRENT_ACTION(), ret.currentAction);
get(obj, CURRENT_MISSION_NAME(), ret.currentMissionName);
get(obj, MISSION_ENDED(), ret.missionEnded);
return ret;
}
@@ -3146,14 +3128,11 @@ namespace TrainingAreaBase
{MISSION_ENDED(), missionEnded}};
}
UAVChangeState UAVChangeState::fromJson(const QJsonObject &obj)
{
UAVChangeState ret;
get(obj, HEADER(), ret.header);
get(obj, REQUESTED_STATE(), ret.requestedState);
return ret;
}
@@ -3165,11 +3144,9 @@ namespace TrainingAreaBase
ExFireReadiness ExFireReadiness::fromJson(const QJsonObject &obj)
{
ExFireReadiness ret;
get(obj, HEADER(), ret.header);
get(obj, PARTY_ID(), ret.partyId);
get(obj, REFERENCE(), ret.reference);
return ret;
}
@@ -3181,7 +3158,6 @@ namespace TrainingAreaBase
ExFiredReport ExFiredReport::fromJson(const QJsonObject &obj)
{
ExFiredReport ret;
get(obj, HEADER(), ret.header);
get(obj, PARTY_ID(), ret.partyId);
get(obj, REFERENCE(), ret.reference);
@@ -3198,7 +3174,6 @@ namespace TrainingAreaBase
ExConfirmationReport ExConfirmationReport::fromJson(const QJsonObject &obj)
{
ExConfirmationReport ret;
get(obj, HEADER(), ret.header);
get(obj, PARTY_ID(), ret.partyId);
get(obj, REFERENCE(), ret.reference);
@@ -20,15 +20,6 @@ SET(SRCS_common
logger.h
)
# pdm_types.h was a migration-scaffolding stub with no qt5 counterpart and
# no consumer; the stub in include/ was removed and the copy with it.
# pdm_translation.h and pdm_enums.hpp stub copies (OFF-variant fallbacks whose
# include/ sources were removed together with the other shadowing stubs):
# with BUILD_GRANTLEE=ON and BUILD_RTI=ON the codegen writes the real files to
# these build-dir paths, so the copies are gone rather than kept for forbidden
# OFF variants.
# Define target name early for use in subsequent macros
SET(PDM_COMMON_TARGET svcPdmCommon)
@@ -193,9 +184,7 @@ ENDIF()
#
# --- Executable svcProjectDataManagement (sPDM) -------------------------------------------------
#
# The executable links LtsWebSocketServer, which was pruned from the
# tree (prune commit 7fc6f6664), so the target is only created when the
# module is present.
# The executable links LtsWebSocketServer
IF(EXISTS "${CMAKE_SOURCE_DIR}/Lts/Common/LtsWebSocket")
LIST(APPEND SRCS_exe
convert_db_to_dds.h
@@ -48,7 +48,6 @@ void ChargeTypeRename::onUpdateChargeNamesRequest(const rti::core::SampleIdentit
}
m_dds->fts()->updateChargeNamesReply(cookie, Core::FunctionReplyObject(ct.id));
m_dds->dts()->publish(Database::convert(ct));
}
@@ -9,7 +9,6 @@
#include <ProjectDataManagement/pdm_fts.h>
#include <QtCore/QObject>
#include "logger.h"
namespace ProjectDataManagement
@@ -26,7 +26,6 @@ void MyLabel::mousePressEvent(QMouseEvent *ev)
/****************************************************************/
ResizableStackedWidget::ResizableStackedWidget(QWidget *parent)
: QStackedWidget(parent)
{
@@ -58,7 +57,6 @@ void ResizableStackedWidget::onCurrentChanged(int index)
/****************************************************************/
RWWidget::RWWidget(QWidget *parent)
: QWidget(parent)
, m_label(new MyLabel(this))
@@ -95,8 +93,6 @@ void RWWidget::onSetWritablePrivate()
}
/****************************************************************/
RWSpinBox::RWSpinBox(RwMode readOnly, QWidget *parent)
: RWWidget(parent)
, m_spinBox(readOnly == RwMode::ReadOnly ? nullptr : new QSpinBox(this))
@@ -136,8 +132,6 @@ int RWSpinBox::value() const
}
/*****************************************************/
RWDoubleSpinBox::RWDoubleSpinBox(RwMode readOnly, QWidget *parent)
: RWWidget(parent)
, m_doubleSpinBox(readOnly == RwMode::ReadOnly ? nullptr : new QDoubleSpinBox(this))
@@ -188,7 +182,6 @@ double RWDoubleSpinBox::value() const
/*****************************************************/
RWCheckBox::RWCheckBox(RwMode readOnly, QWidget *parent)
: RWWidget(parent)
, m_checkBox(readOnly == RwMode::ReadOnly ? nullptr : new QCheckBox(this))
@@ -248,7 +241,6 @@ QString RWLineEdit::text() const
/*****************************************************/
RWComboBox::RWComboBox(RwMode readOnly, QWidget *parent)
: RWWidget(parent)
, m_comboBox(readOnly == RwMode::ReadOnly ? nullptr : new QComboBox(this))
@@ -1,18 +1,13 @@
#include "AddLine.h"
#include "ui_AddLinesUi.h"
#include <QtCore/QDebug>
AddLines::AddLines(QWidget* parent)
: QDialog(parent)
, m_ui(new Ui::AddLines)
{
qRegisterMetaType<AddModel*>("AddModel*");
m_ui->setupUi(this);
m_ui->dataView->setModel(&addModel);
connect(m_ui->pbDone, &QPushButton::clicked,
@@ -28,21 +23,17 @@ AddLines::AddLines(QWidget* parent)
this, &AddLines::slotClear);
}
AddLines::~AddLines()
{
delete m_ui;
}
void AddLines::slotDeleteLines()
{
//qWarning() << "slotDeleteLines";
while (m_ui->dataView->selectionModel()->selectedRows().count())
{
const QModelIndexList selectedRows = m_ui->dataView->selectionModel()->selectedRows();
if (selectedRows.at(0).row() == addModel.rowCount()-1) // do not delete empty row!
{
return; // In hope that the selectedRows list is sorted.....
@@ -52,27 +43,23 @@ void AddLines::slotDeleteLines()
}
}
void AddLines::slotClear()
{
//qWarning() << "slotClear";
addModel.clear();
}
void AddLines::reject()
{
emit signalAddLines(nullptr);
}
void AddLines::copyDataFromModel(DataModel* dataModel)
{
addModel.setHeaderList(dataModel->getHeaderList());
addModel.setTablename(dataModel->getTableName());
}
void AddLines::slotAddLines()
{
this->hide(); // hide until in work..
@@ -1,7 +1,6 @@
#pragma once
#include "AddModel.h"
#include <QtWidgets/QDialog>
namespace Ui
@@ -9,7 +8,6 @@ namespace Ui
class AddLines;
}
class AddLines : public QDialog
{
Q_OBJECT
@@ -17,7 +15,6 @@ class AddLines : public QDialog
public:
explicit AddLines(QWidget *parent = nullptr);
~AddLines();
void copyDataFromModel(DataModel* dataModel);
protected:
@@ -1,8 +1,6 @@
#include "AddModel.h"
#include <QtCore/QDebug>
void AddModel::setHeaderList(const HeaderList& headerList)
{
m_headerList = headerList;
@@ -10,17 +8,14 @@ void AddModel::setHeaderList(const HeaderList& headerList)
endResetModel();
}
const HeaderList& AddModel::getHeaderList() const
{
return m_headerList;
}
bool AddModel::removeRow(int row, const QModelIndex &parent)
{
//qWarning() << "removeRow";
(void)parent;
if (row >= m_dataList.count())
@@ -36,7 +31,6 @@ bool AddModel::removeRow(int row, const QModelIndex &parent)
return true;
}
void AddModel::clear()
{
beginResetModel();
@@ -44,7 +38,6 @@ void AddModel::clear()
endResetModel();
}
QVariant AddModel::data(const QModelIndex &index, int role) const
{
switch (role)
@@ -96,7 +89,6 @@ bool AddModel::setData(const QModelIndex &index, const QVariant &value, int role
return true;
}
QMetaType::Type AddModel::getColumnType(const int column) const
{
if (column < 0 || column >= m_headerList.size())
@@ -104,7 +96,6 @@ QMetaType::Type AddModel::getColumnType(const int column) const
return m_headerList.at(column).second;
}
QVariant AddModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation != Qt::Horizontal)
@@ -121,19 +112,16 @@ QVariant AddModel::headerData(int section, Qt::Orientation orientation, int role
return QVariant();
}
int AddModel::rowCount(const QModelIndex &) const
{
return m_dataList.count() + 1 /* empty row for new data */; // yes, if the user wants to add more than 1 line!
}
int AddModel::columnCount(const QModelIndex &) const
{
return m_headerList.count();
}
Qt::ItemFlags AddModel::flags(const QModelIndex &) const
{
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;
@@ -145,7 +133,6 @@ void AddModel::setTablename(const QString& tableName)
m_tableName = tableName;
}
const QString& AddModel::getTableName() const
{
return m_tableName;
@@ -13,7 +13,6 @@
#include <QShortcut>
#include <QtCore/QThread>
BrowserWnd::BrowserWnd()
: QWidget(nullptr)
, m_loginWnd(new LoginWnd(this))
@@ -49,13 +48,11 @@ BrowserWnd::~BrowserWnd()
delete m_loginWnd;
}
void BrowserWnd::slotAddNewQuery()
{
addNewQuery();
}
void BrowserWnd::slotConnectResult(const QString &result)
{
if (result.isEmpty()) // connection success!
@@ -70,9 +67,7 @@ void BrowserWnd::slotConnectResult(const QString &result)
m_ui->splitter->setStretchFactor(1, 1); // stretch the query widget
this->show();
addNewQuery();
refreshTableList();
connect(m_ui->leFilter, &QLineEdit::textChanged, this, &BrowserWnd::slotFilterTableList);
@@ -94,13 +89,11 @@ void BrowserWnd::slotConnectResult(const QString &result)
m_waitWnd->hide();
}
void BrowserWnd::slotFilterTableList(const QString &)
{
refreshTableList();
}
void BrowserWnd::addNewQuery(const QString &tableName) // tableName only set when query from double clicking table list
{
Query *query = new Query(m_queryWorker);
@@ -127,7 +120,6 @@ void BrowserWnd::addNewQuery(const QString &tableName) // tableName only set whe
// m_waitWnd->setStatus(percent);
//}
void BrowserWnd::endThread()
{
if (!m_queryThread)
@@ -143,17 +135,13 @@ void BrowserWnd::endThread()
m_queryWorker = nullptr;
}
void BrowserWnd::refreshTableList()
{
m_ui->lwTables->clear();
m_waitWnd->wait(QStringLiteral("Refreshing Table List .."));
emit signalGetTableList();
}
void BrowserWnd::slotNewTableList(QStringList tables)
{
if (!m_ui->leFilter->text().isEmpty()) // filter when there is a filter
@@ -163,15 +151,12 @@ void BrowserWnd::slotNewTableList(QStringList tables)
}
m_ui->lwTables->addItems(tables);
m_waitWnd->hide();
}
void BrowserWnd::startConnect()
{
//m_loginWnd->setDefaultLoginData(presetManager. defaultLoginData);
if (!m_loginWnd->exec()) // false = user reject
{
QCoreApplication::quit();
@@ -179,11 +164,9 @@ void BrowserWnd::startConnect()
}
m_waitWnd->wait(tr("Connecting .."));
emit signalConnect(m_loginWnd->getLoginData());
}
bool BrowserWnd::test()
{
if (QSqlDatabase::drivers().isEmpty() ||
@@ -193,25 +176,20 @@ bool BrowserWnd::test()
tr("Missing Qt PostgreSQL driver"),
tr("There is no QPSQL driver."
"\nDid you install the package 'libQt5Sql5-postgresql'?"));
return false;
}
return true;
}
void BrowserWnd::slotFilterTableItemChanged(QListWidgetItem *item)
{
QString tableName = item->text();
addNewQuery(tableName);
}
void BrowserWnd::slotTabCloseRequested(int index)
{
Query *q = qobject_cast<Query *>(m_ui->twQueries->widget(index));
m_ui->twQueries->removeTab(index);
if (!q)
@@ -220,19 +198,16 @@ void BrowserWnd::slotTabCloseRequested(int index)
delete q; // It´s safe to delete nullptr;
}
void BrowserWnd::slotShowWait(const QString &msg)
{
m_waitWnd->wait(msg);
}
void BrowserWnd::slotHideWait()
{
m_waitWnd->hide();
}
void BrowserWnd::slotHeart()
{
QWidget *w = new QWidget;
@@ -246,6 +221,5 @@ void BrowserWnd::slotHeart()
l->setGraphicsEffect(shadow);
b->addWidget(l);
w->setLayout(b);
w->show();
}
@@ -6,7 +6,6 @@
#include <QtWidgets/QWidget>
class QListWidgetItem;
class Query;
@@ -15,7 +14,6 @@ namespace Ui
class BrowserWnd;
}
class BrowserWnd: public QWidget
{
Q_OBJECT
@@ -49,7 +47,6 @@ private slots:
void slotConnectResult(const QString &);
void slotNewTableList(QStringList);
void slotHeart();
/*void slotSelectQueryResult(QString errorMsg, DataModel* dataModel);
void slotSelectQueryStatus(int percent);
void slotQueryQuery(QString); // when the query widget starts a query....*/
@@ -57,8 +54,6 @@ private slots:
/*void slotExecute(QString, QVariant, QModelIndex);
void slotExecuteQueryResult(bool success, QString msg, QVariant val, QModelIndex onThisPosition);*/
void slotAddNewQuery();
void slotShowWait(const QString &msg);
void slotHideWait();
@@ -14,7 +14,6 @@ else()
set(Qt6_Widgets "")
endif()
SET(my_SRCS
main.cpp
LoginWnd.cpp
@@ -46,7 +45,6 @@ SET(my_UICS
)
set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/ui)
NGL_ADD_TOOL_ICON(my_SRCS "sql")
NGL_WRAP_UI(my_SRCS ${my_UICS})
NGL_ADD_EXECUTABLE(AAR SV WS NO_TRANSLATION sqlbrowser ${my_SRCS} ${my_UICS})
@@ -9,7 +9,6 @@
//#define WAIT_FOR_IDLE while (!m_idle) { QThread::msleep(50); } (void)m_idle
DataModel::DataModel(QObject *parent) // [M]VC
: QAbstractTableModel(parent)
, m_idle(true)
@@ -28,19 +27,16 @@ DataModel::DataModel(QObject *parent) // [M]VC
// endResetModel();
//}
void DataModel::dataListReserve(const int size)
{
m_newDataList.reserve(size);
}
void DataModel::addLine(const Data& data)
{
m_newDataList.append(data);
}
void DataModel::addColumn(const QString& columnName, QMetaType::Type type)
{
// QPair<QString,QVariant::Type> pair;
@@ -49,7 +45,6 @@ void DataModel::addColumn(const QString& columnName, QMetaType::Type type)
m_newHeaderList.append(QPair<QString,QMetaType::Type>(columnName, type));
}
void DataModel::slotSwapLists() // for threading..
{
m_dataList = m_newDataList;
@@ -62,32 +57,27 @@ void DataModel::slotSwapLists() // for threading..
endResetModel();
}
void DataModel::setTableName(const QString &tableName)
{
m_tableName = tableName;
setEditable(!m_tableName.isEmpty()); // editable items depend on wether it's a custom query, or a table list query
}
QString DataModel::getTableName() const
{
return m_tableName;
}
int DataModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_dataList.count();
}
int DataModel::columnCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_headerList.count();
}
QVariant DataModel::data(const QModelIndex &index, int role) const
{
if (index.row() >= m_dataList.count())
@@ -127,7 +117,6 @@ QVariant DataModel::data(const QModelIndex &index, int role) const
return QVariant();
}
QVariant DataModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && section >= 0 && section < m_headerList.size())
@@ -145,7 +134,6 @@ QVariant DataModel::headerData(int section, Qt::Orientation orientation, int rol
return QAbstractTableModel::headerData(section, orientation, role);
}
void DataModel::setEditable(bool editable)
{
resetFlags();
@@ -154,19 +142,16 @@ void DataModel::setEditable(bool editable)
m_flags |= Qt::ItemIsEditable;
}
const HeaderList& DataModel::getHeaderList() const
{
return m_headerList;
}
void DataModel::resetFlags()
{
m_flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
}
Qt::ItemFlags DataModel::flags(const QModelIndex &index) const
{
Q_UNUSED(index);
@@ -174,7 +159,6 @@ Qt::ItemFlags DataModel::flags(const QModelIndex &index) const
return m_flags;
}
void DataModel::slotSetData(const QModelIndex &index, const QVariant &value)
{
Data row = m_dataList.at(index.row()); // get row from data list
@@ -197,7 +181,6 @@ bool DataModel::setData(const QModelIndex &index, const QVariant &value, int rol
return false; // ALWAYS! as we need to wait for a result (which is async)
}
void DataModel::deleteLines(const QList<QModelIndex> &affectedRowsList)
{
if (affectedRowsList.isEmpty())
@@ -2,13 +2,11 @@
#include <QtWidgets/QDialog>
namespace Ui
{
class WaitWnd;
}
class WaitWnd: public QDialog
{
Q_OBJECT