Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+30
@@ -0,0 +1,30 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-09-06
|
||||
#
|
||||
|
||||
#
|
||||
# Data Plugin
|
||||
#
|
||||
SET(gna_common_gui_SRCS
|
||||
gna_nasat_aircraft_model.cpp
|
||||
gna_nasat_aircraft_model.h
|
||||
gna_nasat_aircraft_part_model.cpp
|
||||
gna_nasat_aircraft_part_model.h
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY2(WS GnaCommon SHARED ${gna_common_gui_SRCS} )
|
||||
NGL_TARGET_LINK_LIBRARIES(GnaCommon
|
||||
PRIVATE
|
||||
LtsSessionData
|
||||
NGLLogger
|
||||
PUBLIC
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
PpmGuiComboboxPluginInterface
|
||||
svcGnaCommon
|
||||
svcExmCommon
|
||||
svcPpmCommon
|
||||
)
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AlarmManagement - AlarmManagement Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10.05
|
||||
*/
|
||||
|
||||
#include "gna_nasat_aircraft_model.h"
|
||||
#include <GuezNasat/gna_translation.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
|
||||
namespace GuezNasat
|
||||
{
|
||||
//---------------------------------
|
||||
// NasatAircraftModel
|
||||
//---------------------------------
|
||||
NasatAircraftModel::NasatAircraftModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<GuezNasat::NasatAircraft>(
|
||||
{
|
||||
tr("Id"),
|
||||
tr("NASAT Identifier"),
|
||||
tr("Name"),
|
||||
tr("Simulation Activated")
|
||||
},
|
||||
parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_logger(getLogger("NasatAircraftModel"))
|
||||
{}
|
||||
|
||||
|
||||
bool NasatAircraftModel::initModel(const std::shared_ptr<GuezNasat::Interface::Dtc> &dtc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
|
||||
// insert Model
|
||||
connect(m_dtc.get(), &Interface::Dtc::nasatAircraftChanged,
|
||||
this, &NasatAircraftModel::onDataChanged);
|
||||
auto cb = [this](const NasatAircraft &data)
|
||||
{
|
||||
onDataChanged(data, DataModification::eAdded);
|
||||
};
|
||||
m_dtc->nasatAircrafts(cb);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant NasatAircraftModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
INFO_LOG(m_logger) << "NasatAircraftModel::data";
|
||||
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const GuezNasat::NasatAircraft &nasatAircraft = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return nasatAircraft.id();
|
||||
case NasatId:
|
||||
return nasatAircraft.nasatId();
|
||||
case SimulationActive:
|
||||
return nasatAircraft.simulationActive() ? tr("Yes") : tr("No");
|
||||
case Name:
|
||||
return QString::fromStdString(nasatAircraft.name());
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
} // namespace GuezNasat
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for Messaging - Messaging Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10.05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Common/gnacommon_export.h>
|
||||
#include <GuezNasat/gna_dtc.h>
|
||||
#include <GuezNasat/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
namespace GuezNasat
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// NasatAircraftModel
|
||||
// --------------------------------------------------------
|
||||
class GNACOMMON_EXPORT NasatAircraftModel final : public LtsWidgets::LtsAbstractTableModel<GuezNasat::NasatAircraft>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
NasatId,
|
||||
Name,
|
||||
SimulationActive
|
||||
};
|
||||
|
||||
explicit NasatAircraftModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(const std::shared_ptr<GuezNasat::Interface::Dtc> &dtc);
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<GuezNasat::Interface::Dtc> m_dtc;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} //namespace GuezNasat
|
||||
@@ -0,0 +1,251 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AlarmManagement - AlarmManagement Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10.05
|
||||
*/
|
||||
|
||||
#include "gna_nasat_aircraft_part_model.h"
|
||||
#include <GuezNasat/gna_translation.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
|
||||
namespace GuezNasat
|
||||
{
|
||||
//---------------------------------
|
||||
// NasatAircraftParticipantModel
|
||||
//---------------------------------
|
||||
NasatAircraftParticipantModel::NasatAircraftParticipantModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<GuezNasat::NasatAircraftParticipant>(
|
||||
{
|
||||
tr("Id"),
|
||||
tr("NASAT Aircraft Id"),
|
||||
tr("Aircraft Name"),
|
||||
tr("Exercise Id"),
|
||||
tr("Exercise Name"),
|
||||
tr("Participant Id"),
|
||||
tr("Participant")
|
||||
},
|
||||
parent)
|
||||
, m_logger(getLogger("NasatAircraftParticipantModel"))
|
||||
{}
|
||||
|
||||
|
||||
bool NasatAircraftParticipantModel::initModel(const std::shared_ptr<GuezNasat::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> &ppmGuiCbxIfc,
|
||||
LtsSession::LtsSession *session)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_exm_dtc = exmDtc;
|
||||
m_ppm_dtc = ppmDtc;
|
||||
m_ppmGuiCbxIfc = ppmGuiCbxIfc;
|
||||
m_session = session;
|
||||
|
||||
// insert Model
|
||||
const QMap<qint32, GuezNasat::NasatAircraftParticipant> nasatAircraftParticipants = m_dtc->nasatAircraftParticipants();
|
||||
INFO_LOG(m_logger) << "initModel - #NasatAircraftParticipantModel: " << nasatAircraftParticipants.size() ;
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::nasatAircraftParticipantChanged,
|
||||
this, &NasatAircraftParticipantModel::onNasatAircraftParticipantChanged);
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::nasatAircraftChanged,
|
||||
this, &NasatAircraftParticipantModel::onNasatAircraftChanged);
|
||||
|
||||
connect(m_ppm_dtc.get(), &ParticipantManagement::Interface::Dtc::typeChanged,
|
||||
this, &NasatAircraftParticipantModel::onTypeChanged);
|
||||
|
||||
connect(m_ppm_dtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged,
|
||||
this, &NasatAircraftParticipantModel::onParticipantChanged);
|
||||
|
||||
{
|
||||
auto cb = [this](const NasatAircraftParticipant &d) { onNasatAircraftParticipantChanged(d, DataModification::eAdded); };
|
||||
m_dtc->nasatAircraftParticipants(cb);
|
||||
}
|
||||
|
||||
{
|
||||
auto cb = [this](const NasatAircraft &d) { onNasatAircraftChanged(d, DataModification::eAdded); };
|
||||
m_dtc->nasatAircrafts(cb);
|
||||
}
|
||||
|
||||
{
|
||||
auto cb = [this](const ExerciseManagement::Exercise &d) { onExerciseChanged(d, DataModification::eAdded); };
|
||||
m_exm_dtc->exercises(cb);
|
||||
}
|
||||
|
||||
{
|
||||
auto cb = [this](const ParticipantManagement::Type &d) { onTypeChanged(d, DataModification::eAdded); };
|
||||
m_ppm_dtc->types(cb);
|
||||
}
|
||||
|
||||
{
|
||||
auto cb = [this](const ParticipantManagement::Participant &d) { onParticipantChanged(d, DataModification::eAdded); };
|
||||
m_ppm_dtc->participants(cb);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant NasatAircraftParticipantModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
INFO_LOG(m_logger) << "NasatAircraftParticipantModel::data";
|
||||
|
||||
if ((role != Qt::DisplayRole && role != Qt::DecorationRole) || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const GuezNasat::NasatAircraftParticipant &nasatAircraftParticipant = m_vecData.at(index.row());
|
||||
|
||||
if (role == Qt::DecorationRole)
|
||||
{
|
||||
if (index.column() == Participant)
|
||||
return m_participantDecorations.value(nasatAircraftParticipant.participantId());
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
INFO_LOG(m_logger) << "nasatAircraftParticipant.id()=" << nasatAircraftParticipant.id();
|
||||
return nasatAircraftParticipant.id();
|
||||
case NasatAircreaftId:
|
||||
return nasatAircraftParticipant.nasatAircraftId();
|
||||
case Nasat:
|
||||
if (m_nasatNames.contains(nasatAircraftParticipant.nasatAircraftId()))
|
||||
return m_nasatNames[nasatAircraftParticipant.nasatAircraftId()];
|
||||
return tr("No Participant");
|
||||
case ExerciseId:
|
||||
return nasatAircraftParticipant.exerciseId();
|
||||
case ExerciseName:
|
||||
if (m_exerciseNames.contains(nasatAircraftParticipant.exerciseId()))
|
||||
return m_exerciseNames[nasatAircraftParticipant.exerciseId()];
|
||||
return tr("No exercise name available");
|
||||
case ParticipantId:
|
||||
return nasatAircraftParticipant.participantId();
|
||||
case Participant:
|
||||
if (m_participantHierarchies.contains(nasatAircraftParticipant.participantId()))
|
||||
return m_participantHierarchies[nasatAircraftParticipant.participantId()];
|
||||
return tr("No participant name available");
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QSet<int> NasatAircraftParticipantModel::getAssociatedNasatIds() const
|
||||
{
|
||||
QSet<int> ret;
|
||||
ret.reserve(m_vecData.size());
|
||||
for (const NasatAircraftParticipant &data : m_vecData)
|
||||
ret += data.nasatAircraftId();
|
||||
return ret;
|
||||
}
|
||||
|
||||
QSet<int> NasatAircraftParticipantModel::getAssociatedParticipantIds() const
|
||||
{
|
||||
QSet<int> ret;
|
||||
ret.reserve(m_vecData.size());
|
||||
for (const NasatAircraftParticipant &data : m_vecData)
|
||||
ret += data.participantId();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void NasatAircraftParticipantModel::onNasatAircraftParticipantChanged(const GuezNasat::NasatAircraftParticipant &data,
|
||||
const DataModification modType)
|
||||
{
|
||||
if (data.exerciseId() != m_session->exerciseId())
|
||||
return;
|
||||
|
||||
LtsWidgets::LtsAbstractTableModel<GuezNasat::NasatAircraftParticipant>::onDataChanged(data, modType);
|
||||
|
||||
emit signalNasatNamesChanged();
|
||||
emit signalParticipantNamesChanged();
|
||||
}
|
||||
|
||||
void NasatAircraftParticipantModel::onExerciseChanged(const ExerciseManagement::Exercise &data,
|
||||
const DataModification modType)
|
||||
{
|
||||
INFO_LOG(m_logger) << "onExerciseChanged: " << data << ", " << modType;
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eRemoved:
|
||||
m_exerciseNames.remove(data.id());
|
||||
break;
|
||||
case DataModification::eModified:
|
||||
case DataModification::eAdded:
|
||||
m_exerciseNames.insert(data.id(), QString::fromStdString(data.name()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void NasatAircraftParticipantModel::onTypeChanged(const ParticipantManagement::Type &data,
|
||||
const DataModification modType)
|
||||
{
|
||||
INFO_LOG(m_logger) << "onTypeChanged:" << data << ", " << modType;
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eRemoved:
|
||||
m_typeToTypeClass.remove(data.id());
|
||||
break;
|
||||
case DataModification::eModified:
|
||||
case DataModification::eAdded:
|
||||
m_typeToTypeClass.insert(data.id(), data.typeClass());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void NasatAircraftParticipantModel::onParticipantChanged(const ParticipantManagement::Participant &data,
|
||||
DataModification modType)
|
||||
{
|
||||
INFO_LOG(m_logger) << "onParticipantChanged: " << data << ", " << modType;
|
||||
|
||||
if (data.isDeleted())
|
||||
modType = DataModification::eRemoved;
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eRemoved:
|
||||
m_participantHierarchies.remove(data.id());
|
||||
break;
|
||||
case DataModification::eModified:
|
||||
case DataModification::eAdded:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DataModification::eAdded Participant"
|
||||
<< " TypeId=" << data.typeId()
|
||||
<< " " << data.name();
|
||||
|
||||
ParticipantManagement::TypeClass typeClass = m_typeToTypeClass.value(data.typeId());
|
||||
if (typeClass != ParticipantManagement::TypeClass::Aircraft)
|
||||
return;
|
||||
const QString hierarchy = m_ppm_dtc->hierarchyFromParticipant(data.id());
|
||||
m_participantHierarchies.insert(data.id(), hierarchy);
|
||||
if (m_ppmGuiCbxIfc)
|
||||
{
|
||||
const auto party = m_ppm_dtc->party(data.partyId());
|
||||
const QRgb col = QRgb(party.color());
|
||||
m_participantDecorations.insert(data.id(), m_ppmGuiCbxIfc->pixmapFromParty(col));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
emit signalParticipantNamesChanged();
|
||||
}
|
||||
|
||||
void NasatAircraftParticipantModel::onNasatAircraftChanged(const GuezNasat::NasatAircraft &data,
|
||||
const DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onNasatAircraftChanged: " << data << ", " << modType;
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eRemoved:
|
||||
m_nasatNames.remove(data.id());
|
||||
break;
|
||||
case DataModification::eModified:
|
||||
case DataModification::eAdded:
|
||||
m_nasatNames.insert(data.id(), QString::fromStdString(data.name()));
|
||||
break;
|
||||
}
|
||||
emit signalNasatNamesChanged();
|
||||
}
|
||||
} // namespace GuezNasat
|
||||
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for Messaging - Messaging Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10.05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Common/gnacommon_export.h>
|
||||
#include <GuezNasat/gna_dtc.h>
|
||||
// Get exercise names
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
// Get Participants
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
#include <GuezNasat/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
namespace GuezNasat
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// NasatAircraftParticipantModel
|
||||
// --------------------------------------------------------
|
||||
class GNACOMMON_EXPORT NasatAircraftParticipantModel final : public LtsWidgets::LtsAbstractTableModel<GuezNasat::NasatAircraftParticipant>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
NasatAircreaftId,
|
||||
Nasat,
|
||||
ExerciseId,
|
||||
ExerciseName,
|
||||
ParticipantId,
|
||||
Participant
|
||||
};
|
||||
|
||||
explicit NasatAircraftParticipantModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(const std::shared_ptr<GuezNasat::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> &ppmGuiCbxIfc,
|
||||
LtsSession::LtsSession *session);
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override;
|
||||
|
||||
QHash <int, QString> getExerciseNames() const { return m_exerciseNames; }
|
||||
QHash <int, QString> getNasatNames() const { return m_nasatNames; }
|
||||
QHash <int, QString> getParticipantHierarchies() const { return m_participantHierarchies; }
|
||||
QHash <int, QPixmap> getParticipantDecorations() const { return m_participantDecorations; }
|
||||
QSet<int> getAssociatedNasatIds() const;
|
||||
QSet<int> getAssociatedParticipantIds() const;
|
||||
|
||||
|
||||
signals:
|
||||
void signalNasatNamesChanged();
|
||||
void signalParticipantNamesChanged();
|
||||
|
||||
private slots:
|
||||
void onNasatAircraftParticipantChanged(const GuezNasat::NasatAircraftParticipant &data,
|
||||
const DataModification modType);
|
||||
void onExerciseChanged(const ExerciseManagement::Exercise &data,
|
||||
const DataModification modType);
|
||||
void onTypeChanged(const ParticipantManagement::Type &data,
|
||||
const DataModification modType);
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &data,
|
||||
DataModification modType);
|
||||
void onNasatAircraftChanged(const GuezNasat::NasatAircraft &data,
|
||||
const DataModification modType);
|
||||
|
||||
private:
|
||||
std::shared_ptr<GuezNasat::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exm_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppm_dtc;
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmGuiCbxIfc;
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
|
||||
QHash <int, QString> m_exerciseNames; // key = ExerciseId, value = ExerciseName
|
||||
QHash <int, QString> m_nasatNames; // key = nasatId, value = NasatName
|
||||
QHash <int, QString> m_participantHierarchies; // key = participantId, value = HirarchyString
|
||||
QHash <int, QPixmap> m_participantDecorations;
|
||||
QHash <int, ParticipantManagement::TypeClass> m_typeToTypeClass; // key = ParticipantType, value = TypeClass
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} //namespace GuezNasat
|
||||
Reference in new issue
Block a user