Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+156
-163
@@ -1,218 +1,211 @@
|
||||
|
||||
|
||||
|
||||
#include "asb_foreign_interface_impl.h"
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <AreaEffectSimulation/aes_dtc.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <SymbologyImpl/advanced_symbology_logging.h>
|
||||
#include <Symbology/symbol_data_to_render_role.h>
|
||||
#include <SymbologyImpl/advanced_symbology_logging.h>
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
ForeignInterfaceImpl::ForeignInterfaceImpl(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc,
|
||||
const std::shared_ptr<GuezIedManagement::Interface::Dtc> &guezIedDtc)
|
||||
: m_ppmDtc(ppmDtc)
|
||||
, m_aesDtc(aesDtc)
|
||||
, m_guezIedDtc(guezIedDtc)
|
||||
ForeignInterfaceImpl::ForeignInterfaceImpl(const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc>& aesDtc,
|
||||
const std::shared_ptr<GuezIedManagement::Interface::Dtc>& guezIedDtc)
|
||||
: m_ppmDtc(ppmDtc), m_aesDtc(aesDtc), m_guezIedDtc(guezIedDtc)
|
||||
{
|
||||
if (!m_ppmDtc)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "m_ppmDtc not available, No color and injury information will be included in created symbols";
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
if (!m_ppmDtc)
|
||||
{
|
||||
WARNING_LOG(m_logger)
|
||||
<< "m_ppmDtc not available, No color and injury information will be included in created symbols";
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AdvancedSymbology::SymbolDictionary &ForeignInterfaceImpl::getSymbolDictionary(AdvancedSymbology::SymbologyType type) const
|
||||
AdvancedSymbology::SymbolDictionary&
|
||||
ForeignInterfaceImpl::getSymbolDictionary(AdvancedSymbology::SymbologyType type) const
|
||||
{
|
||||
|
||||
return AdvancedSymbology::SymbolDictionary::dictionary(type);
|
||||
}
|
||||
|
||||
return AdvancedSymbology::SymbolDictionary::dictionary(type);
|
||||
}
|
||||
|
||||
AdvancedSymbology::SymbologyType ForeignInterfaceImpl::defaultSymbologyType() const
|
||||
{
|
||||
return AdvancedSymbology::SymbolDictionary::defaultSymbologyType();
|
||||
}
|
||||
|
||||
|
||||
QSharedPointer<SymbolResult> ForeignInterfaceImpl::findImage(const SymbolDictionary &dict,
|
||||
const SymbolDataToRender &symDataToRender) const
|
||||
{
|
||||
return dict.findImage(symDataToRender);
|
||||
return AdvancedSymbology::SymbolDictionary::defaultSymbologyType();
|
||||
}
|
||||
|
||||
|
||||
QSharedPointer<SymbolResult> ForeignInterfaceImpl::findImage(const SymbolDataToRender &symDataToRender) const
|
||||
QSharedPointer<SymbolResult> ForeignInterfaceImpl::findImage(const SymbolDictionary& dict,
|
||||
const SymbolDataToRender& symDataToRender) const
|
||||
{
|
||||
return AdvancedSymbology::SymbolDictionary::dictionary(defaultSymbologyType()).findImage(symDataToRender);
|
||||
return dict.findImage(symDataToRender);
|
||||
}
|
||||
|
||||
|
||||
QSharedPointer<SymbolResult> ForeignInterfaceImpl::findImage(const ParticipantManagement::Participant &participant, int sizeL, const QColor &desiredColor) const
|
||||
QSharedPointer<SymbolResult> ForeignInterfaceImpl::findImage(const SymbolDataToRender& symDataToRender) const
|
||||
{
|
||||
AdvancedSymbology::SymbolDataToRender symDataToRender(QString::fromStdString(participant.symbol()), sizeL);
|
||||
return AdvancedSymbology::SymbolDictionary::dictionary(defaultSymbologyType()).findImage(symDataToRender);
|
||||
}
|
||||
|
||||
if (!m_ppmDtc)
|
||||
return findImage(symDataToRender);
|
||||
QSharedPointer<SymbolResult> ForeignInterfaceImpl::findImage(const ParticipantManagement::Participant& participant,
|
||||
int sizeL, const QColor& desiredColor) const
|
||||
{
|
||||
AdvancedSymbology::SymbolDataToRender symDataToRender(QString::fromStdString(participant.symbol()), sizeL);
|
||||
|
||||
|
||||
const ParticipantManagement::Party &party = m_ppmDtc->party(participant.partyId());
|
||||
symDataToRender.role = AdvancedSymbology::roleToRole<>(party.role());
|
||||
if (!m_ppmDtc)
|
||||
return findImage(symDataToRender);
|
||||
|
||||
|
||||
symDataToRender.fillColor = desiredColor.isValid() ? desiredColor : QColor::fromRgb(QRgb(party.color()));
|
||||
symDataToRender.fillColorReplace = true;
|
||||
const ParticipantManagement::Party& party = m_ppmDtc->party(participant.partyId());
|
||||
symDataToRender.role = AdvancedSymbology::roleToRole<>(party.role());
|
||||
|
||||
|
||||
QColor injuryColor = QColor(100, 100, 0);
|
||||
ProjectDataManagement::VulnerabilityState currentState = ProjectDataManagement::VulnerabilityState::CombatReady;
|
||||
symDataToRender.fillColor = desiredColor.isValid() ? desiredColor : QColor::fromRgb(QRgb(party.color()));
|
||||
symDataToRender.fillColorReplace = true;
|
||||
|
||||
const ParticipantManagement::DynamicParticipantData dData = m_ppmDtc->dynamicParticipantData(participant.id());
|
||||
QColor injuryColor = QColor(100, 100, 0);
|
||||
ProjectDataManagement::VulnerabilityState currentState = ProjectDataManagement::VulnerabilityState::CombatReady;
|
||||
|
||||
if (dData.stateHistory().size())
|
||||
{
|
||||
const ParticipantManagement::StateInformation &lastState = m_ppmDtc->youngestStateInformation(dData.stateHistory());
|
||||
currentState = lastState.vulnerabilityState();
|
||||
const ParticipantManagement::DynamicParticipantData dData = m_ppmDtc->dynamicParticipantData(participant.id());
|
||||
|
||||
switch (lastState.originatorType().underlying())
|
||||
if (dData.stateHistory().size())
|
||||
{
|
||||
case ProjectDataManagement::StateChangeOriginator::ImprovisedExplosiveDevice:
|
||||
{
|
||||
if (m_guezIedDtc)
|
||||
{
|
||||
const GuezIedManagement::Ied &gIed = m_guezIedDtc->iedForEquipmentNumber(lastState.originatorId());
|
||||
if (gIed.id() > 0)
|
||||
const ParticipantManagement::StateInformation& lastState =
|
||||
m_ppmDtc->youngestStateInformation(dData.stateHistory());
|
||||
currentState = lastState.vulnerabilityState();
|
||||
|
||||
switch (lastState.originatorType().underlying())
|
||||
{
|
||||
int injuryPartyId = gIed.partyId();
|
||||
if (injuryPartyId >= 0)
|
||||
injuryColor = m_ppmDtc->party(injuryPartyId).color();
|
||||
case ProjectDataManagement::StateChangeOriginator::ImprovisedExplosiveDevice: {
|
||||
if (m_guezIedDtc)
|
||||
{
|
||||
const GuezIedManagement::Ied& gIed = m_guezIedDtc->iedForEquipmentNumber(lastState.originatorId());
|
||||
if (gIed.id() > 0)
|
||||
{
|
||||
int injuryPartyId = gIed.partyId();
|
||||
if (injuryPartyId >= 0)
|
||||
injuryColor = m_ppmDtc->party(injuryPartyId).color();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::StateChangeOriginator::DusMine: {
|
||||
if (!m_aesDtc)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Fetching 'm_aesDtc' failed, No color and injury information will be "
|
||||
"included in symbol created for participant.id() "
|
||||
<< participant.id();
|
||||
return findImage(symDataToRender);
|
||||
}
|
||||
const int partyId = m_aesDtc->partyForDusMine(lastState.originatorId());
|
||||
if (partyId >= 0)
|
||||
injuryColor = m_ppmDtc->party(partyId).color();
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::StateChangeOriginator::AreaEffectSimulation:
|
||||
case ProjectDataManagement::StateChangeOriginator::FunctionalArea: {
|
||||
if (!m_aesDtc)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Fetching 'm_aesDtc' failed, No color and injury information will be "
|
||||
"included in symbol created for participant.id() "
|
||||
<< participant.id();
|
||||
return findImage(symDataToRender);
|
||||
}
|
||||
|
||||
AreaEffectSimulation::AesItem aesItem;
|
||||
m_aesDtc->aesItemFromId(lastState.originatorId(), aesItem);
|
||||
|
||||
if (aesItem.partyId().is_set())
|
||||
injuryColor = m_ppmDtc->party(aesItem.partyId().get()).color();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ProjectDataManagement::StateChangeOriginator::Participant: {
|
||||
const ParticipantManagement::Participant& participantOrigin =
|
||||
m_ppmDtc->participant(lastState.originatorId());
|
||||
|
||||
if (participantOrigin.id())
|
||||
injuryColor = m_ppmDtc->party(participantOrigin.partyId()).color();
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::StateChangeOriginator::Party: {
|
||||
const ParticipantManagement::Party& partyOrigin = m_ppmDtc->party(lastState.originatorId());
|
||||
|
||||
if (partyOrigin.id())
|
||||
injuryColor = partyOrigin.color();
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::StateChangeOriginator::ObserverController:
|
||||
case ProjectDataManagement::StateChangeOriginator::ExerciseControl:
|
||||
case ProjectDataManagement::StateChangeOriginator::Initialization:
|
||||
injuryColor = m_ppmDtc->party(1).color();
|
||||
break;
|
||||
case ProjectDataManagement::StateChangeOriginator::WoundTreatmentDevice:
|
||||
case ProjectDataManagement::StateChangeOriginator::MedicalTimeout:
|
||||
case ProjectDataManagement::StateChangeOriginator::Sanitation:
|
||||
case ProjectDataManagement::StateChangeOriginator::MaintainanceDevice:
|
||||
case ProjectDataManagement::StateChangeOriginator::Unknown:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::StateChangeOriginator::DusMine:
|
||||
{
|
||||
if (!m_aesDtc)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Fetching 'm_aesDtc' failed, No color and injury information will be included in symbol created for participant.id() " << participant.id();
|
||||
return findImage(symDataToRender);
|
||||
}
|
||||
const int partyId = m_aesDtc->partyForDusMine(lastState.originatorId());
|
||||
if (partyId >= 0)
|
||||
injuryColor = m_ppmDtc->party(partyId).color();
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::StateChangeOriginator::AreaEffectSimulation:
|
||||
case ProjectDataManagement::StateChangeOriginator::FunctionalArea:
|
||||
{
|
||||
if (!m_aesDtc)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Fetching 'm_aesDtc' failed, No color and injury information will be included in symbol created for participant.id() " << participant.id();
|
||||
return findImage(symDataToRender);
|
||||
}
|
||||
|
||||
AreaEffectSimulation::AesItem aesItem;
|
||||
m_aesDtc->aesItemFromId(lastState.originatorId(), aesItem);
|
||||
|
||||
if (aesItem.partyId().is_set())
|
||||
injuryColor = m_ppmDtc->party(aesItem.partyId().get()).color();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ProjectDataManagement::StateChangeOriginator::Participant:
|
||||
{
|
||||
const ParticipantManagement::Participant &participantOrigin = m_ppmDtc->participant(lastState.originatorId());
|
||||
symDataToRender.injury = stateToInjury(currentState);
|
||||
symDataToRender.injuryColor = injuryColor;
|
||||
|
||||
|
||||
if (participantOrigin.id())
|
||||
injuryColor = m_ppmDtc->party(participantOrigin.partyId()).color();
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::StateChangeOriginator::Party:
|
||||
{
|
||||
const ParticipantManagement::Party &partyOrigin = m_ppmDtc->party(lastState.originatorId());
|
||||
|
||||
if (partyOrigin.id())
|
||||
injuryColor = partyOrigin.color();
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::StateChangeOriginator::ObserverController:
|
||||
case ProjectDataManagement::StateChangeOriginator::ExerciseControl:
|
||||
case ProjectDataManagement::StateChangeOriginator::Initialization:
|
||||
injuryColor = m_ppmDtc->party(1).color();
|
||||
break;
|
||||
case ProjectDataManagement::StateChangeOriginator::WoundTreatmentDevice:
|
||||
case ProjectDataManagement::StateChangeOriginator::MedicalTimeout:
|
||||
case ProjectDataManagement::StateChangeOriginator::Sanitation:
|
||||
case ProjectDataManagement::StateChangeOriginator::MaintainanceDevice:
|
||||
case ProjectDataManagement::StateChangeOriginator::Unknown:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
symDataToRender.injury = stateToInjury(currentState);
|
||||
symDataToRender.injuryColor = injuryColor;
|
||||
|
||||
return findImage(symDataToRender);
|
||||
return findImage(symDataToRender);
|
||||
}
|
||||
|
||||
|
||||
AdvancedSymbology::Injury ForeignInterfaceImpl::stateToInjury(const ProjectDataManagement::VulnerabilityState &state)
|
||||
AdvancedSymbology::Injury ForeignInterfaceImpl::stateToInjury(const ProjectDataManagement::VulnerabilityState& state)
|
||||
{
|
||||
switch (state.underlying())
|
||||
{
|
||||
case ProjectDataManagement::VulnerabilityState::CombatReady:
|
||||
case ProjectDataManagement::VulnerabilityState::TemporarySeverance:
|
||||
case ProjectDataManagement::VulnerabilityState::NearMiss:
|
||||
case ProjectDataManagement::VulnerabilityState::HitWithNoEffect:
|
||||
switch (state.underlying())
|
||||
{
|
||||
case ProjectDataManagement::VulnerabilityState::CombatReady:
|
||||
case ProjectDataManagement::VulnerabilityState::TemporarySeverance:
|
||||
case ProjectDataManagement::VulnerabilityState::NearMiss:
|
||||
case ProjectDataManagement::VulnerabilityState::HitWithNoEffect:
|
||||
return AdvancedSymbology::Injury::NoInjury;
|
||||
case ProjectDataManagement::VulnerabilityState::LightDamage:
|
||||
case ProjectDataManagement::VulnerabilityState::MediumDamage:
|
||||
case ProjectDataManagement::VulnerabilityState::HeavyDamage:
|
||||
case ProjectDataManagement::VulnerabilityState::NotReady:
|
||||
return AdvancedSymbology::Injury::Hit;
|
||||
case ProjectDataManagement::VulnerabilityState::MobilityKill:
|
||||
case ProjectDataManagement::VulnerabilityState::VisibleMobilityKill:
|
||||
return AdvancedSymbology::Injury::MobilityKill;
|
||||
case ProjectDataManagement::VulnerabilityState::WeaponSystemDamage:
|
||||
case ProjectDataManagement::VulnerabilityState::VisibleWeaponSystemDamage:
|
||||
return AdvancedSymbology::Injury::WeaponKill;
|
||||
case ProjectDataManagement::VulnerabilityState::CatastrophicKill:
|
||||
return AdvancedSymbology::Injury::TotalKill;
|
||||
case ProjectDataManagement::VulnerabilityState::NContamination:
|
||||
case ProjectDataManagement::VulnerabilityState::BContamination:
|
||||
case ProjectDataManagement::VulnerabilityState::CContamination:
|
||||
case ProjectDataManagement::VulnerabilityState::VulnerabilityBitsChanged:
|
||||
case ProjectDataManagement::VulnerabilityState::Reserved:
|
||||
case ProjectDataManagement::VulnerabilityState::NoChange:
|
||||
break;
|
||||
}
|
||||
return AdvancedSymbology::Injury::NoInjury;
|
||||
case ProjectDataManagement::VulnerabilityState::LightDamage:
|
||||
case ProjectDataManagement::VulnerabilityState::MediumDamage:
|
||||
case ProjectDataManagement::VulnerabilityState::HeavyDamage:
|
||||
case ProjectDataManagement::VulnerabilityState::NotReady:
|
||||
return AdvancedSymbology::Injury::Hit;
|
||||
case ProjectDataManagement::VulnerabilityState::MobilityKill:
|
||||
case ProjectDataManagement::VulnerabilityState::VisibleMobilityKill:
|
||||
return AdvancedSymbology::Injury::MobilityKill;
|
||||
case ProjectDataManagement::VulnerabilityState::WeaponSystemDamage:
|
||||
case ProjectDataManagement::VulnerabilityState::VisibleWeaponSystemDamage:
|
||||
return AdvancedSymbology::Injury::WeaponKill;
|
||||
case ProjectDataManagement::VulnerabilityState::CatastrophicKill:
|
||||
return AdvancedSymbology::Injury::TotalKill;
|
||||
case ProjectDataManagement::VulnerabilityState::NContamination:
|
||||
case ProjectDataManagement::VulnerabilityState::BContamination:
|
||||
case ProjectDataManagement::VulnerabilityState::CContamination:
|
||||
case ProjectDataManagement::VulnerabilityState::VulnerabilityBitsChanged:
|
||||
case ProjectDataManagement::VulnerabilityState::Reserved:
|
||||
case ProjectDataManagement::VulnerabilityState::NoChange:
|
||||
break;
|
||||
}
|
||||
return AdvancedSymbology::Injury::NoInjury;
|
||||
}
|
||||
|
||||
|
||||
QSharedPointer<SymbolResult> ForeignInterfaceImpl::findPreview(const SymbolDictionary &dict, const QString &sidc) const
|
||||
QSharedPointer<SymbolResult> ForeignInterfaceImpl::findPreview(const SymbolDictionary& dict, const QString& sidc) const
|
||||
{
|
||||
return dict.findPreview(sidc);
|
||||
return dict.findPreview(sidc);
|
||||
}
|
||||
|
||||
QSharedPointer<SymbolResult> ForeignInterfaceImpl::findPreview(const QString &sidc) const
|
||||
QSharedPointer<SymbolResult> ForeignInterfaceImpl::findPreview(const QString& sidc) const
|
||||
{
|
||||
return AdvancedSymbology::SymbolDictionary::dictionary(defaultSymbologyType()).findPreview(sidc);
|
||||
return AdvancedSymbology::SymbolDictionary::dictionary(defaultSymbologyType()).findPreview(sidc);
|
||||
}
|
||||
|
||||
QSharedPointer<SymbolResult> ForeignInterfaceImpl::findBaseSymbol(const SymbolDictionary &dict, const QString &sidc) const
|
||||
QSharedPointer<SymbolResult> ForeignInterfaceImpl::findBaseSymbol(const SymbolDictionary& dict,
|
||||
const QString& sidc) const
|
||||
{
|
||||
return dict.findBaseSymbol(sidc);
|
||||
return dict.findBaseSymbol(sidc);
|
||||
}
|
||||
|
||||
QSharedPointer<SymbolResult> ForeignInterfaceImpl::findBaseSymbol(const QString &sidc) const
|
||||
QSharedPointer<SymbolResult> ForeignInterfaceImpl::findBaseSymbol(const QString& sidc) const
|
||||
{
|
||||
return AdvancedSymbology::SymbolDictionary::dictionary(defaultSymbologyType()).findBaseSymbol(sidc);
|
||||
return AdvancedSymbology::SymbolDictionary::dictionary(defaultSymbologyType()).findBaseSymbol(sidc);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AdvancedSymbology
|
||||
Executable → Regular
+28
-30
@@ -1,12 +1,11 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_enums.hpp>
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <Plugins/GuezIedManagement/gim_data_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_enums.hpp>
|
||||
#include <Symbology/symbol_dictionary.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
@@ -15,50 +14,49 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
class ForeignInterfaceImpl final : public QObject, public ForeignDataInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ForeignInterfaceImpl(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc,
|
||||
const std::shared_ptr<GuezIedManagement::Interface::Dtc> &guezIedDtc);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ForeignInterfaceImpl(const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc>& aesDtc,
|
||||
const std::shared_ptr<GuezIedManagement::Interface::Dtc>& guezIedDtc);
|
||||
|
||||
|
||||
|
||||
|
||||
AdvancedSymbology::SymbolDictionary &getSymbolDictionary(AdvancedSymbology::SymbologyType type) const override;
|
||||
AdvancedSymbology::SymbolDictionary& getSymbolDictionary(AdvancedSymbology::SymbologyType type) const override;
|
||||
|
||||
QSharedPointer<SymbolResult> findImage(const SymbolDictionary &dict, const SymbolDataToRender &symDataToRender) const override;
|
||||
QSharedPointer<SymbolResult> findImage(const SymbolDataToRender &symDataToRender) const override;
|
||||
QSharedPointer<SymbolResult> findImage(const ParticipantManagement::Participant &participant, int sizeL = 100, const QColor& desiredColor = QColor()) const override;
|
||||
QSharedPointer<SymbolResult> findImage(const SymbolDictionary& dict,
|
||||
const SymbolDataToRender& symDataToRender) const override;
|
||||
QSharedPointer<SymbolResult> findImage(const SymbolDataToRender& symDataToRender) const override;
|
||||
QSharedPointer<SymbolResult> findImage(const ParticipantManagement::Participant& participant, int sizeL = 100,
|
||||
const QColor& desiredColor = QColor()) const override;
|
||||
|
||||
QSharedPointer<SymbolResult> findPreview(const SymbolDictionary &dict, const QString &sidc) const override;
|
||||
QSharedPointer<SymbolResult> findPreview(const QString &sidc) const override;
|
||||
QSharedPointer<SymbolResult> findPreview(const SymbolDictionary& dict, const QString& sidc) const override;
|
||||
QSharedPointer<SymbolResult> findPreview(const QString& sidc) const override;
|
||||
|
||||
QSharedPointer<SymbolResult> findBaseSymbol(const SymbolDictionary &dict, const QString &sidc) const override;
|
||||
QSharedPointer<SymbolResult> findBaseSymbol(const QString &sidc) const override;
|
||||
QSharedPointer<SymbolResult> findBaseSymbol(const SymbolDictionary& dict, const QString& sidc) const override;
|
||||
QSharedPointer<SymbolResult> findBaseSymbol(const QString& sidc) const override;
|
||||
|
||||
AdvancedSymbology::SymbologyType defaultSymbologyType() const override;
|
||||
AdvancedSymbology::SymbologyType defaultSymbologyType() const override;
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
static AdvancedSymbology::Injury stateToInjury(const ProjectDataManagement::VulnerabilityState& state);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
static AdvancedSymbology::Injury stateToInjury(const ProjectDataManagement::VulnerabilityState &state);
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
std::shared_ptr<GuezIedManagement::Interface::Dtc> m_guezIedDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
std::shared_ptr<GuezIedManagement::Interface::Dtc> m_guezIedDtc;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AdvancedSymbology
|
||||
Executable → Regular
+13
-17
@@ -1,10 +1,9 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QVariant>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <QVariant>
|
||||
|
||||
class Ui_SelectTextDialog;
|
||||
|
||||
@@ -13,24 +12,21 @@ namespace AdvancedSymbology
|
||||
|
||||
class SelectTextDialog final : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SelectTextDialog(QVariant &returnData, QWidget *parent);
|
||||
~SelectTextDialog();
|
||||
public:
|
||||
SelectTextDialog(QVariant& returnData, QWidget* parent);
|
||||
~SelectTextDialog();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
Ui_SelectTextDialog* ui;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
Ui_SelectTextDialog *ui;
|
||||
private:
|
||||
QVariant& m_returnData;
|
||||
|
||||
private:
|
||||
|
||||
QVariant &m_returnData;
|
||||
|
||||
|
||||
public slots:
|
||||
void accept() override final;
|
||||
public slots:
|
||||
void accept() override final;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AdvancedSymbology
|
||||
Executable → Regular
+2329
-2604
File diff suppressed because it is too large.
Load diff
Executable → Regular
+158
-163
@@ -1,25 +1,33 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
|
||||
#include <Viewer/SituationMap/SymbologyXML/symbol_types.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
class QGraphicsScene;
|
||||
class QComboBox;
|
||||
|
||||
namespace Ui { class SymbolEditor; }
|
||||
namespace FileManagement { class ForeignGuiInterface; }
|
||||
namespace SymbologyXML { class Symbol; class Primitive;}
|
||||
namespace Ui
|
||||
{
|
||||
class SymbolEditor;
|
||||
}
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
class ForeignGuiInterface;
|
||||
}
|
||||
|
||||
namespace SymbologyXML
|
||||
{
|
||||
class Symbol;
|
||||
class Primitive;
|
||||
} // namespace SymbologyXML
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
@@ -28,203 +36,190 @@ class SymbolEditorPrivate;
|
||||
|
||||
class SymbolEditor final : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit SymbolEditor(LtsSession::LtsSession* session, QWidget* parent = nullptr);
|
||||
|
||||
explicit SymbolEditor(LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~SymbolEditor();
|
||||
|
||||
~SymbolEditor();
|
||||
bool init(const std::shared_ptr<FileManagement::Interface::Ftc>& flmFtc,
|
||||
const std::shared_ptr<FileManagement::Interface::Dtc>& flmDtc,
|
||||
const std::shared_ptr<FileManagement::ForeignGuiInterface>& flmGui,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc, bool asApp = false);
|
||||
|
||||
bool init(const std::shared_ptr<FileManagement::Interface::Ftc> &flmFtc,
|
||||
const std::shared_ptr<FileManagement::Interface::Dtc> &flmDtc,
|
||||
const std::shared_ptr<FileManagement::ForeignGuiInterface> &flmGui,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
bool asApp = false);
|
||||
void keyPressEvent(QKeyEvent* keyEvent) override final;
|
||||
void retranslate() override final;
|
||||
bool apply() override final;
|
||||
|
||||
void keyPressEvent(QKeyEvent *keyEvent) override final;
|
||||
void retranslate() override final;
|
||||
bool apply() override final;
|
||||
bool writeFile(bool saveAsNew);
|
||||
|
||||
bool writeFile(bool saveAsNew);
|
||||
enum e_category {
|
||||
CATEGORY_UNDEFINED = 0,
|
||||
CATEGORY_HEADQUARTER,
|
||||
CATEGORY_DIMENSION,
|
||||
CATEGORY_AFFILIATION,
|
||||
CATEGORY_BCDAB,
|
||||
CATEGORY_COMMANDLEVEL,
|
||||
CATEGORY_MOBILITY,
|
||||
CATEGORY_BRANCH,
|
||||
CATEGORY_ICON_TYPE
|
||||
};
|
||||
|
||||
enum e_category
|
||||
{
|
||||
CATEGORY_UNDEFINED = 0,
|
||||
CATEGORY_HEADQUARTER,
|
||||
CATEGORY_DIMENSION,
|
||||
CATEGORY_AFFILIATION,
|
||||
CATEGORY_BCDAB,
|
||||
CATEGORY_COMMANDLEVEL,
|
||||
CATEGORY_MOBILITY,
|
||||
CATEGORY_BRANCH,
|
||||
CATEGORY_ICON_TYPE
|
||||
};
|
||||
enum t_editMode {
|
||||
EDIT_NONE,
|
||||
EDIT_PICK,
|
||||
EDIT_MOVE,
|
||||
EDIT_ROTATE,
|
||||
EDIT_SCALE,
|
||||
EDIT_COPY,
|
||||
EDIT_PASTE,
|
||||
EDIT_DELETE,
|
||||
EDIT_EDIT
|
||||
};
|
||||
|
||||
enum t_editMode
|
||||
{
|
||||
EDIT_NONE,
|
||||
EDIT_PICK,
|
||||
EDIT_MOVE,
|
||||
EDIT_ROTATE,
|
||||
EDIT_SCALE,
|
||||
EDIT_COPY,
|
||||
EDIT_PASTE,
|
||||
EDIT_DELETE,
|
||||
EDIT_EDIT
|
||||
};
|
||||
public slots:
|
||||
|
||||
public slots:
|
||||
void movePrimitive(QPointF diff);
|
||||
bool createNewSymbol(const QString& symbolname);
|
||||
void setChanged(bool changed);
|
||||
void updateGraphicViews(bool editview = true, bool preview = true);
|
||||
void reset();
|
||||
void slotSaveAs();
|
||||
void slotSave();
|
||||
void slotSaveFinished();
|
||||
void slotImportTemplate();
|
||||
|
||||
void movePrimitive(QPointF diff);
|
||||
bool createNewSymbol(const QString &symbolname);
|
||||
void setChanged(bool changed);
|
||||
void updateGraphicViews(bool editview = true, bool preview = true);
|
||||
void reset();
|
||||
void slotSaveAs();
|
||||
void slotSave();
|
||||
void slotSaveFinished();
|
||||
void slotImportTemplate();
|
||||
signals:
|
||||
|
||||
signals:
|
||||
void documentChanged(bool changed);
|
||||
void symbolSaved(bool saveToLib, bool saveToCurrent, bool saveToAll);
|
||||
void canceled();
|
||||
void helpRequested();
|
||||
void invokeHelp(const QString& context);
|
||||
void saveFinished();
|
||||
|
||||
void documentChanged(bool changed);
|
||||
void symbolSaved(bool saveToLib, bool saveToCurrent, bool saveToAll);
|
||||
void canceled();
|
||||
void helpRequested();
|
||||
void invokeHelp(const QString &context);
|
||||
void saveFinished();
|
||||
private slots:
|
||||
|
||||
private slots:
|
||||
void transformSelection(int key, Qt::KeyboardModifiers modifiers);
|
||||
|
||||
void transformSelection(int key, Qt::KeyboardModifiers modifiers);
|
||||
void onToolButtonSelectClicked();
|
||||
void onToolButtonRotateClicked();
|
||||
void onToolButtonScaleClicked();
|
||||
void onToolButtonDeleteClicked();
|
||||
void onToolButtonClearClicked();
|
||||
void onToolButtonUndoClicked();
|
||||
void onToolButtonCopyClicked();
|
||||
void onToolButtonPasteClicked();
|
||||
void onToolButtonEllipseClicked();
|
||||
void onToolButtonLineClicked();
|
||||
void onToolButtonPolylineClicked();
|
||||
void onToolButtonPolygonClicked();
|
||||
void onToolButtonRectClicked();
|
||||
void onToolButtonTextClicked();
|
||||
|
||||
void onToolButtonSelectClicked();
|
||||
void onToolButtonRotateClicked();
|
||||
void onToolButtonScaleClicked();
|
||||
void onToolButtonDeleteClicked();
|
||||
void onToolButtonClearClicked();
|
||||
void onToolButtonUndoClicked();
|
||||
void onToolButtonCopyClicked();
|
||||
void onToolButtonPasteClicked();
|
||||
void onToolButtonEllipseClicked();
|
||||
void onToolButtonLineClicked();
|
||||
void onToolButtonPolylineClicked();
|
||||
void onToolButtonPolygonClicked();
|
||||
void onToolButtonRectClicked();
|
||||
void onToolButtonTextClicked();
|
||||
void onPushButtonFillColorClicked();
|
||||
|
||||
void onPushButtonFillColorClicked();
|
||||
void onComboBoxDimenCurrentIndexChanged(int index);
|
||||
void onComboBoxAffilCurrentIndexChanged(int index);
|
||||
void onComboBoxBCDABCurrentIndexChanged(int index);
|
||||
void onComboBoxHeadquarterCurrentIndexChanged(int index);
|
||||
void onComboBoxCommandLevelCurrentIndexChanged(int index);
|
||||
void onComboBoxMobCurrentIndexChanged(int index);
|
||||
void onComboBoxVehicleCurrentIndexChanged(int index);
|
||||
void onComboBoxIntrinsicMobCurrentIndexChanged(int index);
|
||||
void onComboBoxIntrinsicMob2CurrentIndexChanged(int index);
|
||||
void onComboBoxArmingCurrentIndexChanged(int index);
|
||||
|
||||
void onComboBoxDimenCurrentIndexChanged(int index);
|
||||
void onComboBoxAffilCurrentIndexChanged(int index);
|
||||
void onComboBoxBCDABCurrentIndexChanged(int index);
|
||||
void onComboBoxHeadquarterCurrentIndexChanged(int index);
|
||||
void onComboBoxCommandLevelCurrentIndexChanged(int index);
|
||||
void onComboBoxMobCurrentIndexChanged(int index);
|
||||
void onComboBoxVehicleCurrentIndexChanged(int index);
|
||||
void onComboBoxIntrinsicMobCurrentIndexChanged(int index);
|
||||
void onComboBoxIntrinsicMob2CurrentIndexChanged(int index);
|
||||
void onComboBoxArmingCurrentIndexChanged(int index);
|
||||
void onListViewMiscItemSelectionChanged();
|
||||
|
||||
void onListViewMiscItemSelectionChanged();
|
||||
void onCheckBoxVehicleStateChanged(int state);
|
||||
void onCheckBoxArmingStateChanged(int state);
|
||||
void onCheckBoxMainStateChanged(int state);
|
||||
|
||||
void onCheckBoxVehicleStateChanged(int state);
|
||||
void onCheckBoxArmingStateChanged(int state);
|
||||
void onCheckBoxMainStateChanged(int state);
|
||||
void onComboBoxSector1CurrentIndexChanged(int index);
|
||||
void onComboBoxSectorMainCurrentIndexChanged(int index);
|
||||
|
||||
void onComboBoxSector1CurrentIndexChanged(int index);
|
||||
void onComboBoxSectorMainCurrentIndexChanged(int index);
|
||||
void onListViewSectorMainItemSelectionChanged();
|
||||
|
||||
void onListViewSectorMainItemSelectionChanged();
|
||||
void onComboBoxSector2CurrentIndexChanged(int index);
|
||||
|
||||
void onComboBoxSector2CurrentIndexChanged(int index);
|
||||
void help_on_ComboBoxIndexChanged(
|
||||
QComboBox* comboBox, int index, const QMap<int, QString>& contv,
|
||||
SymbologyXML::SymbolTypes::t_icon_type iconType, SymbologyXML::SymbolTypes::t_sector_position pos,
|
||||
SymbologyXML::SymbolTypes::t_sector_rectpos rectpos = SymbologyXML::SymbolTypes::SECTOR_RECTPOS_DEFAULT);
|
||||
|
||||
void help_on_ComboBoxIndexChanged(QComboBox *comboBox,
|
||||
int index, const QMap<int, QString> &contv,
|
||||
SymbologyXML::SymbolTypes::t_icon_type iconType,
|
||||
SymbologyXML::SymbolTypes::t_sector_position pos,
|
||||
SymbologyXML::SymbolTypes::t_sector_rectpos rectpos = SymbologyXML::SymbolTypes::SECTOR_RECTPOS_DEFAULT);
|
||||
void onComboBoxAlign1CurrentIndexChanged(int index);
|
||||
void onComboBoxAlign2CurrentIndexChanged(int index);
|
||||
void onComboBoxAlign3CurrentIndexChanged(int index);
|
||||
|
||||
void onComboBoxColorCurrentIndexChanged(int index);
|
||||
void onComboBoxLineStyleCurrentIndexChanged(int index);
|
||||
|
||||
void onComboBoxAlign1CurrentIndexChanged(int index);
|
||||
void onComboBoxAlign2CurrentIndexChanged(int index);
|
||||
void onComboBoxAlign3CurrentIndexChanged(int index);
|
||||
void onLineEdit1TextChanged(const QString& text);
|
||||
void onLineEdit2TextChanged(const QString& text);
|
||||
void onLineEdit3TextChanged(const QString& text);
|
||||
|
||||
void onComboBoxColorCurrentIndexChanged(int index);
|
||||
void onComboBoxLineStyleCurrentIndexChanged(int index);
|
||||
void onListViewTruppengattungItemSelectionChanged();
|
||||
|
||||
void onLineEdit1TextChanged(const QString &text);
|
||||
void onLineEdit2TextChanged(const QString &text);
|
||||
void onLineEdit3TextChanged(const QString &text);
|
||||
void onCheckBoxBackgroundStateChanged(int state);
|
||||
void onCheckBoxCopyValuesStateChanged(int state);
|
||||
void onCheckBoxFillStateChanged(int state);
|
||||
void onCheckBoxPlannedStateChanged(int state);
|
||||
void onCheckBoxDrawAreaStateChanged(int state);
|
||||
|
||||
void onListViewTruppengattungItemSelectionChanged();
|
||||
void onSpinBoxRasterValueChanged(double d);
|
||||
void onSpinBoxLineWidthValueChanged(double d);
|
||||
void onSpinBoxScaleValueChanged(double d);
|
||||
|
||||
void onCheckBoxBackgroundStateChanged(int state);
|
||||
void onCheckBoxCopyValuesStateChanged(int state);
|
||||
void onCheckBoxFillStateChanged(int state);
|
||||
void onCheckBoxPlannedStateChanged(int state);
|
||||
void onCheckBoxDrawAreaStateChanged(int state);
|
||||
void onSliderTransparencyValueChanged(int value);
|
||||
|
||||
void onSpinBoxRasterValueChanged(double d);
|
||||
void onSpinBoxLineWidthValueChanged(double d);
|
||||
void onSpinBoxScaleValueChanged(double d);
|
||||
void setZoom(double zoom);
|
||||
|
||||
void onSliderTransparencyValueChanged(int value);
|
||||
void addItem(SymbologyXML::Primitive* prim);
|
||||
|
||||
void setZoom(double zoom);
|
||||
void selectionChanged();
|
||||
|
||||
void addItem(SymbologyXML::Primitive *prim);
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void resetGUI();
|
||||
void updateGUI();
|
||||
void updateSymbolAttributesWidgets();
|
||||
void updateTextProperties();
|
||||
void resetToolButtonGroupState();
|
||||
|
||||
void selectionChanged();
|
||||
void pushUndo();
|
||||
void popUndo();
|
||||
void clearUndo();
|
||||
|
||||
private:
|
||||
void restoreSelection(SymbologyXML::Primitive* prim);
|
||||
void copyFromSelectedPrimitive();
|
||||
void enableSelectMove(bool enable);
|
||||
|
||||
void setPushButtonFillColorBackground(QColor color);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void resetGUI();
|
||||
void updateGUI();
|
||||
void updateSymbolAttributesWidgets();
|
||||
void updateTextProperties();
|
||||
void resetToolButtonGroupState();
|
||||
QIcon getIcon(e_category category, SymbologyXML::SymbolTypes::t_icon_type iconType, int iconId, QSize iconSize);
|
||||
|
||||
void pushUndo();
|
||||
void popUndo();
|
||||
void clearUndo();
|
||||
int getFrameSymbolID(SymbologyXML::SymbolTypes::t_dimen dimen, SymbologyXML::SymbolTypes::t_affil affil);
|
||||
|
||||
void restoreSelection(SymbologyXML::Primitive *prim);
|
||||
void copyFromSelectedPrimitive();
|
||||
void enableSelectMove(bool enable);
|
||||
void fillListWidget(const QMap<int, QString>& container, QWidget* widget, e_category category,
|
||||
SymbologyXML::SymbolTypes::t_icon_type iconType, bool withIcons = true, bool sort = true);
|
||||
|
||||
void setPushButtonFillColorBackground(QColor color);
|
||||
void widgetInsertItem(QWidget* widget, int index, const QString& text, int key, e_category category,
|
||||
SymbologyXML::SymbolTypes::t_icon_type iconType, bool withIcons);
|
||||
|
||||
QIcon getIcon(e_category category, SymbologyXML::SymbolTypes::t_icon_type iconType,
|
||||
int iconId, QSize iconSize);
|
||||
void drawSymbol(const SymbologyXML::Symbol* symbol, QGraphicsScene* scene, const QColor& color,
|
||||
const QColor& fillColor, double z, bool isAttrib = false, bool updateMap = false,
|
||||
bool drawBoundRect = false);
|
||||
|
||||
int getFrameSymbolID(SymbologyXML::SymbolTypes::t_dimen dimen,
|
||||
SymbologyXML::SymbolTypes::t_affil affil);
|
||||
void drawSymbolPrimitive(SymbologyXML::Primitive* primitive, QGraphicsScene* scene, const QColor& color,
|
||||
const QColor& fillColor, double z, bool isAttrib = false, bool drawBoundRect = false);
|
||||
|
||||
void fillListWidget(const QMap<int, QString> &container, QWidget *widget,
|
||||
e_category category, SymbologyXML::SymbolTypes::t_icon_type iconType,
|
||||
bool withIcons = true, bool sort = true);
|
||||
void copyElementsFromSymbol(const SymbologyXML::Symbol& tmpSymbol) const;
|
||||
|
||||
void widgetInsertItem(QWidget *widget, int index, const QString &text, int key,
|
||||
e_category category, SymbologyXML::SymbolTypes::t_icon_type iconType,
|
||||
bool withIcons);
|
||||
|
||||
void drawSymbol(const SymbologyXML::Symbol *symbol, QGraphicsScene *scene,
|
||||
const QColor &color, const QColor &fillColor,
|
||||
double z, bool isAttrib = false, bool updateMap = false, bool drawBoundRect = false);
|
||||
|
||||
void drawSymbolPrimitive(SymbologyXML::Primitive *primitive, QGraphicsScene *scene,
|
||||
const QColor &color, const QColor &fillColor,
|
||||
double z, bool isAttrib = false, bool drawBoundRect = false);
|
||||
|
||||
void copyElementsFromSymbol(const SymbologyXML::Symbol &tmpSymbol) const;
|
||||
|
||||
Ui::SymbolEditor *m_ui;
|
||||
SymbolEditorPrivate *m_internal;
|
||||
LtsSession::LtsSession *m_session;
|
||||
Ui::SymbolEditor* m_ui;
|
||||
SymbolEditorPrivate* m_internal;
|
||||
LtsSession::LtsSession* m_session;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AdvancedSymbology
|
||||
Executable → Regular
+481
-589
File diff suppressed because it is too large.
Load diff
Executable → Regular
+39
-66
@@ -1,20 +1,15 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <AdvancedSymbology/asb_symbol_proxy_gui_plugin_interface.h>
|
||||
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
|
||||
#include <FileManagement/flm.hpp>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
@@ -23,75 +18,53 @@ class RequestHelper;
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
class FlmSubscriber final
|
||||
: public QObject
|
||||
, public ForeignGuiFlmSymbolsProxyInterface
|
||||
, public FileManagement::Interface::Ftc::GetFileContentDataReplyHandler
|
||||
class FlmSubscriber final : public QObject,
|
||||
public ForeignGuiFlmSymbolsProxyInterface,
|
||||
public FileManagement::Interface::Ftc::GetFileContentDataReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FlmSubscriber(const std::shared_ptr<FileManagement::Interface::Dtc> &flmDtc,
|
||||
const std::shared_ptr<FileManagement::Interface::Ftc> &flmFtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc);
|
||||
~FlmSubscriber();
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FlmSubscriber(const std::shared_ptr<FileManagement::Interface::Dtc>& flmDtc,
|
||||
const std::shared_ptr<FileManagement::Interface::Ftc>& flmFtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc>& opmDtc);
|
||||
~FlmSubscriber();
|
||||
|
||||
bool createFlmSymbolProxy(int type_placeholder) override;
|
||||
bool connectFlmSymbolProxy(int type_placeholder, SymbologyType symbologyType) override;
|
||||
|
||||
bool createFlmSymbolProxy(int type_placeholder) override;
|
||||
bool connectFlmSymbolProxy(int type_placeholder, SymbologyType symbologyType) override;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool setEtsSymbolToDict(SymbolDictionary& dict, qint32 fileContentId, const QString& name, const QImage& image,
|
||||
const QColor& colorToBeReplaced, const QStringList& usrTags);
|
||||
|
||||
private:
|
||||
bool setXmlSymbolToDict(SymbolDictionary& dict, qint32 fileContentId, const QString& operatorName,
|
||||
qint64 lastModified, const QString& name, const QString& xmlContent,
|
||||
const QStringList& usrTags);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool setEtsSymbolToDict(SymbolDictionary &dict,
|
||||
qint32 fileContentId,
|
||||
const QString &name,
|
||||
const QImage &image,
|
||||
const QColor &colorToBeReplaced,
|
||||
const QStringList &usrTags);
|
||||
protected slots:
|
||||
void onFileContentChanged(const FileManagement::FileContent& data, DataModification modType);
|
||||
void updateFileContentMap(const FileManagement::FileContent& data);
|
||||
|
||||
bool setXmlSymbolToDict(SymbolDictionary &dict,
|
||||
qint32 fileContentId,
|
||||
const QString &operatorName,
|
||||
qint64 lastModified,
|
||||
const QString &name,
|
||||
const QString &xmlContent,
|
||||
const QStringList &usrTags);
|
||||
void onLocalSymbolProxyEtsSymbolAdded(qint32 fileContentId, const QString& name, const QImage& image,
|
||||
const QColor& colorToBeReplaced, const QStringList& usrTags);
|
||||
void onLocalSymbolProxyEtsSymbolRemoved(qint32 fileContentId, const QString& name);
|
||||
|
||||
protected slots:
|
||||
void onFileContentChanged(const FileManagement::FileContent &data, DataModification modType);
|
||||
void updateFileContentMap(const FileManagement::FileContent &data);
|
||||
void onLocalSymbolProxyXmlSymbolAdded(qint32 fileContentId, const QString& operatorName, qint64 lastModified,
|
||||
const QString& name, const QString& xmlContent, const QStringList& usrTags);
|
||||
void onLocalSymbolProxyXmlSymbolRemoved(qint32 fileContentId);
|
||||
|
||||
void onLocalSymbolProxyEtsSymbolAdded(qint32 fileContentId,
|
||||
const QString &name,
|
||||
const QImage &image,
|
||||
const QColor &colorToBeReplaced,
|
||||
const QStringList &usrTags);
|
||||
void onLocalSymbolProxyEtsSymbolRemoved(qint32 fileContentId, const QString &name);
|
||||
protected:
|
||||
void onGetFileContentDataReply(const FileManagement::GetFileContentDataReply& reply) override;
|
||||
|
||||
void onLocalSymbolProxyXmlSymbolAdded(qint32 fileContentId,
|
||||
const QString &operatorName,
|
||||
qint64 lastModified,
|
||||
const QString &name,
|
||||
const QString &xmlContent,
|
||||
const QStringList &usrTags);
|
||||
void onLocalSymbolProxyXmlSymbolRemoved(qint32 fileContentId);
|
||||
bool svgToImage(const QByteArray& svgByteArray, QImage& imageOut);
|
||||
|
||||
protected:
|
||||
|
||||
QString operatorName(int operatorId);
|
||||
|
||||
void onGetFileContentDataReply(const FileManagement::GetFileContentDataReply &reply) override;
|
||||
void checkForReFetching();
|
||||
|
||||
bool svgToImage(const QByteArray &svgByteArray, QImage &imageOut);
|
||||
|
||||
QString operatorName(int operatorId);
|
||||
|
||||
void checkForReFetching();
|
||||
|
||||
private:
|
||||
struct Private;
|
||||
|
||||
|
||||
Private *d = nullptr;
|
||||
private:
|
||||
struct Private;
|
||||
|
||||
Private* d = nullptr;
|
||||
};
|
||||
}
|
||||
} // namespace AdvancedSymbology
|
||||
Executable → Regular
+113
-137
@@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_config_alarm_model.h"
|
||||
|
||||
#include <AlarmManagement/alm_translation.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ProjectDataManagement/pdm_to_string.h>
|
||||
@@ -9,156 +9,132 @@
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
ConfigAlarmModel::ConfigAlarmModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AlarmManagement::AlarmConfig>(
|
||||
ConfigAlarmModel::ConfigAlarmModel(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AlarmManagement::AlarmConfig>(
|
||||
{tr("Id"), tr("Equip. No."), tr("Designator"), tr("Tact. Identifier"), tr("Vulnerability State"),
|
||||
tr("Event Type"), tr("Message Window"), tr("Set Marker")},
|
||||
parent),
|
||||
m_dtc(nullptr), m_ppmDtc(nullptr), m_alarmHistoryModel(nullptr), m_global(false)
|
||||
{
|
||||
tr("Id"),
|
||||
tr("Equip. No."),
|
||||
tr("Designator"),
|
||||
tr("Tact. Identifier"),
|
||||
tr("Vulnerability State"),
|
||||
tr("Event Type"),
|
||||
tr("Message Window"),
|
||||
tr("Set Marker")
|
||||
},
|
||||
parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_alarmHistoryModel(nullptr)
|
||||
, m_global(false)
|
||||
{}
|
||||
|
||||
|
||||
bool ConfigAlarmModel::initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
AlarmHistoryModel *alarmHistoryModel,
|
||||
bool global)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_alarmHistoryModel = alarmHistoryModel;
|
||||
m_global = global;
|
||||
|
||||
|
||||
const QMap<qint32, AlarmManagement::AlarmConfig> alarmConfigs = m_dtc->alarmConfigs();
|
||||
INFO_LOG(m_logger) << "initModel - #AlarmConfig: " << alarmConfigs.size();
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::alarmConfigChanged,
|
||||
this, &ConfigAlarmModel::onAlarmConfigChanged);
|
||||
|
||||
m_dtc->enableAlarmConfig();
|
||||
auto cb = [this] (const AlarmManagement::AlarmConfig &d)
|
||||
{
|
||||
onAlarmConfigChanged(d, DataModification::eAdded);
|
||||
};
|
||||
m_dtc->alarmConfigs(cb);
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant ConfigAlarmModel::data(const QModelIndex &index, int role) const
|
||||
bool ConfigAlarmModel::initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
AlarmHistoryModel* alarmHistoryModel, bool global)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "AlarmManagementModel::data";
|
||||
m_dtc = dtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_alarmHistoryModel = alarmHistoryModel;
|
||||
m_global = global;
|
||||
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
const QMap<qint32, AlarmManagement::AlarmConfig> alarmConfigs = m_dtc->alarmConfigs();
|
||||
INFO_LOG(m_logger) << "initModel - #AlarmConfig: " << alarmConfigs.size();
|
||||
|
||||
const AlarmManagement::AlarmConfig &alarmConfig = m_vecData.at(index.row());
|
||||
if (alarmConfig.global() != m_global)
|
||||
return QVariant();
|
||||
connect(m_dtc.get(), &Interface::Dtc::alarmConfigChanged, this, &ConfigAlarmModel::onAlarmConfigChanged);
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return alarmConfig.id();
|
||||
case EquipmentNumber:
|
||||
{
|
||||
const int equipmentNumber = m_alarmHistoryModel->participantId2EquipNo(alarmConfig.participantId());
|
||||
if (equipmentNumber == 0)
|
||||
return tr("All");
|
||||
return equipmentNumber;
|
||||
}
|
||||
case Designator:
|
||||
return m_alarmHistoryModel->getDesignator(alarmConfig.participantId());
|
||||
case TactIdentifier:
|
||||
return m_alarmHistoryModel->getTactIdentifier(alarmConfig.participantId());
|
||||
case VulnerabilityState:
|
||||
{
|
||||
QString vulnerabilityState = tr("All Types");
|
||||
if (alarmConfig.vulnerabilityState()>=0){
|
||||
ParticipantManagement::TypeClass typeClass =
|
||||
m_ppmDtc->type(m_ppmDtc->participant(alarmConfig.participantId()).typeId()).typeClass();
|
||||
|
||||
const ProjectDataManagement::VulnerabilityClass vc = typeClass == ParticipantManagement::TypeClass::Human ?
|
||||
ProjectDataManagement::VulnerabilityClass_def::SoldierInjuries :
|
||||
ProjectDataManagement::VulnerabilityClass_def::VehicleDamages;
|
||||
ProjectDataManagement::VulnerabilityState vs = static_cast<ProjectDataManagement::VulnerabilityState_def::type>(alarmConfig.vulnerabilityState());
|
||||
vulnerabilityState = ProjectDataManagement::toString(vs, vc);
|
||||
}
|
||||
return vulnerabilityState;
|
||||
}
|
||||
|
||||
case EventType:
|
||||
return ProjectDataManagement::toString(alarmConfig.eventTypeId());
|
||||
case MessageWindow:
|
||||
return alarmConfig.messageWindow() ? tr("Yes") : tr("No");
|
||||
case SetMarker:
|
||||
return alarmConfig.setMarker() ? tr("Yes") : tr("No");
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
m_dtc->enableAlarmConfig();
|
||||
auto cb = [this](const AlarmManagement::AlarmConfig& d) { onAlarmConfigChanged(d, DataModification::eAdded); };
|
||||
m_dtc->alarmConfigs(cb);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ConfigAlarmModel::onAlarmConfigChanged(const AlarmManagement::AlarmConfig &data,
|
||||
const DataModification modType)
|
||||
QVariant ConfigAlarmModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
const int id = data.id();
|
||||
if (data.global() != m_global)
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "AlarmManagementModel::data";
|
||||
|
||||
int row = findRowForId(id);
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const int eventTypeId = data.eventTypeId().underlying();
|
||||
const bool messageWindow = data.messageWindow();
|
||||
const bool setMarker = data.setMarker();
|
||||
DEBUG_LOG(m_logger) << "onAlarmConfigChanged: " << eventTypeId << " messageWindow=" << messageWindow
|
||||
<< "setMarker"<<setMarker;
|
||||
const AlarmManagement::AlarmConfig& alarmConfig = m_vecData.at(index.row());
|
||||
if (alarmConfig.global() != m_global)
|
||||
return QVariant();
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
|
||||
DEBUG_LOG(m_logger) << "AlarmConfig was removed: " << id;
|
||||
AlarmManagement::AlarmConfig data1 = data;
|
||||
data1.messageWindow(false);
|
||||
data1.setMarker(false);
|
||||
setRowData(row, data1);
|
||||
removeRow(row);
|
||||
return;
|
||||
}
|
||||
case DataModification::eModified:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DataModification::eModified: ";
|
||||
if (row < 0)
|
||||
switch (index.column())
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
if (m_alarmHistoryModel->participantId2EquipNo(data.participantId()) > 0)
|
||||
setRowData(row, data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eAdded:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DataModification::eAdded";
|
||||
insertRow(data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Id:
|
||||
return alarmConfig.id();
|
||||
case EquipmentNumber: {
|
||||
const int equipmentNumber = m_alarmHistoryModel->participantId2EquipNo(alarmConfig.participantId());
|
||||
if (equipmentNumber == 0)
|
||||
return tr("All");
|
||||
return equipmentNumber;
|
||||
}
|
||||
case Designator:
|
||||
return m_alarmHistoryModel->getDesignator(alarmConfig.participantId());
|
||||
case TactIdentifier:
|
||||
return m_alarmHistoryModel->getTactIdentifier(alarmConfig.participantId());
|
||||
case VulnerabilityState: {
|
||||
QString vulnerabilityState = tr("All Types");
|
||||
if (alarmConfig.vulnerabilityState() >= 0)
|
||||
{
|
||||
ParticipantManagement::TypeClass typeClass =
|
||||
m_ppmDtc->type(m_ppmDtc->participant(alarmConfig.participantId()).typeId()).typeClass();
|
||||
|
||||
const ProjectDataManagement::VulnerabilityClass vc =
|
||||
typeClass == ParticipantManagement::TypeClass::Human
|
||||
? ProjectDataManagement::VulnerabilityClass_def::SoldierInjuries
|
||||
: ProjectDataManagement::VulnerabilityClass_def::VehicleDamages;
|
||||
ProjectDataManagement::VulnerabilityState vs =
|
||||
static_cast<ProjectDataManagement::VulnerabilityState_def::type>(alarmConfig.vulnerabilityState());
|
||||
vulnerabilityState = ProjectDataManagement::toString(vs, vc);
|
||||
}
|
||||
return vulnerabilityState;
|
||||
}
|
||||
|
||||
case EventType:
|
||||
return ProjectDataManagement::toString(alarmConfig.eventTypeId());
|
||||
case MessageWindow:
|
||||
return alarmConfig.messageWindow() ? tr("Yes") : tr("No");
|
||||
case SetMarker:
|
||||
return alarmConfig.setMarker() ? tr("Yes") : tr("No");
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
}
|
||||
void ConfigAlarmModel::onAlarmConfigChanged(const AlarmManagement::AlarmConfig& data, const DataModification modType)
|
||||
{
|
||||
const int id = data.id();
|
||||
if (data.global() != m_global)
|
||||
return;
|
||||
|
||||
int row = findRowForId(id);
|
||||
|
||||
const int eventTypeId = data.eventTypeId().underlying();
|
||||
const bool messageWindow = data.messageWindow();
|
||||
const bool setMarker = data.setMarker();
|
||||
DEBUG_LOG(m_logger) << "onAlarmConfigChanged: " << eventTypeId << " messageWindow=" << messageWindow << "setMarker"
|
||||
<< setMarker;
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eRemoved: {
|
||||
|
||||
DEBUG_LOG(m_logger) << "AlarmConfig was removed: " << id;
|
||||
AlarmManagement::AlarmConfig data1 = data;
|
||||
data1.messageWindow(false);
|
||||
data1.setMarker(false);
|
||||
setRowData(row, data1);
|
||||
removeRow(row);
|
||||
return;
|
||||
}
|
||||
case DataModification::eModified: {
|
||||
DEBUG_LOG(m_logger) << "DataModification::eModified: ";
|
||||
if (row < 0)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
if (m_alarmHistoryModel->participantId2EquipNo(data.participantId()) > 0)
|
||||
setRowData(row, data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eAdded: {
|
||||
DEBUG_LOG(m_logger) << "DataModification::eAdded";
|
||||
insertRow(data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+30
-35
@@ -1,54 +1,49 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "alm_history_alarm_model.h"
|
||||
#include "almcommon_export.h"
|
||||
|
||||
#include <AlarmManagement/alm_dtc.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include "alm_history_alarm_model.h"
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
class ALMCOMMON_EXPORT ConfigAlarmModel final : public LtsWidgets::LtsAbstractTableModel<AlarmManagement::AlarmConfig>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
EquipmentNumber,
|
||||
Designator,
|
||||
TactIdentifier,
|
||||
VulnerabilityState,
|
||||
EventType,
|
||||
MessageWindow,
|
||||
SetMarker
|
||||
};
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns {
|
||||
Id,
|
||||
EquipmentNumber,
|
||||
Designator,
|
||||
TactIdentifier,
|
||||
VulnerabilityState,
|
||||
EventType,
|
||||
MessageWindow,
|
||||
SetMarker
|
||||
};
|
||||
|
||||
explicit ConfigAlarmModel(QObject *parent = nullptr);
|
||||
explicit ConfigAlarmModel(QObject* parent = nullptr);
|
||||
|
||||
bool initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
AlarmHistoryModel *alarmHistoryModel,
|
||||
bool global);
|
||||
bool initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
AlarmHistoryModel* alarmHistoryModel, bool global);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
private slots:
|
||||
void onAlarmConfigChanged(const AlarmManagement::AlarmConfig &data,
|
||||
const DataModification modType);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
AlarmHistoryModel *m_alarmHistoryModel;
|
||||
bool m_global;
|
||||
private slots:
|
||||
void onAlarmConfigChanged(const AlarmManagement::AlarmConfig& data, const DataModification modType);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
AlarmHistoryModel* m_alarmHistoryModel;
|
||||
bool m_global;
|
||||
};
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+226
-262
@@ -1,318 +1,282 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_history_alarm_model.h"
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
#include <AlarmManagement/alm_translation.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <AlarmManagement/alm_translation.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonParseError>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
AlarmHistoryModel::AlarmHistoryModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<NotificationEx>(
|
||||
AlarmHistoryModel::AlarmHistoryModel(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<NotificationEx>(
|
||||
{
|
||||
tr("Id"),
|
||||
tr("Date"),
|
||||
tr("Incident"),
|
||||
tr("Equip. No."),
|
||||
tr("Hierarchie"),
|
||||
tr("Participant Id"),
|
||||
tr("Position"),
|
||||
tr("Aes Id"),
|
||||
tr("Aes Name"),
|
||||
},
|
||||
parent),
|
||||
m_dtc(nullptr), m_ppmDtc(nullptr)
|
||||
{
|
||||
tr("Id"),
|
||||
tr("Date"),
|
||||
tr("Incident"),
|
||||
tr("Equip. No."),
|
||||
tr("Hierarchie"),
|
||||
tr("Participant Id"),
|
||||
tr("Position"),
|
||||
tr("Aes Id"),
|
||||
tr("Aes Name"),
|
||||
},
|
||||
parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
bool AlarmHistoryModel::initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_aesDtc = aesDtc;
|
||||
|
||||
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::notificationChanged,
|
||||
this, &AlarmHistoryModel::onNotificationChanged);
|
||||
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged,
|
||||
this, &AlarmHistoryModel::onParticipantChanged);
|
||||
|
||||
m_ppmDtc->enableParticipant();
|
||||
m_dtc->enableNotification();
|
||||
|
||||
|
||||
const auto cbParticipants = [this](const ParticipantManagement::Participant & participant)
|
||||
{
|
||||
onParticipantChanged(participant, DataModification::eAdded);
|
||||
};
|
||||
m_ppmDtc->participants(cbParticipants);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::borderlineChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::dangerAreaChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::nContaminationChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::bCContaminationChanged,
|
||||
this, &AlarmHistoryModel::onBCContaminationChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::mineAreaChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::functionalAreaChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::boobyTrapChanged,
|
||||
this, &AlarmHistoryModel::onBoobyTrapChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::offRouteMineChanged,
|
||||
this, &AlarmHistoryModel::onOffRouteMineChanged);
|
||||
|
||||
|
||||
auto cbAesItem = [this](const AreaEffectSimulation::AesItem & item)
|
||||
{
|
||||
onAesItemChanged(item, DataModification::eAdded);
|
||||
};
|
||||
m_aesDtc->borderlines(cbAesItem);
|
||||
m_aesDtc->dangerAreas(cbAesItem);
|
||||
m_aesDtc->nContaminations(cbAesItem);
|
||||
m_aesDtc->mineAreas(cbAesItem);
|
||||
m_aesDtc->functionalAreas(cbAesItem);
|
||||
m_aesDtc->boobyTraps(cbAesItem);
|
||||
m_aesDtc->offRouteMines(cbAesItem);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVariant AlarmHistoryModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
if ((role != Qt::DisplayRole) && (role != Qt::UserRole) && (role != Qt::BackgroundRole))
|
||||
return QVariant();
|
||||
|
||||
const NotificationEx ¬ificationEx = m_vecData.at(index.row());
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (notificationEx.eventType() == ProjectDataManagement::EventType_def::EmergencyCall)
|
||||
return QColor(Qt::red);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return notificationEx.id();
|
||||
case Date:
|
||||
return QDateTime::fromMSecsSinceEpoch(notificationEx.time());
|
||||
case EquipmentNumber:
|
||||
if (notificationEx.equipmentNumber)
|
||||
return notificationEx.equipmentNumber;
|
||||
break;
|
||||
case Incident:
|
||||
return ProjectDataManagement::toString(notificationEx.eventTypeId);
|
||||
case Hierarchie:
|
||||
return m_ppmDtc->hierarchyFromParticipant(notificationEx.participantId);
|
||||
case ParticipantId:
|
||||
return notificationEx.participantId;
|
||||
case Position:
|
||||
if (role == Qt::DisplayRole)
|
||||
return LtsCoordTrans::mgrsFromGeographic(notificationEx.position().lon(), notificationEx.position().lat());
|
||||
else if (role == Qt::UserRole)
|
||||
return QPointF(notificationEx.position().lon(), notificationEx.position().lat());
|
||||
break;
|
||||
case AesId:
|
||||
return notificationEx.aesId;
|
||||
case AesName:
|
||||
|
||||
return m_aesNameMap.value(notificationEx.aesId, tr("-"));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
bool AlarmHistoryModel::isFiltered(const NotificationEx &data, DataModification modType) const
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
if (data.operatorId() == 0)
|
||||
return false;
|
||||
return data.operatorId() != LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onNotificationChanged(const AlarmManagement::Notification &data,
|
||||
const DataModification modType)
|
||||
bool AlarmHistoryModel::initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc>& aesDtc)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
m_dtc = dtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_aesDtc = aesDtc;
|
||||
|
||||
NotificationEx notification(data);
|
||||
const QByteArray properties = QByteArray::fromRawData(data.properties().c_str(), data.properties().size());
|
||||
const QJsonDocument propertieJsonDoc = QJsonDocument::fromJson(properties);
|
||||
const QJsonObject propertieJsonObj = propertieJsonDoc.object();
|
||||
connect(m_dtc.get(), &Interface::Dtc::notificationChanged, this, &AlarmHistoryModel::onNotificationChanged);
|
||||
|
||||
notification.equipmentNumber = data.equipmentNumber();
|
||||
if (data.participantId().is_set())
|
||||
notification.participantId = data.participantId().get();
|
||||
notification.eventTypeId = data.eventType();
|
||||
if (data.aesId().is_set())
|
||||
notification.aesId = data.aesId().get();
|
||||
const int global = propertieJsonObj[QStringLiteral("Global")].toInt();
|
||||
const int friendlyFire = propertieJsonObj[QStringLiteral("FriendlyFire")].toInt();
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged, this,
|
||||
&AlarmHistoryModel::onParticipantChanged);
|
||||
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO
|
||||
<< " notification:" << data
|
||||
<< ", Global: " << global
|
||||
<< ", FriendlyFire: " << friendlyFire;
|
||||
m_ppmDtc->enableParticipant();
|
||||
m_dtc->enableNotification();
|
||||
|
||||
onDataChanged(notification, modType);
|
||||
}
|
||||
const auto cbParticipants = [this](const ParticipantManagement::Participant& participant) {
|
||||
onParticipantChanged(participant, DataModification::eAdded);
|
||||
};
|
||||
m_ppmDtc->participants(cbParticipants);
|
||||
|
||||
void AlarmHistoryModel::onParticipantChanged(const ParticipantManagement::Participant &participant,
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::borderlineChanged, this,
|
||||
&AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::dangerAreaChanged, this,
|
||||
&AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::nContaminationChanged, this,
|
||||
&AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::bCContaminationChanged, this,
|
||||
&AlarmHistoryModel::onBCContaminationChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::mineAreaChanged, this,
|
||||
&AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::functionalAreaChanged, this,
|
||||
&AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::boobyTrapChanged, this,
|
||||
&AlarmHistoryModel::onBoobyTrapChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::offRouteMineChanged, this,
|
||||
&AlarmHistoryModel::onOffRouteMineChanged);
|
||||
|
||||
auto cbAesItem = [this](const AreaEffectSimulation::AesItem& item) {
|
||||
onAesItemChanged(item, DataModification::eAdded);
|
||||
};
|
||||
m_aesDtc->borderlines(cbAesItem);
|
||||
m_aesDtc->dangerAreas(cbAesItem);
|
||||
m_aesDtc->nContaminations(cbAesItem);
|
||||
m_aesDtc->mineAreas(cbAesItem);
|
||||
m_aesDtc->functionalAreas(cbAesItem);
|
||||
m_aesDtc->boobyTraps(cbAesItem);
|
||||
m_aesDtc->offRouteMines(cbAesItem);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant AlarmHistoryModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
if ((role != Qt::DisplayRole) && (role != Qt::UserRole) && (role != Qt::BackgroundRole))
|
||||
return QVariant();
|
||||
|
||||
const NotificationEx& notificationEx = m_vecData.at(index.row());
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (notificationEx.eventType() == ProjectDataManagement::EventType_def::EmergencyCall)
|
||||
return QColor(Qt::red);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return notificationEx.id();
|
||||
case Date:
|
||||
return QDateTime::fromMSecsSinceEpoch(notificationEx.time());
|
||||
case EquipmentNumber:
|
||||
if (notificationEx.equipmentNumber)
|
||||
return notificationEx.equipmentNumber;
|
||||
break;
|
||||
case Incident:
|
||||
return ProjectDataManagement::toString(notificationEx.eventTypeId);
|
||||
case Hierarchie:
|
||||
return m_ppmDtc->hierarchyFromParticipant(notificationEx.participantId);
|
||||
case ParticipantId:
|
||||
return notificationEx.participantId;
|
||||
case Position:
|
||||
if (role == Qt::DisplayRole)
|
||||
return LtsCoordTrans::mgrsFromGeographic(notificationEx.position().lon(),
|
||||
notificationEx.position().lat());
|
||||
else if (role == Qt::UserRole)
|
||||
return QPointF(notificationEx.position().lon(), notificationEx.position().lat());
|
||||
break;
|
||||
case AesId:
|
||||
return notificationEx.aesId;
|
||||
case AesName:
|
||||
|
||||
return m_aesNameMap.value(notificationEx.aesId, tr("-"));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool AlarmHistoryModel::isFiltered(const NotificationEx& data, DataModification modType) const
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
if (data.operatorId() == 0)
|
||||
return false;
|
||||
return data.operatorId() != LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onNotificationChanged(const AlarmManagement::Notification& data, const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
NotificationEx notification(data);
|
||||
const QByteArray properties = QByteArray::fromRawData(data.properties().c_str(), data.properties().size());
|
||||
const QJsonDocument propertieJsonDoc = QJsonDocument::fromJson(properties);
|
||||
const QJsonObject propertieJsonObj = propertieJsonDoc.object();
|
||||
|
||||
notification.equipmentNumber = data.equipmentNumber();
|
||||
if (data.participantId().is_set())
|
||||
notification.participantId = data.participantId().get();
|
||||
notification.eventTypeId = data.eventType();
|
||||
if (data.aesId().is_set())
|
||||
notification.aesId = data.aesId().get();
|
||||
const int global = propertieJsonObj[QStringLiteral("Global")].toInt();
|
||||
const int friendlyFire = propertieJsonObj[QStringLiteral("FriendlyFire")].toInt();
|
||||
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " notification:" << data << ", Global: " << global
|
||||
<< ", FriendlyFire: " << friendlyFire;
|
||||
|
||||
onDataChanged(notification, modType);
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onParticipantChanged(const ParticipantManagement::Participant& participant,
|
||||
const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
QString designator = QString::fromStdString(participant.designator());
|
||||
m_idDesignatorMap.insert(participant.id(), designator);
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
QString designator = QString::fromStdString(participant.designator());
|
||||
m_idDesignatorMap.insert(participant.id(), designator);
|
||||
|
||||
const int equipNo = participant.equipmentNumber().is_set() ? participant.equipmentNumber().get() : 0;
|
||||
m_partId2EquipNoMap.insert(participant.id(), equipNo);
|
||||
const int equipNo = participant.equipmentNumber().is_set() ? participant.equipmentNumber().get() : 0;
|
||||
m_partId2EquipNoMap.insert(participant.id(), equipNo);
|
||||
|
||||
QString tacticalIdentifier = QString::fromStdString(participant.tacticalIdentifier());
|
||||
m_idTactIdentifierMap.insert(participant.id(), tacticalIdentifier);
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " id=" << participant.id()
|
||||
<< " designator=" << designator
|
||||
<< " tacticalIdentifier=" << tacticalIdentifier;
|
||||
}
|
||||
QString tacticalIdentifier = QString::fromStdString(participant.tacticalIdentifier());
|
||||
m_idTactIdentifierMap.insert(participant.id(), tacticalIdentifier);
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " id=" << participant.id() << " designator=" << designator
|
||||
<< " tacticalIdentifier=" << tacticalIdentifier;
|
||||
}
|
||||
|
||||
int AlarmHistoryModel::participantId2EquipNo(const int participantId) const
|
||||
{
|
||||
int ret = m_partId2EquipNoMap.value(participantId, 0);
|
||||
INFO_LOG(m_logger) << "participantId2EquipNo participantId=" << participantId
|
||||
<< " EquipmentNumber=" << ret;
|
||||
return ret;
|
||||
}
|
||||
int ret = m_partId2EquipNoMap.value(participantId, 0);
|
||||
INFO_LOG(m_logger) << "participantId2EquipNo participantId=" << participantId << " EquipmentNumber=" << ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString AlarmHistoryModel::getDesignator(const int participantId) const
|
||||
{
|
||||
QString designator = m_idDesignatorMap.value(participantId);
|
||||
DEBUG_LOG(m_logger) << "m_idDesignatorMap.value(participantId)=" << designator;
|
||||
QString designator = m_idDesignatorMap.value(participantId);
|
||||
DEBUG_LOG(m_logger) << "m_idDesignatorMap.value(participantId)=" << designator;
|
||||
|
||||
return designator;
|
||||
return designator;
|
||||
}
|
||||
|
||||
QString AlarmHistoryModel::getTactIdentifier(const int participantId) const
|
||||
{
|
||||
QString tactIdentifier = m_idTactIdentifierMap.value(participantId);
|
||||
DEBUG_LOG(m_logger) << "m_idTactIdentifierMap.value(participantId)=" << tactIdentifier;
|
||||
QString tactIdentifier = m_idTactIdentifierMap.value(participantId);
|
||||
DEBUG_LOG(m_logger) << "m_idTactIdentifierMap.value(participantId)=" << tactIdentifier;
|
||||
|
||||
return tactIdentifier;
|
||||
return tactIdentifier;
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onBCContaminationChanged(const AreaEffectSimulation::BCContamination &data,
|
||||
const DataModification modType)
|
||||
void AlarmHistoryModel::onBCContaminationChanged(const AreaEffectSimulation::BCContamination& data,
|
||||
const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "onBCContaminationChanged: " << data
|
||||
<< " Name=" << name
|
||||
<< " id=" << id;
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "onBCContaminationChanged: " << data << " Name=" << name << " id=" << id;
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap &data,
|
||||
const DataModification modType)
|
||||
void AlarmHistoryModel::onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap& data, const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "BoobyTrap: " << data
|
||||
<< " Name=" << name
|
||||
<< " id=" << id;
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "BoobyTrap: " << data << " Name=" << name << " id=" << id;
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine &data,
|
||||
const DataModification modType)
|
||||
void AlarmHistoryModel::onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine& data,
|
||||
const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "OffRouteMine: " << data
|
||||
<< " Name=" << name
|
||||
<< " id=" << id;
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "OffRouteMine: " << data << " Name=" << name << " id=" << id;
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onAesItemChanged(const AreaEffectSimulation::AesItem &item,
|
||||
const DataModification modType)
|
||||
void AlarmHistoryModel::onAesItemChanged(const AreaEffectSimulation::AesItem& item, const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
QString name = QString::fromStdString(item.name());
|
||||
int id = item.id();
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "AreaEffectSimulation::AesItem onAesItemChanged: " << item
|
||||
<< " Name=" << name
|
||||
<< " id=" << item.id();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AlarmHistoryProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<AlarmHistoryModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
QString name = QString::fromStdString(item.name());
|
||||
int id = item.id();
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "AreaEffectSimulation::AesItem onAesItemChanged: " << item << " Name=" << name
|
||||
<< " id=" << item.id();
|
||||
}
|
||||
|
||||
bool AlarmHistoryProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
void AlarmHistoryProxyModel::setSourceModel(QAbstractItemModel* sourceModel)
|
||||
{
|
||||
if (!m_sourceModel ||
|
||||
source_left.column() != source_right.column() ||
|
||||
!source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
m_sourceModel = qobject_cast<AlarmHistoryModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool AlarmHistoryProxyModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const
|
||||
{
|
||||
if (!m_sourceModel || source_left.column() != source_right.column() || !source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
const auto& dataLeft = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
case AlarmHistoryModel::Date:
|
||||
return dataLeft.time() < dataRight.time();
|
||||
|
||||
case AlarmHistoryModel::Id:
|
||||
case AlarmHistoryModel::Incident:
|
||||
case AlarmHistoryModel::EquipmentNumber:
|
||||
case AlarmHistoryModel::Hierarchie:
|
||||
case AlarmHistoryModel::ParticipantId:
|
||||
case AlarmHistoryModel::Position:
|
||||
case AlarmHistoryModel::AesId:
|
||||
case AlarmHistoryModel::AesName:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
case AlarmHistoryModel::Date:
|
||||
return dataLeft.time() < dataRight.time();
|
||||
|
||||
case AlarmHistoryModel::Id:
|
||||
case AlarmHistoryModel::Incident:
|
||||
case AlarmHistoryModel::EquipmentNumber:
|
||||
case AlarmHistoryModel::Hierarchie:
|
||||
case AlarmHistoryModel::ParticipantId:
|
||||
case AlarmHistoryModel::Position:
|
||||
case AlarmHistoryModel::AesId:
|
||||
case AlarmHistoryModel::AesName:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+52
-75
@@ -1,107 +1,84 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "almcommon_export.h"
|
||||
#include <AlarmManagement/alm_dtc.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <AreaEffectSimulation/aes_dtc.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
|
||||
#include <AlarmManagement/alm_dtc.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
#include <AreaEffectSimulation/aes_dtc.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
struct NotificationEx : public AlarmManagement::Notification
|
||||
{
|
||||
int equipmentNumber = 0;
|
||||
int participantId = 0;
|
||||
int aesId = 0;
|
||||
ProjectDataManagement::EventType eventTypeId = ProjectDataManagement::EventType::Unknown;
|
||||
int equipmentNumber = 0;
|
||||
int participantId = 0;
|
||||
int aesId = 0;
|
||||
ProjectDataManagement::EventType eventTypeId = ProjectDataManagement::EventType::Unknown;
|
||||
|
||||
NotificationEx() = default;
|
||||
explicit NotificationEx(const AlarmManagement::Notification &n)
|
||||
: AlarmManagement::Notification(n)
|
||||
{}
|
||||
NotificationEx() = default;
|
||||
|
||||
explicit NotificationEx(const AlarmManagement::Notification& n) : AlarmManagement::Notification(n) {}
|
||||
};
|
||||
|
||||
class ALMCOMMON_EXPORT AlarmHistoryModel final : public LtsWidgets::LtsAbstractTableModel<NotificationEx>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns { Id, Date, Incident, EquipmentNumber, Hierarchie, ParticipantId, Position, AesId, AesName };
|
||||
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
Date,
|
||||
Incident,
|
||||
EquipmentNumber,
|
||||
Hierarchie,
|
||||
ParticipantId,
|
||||
Position,
|
||||
AesId,
|
||||
AesName
|
||||
};
|
||||
explicit AlarmHistoryModel(QObject* parent = nullptr);
|
||||
|
||||
explicit AlarmHistoryModel(QObject *parent = nullptr);
|
||||
bool initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc>& aesDtc);
|
||||
|
||||
bool initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc);
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
int participantId2EquipNo(const int participantId) const;
|
||||
QString getDesignator(const int participantId) const;
|
||||
QString getTactIdentifier(const int participantId) const;
|
||||
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool isFiltered(const NotificationEx& data, DataModification modType) const override;
|
||||
private slots:
|
||||
void onNotificationChanged(const AlarmManagement::Notification& data, const DataModification modType);
|
||||
void onParticipantChanged(const ParticipantManagement::Participant& participant, const DataModification modType);
|
||||
void onAesItemChanged(const AreaEffectSimulation::AesItem& item, const DataModification modType);
|
||||
void onBCContaminationChanged(const AreaEffectSimulation::BCContamination& data, const DataModification modType);
|
||||
void onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap& data, const DataModification modType);
|
||||
void onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine& data, const DataModification modType);
|
||||
|
||||
int participantId2EquipNo(const int participantId) const;
|
||||
QString getDesignator(const int participantId) const;
|
||||
QString getTactIdentifier(const int participantId) const;
|
||||
private:
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
|
||||
protected:
|
||||
QMap<int, int> m_partId2EquipNoMap;
|
||||
QHash<int, QString> m_idDesignatorMap;
|
||||
QHash<int, QString> m_idTactIdentifierMap;
|
||||
QHash<int, QString> m_aesNameMap;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool isFiltered(const NotificationEx &data, DataModification modType) const override;
|
||||
private slots:
|
||||
void onNotificationChanged(const AlarmManagement::Notification &data,
|
||||
const DataModification modType);
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &participant,
|
||||
const DataModification modType);
|
||||
void onAesItemChanged(const AreaEffectSimulation::AesItem &item,
|
||||
const DataModification modType);
|
||||
void onBCContaminationChanged(const AreaEffectSimulation::BCContamination &data,
|
||||
const DataModification modType);
|
||||
void onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap &data,
|
||||
const DataModification modType);
|
||||
void onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine &data,
|
||||
const DataModification modType);
|
||||
|
||||
private:
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
|
||||
QMap<int, int> m_partId2EquipNoMap;
|
||||
QHash<int, QString> m_idDesignatorMap;
|
||||
QHash<int, QString> m_idTactIdentifierMap;
|
||||
QHash<int, QString> m_aesNameMap;
|
||||
|
||||
friend class AlarmHistoryProxyModel;
|
||||
friend class AlarmHistoryProxyModel;
|
||||
};
|
||||
|
||||
class ALMCOMMON_EXPORT AlarmHistoryProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
private:
|
||||
AlarmHistoryModel *m_sourceModel = nullptr;
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel* sourceModel) override;
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override;
|
||||
|
||||
private:
|
||||
AlarmHistoryModel* m_sourceModel = nullptr;
|
||||
};
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+225
-249
@@ -1,311 +1,287 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_dialog.h"
|
||||
#include <utility>
|
||||
#include "ui_alm_dialog.h"
|
||||
|
||||
#include "alm_history.h"
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_config_alarm_model.h>
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_history_alarm_model.h>
|
||||
#include "ui_alm_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <ProjectDataManagement/pdm_enums.hpp>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_config_alarm_model.h>
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_history_alarm_model.h>
|
||||
#include <ProjectDataManagement/pdm_enums.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
AlarmDialog::AlarmDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_configAlarmModel(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_ui(new Ui::AlarmDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_operatorId(-1)
|
||||
AlarmDialog::AlarmDialog(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_configAlarmModel(nullptr),
|
||||
m_dtc(nullptr), m_ftc(nullptr), m_ui(new Ui::AlarmDialog), m_requestHelper(new LtsUtils::RequestHelper(this)),
|
||||
m_operatorId(-1)
|
||||
{
|
||||
AlarmCheckBox alarmCheckBox;
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
AlarmCheckBox alarmCheckBox;
|
||||
LtsUtils::ProjectSettings* ps = LtsUtils::ProjectSettings::getInstance();
|
||||
|
||||
const bool enableNuclearContaminations = ps->value(QLatin1String("aes"),
|
||||
QLatin1String("enableNuclearContaminations")).toBool();
|
||||
const bool enableDangerAreas = ps->value(QLatin1String("aes"),
|
||||
QLatin1String("enableDangerAreas")).toBool();
|
||||
const bool enableMineAreas = ps->value(QLatin1String("aes"),
|
||||
QLatin1String("enableMineAreas")).toBool();
|
||||
const bool enableNuclearContaminations =
|
||||
ps->value(QLatin1String("aes"), QLatin1String("enableNuclearContaminations")).toBool();
|
||||
const bool enableDangerAreas = ps->value(QLatin1String("aes"), QLatin1String("enableDangerAreas")).toBool();
|
||||
const bool enableMineAreas = ps->value(QLatin1String("aes"), QLatin1String("enableMineAreas")).toBool();
|
||||
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
if (!enableNuclearContaminations)
|
||||
{
|
||||
m_ui->lblNAgentEntry->hide();
|
||||
m_ui->cbxNMarker->hide();
|
||||
m_ui->cbxNMessage->hide();
|
||||
}
|
||||
if (!enableNuclearContaminations)
|
||||
{
|
||||
m_ui->lblNAgentEntry->hide();
|
||||
m_ui->cbxNMarker->hide();
|
||||
m_ui->cbxNMessage->hide();
|
||||
}
|
||||
|
||||
if (!enableDangerAreas)
|
||||
{
|
||||
m_ui->lblDangerAreaEntry->hide();
|
||||
m_ui->cbxDanerAreaMarker->hide();
|
||||
m_ui->cbxDangerAreaMessage->hide();
|
||||
}
|
||||
if (!enableMineAreas)
|
||||
{
|
||||
m_ui->lblMineAreaEntry->hide();
|
||||
m_ui->cbxMineAreaEntryMarker->hide();
|
||||
m_ui->cbxMineAreaEntryMessage->hide();
|
||||
m_ui->lblMineAreaHit->hide();
|
||||
m_ui->cbxMineAreaHitMarker->hide();
|
||||
m_ui->cbxMineAreaHitMessage->hide();
|
||||
}
|
||||
if (!enableDangerAreas)
|
||||
{
|
||||
m_ui->lblDangerAreaEntry->hide();
|
||||
m_ui->cbxDanerAreaMarker->hide();
|
||||
m_ui->cbxDangerAreaMessage->hide();
|
||||
}
|
||||
if (!enableMineAreas)
|
||||
{
|
||||
m_ui->lblMineAreaEntry->hide();
|
||||
m_ui->cbxMineAreaEntryMarker->hide();
|
||||
m_ui->cbxMineAreaEntryMessage->hide();
|
||||
m_ui->lblMineAreaHit->hide();
|
||||
m_ui->cbxMineAreaHitMarker->hide();
|
||||
m_ui->cbxMineAreaHitMessage->hide();
|
||||
}
|
||||
|
||||
alarmCheckBox.name = QLatin1String("NuclearAgentEntry");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxNMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxNMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::EnterNuclear;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("NuclearAgentEntry");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxNMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxNMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::EnterNuclear;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("DangerAreasEntry");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxDanerAreaMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxDangerAreaMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::EnterDangerArea;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("DangerAreasEntry");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxDanerAreaMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxDangerAreaMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::EnterDangerArea;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("MineAreaEntry");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxMineAreaEntryMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxMineAreaEntryMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::EnterMineArea;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("MineAreaEntry");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxMineAreaEntryMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxMineAreaEntryMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::EnterMineArea;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("MineAreaHit");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxMineAreaHitMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxMineAreaHitMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::HitMine;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("MineAreaHit");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxMineAreaHitMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxMineAreaHitMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::HitMine;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("DirectFire");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxDirectFireMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxDirectFireMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::Hit;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("DirectFire");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxDirectFireMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxDirectFireMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::Hit;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("IndirectFire");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxIndirectFireMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxIndirectFireMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::HitEffectSimulation;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("IndirectFire");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxIndirectFireMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxIndirectFireMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::HitEffectSimulation;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("CrossLocalBorderlines");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxLocalBorderMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxLocalBorderMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::CrossLocalBorderline;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("CrossLocalBorderlines");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxLocalBorderMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxLocalBorderMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::CrossLocalBorderline;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("CrossGlobalBorderlines");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxGlobalBorderMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxGlobalBorderMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::CrossGlobalBorderline;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("CrossGlobalBorderlines");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxGlobalBorderMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxGlobalBorderMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::CrossGlobalBorderline;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("AirSupport");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxAirSupportMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxAirSupportMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::AirSupport;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("AirSupport");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxAirSupportMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxAirSupportMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::AirSupport;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
setOnlineHelpFilename(QLatin1String("Situation-Configure_Global_Alarms"));
|
||||
setOnlineHelpFilename(QLatin1String("Situation-Configure_Global_Alarms"));
|
||||
}
|
||||
|
||||
AlarmDialog::~AlarmDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool AlarmDialog::init(const std::shared_ptr<AlarmManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
AlarmHistoryModel *alarmHistoryModel)
|
||||
bool AlarmDialog::init(const std::shared_ptr<AlarmManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
AlarmHistoryModel* alarmHistoryModel)
|
||||
{
|
||||
if (!ftc)
|
||||
return false;
|
||||
if (!dtc)
|
||||
return false;
|
||||
if (!ppmDtc)
|
||||
return false;
|
||||
if (!ftc)
|
||||
return false;
|
||||
if (!dtc)
|
||||
return false;
|
||||
if (!ppmDtc)
|
||||
return false;
|
||||
|
||||
m_operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
m_operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
|
||||
m_ftc = ftc;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_dtc = dtc;
|
||||
|
||||
connect(m_dtc.get(), &AlarmManagement::Interface::Dtc::alarmConfigChanged,
|
||||
this, &AlarmDialog::onAlarmConfigChanged);
|
||||
m_dtc->enableAlarmConfig();
|
||||
connect(m_dtc.get(), &AlarmManagement::Interface::Dtc::alarmConfigChanged, this,
|
||||
&AlarmDialog::onAlarmConfigChanged);
|
||||
m_dtc->enableAlarmConfig();
|
||||
|
||||
auto cbConfig = [this](const AlarmManagement::AlarmConfig & c)
|
||||
{
|
||||
onAlarmConfigChanged(c, DataModification::eAdded);
|
||||
};
|
||||
m_dtc->alarmConfigs(cbConfig);
|
||||
auto cbConfig = [this](const AlarmManagement::AlarmConfig& c) {
|
||||
onAlarmConfigChanged(c, DataModification::eAdded);
|
||||
};
|
||||
m_dtc->alarmConfigs(cbConfig);
|
||||
|
||||
delete m_configAlarmModel;
|
||||
m_configAlarmModel = new AlarmManagement::ConfigAlarmModel(this);
|
||||
bool global = true;
|
||||
m_configAlarmModel->initModel(m_dtc, ppmDtc, alarmHistoryModel, global);
|
||||
delete m_configAlarmModel;
|
||||
m_configAlarmModel = new AlarmManagement::ConfigAlarmModel(this);
|
||||
bool global = true;
|
||||
m_configAlarmModel->initModel(m_dtc, ppmDtc, alarmHistoryModel, global);
|
||||
|
||||
INFO_LOG(m_logger) << "AlarmDialog::init";
|
||||
return true;
|
||||
INFO_LOG(m_logger) << "AlarmDialog::init";
|
||||
return true;
|
||||
}
|
||||
|
||||
void AlarmDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Configure Global Alarms"));
|
||||
translate(m_ui, tr("Configure Global Alarms"));
|
||||
}
|
||||
|
||||
void AlarmDialog::onAlarmConfigChanged(const AlarmManagement::AlarmConfig &data, DataModification modType)
|
||||
void AlarmDialog::onAlarmConfigChanged(const AlarmManagement::AlarmConfig& data, DataModification modType)
|
||||
{
|
||||
bool setMarker = data.setMarker();
|
||||
bool messageWindow = data.messageWindow();
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
bool setMarker = data.setMarker();
|
||||
bool messageWindow = data.messageWindow();
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "************** onAlarmConfigChanged "
|
||||
<< " id=" << data.id()
|
||||
<< " operatorId=" << data.operatorId()
|
||||
<< " m_operatorId=" << m_operatorId
|
||||
<< " participantId=" << data.participantId()
|
||||
<< " eventTypeId=" << data.eventTypeId()
|
||||
<< " messageWindow=" << messageWindow
|
||||
<< " setMarker=" << setMarker;
|
||||
if (data.global() == false)
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "************** onAlarmConfigChanged "
|
||||
<< " id=" << data.id() << " operatorId=" << data.operatorId()
|
||||
<< " m_operatorId=" << m_operatorId << " participantId=" << data.participantId()
|
||||
<< " eventTypeId=" << data.eventTypeId() << " messageWindow=" << messageWindow
|
||||
<< " setMarker=" << setMarker;
|
||||
if (data.global() == false)
|
||||
return;
|
||||
|
||||
if (data.operatorId() == m_operatorId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "************** onAlarmConfig zuweisen ";
|
||||
switch (data.eventTypeId().underlying())
|
||||
if (data.operatorId() == m_operatorId)
|
||||
{
|
||||
case ProjectDataManagement::EventType_def::EnterNuclear:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "EnterNuclear zuweisen ";
|
||||
m_ui->cbxNMarker->setChecked(setMarker);
|
||||
m_ui->cbxNMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::EnterDangerArea:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "EnterDangerArea zuweisen ";
|
||||
m_ui->cbxDanerAreaMarker->setChecked(setMarker);
|
||||
m_ui->cbxDangerAreaMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::EnterMineArea:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "EnterMineArea zuweisen ";
|
||||
m_ui->cbxMineAreaEntryMarker->setChecked(setMarker);
|
||||
m_ui->cbxMineAreaEntryMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitMine:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "HitMine zuweisen ";
|
||||
m_ui->cbxMineAreaHitMarker->setChecked(setMarker);
|
||||
m_ui->cbxMineAreaHitMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "************** onAlarmConfig zuweisen ";
|
||||
switch (data.eventTypeId().underlying())
|
||||
{
|
||||
case ProjectDataManagement::EventType_def::EnterNuclear: {
|
||||
DEBUG_LOG(m_logger) << "EnterNuclear zuweisen ";
|
||||
m_ui->cbxNMarker->setChecked(setMarker);
|
||||
m_ui->cbxNMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::EnterDangerArea: {
|
||||
DEBUG_LOG(m_logger) << "EnterDangerArea zuweisen ";
|
||||
m_ui->cbxDanerAreaMarker->setChecked(setMarker);
|
||||
m_ui->cbxDangerAreaMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::EnterMineArea: {
|
||||
DEBUG_LOG(m_logger) << "EnterMineArea zuweisen ";
|
||||
m_ui->cbxMineAreaEntryMarker->setChecked(setMarker);
|
||||
m_ui->cbxMineAreaEntryMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitMine: {
|
||||
DEBUG_LOG(m_logger) << "HitMine zuweisen ";
|
||||
m_ui->cbxMineAreaHitMarker->setChecked(setMarker);
|
||||
m_ui->cbxMineAreaHitMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
|
||||
case ProjectDataManagement::EventType_def::Hit:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Hit zuweisen ";
|
||||
m_ui->cbxDirectFireMarker->setChecked(setMarker);
|
||||
m_ui->cbxDirectFireMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitEffectSimulation:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "HitEffectSimulation zuweisen ";
|
||||
m_ui->cbxIndirectFireMarker->setChecked(setMarker);
|
||||
m_ui->cbxIndirectFireMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::Hit: {
|
||||
DEBUG_LOG(m_logger) << "Hit zuweisen ";
|
||||
m_ui->cbxDirectFireMarker->setChecked(setMarker);
|
||||
m_ui->cbxDirectFireMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitEffectSimulation: {
|
||||
DEBUG_LOG(m_logger) << "HitEffectSimulation zuweisen ";
|
||||
m_ui->cbxIndirectFireMarker->setChecked(setMarker);
|
||||
m_ui->cbxIndirectFireMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
|
||||
case ProjectDataManagement::EventType_def::CrossLocalBorderline:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CrossLocalBorderline zuweisen ";
|
||||
m_ui->cbxLocalBorderMarker->setChecked(setMarker);
|
||||
m_ui->cbxLocalBorderMessage->setChecked(messageWindow);
|
||||
break;
|
||||
case ProjectDataManagement::EventType_def::CrossLocalBorderline: {
|
||||
DEBUG_LOG(m_logger) << "CrossLocalBorderline zuweisen ";
|
||||
m_ui->cbxLocalBorderMarker->setChecked(setMarker);
|
||||
m_ui->cbxLocalBorderMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::CrossGlobalBorderline: {
|
||||
DEBUG_LOG(m_logger) << "CrossGlobalBorderline zuweisen ";
|
||||
m_ui->cbxGlobalBorderMarker->setChecked(setMarker);
|
||||
m_ui->cbxGlobalBorderMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::AirSupport: {
|
||||
DEBUG_LOG(m_logger) << "AirSupport zuweisen ";
|
||||
m_ui->cbxAirSupportMarker->setChecked(setMarker);
|
||||
m_ui->cbxAirSupportMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ERROR_LOG(m_logger) << "Not possible to set with Operator App!!!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::CrossGlobalBorderline:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CrossGlobalBorderline zuweisen ";
|
||||
m_ui->cbxGlobalBorderMarker->setChecked(setMarker);
|
||||
m_ui->cbxGlobalBorderMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::AirSupport:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "AirSupport zuweisen ";
|
||||
m_ui->cbxAirSupportMarker->setChecked(setMarker);
|
||||
m_ui->cbxAirSupportMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ERROR_LOG(m_logger) << "Not possible to set with Operator App!!!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::vector<AlarmManagement::AlarmAction> AlarmDialog::getCheckedValues() const
|
||||
{
|
||||
AlarmManagement::AlarmAction alarmActionDds;
|
||||
std::vector<AlarmManagement::AlarmAction> ret;
|
||||
ret.clear();
|
||||
ret.reserve(m_checkBoxes.size());
|
||||
for (const AlarmCheckBox &item : std::as_const(m_checkBoxes))
|
||||
{
|
||||
alarmActionDds.eventTypeId(item.eventTypeId);
|
||||
if (item.checkboxMarker->isChecked())
|
||||
AlarmManagement::AlarmAction alarmActionDds;
|
||||
std::vector<AlarmManagement::AlarmAction> ret;
|
||||
ret.clear();
|
||||
ret.reserve(m_checkBoxes.size());
|
||||
for (const AlarmCheckBox& item : std::as_const(m_checkBoxes))
|
||||
{
|
||||
alarmActionDds.setMarker(true);
|
||||
DEBUG_LOG(m_logger) << item.name << " setMarker = true";
|
||||
alarmActionDds.eventTypeId(item.eventTypeId);
|
||||
if (item.checkboxMarker->isChecked())
|
||||
{
|
||||
alarmActionDds.setMarker(true);
|
||||
DEBUG_LOG(m_logger) << item.name << " setMarker = true";
|
||||
}
|
||||
else
|
||||
{
|
||||
alarmActionDds.setMarker(false);
|
||||
DEBUG_LOG(m_logger) << item.name << " setMarker = false";
|
||||
}
|
||||
if (item.checkboxWindow->isChecked())
|
||||
{
|
||||
alarmActionDds.messageWindow(true);
|
||||
DEBUG_LOG(m_logger) << item.name << " messageWindow = true";
|
||||
}
|
||||
else
|
||||
{
|
||||
alarmActionDds.messageWindow(false);
|
||||
DEBUG_LOG(m_logger) << item.name << " messageWindow = false";
|
||||
}
|
||||
if (alarmActionDds.setMarker() || alarmActionDds.messageWindow())
|
||||
ret.push_back(alarmActionDds);
|
||||
}
|
||||
else
|
||||
{
|
||||
alarmActionDds.setMarker(false);
|
||||
DEBUG_LOG(m_logger) << item.name << " setMarker = false";
|
||||
}
|
||||
if (item.checkboxWindow->isChecked())
|
||||
{
|
||||
alarmActionDds.messageWindow(true);
|
||||
DEBUG_LOG(m_logger) << item.name << " messageWindow = true";
|
||||
}
|
||||
else
|
||||
{
|
||||
alarmActionDds.messageWindow(false);
|
||||
DEBUG_LOG(m_logger) << item.name << " messageWindow = false";
|
||||
}
|
||||
if (alarmActionDds.setMarker() || alarmActionDds.messageWindow())
|
||||
ret.push_back(alarmActionDds);
|
||||
}
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool AlarmDialog::apply()
|
||||
{
|
||||
std::vector<int32_t> participantIds;
|
||||
participantIds.push_back(0);
|
||||
bool globalEvent = true;
|
||||
bool remove = false;
|
||||
const ConfigureAlarmsRequest req(getCheckedValues(), m_operatorId, participantIds, globalEvent, remove);
|
||||
std::vector<int32_t> participantIds;
|
||||
participantIds.push_back(0);
|
||||
bool globalEvent = true;
|
||||
bool remove = false;
|
||||
const ConfigureAlarmsRequest req(getCheckedValues(), m_operatorId, participantIds, globalEvent, remove);
|
||||
|
||||
return m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->configureAlarmsRequest(req, this);
|
||||
});
|
||||
}
|
||||
}
|
||||
return m_requestHelper->startSingleRequest([req, this]() { return m_ftc->configureAlarmsRequest(req, this); });
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+85
-106
@@ -1,163 +1,142 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_history.h"
|
||||
|
||||
#include "ui_alm_history.h"
|
||||
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_history_alarm_model.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_history_alarm_model.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
AlarmView::AlarmView(LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_alarmHistoryModel(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_sitMapGuiIfc(nullptr)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::AlarmView)
|
||||
AlarmView::AlarmView(LtsSession::LtsSession* session, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_alarmHistoryModel(nullptr),
|
||||
m_dtc(nullptr), m_sitMapGuiIfc(nullptr), m_session(session), m_ui(new Ui::AlarmView)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " --- AlarmView Konstruktor() ";
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " --- AlarmView Konstruktor() ";
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &AlarmView::onSelectionChanged);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &AlarmView::onSelectionChanged);
|
||||
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &AlarmView::onShowAlarm);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &AlarmView::onShowAlarm);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print,
|
||||
this, &AlarmView::onPrint);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &AlarmView::onRemoveAlarm);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &AlarmView::onPrint);
|
||||
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &AlarmView::onCenterAlarm);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &AlarmView::onRemoveAlarm);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Alarm_History"));
|
||||
|
||||
}
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &AlarmView::onCenterAlarm);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Alarm_History"));
|
||||
}
|
||||
|
||||
AlarmView::~AlarmView()
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- AlarmView Destruktor() ";
|
||||
m_sitMapGuiIfc = nullptr;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "--- AlarmView Destruktor() ";
|
||||
m_sitMapGuiIfc = nullptr;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void AlarmView::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Alarm History"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setText(tr("Center Map"));
|
||||
translate(m_ui, tr("Alarm History"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setText(tr("Center Map"));
|
||||
}
|
||||
|
||||
bool AlarmView::init(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
AlarmHistoryModel *alarmHistoryModel)
|
||||
bool AlarmView::init(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc, AlarmHistoryModel* alarmHistoryModel)
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- init() ";
|
||||
if (!dtc)
|
||||
return false;
|
||||
INFO_LOG(m_logger) << "--- init() ";
|
||||
if (!dtc)
|
||||
return false;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_alarmHistoryModel = alarmHistoryModel;
|
||||
|
||||
DEBUG_LOG(m_logger) << "--- AlarmView::init ";
|
||||
m_proxyModel = new AlarmHistoryProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_alarmHistoryModel);
|
||||
m_ui->widget->setModel(m_proxyModel);
|
||||
m_dtc = dtc;
|
||||
m_alarmHistoryModel = alarmHistoryModel;
|
||||
|
||||
DEBUG_LOG(m_logger) << "--- AlarmView::init ";
|
||||
m_proxyModel = new AlarmHistoryProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_alarmHistoryModel);
|
||||
m_ui->widget->setModel(m_proxyModel);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::Id);
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::ParticipantId);
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::AesId);
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::Id);
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::ParticipantId);
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::AesId);
|
||||
#endif
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
return true;
|
||||
}
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AlarmView::onSelectionChanged()
|
||||
{
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, cntSelectedRows > 0);
|
||||
}
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, cntSelectedRows > 0);
|
||||
}
|
||||
|
||||
void AlarmView::onShowAlarm()
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- onShowMAlarm() ";
|
||||
}
|
||||
|
||||
|
||||
INFO_LOG(m_logger) << "--- onShowMAlarm() ";
|
||||
}
|
||||
|
||||
void AlarmView::onRemoveAlarm()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onRemoveAlarm selectedRows.size"
|
||||
<< m_ui->widget->selectedRows().size();
|
||||
|
||||
const QModelIndexList idxList = m_ui->widget->selectedRows();
|
||||
QVector<int> rowsToRemove;
|
||||
rowsToRemove.reserve(idxList.size());
|
||||
for (const auto &idx : idxList)
|
||||
rowsToRemove.push_back(idx.row());
|
||||
std::sort(rowsToRemove.begin(), rowsToRemove.end(), std::greater<int>());
|
||||
for (int i = 0; i < rowsToRemove.length(); i++)
|
||||
m_alarmHistoryModel->removeRow(rowsToRemove.at(i));
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "onRemoveAlarm selectedRows.size" << m_ui->widget->selectedRows().size();
|
||||
|
||||
const QModelIndexList idxList = m_ui->widget->selectedRows();
|
||||
QVector<int> rowsToRemove;
|
||||
rowsToRemove.reserve(idxList.size());
|
||||
for (const auto& idx : idxList)
|
||||
rowsToRemove.push_back(idx.row());
|
||||
std::sort(rowsToRemove.begin(), rowsToRemove.end(), std::greater<int>());
|
||||
for (int i = 0; i < rowsToRemove.length(); i++)
|
||||
m_alarmHistoryModel->removeRow(rowsToRemove.at(i));
|
||||
}
|
||||
|
||||
void AlarmView::onCenterAlarm()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onCenterAlarm";
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
const QModelIndexList indexList = m_ui->widget->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return;
|
||||
const QModelIndex &index = indexList.first();
|
||||
DEBUG_LOG(m_logger) << "onCenterAlarm";
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
const QModelIndexList indexList = m_ui->widget->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return;
|
||||
const QModelIndex& index = indexList.first();
|
||||
|
||||
const QModelIndex indexPosi = m_alarmHistoryModel->index(index.row(), AlarmHistoryModel::Position, index.parent());
|
||||
const QPointF &position = indexPosi.data(Qt::UserRole).toPointF();
|
||||
const QModelIndex indexPosi = m_alarmHistoryModel->index(index.row(), AlarmHistoryModel::Position, index.parent());
|
||||
const QPointF& position = indexPosi.data(Qt::UserRole).toPointF();
|
||||
|
||||
if (!position.isNull())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " position=" << position.x() << " - " << position.y();
|
||||
m_sitMapGuiIfc->setCenterPoint(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QModelIndex &indexParticipantId = m_alarmHistoryModel->index(index.row(), AlarmHistoryModel::ParticipantId, index.parent());
|
||||
const int participantId = indexParticipantId.data().toInt();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " participantId=" << participantId;
|
||||
m_sitMapGuiIfc->centerMapToParticipant(participantId);
|
||||
}
|
||||
}
|
||||
if (!position.isNull())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " position=" << position.x() << " - " << position.y();
|
||||
m_sitMapGuiIfc->setCenterPoint(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QModelIndex& indexParticipantId =
|
||||
m_alarmHistoryModel->index(index.row(), AlarmHistoryModel::ParticipantId, index.parent());
|
||||
const int participantId = indexParticipantId.data().toInt();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " participantId=" << participantId;
|
||||
m_sitMapGuiIfc->centerMapToParticipant(participantId);
|
||||
}
|
||||
}
|
||||
|
||||
void AlarmView::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
}
|
||||
|
||||
void AlarmView::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+24
-26
@@ -1,18 +1,18 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AlarmManagement/alm_dtc.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AlarmView;
|
||||
}
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
class AlarmHistoryModel;
|
||||
@@ -20,33 +20,31 @@ class AlarmHistoryProxyModel;
|
||||
|
||||
class AlarmView final : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlarmView(LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~AlarmView();
|
||||
bool init(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
AlarmHistoryModel *alarmHistoryModel);
|
||||
public:
|
||||
explicit AlarmView(LtsSession::LtsSession* session, QWidget* parent = nullptr);
|
||||
~AlarmView();
|
||||
bool init(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc, AlarmHistoryModel* alarmHistoryModel);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onShowAlarm();
|
||||
void onRemoveAlarm();
|
||||
void onCenterAlarm();
|
||||
void onPrint();
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onShowAlarm();
|
||||
void onRemoveAlarm();
|
||||
void onCenterAlarm();
|
||||
void onPrint();
|
||||
void tableColumnOrganiserSetting() override;
|
||||
private:
|
||||
AlarmHistoryModel* m_alarmHistoryModel;
|
||||
AlarmHistoryProxyModel* m_proxyModel;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
|
||||
private:
|
||||
AlarmHistoryModel *m_alarmHistoryModel;
|
||||
AlarmHistoryProxyModel *m_proxyModel;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
Ui::AlarmView *m_ui;
|
||||
LtsSession::LtsSession* m_session;
|
||||
Ui::AlarmView* m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+240
-254
@@ -1,320 +1,306 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include "alm_config_participant_dialog.h"
|
||||
|
||||
#include "ui_alm_config_participant_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
#include <ParticipantManagement/Gui/Common/participant_vulnerability_types.h>
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
ConfigParticipantsDialog::ConfigParticipantsDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::ConfigParticipantsDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_typeClass(ParticipantManagement::TypeClass::Human)
|
||||
, m_logger(AlarmManagement::getLogger("ConfigParticipantsDialog"))
|
||||
ConfigParticipantsDialog::ConfigParticipantsDialog(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel),
|
||||
m_ui(new Ui::ConfigParticipantsDialog), m_requestHelper(new LtsUtils::RequestHelper(this)),
|
||||
m_typeClass(ParticipantManagement::TypeClass::Human),
|
||||
m_logger(AlarmManagement::getLogger("ConfigParticipantsDialog"))
|
||||
{
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
LtsUtils::ProjectSettings* ps = LtsUtils::ProjectSettings::getInstance();
|
||||
|
||||
const bool enableNuclearContaminations = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableNuclearContaminations")).toBool();
|
||||
const bool enableMineAreas = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableMineAreas")).toBool();
|
||||
m_ui->setupUi(this);
|
||||
const bool enableNuclearContaminations =
|
||||
ps->value(QStringLiteral("aes"), QStringLiteral("enableNuclearContaminations")).toBool();
|
||||
const bool enableMineAreas = ps->value(QStringLiteral("aes"), QStringLiteral("enableMineAreas")).toBool();
|
||||
m_ui->setupUi(this);
|
||||
|
||||
if (!enableNuclearContaminations)
|
||||
{
|
||||
m_ui->cbxNbcAgent->hide();
|
||||
}
|
||||
if (!enableMineAreas)
|
||||
{
|
||||
m_ui->cbxMines->hide();
|
||||
m_ui->cbxIndirectFire->hide();
|
||||
}
|
||||
if (!enableNuclearContaminations)
|
||||
{
|
||||
m_ui->cbxNbcAgent->hide();
|
||||
}
|
||||
if (!enableMineAreas)
|
||||
{
|
||||
m_ui->cbxMines->hide();
|
||||
m_ui->cbxIndirectFire->hide();
|
||||
}
|
||||
|
||||
#ifdef ETS_MODE
|
||||
|
||||
m_ui->cbxFriendlyFire->hide();
|
||||
m_ui->cbStatusFriendly->hide();
|
||||
|
||||
m_ui->cbxFriendlyFire->hide();
|
||||
m_ui->cbStatusFriendly->hide();
|
||||
#endif
|
||||
|
||||
setNoTopicLock();
|
||||
setNoTopicLock();
|
||||
}
|
||||
|
||||
ConfigParticipantsDialog::~ConfigParticipantsDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ConfigParticipantsDialog::retranslate()
|
||||
{
|
||||
if (!m_participantData.equipmentNumber().is_set())
|
||||
{
|
||||
QString hierarchy = m_ppmDtc->hierarchyFromParticipant(m_participantData.id());
|
||||
translate(m_ui, m_participantData, hierarchy, tr("Participant Alarm"));
|
||||
}
|
||||
else
|
||||
translate(m_ui, m_participantData, QString::number(m_participantData.equipmentNumber().get()), tr("Participant Alarm"));
|
||||
if (!m_participantData.equipmentNumber().is_set())
|
||||
{
|
||||
QString hierarchy = m_ppmDtc->hierarchyFromParticipant(m_participantData.id());
|
||||
translate(m_ui, m_participantData, hierarchy, tr("Participant Alarm"));
|
||||
}
|
||||
else
|
||||
translate(m_ui, m_participantData, QString::number(m_participantData.equipmentNumber().get()),
|
||||
tr("Participant Alarm"));
|
||||
|
||||
m_uiRequirements->clear();
|
||||
m_uiRequirements->addRequirement( { m_ui->lbReaction, [this]() { return m_ui->cbxSetMarker->isChecked() || m_ui->cbxMessageWindow->isChecked(); }, tr("Select at least one reaction") });
|
||||
m_uiRequirements->clear();
|
||||
m_uiRequirements->addRequirement(
|
||||
{m_ui->lbReaction, [this]() { return m_ui->cbxSetMarker->isChecked() || m_ui->cbxMessageWindow->isChecked(); },
|
||||
tr("Select at least one reaction")});
|
||||
}
|
||||
|
||||
bool ConfigParticipantsDialog::init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc> &almFtc,
|
||||
const ParticipantManagement::ParticipantData &participantData,
|
||||
const std::vector<int> &participantVector,
|
||||
const std::vector<int> &equipmentVector)
|
||||
bool ConfigParticipantsDialog::init(const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc>& almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc>& almFtc,
|
||||
const ParticipantManagement::ParticipantData& participantData,
|
||||
const std::vector<int>& participantVector, const std::vector<int>& equipmentVector)
|
||||
{
|
||||
if (!ppmDtc || !almDtc || !almFtc)
|
||||
return false;
|
||||
if (!ppmDtc || !almDtc || !almFtc)
|
||||
return false;
|
||||
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_almFtc = almFtc;
|
||||
m_almDtc = almDtc;
|
||||
m_participantVector = participantVector;
|
||||
m_participantData = participantData;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_almFtc = almFtc;
|
||||
m_almDtc = almDtc;
|
||||
m_participantVector = participantVector;
|
||||
m_participantData = participantData;
|
||||
|
||||
m_operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
m_operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
|
||||
m_ui->lbHierarchy->setText(m_ppmDtc->hierarchyFromParticipant(m_participantData.id()));
|
||||
m_ui->lbHierarchy->setText(m_ppmDtc->hierarchyFromParticipant(m_participantData.id()));
|
||||
|
||||
QString equipmentNumbersStr;
|
||||
if (participantData.equipmentNumber().is_set())
|
||||
{
|
||||
equipmentNumbersStr.append(QString::number(participantData.equipmentNumber().get()));
|
||||
equipmentNumbersStr.append(QStringLiteral(": "));
|
||||
}
|
||||
QString equipmentNumbersStr;
|
||||
if (participantData.equipmentNumber().is_set())
|
||||
{
|
||||
equipmentNumbersStr.append(QString::number(participantData.equipmentNumber().get()));
|
||||
equipmentNumbersStr.append(QStringLiteral(": "));
|
||||
}
|
||||
|
||||
for (const int equipNo : equipmentVector)
|
||||
equipmentNumbersStr += QString::number(equipNo) + QStringLiteral(", ");
|
||||
equipmentNumbersStr.chop(2);
|
||||
for (const int equipNo : equipmentVector)
|
||||
equipmentNumbersStr += QString::number(equipNo) + QStringLiteral(", ");
|
||||
equipmentNumbersStr.chop(2);
|
||||
|
||||
m_ui->equipmentNoContent->setText(equipmentNumbersStr);
|
||||
m_ui->equipmentNoContent->setText(equipmentNumbersStr);
|
||||
|
||||
DEBUG_LOG(m_logger) << "current participantId = " << participantData.id();
|
||||
DEBUG_LOG(m_logger) << "current participantId = " << participantData.id();
|
||||
|
||||
m_typeClass = ppmDtc->type(participantData.typeId()).typeClass();
|
||||
DEBUG_LOG(m_logger) << "m_typeClass=" << m_typeClass << " TypeId=" << participantData.typeId();
|
||||
fillCbx();
|
||||
m_typeClass = ppmDtc->type(participantData.typeId()).typeClass();
|
||||
DEBUG_LOG(m_logger) << "m_typeClass=" << m_typeClass << " TypeId=" << participantData.typeId();
|
||||
fillCbx();
|
||||
|
||||
m_almDtc->alarmConfigs([this](const AlarmManagement::AlarmConfig &alarm) { setAlaramData(alarm); });
|
||||
return true;
|
||||
m_almDtc->alarmConfigs([this](const AlarmManagement::AlarmConfig& alarm) { setAlaramData(alarm); });
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConfigParticipantsDialog::setAlaramData(const AlarmManagement::AlarmConfig &alarm)
|
||||
void ConfigParticipantsDialog::setAlaramData(const AlarmManagement::AlarmConfig& alarm)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setAlaramData:" << alarm;
|
||||
if (alarm.operatorId() != m_operatorId ||
|
||||
alarm.participantId() != m_participantData.id() ||
|
||||
alarm.global())
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "setAlaramData:" << alarm;
|
||||
if (alarm.operatorId() != m_operatorId || alarm.participantId() != m_participantData.id() || alarm.global())
|
||||
return;
|
||||
|
||||
switch (alarm.eventTypeId().underlying())
|
||||
{
|
||||
case ProjectDataManagement::EventType_def::Hit:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Hit zuweisen ";
|
||||
m_ui->cbxDirectFire->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
if (alarm.vulnerabilityState() >= 0)
|
||||
switch (alarm.eventTypeId().underlying())
|
||||
{
|
||||
ProjectDataManagement::VulnerabilityState vulState = static_cast<ProjectDataManagement::VulnerabilityState_def::type>(alarm.vulnerabilityState());
|
||||
int index = m_ui->cbStatusDirect->findData(QVariant(vulState.underlying()));
|
||||
m_ui->cbStatusDirect->setCurrentIndex(index);
|
||||
case ProjectDataManagement::EventType_def::Hit: {
|
||||
DEBUG_LOG(m_logger) << "Hit zuweisen ";
|
||||
m_ui->cbxDirectFire->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
if (alarm.vulnerabilityState() >= 0)
|
||||
{
|
||||
ProjectDataManagement::VulnerabilityState vulState =
|
||||
static_cast<ProjectDataManagement::VulnerabilityState_def::type>(alarm.vulnerabilityState());
|
||||
int index = m_ui->cbStatusDirect->findData(QVariant(vulState.underlying()));
|
||||
m_ui->cbStatusDirect->setCurrentIndex(index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitEffectSimulation: {
|
||||
DEBUG_LOG(m_logger) << "HitIndirect zuweisen ";
|
||||
m_ui->cbxIndirectFire->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::AirSupport: {
|
||||
DEBUG_LOG(m_logger) << "AirSupport zuweisen ";
|
||||
m_ui->cbxAirSupport->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitMine: {
|
||||
DEBUG_LOG(m_logger) << "HitMine zuweisen ";
|
||||
m_ui->cbxMines->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitB:
|
||||
case ProjectDataManagement::EventType_def::HitN:
|
||||
case ProjectDataManagement::EventType_def::HitC: {
|
||||
DEBUG_LOG(m_logger) << "Hit N/B/C zuweisen ";
|
||||
m_ui->cbxNbcAgent->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::FriendlyFire: {
|
||||
DEBUG_LOG(m_logger) << "FriendlyFire zuweisen ";
|
||||
m_ui->cbxFriendlyFire->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
if (alarm.vulnerabilityState() >= 0)
|
||||
{
|
||||
ProjectDataManagement::VulnerabilityState vulState =
|
||||
static_cast<ProjectDataManagement::VulnerabilityState_def::type>(alarm.vulnerabilityState());
|
||||
int index = m_ui->cbStatusDirect->findData(QVariant(vulState.underlying()));
|
||||
m_ui->cbStatusFriendly->setCurrentIndex(index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::Manipulation: {
|
||||
DEBUG_LOG(m_logger) << "Manipulation zuweisen ";
|
||||
m_ui->cbxManipulation->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::CrossGlobalBorderline: {
|
||||
DEBUG_LOG(m_logger) << "CrossGlobalBorderline zuweisen ";
|
||||
m_ui->cbxGlobalBorderLine->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::CrossLocalBorderline: {
|
||||
DEBUG_LOG(m_logger) << "CrossLocalBorderline zuweisen ";
|
||||
m_ui->cbxLocalBorderLine->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ERROR_LOG(m_logger) << "Not possible to set with Operator App!!!";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitEffectSimulation:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "HitIndirect zuweisen ";
|
||||
m_ui->cbxIndirectFire->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::AirSupport:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "AirSupport zuweisen ";
|
||||
m_ui->cbxAirSupport->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitMine:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "HitMine zuweisen ";
|
||||
m_ui->cbxMines->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitB:
|
||||
case ProjectDataManagement::EventType_def::HitN:
|
||||
case ProjectDataManagement::EventType_def::HitC:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Hit N/B/C zuweisen ";
|
||||
m_ui->cbxNbcAgent->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::FriendlyFire:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "FriendlyFire zuweisen ";
|
||||
m_ui->cbxFriendlyFire->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
if (alarm.vulnerabilityState() >= 0)
|
||||
{
|
||||
ProjectDataManagement::VulnerabilityState vulState = static_cast<ProjectDataManagement::VulnerabilityState_def::type>(alarm.vulnerabilityState());
|
||||
int index = m_ui->cbStatusDirect->findData(QVariant(vulState.underlying()));
|
||||
m_ui->cbStatusFriendly->setCurrentIndex(index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::Manipulation:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Manipulation zuweisen ";
|
||||
m_ui->cbxManipulation->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::CrossGlobalBorderline:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CrossGlobalBorderline zuweisen ";
|
||||
m_ui->cbxGlobalBorderLine->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::CrossLocalBorderline:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CrossLocalBorderline zuweisen ";
|
||||
m_ui->cbxLocalBorderLine->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to set with Operator App!!!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<AlarmManagement::AlarmAction> ConfigParticipantsDialog::getCheckedValues() const
|
||||
{
|
||||
AlarmManagement::AlarmAction alarmActionDds;
|
||||
DEBUG_LOG(m_logger) << "getCheckedValues";
|
||||
AlarmManagement::AlarmAction alarmActionDds;
|
||||
DEBUG_LOG(m_logger) << "getCheckedValues";
|
||||
|
||||
std::vector<AlarmManagement::AlarmAction> alarmsDds;
|
||||
std::vector<AlarmManagement::AlarmAction> alarmsDds;
|
||||
|
||||
alarmActionDds.setMarker(m_ui->cbxSetMarker->isChecked());
|
||||
alarmActionDds.messageWindow(m_ui->cbxMessageWindow->isChecked());
|
||||
alarmActionDds.vulnerabilityState(-1);
|
||||
alarmActionDds.setMarker(m_ui->cbxSetMarker->isChecked());
|
||||
alarmActionDds.messageWindow(m_ui->cbxMessageWindow->isChecked());
|
||||
alarmActionDds.vulnerabilityState(-1);
|
||||
|
||||
if (alarmActionDds.setMarker() || alarmActionDds.messageWindow())
|
||||
{
|
||||
if (m_ui->cbxDirectFire->isChecked())
|
||||
if (alarmActionDds.setMarker() || alarmActionDds.messageWindow())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::Hit);
|
||||
int statusDirect = -1;
|
||||
if (m_ui->cbStatusDirect->currentIndex() > 0)
|
||||
statusDirect = m_ui->cbStatusDirect->currentData().toInt();
|
||||
alarmActionDds.vulnerabilityState(statusDirect);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
if (m_ui->cbxDirectFire->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::Hit);
|
||||
int statusDirect = -1;
|
||||
if (m_ui->cbStatusDirect->currentIndex() > 0)
|
||||
statusDirect = m_ui->cbStatusDirect->currentData().toInt();
|
||||
alarmActionDds.vulnerabilityState(statusDirect);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxFriendlyFire->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::FriendlyFire);
|
||||
int statusFriendly = -1;
|
||||
if (m_ui->cbStatusFriendly->currentIndex() > 0)
|
||||
statusFriendly = m_ui->cbStatusFriendly->currentData().toInt();
|
||||
alarmActionDds.vulnerabilityState(statusFriendly);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
alarmActionDds.vulnerabilityState(-1);
|
||||
if (m_ui->cbxIndirectFire->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitEffectSimulation);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxAirSupport->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::AirSupport);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxMines->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitMine);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxNbcAgent->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitN);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitB);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitC);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxManipulation->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::Manipulation);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxGlobalBorderLine->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::CrossGlobalBorderline);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxLocalBorderLine->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::CrossLocalBorderline);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
}
|
||||
if (m_ui->cbxFriendlyFire->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::FriendlyFire);
|
||||
int statusFriendly = -1;
|
||||
if (m_ui->cbStatusFriendly->currentIndex() > 0)
|
||||
statusFriendly = m_ui->cbStatusFriendly->currentData().toInt();
|
||||
alarmActionDds.vulnerabilityState(statusFriendly);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
alarmActionDds.vulnerabilityState(-1);
|
||||
if (m_ui->cbxIndirectFire->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitEffectSimulation);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxAirSupport->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::AirSupport);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxMines->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitMine);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxNbcAgent->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitN);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitB);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitC);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxManipulation->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::Manipulation);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxGlobalBorderLine->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::CrossGlobalBorderline);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxLocalBorderLine->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::CrossLocalBorderline);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
}
|
||||
return alarmsDds;
|
||||
return alarmsDds;
|
||||
}
|
||||
|
||||
bool ConfigParticipantsDialog::apply()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "apply";
|
||||
AlarmManagement::ConfigureAlarmsRequest req;
|
||||
req.participantIds(m_participantVector);
|
||||
req.alarms(getCheckedValues());
|
||||
req.operatorId(m_operatorId);
|
||||
req.global(false);
|
||||
req.remove(false);
|
||||
DEBUG_LOG(m_logger) << "apply";
|
||||
AlarmManagement::ConfigureAlarmsRequest req;
|
||||
req.participantIds(m_participantVector);
|
||||
req.alarms(getCheckedValues());
|
||||
req.operatorId(m_operatorId);
|
||||
req.global(false);
|
||||
req.remove(false);
|
||||
|
||||
return m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_almFtc->configureAlarmsRequest(req, this);
|
||||
});
|
||||
return m_requestHelper->startSingleRequest([req, this]() { return m_almFtc->configureAlarmsRequest(req, this); });
|
||||
}
|
||||
|
||||
void ConfigParticipantsDialog::fillCbx()
|
||||
{
|
||||
m_ui->cbStatusDirect->clear();
|
||||
m_ui->cbStatusFriendly->clear();
|
||||
|
||||
m_ui->cbStatusDirect->addItem(tr("All Types"), -1);
|
||||
m_ui->cbStatusFriendly->addItem(tr("All Types"), -1);
|
||||
ParticipantManagement::insertVulnerabilityStates(m_ui->cbStatusDirect, m_typeClass);
|
||||
ParticipantManagement::insertVulnerabilityStates(m_ui->cbStatusFriendly, m_typeClass);
|
||||
m_ui->cbStatusDirect->removeItem(m_ui->cbStatusDirect->findData(ProjectDataManagement::VulnerabilityState::TemporarySeverance));
|
||||
m_ui->cbStatusFriendly->removeItem(m_ui->cbStatusDirect->findData(ProjectDataManagement::VulnerabilityState::TemporarySeverance));
|
||||
m_ui->cbStatusDirect->clear();
|
||||
m_ui->cbStatusFriendly->clear();
|
||||
|
||||
m_ui->cbStatusDirect->addItem(tr("All Types"), -1);
|
||||
m_ui->cbStatusFriendly->addItem(tr("All Types"), -1);
|
||||
ParticipantManagement::insertVulnerabilityStates(m_ui->cbStatusDirect, m_typeClass);
|
||||
ParticipantManagement::insertVulnerabilityStates(m_ui->cbStatusFriendly, m_typeClass);
|
||||
m_ui->cbStatusDirect->removeItem(
|
||||
m_ui->cbStatusDirect->findData(ProjectDataManagement::VulnerabilityState::TemporarySeverance));
|
||||
m_ui->cbStatusFriendly->removeItem(
|
||||
m_ui->cbStatusDirect->findData(ProjectDataManagement::VulnerabilityState::TemporarySeverance));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+37
-36
@@ -1,15 +1,14 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AlarmManagement/logger.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <memory>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <Services/AlarmManagement/alm_dtc.h>
|
||||
#include <Services/AlarmManagement/alm_ftc.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -18,43 +17,45 @@ class ConfigParticipantsDialog;
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
class ConfigParticipantsDialog : public LtsWidgets::LtsDialog
|
||||
, protected AlarmManagement::Interface::Ftc::ConfigureAlarmsReplyHandler
|
||||
class ConfigParticipantsDialog : public LtsWidgets::LtsDialog,
|
||||
protected AlarmManagement::Interface::Ftc::ConfigureAlarmsReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigParticipantsDialog(QWidget *parent = nullptr);
|
||||
~ConfigParticipantsDialog();
|
||||
public:
|
||||
explicit ConfigParticipantsDialog(QWidget* parent = nullptr);
|
||||
~ConfigParticipantsDialog();
|
||||
|
||||
bool init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc> &almFtc,
|
||||
const ParticipantManagement::ParticipantData &participantData,
|
||||
const std::vector<int> &participantVector,
|
||||
const std::vector<int> &equipmentVector);
|
||||
bool init(const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc>& almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc>& almFtc,
|
||||
const ParticipantManagement::ParticipantData& participantData, const std::vector<int>& participantVector,
|
||||
const std::vector<int>& equipmentVector);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onConfigureAlarmsReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onConfigureAlarmsReply(const Core::FunctionReplyObject& replyObject) override final
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
std::vector<AlarmManagement::AlarmAction> getCheckedValues() const;
|
||||
void fillCbx();
|
||||
void setAlaramData(const AlarmManagement::AlarmConfig &alarm);
|
||||
private:
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
std::vector<AlarmManagement::AlarmAction> getCheckedValues() const;
|
||||
void fillCbx();
|
||||
void setAlaramData(const AlarmManagement::AlarmConfig& alarm);
|
||||
|
||||
private:
|
||||
Ui::ConfigParticipantsDialog *m_ui;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_almDtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_almFtc;
|
||||
int m_operatorId;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
std::vector<int> m_participantVector;
|
||||
ParticipantManagement::TypeClass m_typeClass;
|
||||
ParticipantManagement::ParticipantData m_participantData;
|
||||
private:
|
||||
Ui::ConfigParticipantsDialog* m_ui;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_almDtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_almFtc;
|
||||
int m_operatorId;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
std::vector<int> m_participantVector;
|
||||
ParticipantManagement::TypeClass m_typeClass;
|
||||
ParticipantManagement::ParticipantData m_participantData;
|
||||
};
|
||||
}
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+127
-150
@@ -1,228 +1,205 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include "alm_participant_dialog.h"
|
||||
#include "ui_alm_participant_dialog.h"
|
||||
|
||||
#include "alm_config_participant_dialog.h"
|
||||
#include "alm_participant_model.h"
|
||||
#include "ui_alm_participant_dialog.h"
|
||||
|
||||
#include <AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <ParticipantManagement/Gui/Common/participant_edit_model.h>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
#include <QTreeView>
|
||||
#include <LtsPrinting/printing.h>
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
int ParticipantsDialog::s_preselectedParty = -1;
|
||||
|
||||
ParticipantsDialog::ParticipantsDialog(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent)
|
||||
, m_session(nullptr)
|
||||
, m_almDtc(nullptr)
|
||||
, m_almFtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_participantModel(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_ui(new Ui::ParticipantsDialog)
|
||||
, m_logger(AlarmManagement::getLogger("ParticipantsDialog"))
|
||||
ParticipantsDialog::ParticipantsDialog(const QString& menuGroup, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent), m_session(nullptr), m_almDtc(nullptr), m_almFtc(nullptr), m_ppmDtc(nullptr),
|
||||
m_participantModel(nullptr), m_requestHelper(new LtsUtils::RequestHelper(this)), m_menuGroup(menuGroup),
|
||||
m_ui(new Ui::ParticipantsDialog), m_logger(AlarmManagement::getLogger("ParticipantsDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ParticipantsDialog::onAddButtonClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ParticipantsDialog::onPrint);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ParticipantsDialog::onAddButtonClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ParticipantsDialog::onPrint);
|
||||
|
||||
m_ui->cbAllParticipants->setVisible(false);
|
||||
m_ui->cbAllParticipants->setVisible(false);
|
||||
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Assign_Participant_Alarms"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Assign_Participant_Alarms"));
|
||||
}
|
||||
|
||||
ParticipantsDialog::~ParticipantsDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantsDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Assign Participant Alarms"));
|
||||
translate(m_ui, tr("Assign Participant Alarms"));
|
||||
}
|
||||
|
||||
bool ParticipantsDialog::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc> &almFtc,
|
||||
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> &ppmGuiCbxIfc)
|
||||
bool ParticipantsDialog::init(LtsSession::LtsSession* session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc>& almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc>& almFtc,
|
||||
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface>& ppmGuiCbxIfc)
|
||||
{
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_almDtc = almDtc;
|
||||
m_almFtc = almFtc;
|
||||
m_session = session;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_almDtc = almDtc;
|
||||
m_almFtc = almFtc;
|
||||
m_session = session;
|
||||
|
||||
if (m_ppmDtc == nullptr ||
|
||||
!ppmDtc->enableDynamicParticipantData() ||
|
||||
!ppmDtc->enableParticipant())
|
||||
return false;
|
||||
if (m_ppmDtc == nullptr || !ppmDtc->enableDynamicParticipantData() || !ppmDtc->enableParticipant())
|
||||
return false;
|
||||
|
||||
if (m_almFtc == nullptr ||
|
||||
!almFtc->enableConfigureAlarms())
|
||||
return false;
|
||||
if (m_almFtc == nullptr || !almFtc->enableConfigureAlarms())
|
||||
return false;
|
||||
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> asbIfc;
|
||||
m_session->getForeignDataInterface<AdvancedSymbology::DataInterface>(asbIfc);
|
||||
m_participantModel = new ParticipantAlarms::ParticipantAlarmModel(this,
|
||||
m_ppmDtc,
|
||||
asbIfc);
|
||||
m_participantProxyModel = new ParticipantManagement::ParticipantTreeFilterProxyModel(this);
|
||||
m_participantProxyModel->setSourceModel(m_participantModel);
|
||||
m_participantProxyModel->setRecursiveFilteringEnabled(true);
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> asbIfc;
|
||||
m_session->getForeignDataInterface<AdvancedSymbology::DataInterface>(asbIfc);
|
||||
m_participantModel = new ParticipantAlarms::ParticipantAlarmModel(this, m_ppmDtc, asbIfc);
|
||||
m_participantProxyModel = new ParticipantManagement::ParticipantTreeFilterProxyModel(this);
|
||||
m_participantProxyModel->setSourceModel(m_participantModel);
|
||||
m_participantProxyModel->setRecursiveFilteringEnabled(true);
|
||||
|
||||
m_ui->dvParticipants->setModel(m_participantProxyModel);
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ParticipantsDialog::onCbPartyChanged);
|
||||
connect(m_ui->cbAllParticipants, &QCheckBox::clicked,
|
||||
m_ui->dvParticipants, &LtsDataView::LtsDataView::setDisabled);
|
||||
connect(m_ui->dvParticipants, &LtsDataView::LtsDataView::selectionChanged,
|
||||
this, &ParticipantsDialog::onSelectionChanged);
|
||||
connect(m_ui->dvParticipants, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &ParticipantsDialog::onDoubleClicked);
|
||||
connect(m_ui->cbAllParticipants, &QCheckBox::clicked,
|
||||
this, [this](bool checked)
|
||||
{
|
||||
if (checked)
|
||||
m_ui->dvParticipants->treeView()->selectAll();
|
||||
else
|
||||
m_ui->dvParticipants->treeView()->clearSelection();
|
||||
});
|
||||
m_ui->dvParticipants->setModel(m_participantProxyModel);
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged), this,
|
||||
&ParticipantsDialog::onCbPartyChanged);
|
||||
connect(m_ui->cbAllParticipants, &QCheckBox::clicked, m_ui->dvParticipants, &LtsDataView::LtsDataView::setDisabled);
|
||||
connect(m_ui->dvParticipants, &LtsDataView::LtsDataView::selectionChanged, this,
|
||||
&ParticipantsDialog::onSelectionChanged);
|
||||
connect(m_ui->dvParticipants, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&ParticipantsDialog::onDoubleClicked);
|
||||
connect(m_ui->cbAllParticipants, &QCheckBox::clicked, this, [this](bool checked) {
|
||||
if (checked)
|
||||
m_ui->dvParticipants->treeView()->selectAll();
|
||||
else
|
||||
m_ui->dvParticipants->treeView()->clearSelection();
|
||||
});
|
||||
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
const int idx = m_ui->cbParty->findData(s_preselectedParty);
|
||||
if (idx >= 0)
|
||||
m_ui->cbParty->setCurrentIndex(idx);
|
||||
onCbPartyChanged();
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
const int idx = m_ui->cbParty->findData(s_preselectedParty);
|
||||
if (idx >= 0)
|
||||
m_ui->cbParty->setCurrentIndex(idx);
|
||||
onCbPartyChanged();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onSelectionChanged()
|
||||
{
|
||||
bool configureAlarms = false;
|
||||
DEBUG_LOG(m_logger) << "onSelectionChanged";
|
||||
const QModelIndexList currentlySelectedParticipants = m_ui->dvParticipants->selectedRows();
|
||||
bool configureAlarms = false;
|
||||
DEBUG_LOG(m_logger) << "onSelectionChanged";
|
||||
const QModelIndexList currentlySelectedParticipants = m_ui->dvParticipants->selectedRows();
|
||||
|
||||
for (const QModelIndex &index : currentlySelectedParticipants)
|
||||
{
|
||||
const ParticipantManagement::ParticipantData data(m_participantModel->getParticipantData(index));
|
||||
if ((data.equipmentNumber().is_set() && data.equipmentNumber().get() > 0) ||
|
||||
m_ppmDtc->type(data.typeId()).typeClass() == ParticipantManagement::TypeClass_def::Unit)
|
||||
configureAlarms = true;
|
||||
DEBUG_LOG(m_logger) << "setChildrenSelected row =" << index.row() << " column=" << index.column();
|
||||
|
||||
}
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, configureAlarms);
|
||||
for (const QModelIndex& index : currentlySelectedParticipants)
|
||||
{
|
||||
const ParticipantManagement::ParticipantData data(m_participantModel->getParticipantData(index));
|
||||
if ((data.equipmentNumber().is_set() && data.equipmentNumber().get() > 0) ||
|
||||
m_ppmDtc->type(data.typeId()).typeClass() == ParticipantManagement::TypeClass_def::Unit)
|
||||
configureAlarms = true;
|
||||
DEBUG_LOG(m_logger) << "setChildrenSelected row =" << index.row() << " column=" << index.column();
|
||||
}
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, configureAlarms);
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onCbPartyChanged()
|
||||
{
|
||||
const int curPartyId = m_ui->cbParty->currentData().toInt();
|
||||
s_preselectedParty = curPartyId;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_participantModel->onReinitModel(curPartyId);
|
||||
m_ui->dvParticipants->expandAll();
|
||||
if (m_ui->cbAllParticipants->isChecked())
|
||||
m_ui->dvParticipants->treeView()->selectAll();
|
||||
m_ui->dvParticipants->resizeHeadersByContent();
|
||||
const int curPartyId = m_ui->cbParty->currentData().toInt();
|
||||
s_preselectedParty = curPartyId;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_participantModel->onReinitModel(curPartyId);
|
||||
m_ui->dvParticipants->expandAll();
|
||||
if (m_ui->cbAllParticipants->isChecked())
|
||||
m_ui->dvParticipants->treeView()->selectAll();
|
||||
m_ui->dvParticipants->resizeHeadersByContent();
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onAddButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onAddButtonClicked";
|
||||
|
||||
m_participantVector.clear();
|
||||
m_equipmentVector.clear();
|
||||
if (!m_ui->cbAllParticipants->isChecked())
|
||||
{
|
||||
const QModelIndexList currentlySelectedParticipants = m_ui->dvParticipants->selectedRows();
|
||||
DEBUG_LOG(m_logger) << "onAddButtonClicked";
|
||||
|
||||
for (const QModelIndex &index : currentlySelectedParticipants)
|
||||
m_participantVector.clear();
|
||||
m_equipmentVector.clear();
|
||||
if (!m_ui->cbAllParticipants->isChecked())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setChildrenSelected: " << index.row() << " column=" << index.column();
|
||||
setChildrenSelected(index);
|
||||
const QModelIndexList currentlySelectedParticipants = m_ui->dvParticipants->selectedRows();
|
||||
|
||||
for (const QModelIndex& index : currentlySelectedParticipants)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setChildrenSelected: " << index.row() << " column=" << index.column();
|
||||
setChildrenSelected(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex participantIndex = m_ui->dvParticipants->currentIndex();
|
||||
ParticipantManagement::ParticipantData data = m_participantModel->getParticipantData(participantIndex);
|
||||
DEBUG_LOG(m_logger) << "current participantId = " << data.id();
|
||||
m_participantVector.push_back(data.id());
|
||||
QModelIndex participantIndex = m_ui->dvParticipants->currentIndex();
|
||||
ParticipantManagement::ParticipantData data = m_participantModel->getParticipantData(participantIndex);
|
||||
DEBUG_LOG(m_logger) << "current participantId = " << data.id();
|
||||
m_participantVector.push_back(data.id());
|
||||
|
||||
const auto partData = m_participantModel->getParticipantData(participantIndex);
|
||||
addDialog(LtsWidgets::initDialog(new ConfigParticipantsDialog(this),
|
||||
m_ppmDtc, m_almDtc, m_almFtc, partData, m_participantVector, m_equipmentVector),
|
||||
m_menuGroup, QStringLiteral("ConfigAlarms%1").arg(partData.id()));
|
||||
const auto partData = m_participantModel->getParticipantData(participantIndex);
|
||||
addDialog(LtsWidgets::initDialog(new ConfigParticipantsDialog(this), m_ppmDtc, m_almDtc, m_almFtc, partData,
|
||||
m_participantVector, m_equipmentVector),
|
||||
m_menuGroup, QStringLiteral("ConfigAlarms%1").arg(partData.id()));
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->dvParticipants->treeView());
|
||||
LtsPrinting::printView(m_session, this, m_ui->dvParticipants->treeView());
|
||||
}
|
||||
|
||||
void ParticipantsDialog::setChildrenSelected(const QModelIndex &parent)
|
||||
void ParticipantsDialog::setChildrenSelected(const QModelIndex& parent)
|
||||
{
|
||||
if (!(parent.isValid() &&
|
||||
m_participantModel->hasChildren(parent)))
|
||||
return;
|
||||
if (!(parent.isValid() && m_participantModel->hasChildren(parent)))
|
||||
return;
|
||||
|
||||
const int rc = m_participantModel->rowCount(parent);
|
||||
for (int currentRow = 0; currentRow < rc; ++currentRow)
|
||||
{
|
||||
QModelIndex childIndex = m_participantModel->index(currentRow, 0, parent);
|
||||
|
||||
if (m_participantModel->hasChildren(childIndex))
|
||||
setChildrenSelected(childIndex);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Setting row "
|
||||
<< childIndex.row()
|
||||
<< " selected";
|
||||
|
||||
ParticipantManagement::ParticipantData data = m_participantModel->getParticipantData(childIndex);
|
||||
DEBUG_LOG(m_logger) << "append participantId = " << data.id();
|
||||
m_participantVector.push_back(data.id());
|
||||
if (data.equipmentNumber().is_set())
|
||||
const int rc = m_participantModel->rowCount(parent);
|
||||
for (int currentRow = 0; currentRow < rc; ++currentRow)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "append equipmentNumber = " << data.equipmentNumber().get();
|
||||
m_equipmentVector.push_back(data.equipmentNumber().get());
|
||||
}
|
||||
QModelIndex childIndex = m_participantModel->index(currentRow, 0, parent);
|
||||
|
||||
m_ui->dvParticipants->selectionModel()->select(m_participantProxyModel->mapFromSource(childIndex), QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
}
|
||||
if (m_participantModel->hasChildren(childIndex))
|
||||
setChildrenSelected(childIndex);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Setting row " << childIndex.row() << " selected";
|
||||
|
||||
ParticipantManagement::ParticipantData data = m_participantModel->getParticipantData(childIndex);
|
||||
DEBUG_LOG(m_logger) << "append participantId = " << data.id();
|
||||
m_participantVector.push_back(data.id());
|
||||
if (data.equipmentNumber().is_set())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "append equipmentNumber = " << data.equipmentNumber().get();
|
||||
m_equipmentVector.push_back(data.equipmentNumber().get());
|
||||
}
|
||||
|
||||
m_ui->dvParticipants->selectionModel()->select(m_participantProxyModel->mapFromSource(childIndex),
|
||||
QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
}
|
||||
}
|
||||
|
||||
void ParticipantsDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->dvParticipants->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->dvParticipants->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onConfigureAlarmsReply(const Core::FunctionReplyObject &replyObject)
|
||||
void ParticipantsDialog::onConfigureAlarmsReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onConfigureAlarmsReply" << replyObject.str();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
DEBUG_LOG(m_logger) << "onConfigureAlarmsReply" << replyObject.str();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onDoubleClicked()
|
||||
{
|
||||
if (!m_buttonBox->isButtonEnabled(LtsWidgets::DialogButton::Edit))
|
||||
return;
|
||||
if (!m_buttonBox->isButtonEnabled(LtsWidgets::DialogButton::Edit))
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "onDoubleClicked";
|
||||
onAddButtonClicked();
|
||||
DEBUG_LOG(m_logger) << "onDoubleClicked";
|
||||
onAddButtonClicked();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+42
-45
@@ -1,18 +1,17 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "alm_participant_model.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <memory>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <Services/AlarmManagement/alm.hpp>
|
||||
#include <Services/AlarmManagement/alm_dtc.h>
|
||||
#include <Services/AlarmManagement/alm_ftc.h>
|
||||
#include <Services/AlarmManagement/alm.hpp>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -23,56 +22,54 @@ namespace ParticipantManagement
|
||||
{
|
||||
class ParticipantTreeFilterProxyModel;
|
||||
class ForeignGuiComboboxInterface;
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
class TypeModel;
|
||||
|
||||
class ParticipantsDialog : public LtsWidgets::LtsDialog
|
||||
, protected AlarmManagement::Interface::Ftc::ConfigureAlarmsReplyHandler
|
||||
class ParticipantsDialog : public LtsWidgets::LtsDialog,
|
||||
protected AlarmManagement::Interface::Ftc::ConfigureAlarmsReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParticipantsDialog(const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~ParticipantsDialog();
|
||||
public:
|
||||
explicit ParticipantsDialog(const QString& menuGroup, QWidget* parent = nullptr);
|
||||
~ParticipantsDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc> &almFtc,
|
||||
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> &ppmGuiCbxIfc);
|
||||
bool init(LtsSession::LtsSession* session, const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc>& almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc>& almFtc,
|
||||
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface>& ppmGuiCbxIfc);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void onConfigureAlarmsReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onConfigureAlarmsReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
private slots:
|
||||
void onAddButtonClicked();
|
||||
void onPrint();
|
||||
void onCbPartyChanged();
|
||||
void onDoubleClicked();
|
||||
void onSelectionChanged();
|
||||
|
||||
private slots:
|
||||
void onAddButtonClicked();
|
||||
void onPrint();
|
||||
void onCbPartyChanged();
|
||||
void onDoubleClicked();
|
||||
void onSelectionChanged();
|
||||
private:
|
||||
void retranslate() override;
|
||||
void setChildrenSelected(const QModelIndex& parent);
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void setChildrenSelected(const QModelIndex &parent);
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_almDtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_almFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
ParticipantAlarmModel *m_participantModel;
|
||||
ParticipantManagement::ParticipantTreeFilterProxyModel *m_participantProxyModel;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
std::vector<int> m_participantVector;
|
||||
std::vector<int> m_equipmentVector;
|
||||
QString m_menuGroup;
|
||||
static int s_preselectedParty;
|
||||
Ui::ParticipantsDialog *m_ui;
|
||||
private:
|
||||
LtsSession::LtsSession* m_session;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_almDtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_almFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
ParticipantAlarmModel* m_participantModel;
|
||||
ParticipantManagement::ParticipantTreeFilterProxyModel* m_participantProxyModel;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
std::vector<int> m_participantVector;
|
||||
std::vector<int> m_equipmentVector;
|
||||
QString m_menuGroup;
|
||||
static int s_preselectedParty;
|
||||
Ui::ParticipantsDialog* m_ui;
|
||||
};
|
||||
}
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+39
-44
@@ -1,73 +1,68 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_participant_model.h"
|
||||
|
||||
#include <AlarmManagement/logger.h>
|
||||
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
|
||||
ParticipantAlarmModel::ParticipantAlarmModel(QObject *parent,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface> &asbIfc)
|
||||
: ParticipantManagement::ParticipantEditModel(parent, ppmDtc, asbIfc)
|
||||
, m_logger(AlarmManagement::getLogger("ParticipantAlarmModel"))
|
||||
ParticipantAlarmModel::ParticipantAlarmModel(QObject* parent,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface>& asbIfc)
|
||||
: ParticipantManagement::ParticipantEditModel(parent, ppmDtc, asbIfc),
|
||||
m_logger(AlarmManagement::getLogger("ParticipantAlarmModel"))
|
||||
{
|
||||
m_titles += tr("Alarm Assignable");
|
||||
m_titles += tr("Alarm Assignable");
|
||||
|
||||
DEBUG_LOG(m_logger) << "ParticipantAlarmModel::ParticipantAlarmModel";
|
||||
DEBUG_LOG(m_logger) << "ParticipantAlarmModel::ParticipantAlarmModel";
|
||||
}
|
||||
|
||||
QVariant ParticipantAlarmModel::data(const QModelIndex &index, int role) const
|
||||
QVariant ParticipantAlarmModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
|
||||
if (role == Qt::DisplayRole && index.column() == columnCount() - 1)
|
||||
{
|
||||
bool bIsSimulated = false;
|
||||
if (!isSelectableByAlarm(index, &bIsSimulated))
|
||||
return QVariant();
|
||||
return !bIsSimulated ? tr("Yes") : tr("No");
|
||||
}
|
||||
|
||||
return ParticipantManagement::ParticipantEditModel::data(index, role);
|
||||
if (role == Qt::DisplayRole && index.column() == columnCount() - 1)
|
||||
{
|
||||
bool bIsSimulated = false;
|
||||
if (!isSelectableByAlarm(index, &bIsSimulated))
|
||||
return QVariant();
|
||||
return !bIsSimulated ? tr("Yes") : tr("No");
|
||||
}
|
||||
|
||||
return ParticipantManagement::ParticipantEditModel::data(index, role);
|
||||
}
|
||||
|
||||
void ParticipantAlarmModel::onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType)
|
||||
void ParticipantAlarmModel::onParticipantChanged(const ParticipantManagement::Participant& data,
|
||||
DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
if (data.partyId() != partyId())
|
||||
return;
|
||||
Q_UNUSED(modType);
|
||||
if (data.partyId() != partyId())
|
||||
return;
|
||||
|
||||
INFO_LOG(m_logger) << "onParticipantChanged isSimulated=" << data.isSimulated();
|
||||
onReinitModel(partyId());
|
||||
emit newData();
|
||||
INFO_LOG(m_logger) << "onParticipantChanged isSimulated=" << data.isSimulated();
|
||||
onReinitModel(partyId());
|
||||
emit newData();
|
||||
}
|
||||
|
||||
bool ParticipantAlarmModel::isSelectableByAlarm(const QModelIndex &index, bool *bIsSimulated) const
|
||||
bool ParticipantAlarmModel::isSelectableByAlarm(const QModelIndex& index, bool* bIsSimulated) const
|
||||
{
|
||||
bool isSimulatable = false;
|
||||
const ParticipantManagement::ParticipantData data(getParticipantData(index));
|
||||
bool isSimulatable = false;
|
||||
const ParticipantManagement::ParticipantData data(getParticipantData(index));
|
||||
|
||||
if ((data.equipmentNumber().is_set() && data.equipmentNumber().get() > 0) ||
|
||||
m_dtc->type(data.typeId()).typeClass() == ParticipantManagement::TypeClass_def::Unit)
|
||||
isSimulatable = true;
|
||||
if ((data.equipmentNumber().is_set() && data.equipmentNumber().get() > 0) ||
|
||||
m_dtc->type(data.typeId()).typeClass() == ParticipantManagement::TypeClass_def::Unit)
|
||||
isSimulatable = true;
|
||||
|
||||
DEBUG_LOG(m_logger) << "ParticipantId: " << data.id()
|
||||
<< " isSimulated:" << data.isSimulated()
|
||||
<< " equipmentNo:" << data.equipmentNumber()
|
||||
<< " typeId=" << data.typeId()
|
||||
<< " modId=" << data.modId()
|
||||
<< " typeClass=" << m_dtc->type(data.typeId()).typeClass()
|
||||
<< " isSimulatable=" << isSimulatable;
|
||||
DEBUG_LOG(m_logger) << "ParticipantId: " << data.id() << " isSimulated:" << data.isSimulated()
|
||||
<< " equipmentNo:" << data.equipmentNumber() << " typeId=" << data.typeId()
|
||||
<< " modId=" << data.modId() << " typeClass=" << m_dtc->type(data.typeId()).typeClass()
|
||||
<< " isSimulatable=" << isSimulatable;
|
||||
|
||||
if (bIsSimulated)
|
||||
*bIsSimulated = data.isSimulated();
|
||||
if (bIsSimulated)
|
||||
*bIsSimulated = data.isSimulated();
|
||||
|
||||
return isSimulatable;
|
||||
return isSimulatable;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+12
-15
@@ -1,6 +1,5 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ParticipantManagement/Gui/Common/participant_edit_model.h>
|
||||
@@ -9,21 +8,19 @@ namespace ParticipantAlarms
|
||||
{
|
||||
class ParticipantAlarmModel final : public ParticipantManagement::ParticipantEditModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ParticipantAlarmModel(QObject *parent,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface> &asbIfc);
|
||||
Q_OBJECT
|
||||
public:
|
||||
ParticipantAlarmModel(QObject* parent, const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface>& asbIfc);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
signals:
|
||||
void newData();
|
||||
signals:
|
||||
void newData();
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType);
|
||||
bool isSelectableByAlarm(const QModelIndex &index, bool *bIsSimulated = nullptr) const;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void onParticipantChanged(const ParticipantManagement::Participant& data, DataModification modType);
|
||||
bool isSelectableByAlarm(const QModelIndex& index, bool* bIsSimulated = nullptr) const;
|
||||
};
|
||||
}
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+83
-100
@@ -1,150 +1,133 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_participant_show_config.h"
|
||||
|
||||
#include "ui_alm_participant_show_config.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
|
||||
ParticipantShowConfigView::ParticipantShowConfigView(LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_configAlarmModel(nullptr)
|
||||
, m_alarmHistoryModel(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_almFtc(nullptr)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::ParticipantShowConfigView)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(AlarmManagement::getLogger("ParticipantShowConfigView"))
|
||||
ParticipantShowConfigView::ParticipantShowConfigView(LtsSession::LtsSession* session, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_configAlarmModel(nullptr),
|
||||
m_alarmHistoryModel(nullptr), m_dtc(nullptr), m_almFtc(nullptr), m_session(session),
|
||||
m_ui(new Ui::ParticipantShowConfigView), m_requestHelper(new LtsUtils::RequestHelper(this)),
|
||||
m_logger(AlarmManagement::getLogger("ParticipantShowConfigView"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "--- ParticipantShowConfigView Konstruktor() ";
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
DEBUG_LOG(m_logger) << "--- ParticipantShowConfigView Konstruktor() ";
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &ParticipantShowConfigView::onSelectionChanged);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&ParticipantShowConfigView::onSelectionChanged);
|
||||
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &ParticipantShowConfigView::onShowAlarm);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&ParticipantShowConfigView::onShowAlarm);
|
||||
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &ParticipantShowConfigView::onRemoveAlarm);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ParticipantShowConfigView::onPrint);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Show_Config_Participant_Alarms"));
|
||||
|
||||
}
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &ParticipantShowConfigView::onRemoveAlarm);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ParticipantShowConfigView::onPrint);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Show_Config_Participant_Alarms"));
|
||||
}
|
||||
|
||||
ParticipantShowConfigView::~ParticipantShowConfigView()
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- ParticipantShowConfigView Destruktor() ";
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "--- ParticipantShowConfigView Destruktor() ";
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantShowConfigView::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Show Config Participant Alarms"));
|
||||
translate(m_ui, tr("Show Config Participant Alarms"));
|
||||
}
|
||||
|
||||
bool ParticipantShowConfigView::init(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc)
|
||||
bool ParticipantShowConfigView::init(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc>& aesDtc)
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- init() ";
|
||||
if (!dtc || !ftc)
|
||||
return false;
|
||||
INFO_LOG(m_logger) << "--- init() ";
|
||||
if (!dtc || !ftc)
|
||||
return false;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_almFtc = ftc;
|
||||
m_alarmHistoryModel = new AlarmManagement::AlarmHistoryModel(this);
|
||||
m_alarmHistoryModel->initModel(dtc, ppmDtc, aesDtc);
|
||||
|
||||
DEBUG_LOG(m_logger) << "--- ParticipantShowConfigView::init ";
|
||||
m_configAlarmModel = new AlarmManagement::ConfigAlarmModel(this);
|
||||
m_configAlarmModel->initModel(m_dtc, ppmDtc, m_alarmHistoryModel, false);
|
||||
m_ui->widget->setModel(m_configAlarmModel);
|
||||
return true;
|
||||
}
|
||||
m_dtc = dtc;
|
||||
m_almFtc = ftc;
|
||||
m_alarmHistoryModel = new AlarmManagement::AlarmHistoryModel(this);
|
||||
m_alarmHistoryModel->initModel(dtc, ppmDtc, aesDtc);
|
||||
|
||||
DEBUG_LOG(m_logger) << "--- ParticipantShowConfigView::init ";
|
||||
m_configAlarmModel = new AlarmManagement::ConfigAlarmModel(this);
|
||||
m_configAlarmModel->initModel(m_dtc, ppmDtc, m_alarmHistoryModel, false);
|
||||
m_ui->widget->setModel(m_configAlarmModel);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantShowConfigView::onSelectionChanged()
|
||||
{
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, cntSelectedRows == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, cntSelectedRows == 1);
|
||||
}
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, cntSelectedRows == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, cntSelectedRows == 1);
|
||||
}
|
||||
|
||||
|
||||
void ParticipantShowConfigView::onConfigureAlarmsReply(const Core::FunctionReplyObject &replyObject)
|
||||
void ParticipantShowConfigView::onConfigureAlarmsReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
DEBUG_LOG(m_logger)<<"onConfigureAlarmsReply"<<replyObject.str();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "onConfigureAlarmsReply" << replyObject.str();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void ParticipantShowConfigView::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
void ParticipantShowConfigView::onShowAlarm()
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- onShowAlarm() ";
|
||||
}
|
||||
|
||||
|
||||
INFO_LOG(m_logger) << "--- onShowAlarm() ";
|
||||
}
|
||||
|
||||
void ParticipantShowConfigView::onRemoveAlarm()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onRemoveAlarm"
|
||||
<< " id = "<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).id()
|
||||
<< " eventTypeId = "<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).eventTypeId()
|
||||
<< " operatorId = "<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).operatorId()
|
||||
<< " participantId = "<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).participantId();
|
||||
DEBUG_LOG(m_logger) << "onRemoveAlarm"
|
||||
<< " id = " << m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).id()
|
||||
<< " eventTypeId = "
|
||||
<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).eventTypeId()
|
||||
<< " operatorId = "
|
||||
<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).operatorId()
|
||||
<< " participantId = "
|
||||
<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).participantId();
|
||||
|
||||
const QModelIndex curIdx = m_ui->widget->currentIndex();
|
||||
if (!curIdx.isValid())
|
||||
return;
|
||||
const AlarmManagement::AlarmConfig &rowdata = m_configAlarmModel->getRowData(curIdx.row());
|
||||
int operatorId = rowdata.operatorId();
|
||||
std::vector<int32_t> ddsParticipantIds;
|
||||
ddsParticipantIds.push_back(rowdata.participantId());
|
||||
bool globalEvent = true;
|
||||
bool remove = true;
|
||||
std::vector<AlarmManagement::AlarmAction> alarmsDds;
|
||||
alarmsDds.resize(1);
|
||||
alarmsDds[0].setMarker(false);
|
||||
alarmsDds[0].messageWindow(false);
|
||||
alarmsDds[0].eventTypeId(rowdata.eventTypeId());
|
||||
AlarmManagement::ConfigureAlarmsRequest request(alarmsDds, operatorId, ddsParticipantIds, globalEvent, remove);
|
||||
|
||||
m_requestHelper->startSingleRequest([request, this]()
|
||||
{
|
||||
return m_almFtc->configureAlarmsRequest(request, this);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
const QModelIndex curIdx = m_ui->widget->currentIndex();
|
||||
if (!curIdx.isValid())
|
||||
return;
|
||||
const AlarmManagement::AlarmConfig& rowdata = m_configAlarmModel->getRowData(curIdx.row());
|
||||
int operatorId = rowdata.operatorId();
|
||||
std::vector<int32_t> ddsParticipantIds;
|
||||
ddsParticipantIds.push_back(rowdata.participantId());
|
||||
bool globalEvent = true;
|
||||
bool remove = true;
|
||||
std::vector<AlarmManagement::AlarmAction> alarmsDds;
|
||||
alarmsDds.resize(1);
|
||||
alarmsDds[0].setMarker(false);
|
||||
alarmsDds[0].messageWindow(false);
|
||||
alarmsDds[0].eventTypeId(rowdata.eventTypeId());
|
||||
AlarmManagement::ConfigureAlarmsRequest request(alarmsDds, operatorId, ddsParticipantIds, globalEvent, remove);
|
||||
|
||||
m_requestHelper->startSingleRequest([request, this]() {
|
||||
return m_almFtc->configureAlarmsRequest(request, this);
|
||||
});
|
||||
}
|
||||
|
||||
void ParticipantShowConfigView::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView() );
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+36
-38
@@ -1,65 +1,63 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Services/AlarmManagement/alm_dtc.h>
|
||||
#include <Services/AlarmManagement/alm_ftc.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_config_alarm_model.h>
|
||||
#include <Services/AlarmManagement/alm_dtc.h>
|
||||
#include <Services/AlarmManagement/alm_ftc.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ParticipantShowConfigView;
|
||||
}
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
|
||||
class ParticipantShowConfigView : public LtsWidgets::LtsDialog
|
||||
, protected AlarmManagement::Interface::Ftc::ConfigureAlarmsReplyHandler
|
||||
class ParticipantShowConfigView : public LtsWidgets::LtsDialog,
|
||||
protected AlarmManagement::Interface::Ftc::ConfigureAlarmsReplyHandler
|
||||
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParticipantShowConfigView(LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~ParticipantShowConfigView();
|
||||
public:
|
||||
explicit ParticipantShowConfigView(LtsSession::LtsSession* session, QWidget* parent = nullptr);
|
||||
~ParticipantShowConfigView();
|
||||
|
||||
bool init(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc);
|
||||
bool init(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc>& aesDtc);
|
||||
|
||||
private Q_SLOTS:
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onShowAlarm();
|
||||
void onRemoveAlarm();
|
||||
void onPrint();
|
||||
|
||||
private Q_SLOTS:
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onShowAlarm();
|
||||
void onRemoveAlarm();
|
||||
void onPrint();
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void onConfigureAlarmsReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
|
||||
protected:
|
||||
private:
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onConfigureAlarmsReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
private:
|
||||
AlarmManagement::ConfigAlarmModel* m_configAlarmModel;
|
||||
AlarmManagement::AlarmHistoryModel* m_alarmHistoryModel;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_almFtc;
|
||||
|
||||
private:
|
||||
void tableColumnOrganiserSetting() override;
|
||||
LtsSession::LtsSession* m_session;
|
||||
Ui::ParticipantShowConfigView* m_ui;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
|
||||
private:
|
||||
AlarmManagement::ConfigAlarmModel *m_configAlarmModel;
|
||||
AlarmManagement::AlarmHistoryModel *m_alarmHistoryModel;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_almFtc;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
Ui::ParticipantShowConfigView *m_ui;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
AlarmManagement::
|
||||
AlarmManagement::
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+143
-175
@@ -1,264 +1,232 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_emergency_call_dialog.h"
|
||||
#include "ui_alm_emergency_call_dialog.h"
|
||||
|
||||
#include "AlarmManagement/Gui/EmergencyCalls/alm_emergency_call_model.h"
|
||||
#include <Services/AlarmManagement/alm_operator_rights.h>
|
||||
#include "ui_alm_emergency_call_dialog.h"
|
||||
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
||||
#include <Services/AlarmManagement/alm_operator_rights.h>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
|
||||
EmergencyCallDialog::EmergencyCallDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_ui(new Ui::EmergencyCallDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
EmergencyCallDialog::EmergencyCallDialog(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_dtc(nullptr), m_ftc(nullptr),
|
||||
m_session(nullptr), m_ui(new Ui::EmergencyCallDialog), m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
|
||||
void EmergencyCallDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Emergency Call "));
|
||||
translate(m_ui, tr("Emergency Call "));
|
||||
}
|
||||
|
||||
bool EmergencyCallDialog::init(const std::shared_ptr<AlarmManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
LtsSession::LtsSession *session)
|
||||
bool EmergencyCallDialog::init(const std::shared_ptr<AlarmManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface>& sitMapGuiIfc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc>& opmDtc,
|
||||
LtsSession::LtsSession* session)
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START ";
|
||||
if (!ftc || !dtc || !session){
|
||||
ERROR_LOG(m_logger)<<" init Emergency call dialog failed !!";
|
||||
return false;
|
||||
}
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START ";
|
||||
if (!ftc || !dtc || !session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << " init Emergency call dialog failed !!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ftc = ftc;
|
||||
m_dtc = dtc;
|
||||
m_opmDtc = opmDtc;
|
||||
m_session = session;
|
||||
m_dtc->enableAlmEmergencyCall();
|
||||
m_ftc->enableEmergencyCallAcknowledge();
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
m_ftc = ftc;
|
||||
m_dtc = dtc;
|
||||
m_opmDtc = opmDtc;
|
||||
m_session = session;
|
||||
m_dtc->enableAlmEmergencyCall();
|
||||
m_ftc->enableEmergencyCallAcknowledge();
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
|
||||
delete m_model;
|
||||
m_model = new AlarmManagement::EmergencyCallModel(this);
|
||||
m_model->initModel(m_dtc, opmDtc);
|
||||
|
||||
delete m_model;
|
||||
m_model = new AlarmManagement::EmergencyCallModel(this);
|
||||
m_model->initModel(m_dtc, opmDtc);
|
||||
m_proxyModel = new EmergencyCallProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->emergencyCallView->setModel(m_proxyModel);
|
||||
m_proxyModel->hideByExerciseStopped(m_session->exerciseState() != LtsWidgets::ExcState::eStarted &&
|
||||
m_session->exerciseState() != LtsWidgets::ExcState::ePaused);
|
||||
m_ui->emergencyCallView->setSortingEnabled(true);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::SAMPLE_TIME, 300);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::POSITION, 300);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::DELETED_TIMESTAMP, 300);
|
||||
|
||||
m_proxyModel = new EmergencyCallProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->emergencyCallView->setModel(m_proxyModel);
|
||||
m_proxyModel->hideByExerciseStopped(m_session->exerciseState()!=LtsWidgets::ExcState::eStarted &&
|
||||
m_session->exerciseState() != LtsWidgets::ExcState::ePaused);
|
||||
m_ui->emergencyCallView->setSortingEnabled(true);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::SAMPLE_TIME, 300);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::POSITION, 300);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::DELETED_TIMESTAMP, 300);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setText(tr("Acknowledge"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setText(tr("Center"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setText(tr("Acknowledge"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setText(tr("Center"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &EmergencyCallDialog::onEditBtCliked);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &EmergencyCallDialog::onEditBtCliked);
|
||||
const bool& hasOperatorRightEmergencyCall =
|
||||
LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::EmergencyCall);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setVisible(hasOperatorRightEmergencyCall);
|
||||
|
||||
const bool &hasOperatorRightEmergencyCall = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::EmergencyCall);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setVisible(hasOperatorRightEmergencyCall);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Show, this, &EmergencyCallDialog::onFindEmergencyOnMap);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Show, this, &EmergencyCallDialog::onFindEmergencyOnMap);
|
||||
QCheckBox* cbExpired = new QCheckBox(tr("Show expired"), m_ui->emergencyCallView);
|
||||
cbExpired->setProperty("const", true);
|
||||
m_ui->emergencyCallView->setCustomWidget(cbExpired);
|
||||
connect(cbExpired, &QCheckBox::toggled, this, &EmergencyCallDialog::onSetShowExpired);
|
||||
|
||||
|
||||
|
||||
QCheckBox *cbExpired = new QCheckBox(tr("Show expired"), m_ui->emergencyCallView);
|
||||
cbExpired->setProperty("const", true);
|
||||
m_ui->emergencyCallView->setCustomWidget(cbExpired);
|
||||
connect(cbExpired, &QCheckBox::toggled, this, &EmergencyCallDialog::onSetShowExpired);
|
||||
|
||||
connect(m_ui->emergencyCallView, &LtsDataView::LtsDataView::signalSelectionChanged, this, &EmergencyCallDialog::enaDisa);
|
||||
connect(m_ui->emergencyCallView, &LtsDataView::LtsDataView::doubleClicked, this, &EmergencyCallDialog::onEmergencyIndexDoubleClicked);
|
||||
enaDisa();
|
||||
connect(m_ui->emergencyCallView, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&EmergencyCallDialog::enaDisa);
|
||||
connect(m_ui->emergencyCallView, &LtsDataView::LtsDataView::doubleClicked, this,
|
||||
&EmergencyCallDialog::onEmergencyIndexDoubleClicked);
|
||||
enaDisa();
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::ID);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::SAMPLE_TIME);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::NAME);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::EXPIRED);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::ID);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::SAMPLE_TIME);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::NAME);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::EXPIRED);
|
||||
#endif
|
||||
|
||||
INFO_LOG(m_logger) << "EmergencyCallDialog::init done";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
INFO_LOG(m_logger) << "EmergencyCallDialog::init done";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallDialog::enaDisa()
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, false);
|
||||
|
||||
const AlmEmergencyCall &sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
const AlmEmergencyCall& sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
|
||||
if (!sos.expired())
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, true);
|
||||
if (!sos.expired())
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, true);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, true);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
AlmEmergencyCall EmergencyCallDialog::getSelectedSOS()
|
||||
{
|
||||
QModelIndexList indexList = m_ui->emergencyCallView->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return {};
|
||||
QModelIndexList indexList = m_ui->emergencyCallView->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return {};
|
||||
|
||||
return m_model->getRowData(indexList.front().row());
|
||||
return m_model->getRowData(indexList.front().row());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EmergencyCallDialog::setAcknowledgeUi()
|
||||
{
|
||||
LtsWidgets::LtsFramelessDialog *popup = new LtsWidgets::LtsFramelessDialog(this, LtsWidgets::Behaviour::Popup);
|
||||
LtsWidgets::LtsDialogButtonBox *btnBox = new LtsWidgets::LtsDialogButtonBox(popup);
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(false);
|
||||
QVBoxLayout *lay = new QVBoxLayout(popup);
|
||||
QLineEdit *le = new QLineEdit(popup);
|
||||
QLabel *lblTxt = new QLabel(tr("Acknowledged by:"), popup);
|
||||
LtsWidgets::LtsFramelessDialog* popup = new LtsWidgets::LtsFramelessDialog(this, LtsWidgets::Behaviour::Popup);
|
||||
LtsWidgets::LtsDialogButtonBox* btnBox = new LtsWidgets::LtsDialogButtonBox(popup);
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(false);
|
||||
QVBoxLayout* lay = new QVBoxLayout(popup);
|
||||
QLineEdit* le = new QLineEdit(popup);
|
||||
QLabel* lblTxt = new QLabel(tr("Acknowledged by:"), popup);
|
||||
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, popup, &LtsWidgets::LtsFramelessDialog::accept);
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, popup,
|
||||
&LtsWidgets::LtsFramelessDialog::accept);
|
||||
|
||||
|
||||
connect(le, &QLineEdit::textChanged, this, [btnBox](const QString &text)
|
||||
{
|
||||
const int textMinSize = 5;
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(text.trimmed().size() >= textMinSize);
|
||||
});
|
||||
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, [this, le, popup]()
|
||||
{
|
||||
sendAcknowledgeEmergency(le->text());
|
||||
popup->accept();
|
||||
});
|
||||
connect(le, &QLineEdit::textChanged, this, [btnBox](const QString& text) {
|
||||
const int textMinSize = 5;
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(text.trimmed().size() >= textMinSize);
|
||||
});
|
||||
|
||||
lay->addWidget(lblTxt);
|
||||
lay->addWidget(le);
|
||||
lay->addWidget(btnBox);
|
||||
popup->setLayout(lay);
|
||||
popup->setMinimumWidth(350);
|
||||
popup->show();
|
||||
le->setFocus();
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, [this, le, popup]() {
|
||||
sendAcknowledgeEmergency(le->text());
|
||||
popup->accept();
|
||||
});
|
||||
|
||||
lay->addWidget(lblTxt);
|
||||
lay->addWidget(le);
|
||||
lay->addWidget(btnBox);
|
||||
popup->setLayout(lay);
|
||||
popup->setMinimumWidth(350);
|
||||
popup->show();
|
||||
le->setFocus();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallDialog::onEditBtCliked()
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
|
||||
const AlmEmergencyCall &sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
setAcknowledgeUi();
|
||||
const AlmEmergencyCall& sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
setAcknowledgeUi();
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EmergencyCallDialog::onSetShowExpired(bool show)
|
||||
{
|
||||
if (m_proxyModel)
|
||||
m_proxyModel->setShowExpired(show);
|
||||
if (m_proxyModel)
|
||||
m_proxyModel->setShowExpired(show);
|
||||
|
||||
|
||||
if (!m_updateSOSGuard)
|
||||
m_updateSOSGuard = QSharedPointer<UpdateSOSGuard>(new UpdateSOSGuard(m_sitMapGuiIfc));
|
||||
m_updateSOSGuard->showExpiredSOS(show);
|
||||
if (!m_updateSOSGuard)
|
||||
m_updateSOSGuard = QSharedPointer<UpdateSOSGuard>(new UpdateSOSGuard(m_sitMapGuiIfc));
|
||||
m_updateSOSGuard->showExpiredSOS(show);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallDialog::onFindEmergencyOnMap()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
const AlmEmergencyCall &sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
const AlmEmergencyCall& sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
|
||||
m_sitMapGuiIfc->setCenterPoint(QPointF(sos.position().lon(), sos.position().lat()));
|
||||
m_sitMapGuiIfc->setCenterPoint(QPointF(sos.position().lon(), sos.position().lat()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallDialog::onEmergencyIndexDoubleClicked(const QModelIndex &index)
|
||||
void EmergencyCallDialog::onEmergencyIndexDoubleClicked(const QModelIndex& index)
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
emit openInfoDlg(getSelectedSOS().id());
|
||||
Q_UNUSED(index)
|
||||
emit openInfoDlg(getSelectedSOS().id());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallDialog::sendAcknowledgeEmergency(const QString &comment)
|
||||
void EmergencyCallDialog::sendAcknowledgeEmergency(const QString& comment)
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
|
||||
const AlmEmergencyCall &sos = getSelectedSOS();
|
||||
if (sos.id() <= 0 || sos.expired())
|
||||
return;
|
||||
const AlmEmergencyCall& sos = getSelectedSOS();
|
||||
if (sos.id() <= 0 || sos.expired())
|
||||
return;
|
||||
|
||||
EmergencyCallAcknowledgeRequest request;
|
||||
request.id(sos.id());
|
||||
request.issi(sos.issi());
|
||||
request.name(sos.name());
|
||||
request.timestamp(QDateTime::currentMSecsSinceEpoch());
|
||||
request.incomingTime(sos.incomingTime());
|
||||
request.expired(true);
|
||||
request.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
request.comment(comment.toStdString());
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_ftc->emergencyCallAcknowledgeRequest(request, this);
|
||||
});
|
||||
EmergencyCallAcknowledgeRequest request;
|
||||
request.id(sos.id());
|
||||
request.issi(sos.issi());
|
||||
request.name(sos.name());
|
||||
request.timestamp(QDateTime::currentMSecsSinceEpoch());
|
||||
request.incomingTime(sos.incomingTime());
|
||||
request.expired(true);
|
||||
request.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
request.comment(comment.toStdString());
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_ftc->emergencyCallAcknowledgeRequest(request, this); });
|
||||
|
||||
enaDisa();
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
enaDisa();
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
void EmergencyCallDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->emergencyCallView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->emergencyCallView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
EmergencyCallDialog::~EmergencyCallDialog()
|
||||
{
|
||||
|
||||
|
||||
|
||||
delete m_ui;
|
||||
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+141
-163
@@ -1,242 +1,220 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_emergency_call_info_dialog.h"
|
||||
|
||||
#include "ui_alm_emergency_call_info_dialog.h"
|
||||
|
||||
#include <AlarmManagement/alm_operator_rights.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <AlarmManagement/alm_operator_rights.h>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
QImage renderEmergencySymbol(bool expired = false)
|
||||
{
|
||||
int size = 64;
|
||||
QImage image(size, size, QImage::Format_ARGB32);
|
||||
image.fill(Qt::transparent);
|
||||
int size = 64;
|
||||
QImage image(size, size, QImage::Format_ARGB32);
|
||||
image.fill(Qt::transparent);
|
||||
|
||||
QPainter painter(&image);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
QPainter painter(&image);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QPen pen(Qt::white);
|
||||
pen.setWidth(3);
|
||||
painter.setPen(pen);
|
||||
QPen pen(Qt::white);
|
||||
pen.setWidth(3);
|
||||
painter.setPen(pen);
|
||||
|
||||
painter.setBrush( expired ? QBrush(Qt::gray) : QBrush(Qt::red));
|
||||
painter.drawEllipse(QPointF(image.rect().center()),
|
||||
image.rect().width() * 0.45,
|
||||
image.rect().height() * 0.45);
|
||||
painter.setBrush(expired ? QBrush(Qt::gray) : QBrush(Qt::red));
|
||||
painter.drawEllipse(QPointF(image.rect().center()), image.rect().width() * 0.45, image.rect().height() * 0.45);
|
||||
|
||||
painter.setPen(QPen(Qt::white));
|
||||
painter.setPen(QPen(Qt::white));
|
||||
|
||||
QFont font = painter.font();
|
||||
font.setBold(true);
|
||||
font.setPixelSize(26);
|
||||
painter.setFont(font);
|
||||
QFont font = painter.font();
|
||||
font.setBold(true);
|
||||
font.setPixelSize(26);
|
||||
painter.setFont(font);
|
||||
|
||||
QPointF pos(image.width() * 0.125,
|
||||
image.height() * 0.625);
|
||||
QPointF pos(image.width() * 0.125, image.height() * 0.625);
|
||||
|
||||
painter.drawText(pos, QLatin1String("SOS"));
|
||||
painter.drawText(pos, QLatin1String("SOS"));
|
||||
|
||||
return image;
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EmergencyCallInfoDialog::EmergencyCallInfoDialog(int entryId, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::EmergencyCallInfoDialog)
|
||||
EmergencyCallInfoDialog::EmergencyCallInfoDialog(int entryId, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_dtc(nullptr), m_ftc(nullptr),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this)), m_ui(new Ui::EmergencyCallInfoDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_emergency.id(entryId);
|
||||
m_ui->setupUi(this);
|
||||
m_emergency.id(entryId);
|
||||
}
|
||||
|
||||
EmergencyCallInfoDialog::~EmergencyCallInfoDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool EmergencyCallInfoDialog::init(const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc>&opmDtc)
|
||||
bool EmergencyCallInfoDialog::init(const std::shared_ptr<Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface>& sitMapGuiIfc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc>& opmDtc)
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
if (!ftc || !dtc)
|
||||
{
|
||||
ERROR_LOG(m_logger)<<" init Emergency call Info dialog failed !!";
|
||||
return false;
|
||||
}
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
if (!ftc || !dtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << " init Emergency call Info dialog failed !!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_opmDtc = opmDtc;
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_opmDtc = opmDtc;
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
|
||||
m_dtc->enableAlmEmergencyCall();
|
||||
m_ftc->enableEmergencyCallAcknowledge();
|
||||
m_dtc->enableAlmEmergencyCall();
|
||||
m_ftc->enableEmergencyCallAcknowledge();
|
||||
|
||||
|
||||
m_emergency = m_dtc->almEmergencyCall(m_emergency.id());
|
||||
setUiValues();
|
||||
m_emergency = m_dtc->almEmergencyCall(m_emergency.id());
|
||||
setUiValues();
|
||||
|
||||
connect(m_dtc.get(), &AlarmManagement::Interface::Dtc::almEmergencyCallChanged, this, &EmergencyCallInfoDialog::onEmergencyCallChanged );
|
||||
connect(m_ui->pbAckEmergency, &QPushButton::clicked, this, &EmergencyCallInfoDialog::onPbAckEmergencyClicked );
|
||||
connect(m_ui->pbEmergencyCallFindOnMap, &QPushButton::clicked, this, &EmergencyCallInfoDialog::onFindEmergencyOnMap);
|
||||
connect(m_dtc.get(), &AlarmManagement::Interface::Dtc::almEmergencyCallChanged, this,
|
||||
&EmergencyCallInfoDialog::onEmergencyCallChanged);
|
||||
connect(m_ui->pbAckEmergency, &QPushButton::clicked, this, &EmergencyCallInfoDialog::onPbAckEmergencyClicked);
|
||||
connect(m_ui->pbEmergencyCallFindOnMap, &QPushButton::clicked, this,
|
||||
&EmergencyCallInfoDialog::onFindEmergencyOnMap);
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString EmergencyCallInfoDialog::emergencyIdentifier() const
|
||||
{
|
||||
return QStringLiteral("emergency_") + QString::number(m_emergency.id());
|
||||
return QStringLiteral("emergency_") + QString::number(m_emergency.id());
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool EmergencyCallInfoDialog::setUiValues()
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
if (!m_dtc || !m_ftc || m_emergency.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger)<<" >> unabled to init EmergencyCallInfoDialog";
|
||||
return false;
|
||||
}
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
if (!m_dtc || !m_ftc || m_emergency.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << " >> unabled to init EmergencyCallInfoDialog";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ui->lblEquipNr->setText(QString::number(m_emergency.issi()));
|
||||
m_ui->lblIncomingTime->setText(DTG::toString(QDateTime::fromMSecsSinceEpoch(m_emergency.incomingTime())));
|
||||
m_ui->lblStatus->setText(m_emergency.expired() ? DTG::toString(QDateTime::fromMSecsSinceEpoch(m_emergency.deleted())) : QStringLiteral("--"));
|
||||
m_ui->lblComment->setText(QString::fromStdString(m_emergency.comment()));
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(m_emergency.position().lon(), m_emergency.position().lat());
|
||||
m_ui->lblPosition->setText(mgrs);
|
||||
m_ui->lblEquipNr->setText(QString::number(m_emergency.issi()));
|
||||
m_ui->lblIncomingTime->setText(DTG::toString(QDateTime::fromMSecsSinceEpoch(m_emergency.incomingTime())));
|
||||
m_ui->lblStatus->setText(m_emergency.expired()
|
||||
? DTG::toString(QDateTime::fromMSecsSinceEpoch(m_emergency.deleted()))
|
||||
: QStringLiteral("--"));
|
||||
m_ui->lblComment->setText(QString::fromStdString(m_emergency.comment()));
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(m_emergency.position().lon(), m_emergency.position().lat());
|
||||
m_ui->lblPosition->setText(mgrs);
|
||||
|
||||
|
||||
const bool &hasOperatorRightEmergencyCall = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::EmergencyCall);
|
||||
m_ui->pbAckEmergency->setIcon(QIcon(QStringLiteral("icon:edit.svg")));
|
||||
m_ui->pbAckEmergency->setEnabled(m_emergency.expired() ? false : true);
|
||||
m_ui->pbAckEmergency->setVisible(hasOperatorRightEmergencyCall);
|
||||
const bool& hasOperatorRightEmergencyCall =
|
||||
LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::EmergencyCall);
|
||||
m_ui->pbAckEmergency->setIcon(QIcon(QStringLiteral("icon:edit.svg")));
|
||||
m_ui->pbAckEmergency->setEnabled(m_emergency.expired() ? false : true);
|
||||
m_ui->pbAckEmergency->setVisible(hasOperatorRightEmergencyCall);
|
||||
|
||||
|
||||
QPixmap iconPixmap = QPixmap::fromImage(renderEmergencySymbol(m_emergency.expired()));
|
||||
m_ui->lblIcon->setPixmap(iconPixmap);
|
||||
QPixmap iconPixmap = QPixmap::fromImage(renderEmergencySymbol(m_emergency.expired()));
|
||||
m_ui->lblIcon->setPixmap(iconPixmap);
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallInfoDialog::onEmergencyCallChanged(AlarmManagement::AlmEmergencyCall data, DataModification modType)
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
if (data.id() != m_emergency.id() || data.id() == 0)
|
||||
return;
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
if (data.id() != m_emergency.id() || data.id() == 0)
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
m_ui->pbAckEmergency->setEnabled(false);
|
||||
m_ui->pbEmergencyCallFindOnMap->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
m_emergency = data;
|
||||
setUiValues();
|
||||
}
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
m_ui->pbAckEmergency->setEnabled(false);
|
||||
m_ui->pbEmergencyCallFindOnMap->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
m_emergency = data;
|
||||
setUiValues();
|
||||
}
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallInfoDialog::onFindEmergencyOnMap()
|
||||
{
|
||||
if (!m_sitMapGuiIfc || m_emergency.id() <= 0)
|
||||
return;
|
||||
m_sitMapGuiIfc->setCenterPoint(QPointF(m_emergency.position().lon(), m_emergency.position().lat()));
|
||||
if (!m_sitMapGuiIfc || m_emergency.id() <= 0)
|
||||
return;
|
||||
m_sitMapGuiIfc->setCenterPoint(QPointF(m_emergency.position().lon(), m_emergency.position().lat()));
|
||||
}
|
||||
|
||||
void EmergencyCallInfoDialog::onPbAckEmergencyClicked()
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
|
||||
LtsWidgets::LtsFramelessDialog *popup = new LtsWidgets::LtsFramelessDialog(this, LtsWidgets::Behaviour::Popup);
|
||||
LtsWidgets::LtsDialogButtonBox *btnBox = new LtsWidgets::LtsDialogButtonBox(popup);
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(false);
|
||||
QVBoxLayout *lay = new QVBoxLayout(popup);
|
||||
QLineEdit *le = new QLineEdit(popup);
|
||||
QLabel *lblTxt = new QLabel(tr("Acknowledged by:"), popup);
|
||||
LtsWidgets::LtsFramelessDialog* popup = new LtsWidgets::LtsFramelessDialog(this, LtsWidgets::Behaviour::Popup);
|
||||
LtsWidgets::LtsDialogButtonBox* btnBox = new LtsWidgets::LtsDialogButtonBox(popup);
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(false);
|
||||
QVBoxLayout* lay = new QVBoxLayout(popup);
|
||||
QLineEdit* le = new QLineEdit(popup);
|
||||
QLabel* lblTxt = new QLabel(tr("Acknowledged by:"), popup);
|
||||
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, popup, &LtsWidgets::LtsFramelessDialog::accept);
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, popup,
|
||||
&LtsWidgets::LtsFramelessDialog::accept);
|
||||
|
||||
|
||||
connect(le, &QLineEdit::textChanged, this, [btnBox](const QString &text)
|
||||
{
|
||||
const int textMinSize = 5;
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(text.trimmed().size() >= textMinSize);
|
||||
});
|
||||
connect(le, &QLineEdit::textChanged, this, [btnBox](const QString& text) {
|
||||
const int textMinSize = 5;
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(text.trimmed().size() >= textMinSize);
|
||||
});
|
||||
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, [this, le, popup]()
|
||||
{
|
||||
const QString c = le->text().trimmed();
|
||||
sendAcknowledgeEmergencyCallRequest(c);
|
||||
popup->accept();
|
||||
});
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, [this, le, popup]() {
|
||||
const QString c = le->text().trimmed();
|
||||
sendAcknowledgeEmergencyCallRequest(c);
|
||||
popup->accept();
|
||||
});
|
||||
|
||||
lay->addWidget(lblTxt);
|
||||
lay->addWidget(le);
|
||||
lay->addWidget(btnBox);
|
||||
popup->setLayout(lay);
|
||||
popup->setMinimumWidth(350);
|
||||
popup->show();
|
||||
le->setFocus();
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
lay->addWidget(lblTxt);
|
||||
lay->addWidget(le);
|
||||
lay->addWidget(btnBox);
|
||||
popup->setLayout(lay);
|
||||
popup->setMinimumWidth(350);
|
||||
popup->show();
|
||||
le->setFocus();
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallInfoDialog::sendAcknowledgeEmergencyCallRequest(const QString &comment)
|
||||
void EmergencyCallInfoDialog::sendAcknowledgeEmergencyCallRequest(const QString& comment)
|
||||
{
|
||||
if (m_emergency.id() <= 0)
|
||||
return ;
|
||||
if (m_emergency.id() <= 0)
|
||||
return;
|
||||
|
||||
EmergencyCallAcknowledgeRequest request;
|
||||
request.id(m_emergency.id());
|
||||
request.name(m_emergency.name());
|
||||
request.issi(m_emergency.issi());
|
||||
request.timestamp(QDateTime::currentMSecsSinceEpoch());
|
||||
request.incomingTime(m_emergency.incomingTime());
|
||||
request.expired(true);
|
||||
request.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
request.comment(comment.toStdString());
|
||||
bool ret = m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_ftc->emergencyCallAcknowledgeRequest(request, this);
|
||||
});
|
||||
EmergencyCallAcknowledgeRequest request;
|
||||
request.id(m_emergency.id());
|
||||
request.name(m_emergency.name());
|
||||
request.issi(m_emergency.issi());
|
||||
request.timestamp(QDateTime::currentMSecsSinceEpoch());
|
||||
request.incomingTime(m_emergency.incomingTime());
|
||||
request.expired(true);
|
||||
request.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
request.comment(comment.toStdString());
|
||||
bool ret = m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_ftc->emergencyCallAcknowledgeRequest(request, this); });
|
||||
|
||||
if (ret)
|
||||
setUiValues();
|
||||
if (ret)
|
||||
setUiValues();
|
||||
}
|
||||
|
||||
void EmergencyCallInfoDialog::retranslate()
|
||||
{
|
||||
m_emergency = m_dtc->almEmergencyCall(m_emergency.id());
|
||||
const QString lbName = tr("SOS_%1").arg(m_emergency.issi());
|
||||
translate(m_ui, lbName);
|
||||
m_emergency = m_dtc->almEmergencyCall(m_emergency.id());
|
||||
const QString lbName = tr("SOS_%1").arg(m_emergency.issi());
|
||||
translate(m_ui, lbName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+52
-53
@@ -1,6 +1,5 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AlarmManagement/alm_dtc.h>
|
||||
@@ -8,7 +7,6 @@
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace AlarmManagement
|
||||
@@ -16,67 +14,68 @@ namespace AlarmManagement
|
||||
|
||||
class EmergencyCallModel : public LtsWidgets::LtsAbstractTableModel<AlarmManagement::AlmEmergencyCall>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
ID,
|
||||
SAMPLE_TIME,
|
||||
INCOMING_TIME,
|
||||
NAME,
|
||||
ISSI,
|
||||
POSITION,
|
||||
EXPIRED,
|
||||
OPERATION_ID,
|
||||
DELETED_TIMESTAMP,
|
||||
COMMENT
|
||||
};
|
||||
explicit EmergencyCallModel(QObject *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns {
|
||||
ID,
|
||||
SAMPLE_TIME,
|
||||
INCOMING_TIME,
|
||||
NAME,
|
||||
ISSI,
|
||||
POSITION,
|
||||
EXPIRED,
|
||||
OPERATION_ID,
|
||||
DELETED_TIMESTAMP,
|
||||
COMMENT
|
||||
};
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
bool initModel(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc);
|
||||
explicit EmergencyCallModel(QObject* parent = nullptr);
|
||||
|
||||
private slots:
|
||||
void onAlarmEmergencyCallChanged(const AlarmManagement::AlmEmergencyCall &data, const DataModification modType);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
friend class EmergencyCallProxyModel;
|
||||
QVariant data(const QModelIndex& index, int role) const override final;
|
||||
bool initModel(const std::shared_ptr<Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc>& opmDtc);
|
||||
|
||||
private slots:
|
||||
void onAlarmEmergencyCallChanged(const AlarmManagement::AlmEmergencyCall& data, const DataModification modType);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
friend class EmergencyCallProxyModel;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class EmergencyCallProxyModel : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
bool showExpired() const { return m_showExpired; }
|
||||
bool exerciseStopped()const {return m_hideByExerciseStopped;}
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
void hideByExerciseStopped(bool show);
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
|
||||
public slots:
|
||||
void setShowExpired(bool show);
|
||||
bool showExpired() const
|
||||
{
|
||||
return m_showExpired;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override final;
|
||||
bool exerciseStopped() const
|
||||
{
|
||||
return m_hideByExerciseStopped;
|
||||
}
|
||||
|
||||
private:
|
||||
bool checkFilter(int source_row) const;
|
||||
void setSourceModel(QAbstractItemModel* sourceModel) override;
|
||||
void hideByExerciseStopped(bool show);
|
||||
|
||||
private:
|
||||
bool m_showExpired{false};
|
||||
bool m_hideByExerciseStopped{false};
|
||||
EmergencyCallModel *m_sourceModel{nullptr};
|
||||
public slots:
|
||||
void setShowExpired(bool show);
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override final;
|
||||
|
||||
private:
|
||||
bool checkFilter(int source_row) const;
|
||||
|
||||
private:
|
||||
bool m_showExpired{false};
|
||||
bool m_hideByExerciseStopped{false};
|
||||
EmergencyCallModel* m_sourceModel{nullptr};
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+259
-275
@@ -1,347 +1,331 @@
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <ChargeEffect/aes_charge_effect_edit.h>
|
||||
#include <ChargeEffect/aes_charge_effect_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/BCContamination/aes_bccontamination_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/NContamination/aes_ncontamination_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Explosion/aes_explosion_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineArea/aes_mine_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineCorridor/aes_mine_corridor_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/GasPipe/aes_gas_pipe_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/DangerArea/aes_danger_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Borderline/aes_borderline_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/FunctionalArea/aes_functional_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineSingleVirtual/aes_mine_single_virtual_gui_plugin_interface.h>
|
||||
#include "aes_charge_effect_item_info.h"
|
||||
|
||||
#include "aes_translation.h"
|
||||
#include "aes_charge_effect_item_info.h"
|
||||
#include "ui_aes_charge_effect_item_info.h"
|
||||
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <ChargeEffect/aes_charge_effect_edit.h>
|
||||
#include <ChargeEffect/aes_charge_effect_gui_plugin_interface.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/BCContamination/aes_bccontamination_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Borderline/aes_borderline_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/DangerArea/aes_danger_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Explosion/aes_explosion_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/FunctionalArea/aes_functional_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/GasPipe/aes_gas_pipe_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineArea/aes_mine_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineCorridor/aes_mine_corridor_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineSingleVirtual/aes_mine_single_virtual_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/NContamination/aes_ncontamination_gui_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
AesChargeEffectItemInfo::AesChargeEffectItemInfo(int chargeEffectId, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_session(nullptr)
|
||||
, m_ChargeEffectId(chargeEffectId)
|
||||
, m_ui(new Ui::AesChargeEffectItemInfo)
|
||||
AesChargeEffectItemInfo::AesChargeEffectItemInfo(int chargeEffectId, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_session(nullptr),
|
||||
m_ChargeEffectId(chargeEffectId), m_ui(new Ui::AesChargeEffectItemInfo)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->lblChargeEffectId->setText(QString::number(m_ChargeEffectId));
|
||||
|
||||
connect(m_ui->pbFindOnMap, &QToolButton::clicked, this, &AesChargeEffectItemInfo::onFindOnMap);
|
||||
connect(m_ui->pbDetails, &QToolButton::clicked, this, &AesChargeEffectItemInfo::onShowDetails);
|
||||
m_ui->lblChargeEffectId->setText(QString::number(m_ChargeEffectId));
|
||||
|
||||
connect(m_ui->pbFindOnMap, &QToolButton::clicked, this, &AesChargeEffectItemInfo::onFindOnMap);
|
||||
connect(m_ui->pbDetails, &QToolButton::clicked, this, &AesChargeEffectItemInfo::onShowDetails);
|
||||
}
|
||||
|
||||
AesChargeEffectItemInfo::~AesChargeEffectItemInfo()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool AesChargeEffectItemInfo::init(LtsSession::LtsSession *session)
|
||||
bool AesChargeEffectItemInfo::init(LtsSession::LtsSession* session)
|
||||
{
|
||||
m_session = session;
|
||||
m_session = session;
|
||||
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get pdmDtc";
|
||||
return false;
|
||||
}
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get pdmDtc";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get aesDtc";
|
||||
return false;
|
||||
}
|
||||
if (!m_aesDtc->isAesItemViewEnabled())
|
||||
m_aesDtc->enableAesItemView();
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get aesDtc";
|
||||
return false;
|
||||
}
|
||||
if (!m_aesDtc->isAesItemViewEnabled())
|
||||
m_aesDtc->enableAesItemView();
|
||||
|
||||
if (!m_pdmDtc->isChargeTypeEnabled())
|
||||
m_pdmDtc->enableChargeType();
|
||||
if (!m_pdmDtc->isChargeTypeEnabled())
|
||||
m_pdmDtc->enableChargeType();
|
||||
|
||||
const ChargeEffect data = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
|
||||
m_ui->lblPosition->hide();
|
||||
|
||||
const ChargeEffect data = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
|
||||
m_ui->lblPosition->hide();
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->lbxChargeEffectId->hide();
|
||||
m_ui->lblChargeEffectId->hide();
|
||||
m_ui->lbxChargeTypeId->hide();
|
||||
m_ui->lblChargeTypeId->hide();
|
||||
m_ui->lbxOriginatorId->hide();
|
||||
m_ui->lblOriginatorId->hide();
|
||||
m_ui->lbxOriginatorType->hide();
|
||||
m_ui->lblOriginatorType->hide();
|
||||
m_ui->lbxChargeEffectId->hide();
|
||||
m_ui->lblChargeEffectId->hide();
|
||||
m_ui->lbxChargeTypeId->hide();
|
||||
m_ui->lblChargeTypeId->hide();
|
||||
m_ui->lbxOriginatorId->hide();
|
||||
m_ui->lblOriginatorId->hide();
|
||||
m_ui->lbxOriginatorType->hide();
|
||||
m_ui->lblOriginatorType->hide();
|
||||
#endif
|
||||
|
||||
m_ui->lblOriginatorId->setText(QString::number(data.originatorId()));
|
||||
m_ui->lblOriginatorType->setText(QString::number(data.originatorTypeId().underlying()));
|
||||
m_ui->lblOriginatorId->setText(QString::number(data.originatorId()));
|
||||
m_ui->lblOriginatorType->setText(QString::number(data.originatorTypeId().underlying()));
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Charge_Effect"));
|
||||
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Charge_Effect"));
|
||||
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::chargeEffectChanged, this,
|
||||
&AesChargeEffectItemInfo::onChargeEffectChanged);
|
||||
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::chargeEffectChanged,
|
||||
this, &AesChargeEffectItemInfo::onChargeEffectChanged);
|
||||
handleChargeEffect(data);
|
||||
|
||||
handleChargeEffect(data);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::retranslate()
|
||||
{
|
||||
const ChargeEffect item = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
const ChargeEffect item = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
translate(m_ui, tr("ChargeEffect: \"%1\"").arg(QString::fromStdString(item.name()), 1, QLatin1Char('?')));
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::onFindOnMap() const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onFindOnMap() aesId: "<<m_ChargeEffectId;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(ifc))
|
||||
ifc->centerMapToChargeEffectObject(m_ChargeEffectId);
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << "getForeignGuiInterface<SituationMap::ForeignGuiInterface> failed!";
|
||||
DEBUG_LOG(m_logger) << "onFindOnMap() aesId: " << m_ChargeEffectId;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(ifc))
|
||||
ifc->centerMapToChargeEffectObject(m_ChargeEffectId);
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << "getForeignGuiInterface<SituationMap::ForeignGuiInterface> failed!";
|
||||
}
|
||||
|
||||
template <typename InterfaceType>
|
||||
bool AesChargeEffectItemInfo::tryShowStandardEditDialog(const AesItemView& aiv)
|
||||
template <typename InterfaceType> bool AesChargeEffectItemInfo::tryShowStandardEditDialog(const AesItemView& aiv)
|
||||
{
|
||||
std::shared_ptr<InterfaceType> ifc;
|
||||
if (m_session->getForeignGuiInterface<InterfaceType>(ifc))
|
||||
{
|
||||
AreaEffectSimulation::BaseEdit* dialog = ifc->showEditWindow(aiv.aesItemId(), this);
|
||||
if (dialog)
|
||||
std::shared_ptr<InterfaceType> ifc;
|
||||
if (m_session->getForeignGuiInterface<InterfaceType>(ifc))
|
||||
{
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
AreaEffectSimulation::BaseEdit* dialog = ifc->showEditWindow(aiv.aesItemId(), this);
|
||||
if (dialog)
|
||||
{
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface failed for specific AES interface!";
|
||||
return false;
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface failed for specific AES interface!";
|
||||
return false;
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::onShowDetails()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
|
||||
const ChargeEffect item = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
const ChargeEffect item = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
|
||||
if (item.originatorTypeId() == ProjectDataManagement::StateChangeOriginator::AreaEffectSimulation)
|
||||
{
|
||||
AesItemView aiv;
|
||||
m_aesDtc->aesItemViewFromEntityId(item.originatorId(), AreaEffectSimulation::AesType::AtUnknown, aiv);
|
||||
DEBUG_LOG(m_logger) << "aiv.id():" << aiv.id() << ", aesType: " << aiv.aesTypeId();
|
||||
if (item.originatorTypeId() == ProjectDataManagement::StateChangeOriginator::AreaEffectSimulation)
|
||||
{
|
||||
AesItemView aiv;
|
||||
m_aesDtc->aesItemViewFromEntityId(item.originatorId(), AreaEffectSimulation::AesType::AtUnknown, aiv);
|
||||
DEBUG_LOG(m_logger) << "aiv.id():" << aiv.id() << ", aesType: " << aiv.aesTypeId();
|
||||
|
||||
|
||||
auto registerDialog = [this](AreaEffectSimulation::BaseEdit* dialog) {
|
||||
if (dialog) {
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
};
|
||||
auto registerDialog = [this](AreaEffectSimulation::BaseEdit* dialog) {
|
||||
if (dialog)
|
||||
{
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
};
|
||||
|
||||
switch(aiv.aesTypeId().underlying())
|
||||
{
|
||||
case AreaEffectSimulation::AesType::AtNContamination:
|
||||
{
|
||||
tryShowStandardEditDialog<AesNContamination::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtMineArea:
|
||||
{
|
||||
tryShowStandardEditDialog<AesMineArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtMineCorridor:
|
||||
{
|
||||
tryShowStandardEditDialog<AesMineCorridor::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtGasPipe:
|
||||
{
|
||||
tryShowStandardEditDialog<AesGasPipe::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtDangerArea:
|
||||
{
|
||||
tryShowStandardEditDialog<AesDangerArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtBorderline:
|
||||
{
|
||||
tryShowStandardEditDialog<AesBorderline::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtFunctionalArea:
|
||||
{
|
||||
tryShowStandardEditDialog<AesFunctionalArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtBCContamination:
|
||||
{
|
||||
std::shared_ptr<AesBCContamination::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesBCContamination::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
const auto gearClass = m_pdmDtc->gearClassFromChargeTypeId(aiv.chargeStruct().chargeTypeId());
|
||||
if (gearClass == ProjectDataManagement::GearClass_def::Biological)
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), false, this));
|
||||
else if (gearClass == ProjectDataManagement::GearClass_def::Chemical)
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), true, this));
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface<AesBCContamination::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtBoobyTrap:
|
||||
case AreaEffectSimulation::AesType::AtBoobyTrapSecondary:
|
||||
{
|
||||
std::shared_ptr<AesMineSingleVirtual::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface>(ifc))
|
||||
registerDialog(ifc->showBoobyTrapEditWindow(aiv.aesItemId(), this));
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtOffRouteMine:
|
||||
case AreaEffectSimulation::AesType::AtOffRouteMineSecondary:
|
||||
{
|
||||
std::shared_ptr<AesMineSingleVirtual::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface>(ifc))
|
||||
registerDialog(ifc->showOffRouteMineEditWindow(aiv.aesItemId(), this));
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingle:
|
||||
case AreaEffectSimulation::AesType::AtExplosionArea:
|
||||
{
|
||||
std::shared_ptr<AesExplosion::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesExplosion::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
const bool isExplosionSingle = (aiv.aesTypeId().underlying() == AreaEffectSimulation::AesType::AtExplosionSingle);
|
||||
const auto gearClass = m_pdmDtc->gearClassFromChargeTypeId(aiv.chargeStruct().chargeTypeId());
|
||||
|
||||
for (auto gc : { ProjectDataManagement::GearClass::Artillery, ProjectDataManagement::GearClass::Mortar, ProjectDataManagement::GearClass::AirSupport })
|
||||
switch (aiv.aesTypeId().underlying())
|
||||
{
|
||||
if (gc == ProjectDataManagement::GearClass::AirSupport && !isExplosionSingle) continue;
|
||||
case AreaEffectSimulation::AesType::AtNContamination: {
|
||||
tryShowStandardEditDialog<AesNContamination::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtMineArea: {
|
||||
tryShowStandardEditDialog<AesMineArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
if (gearClass == gc)
|
||||
{
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), isExplosionSingle, false, gc, this));
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtMineCorridor: {
|
||||
tryShowStandardEditDialog<AesMineCorridor::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtGasPipe: {
|
||||
tryShowStandardEditDialog<AesGasPipe::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtDangerArea: {
|
||||
tryShowStandardEditDialog<AesDangerArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtBorderline: {
|
||||
tryShowStandardEditDialog<AesBorderline::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtFunctionalArea: {
|
||||
tryShowStandardEditDialog<AesFunctionalArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtBCContamination: {
|
||||
std::shared_ptr<AesBCContamination::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesBCContamination::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
const auto gearClass = m_pdmDtc->gearClassFromChargeTypeId(aiv.chargeStruct().chargeTypeId());
|
||||
if (gearClass == ProjectDataManagement::GearClass_def::Biological)
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), false, this));
|
||||
else if (gearClass == ProjectDataManagement::GearClass_def::Chemical)
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), true, this));
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger)
|
||||
<< Q_FUNC_INFO << " getForeignGuiInterface<AesBCContamination::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtBoobyTrap:
|
||||
case AreaEffectSimulation::AesType::AtBoobyTrapSecondary: {
|
||||
std::shared_ptr<AesMineSingleVirtual::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface>(ifc))
|
||||
registerDialog(ifc->showBoobyTrapEditWindow(aiv.aesItemId(), this));
|
||||
else
|
||||
WARNING_LOG(m_logger)
|
||||
<< Q_FUNC_INFO << " getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtOffRouteMine:
|
||||
case AreaEffectSimulation::AesType::AtOffRouteMineSecondary: {
|
||||
std::shared_ptr<AesMineSingleVirtual::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface>(ifc))
|
||||
registerDialog(ifc->showOffRouteMineEditWindow(aiv.aesItemId(), this));
|
||||
else
|
||||
WARNING_LOG(m_logger)
|
||||
<< Q_FUNC_INFO << " getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingle:
|
||||
case AreaEffectSimulation::AesType::AtExplosionArea: {
|
||||
std::shared_ptr<AesExplosion::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesExplosion::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
const bool isExplosionSingle =
|
||||
(aiv.aesTypeId().underlying() == AreaEffectSimulation::AesType::AtExplosionSingle);
|
||||
const auto gearClass = m_pdmDtc->gearClassFromChargeTypeId(aiv.chargeStruct().chargeTypeId());
|
||||
|
||||
for (auto gc :
|
||||
{ProjectDataManagement::GearClass::Artillery, ProjectDataManagement::GearClass::Mortar,
|
||||
ProjectDataManagement::GearClass::AirSupport})
|
||||
{
|
||||
if (gc == ProjectDataManagement::GearClass::AirSupport && !isExplosionSingle)
|
||||
continue;
|
||||
|
||||
if (gearClass == gc)
|
||||
{
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), isExplosionSingle, false, gc, this));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger)
|
||||
<< Q_FUNC_INFO << " getForeignGuiInterface<AesExplosion::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtExplosionCluster:
|
||||
case AreaEffectSimulation::AesType::AtEffectCluster: {
|
||||
std::shared_ptr<AesExplosion::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesExplosion::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
|
||||
AesItem ai;
|
||||
m_aesDtc->aesItemFromId(aiv.aesItemId(), ai);
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), ai.effectSourceId(), this));
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger)
|
||||
<< Q_FUNC_INFO << " getForeignGuiInterface<AesExplosion::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtAirSupportImpact:
|
||||
case AreaEffectSimulation::AesType::AtDusSingleMine:
|
||||
case AreaEffectSimulation::AesType::AtExplosionAreaSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtMineAreaSingleMines:
|
||||
case AreaEffectSimulation::AesType::AtReconArea:
|
||||
case AreaEffectSimulation::AesType::AtTechnicalArea:
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingleCentral:
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingleCentralTrajectory:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterSingleTrajectory:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterGunToTargetLine:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterGunToTargetLine:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterSingleTrajectory:
|
||||
|
||||
m_ui->pbDetails->hide();
|
||||
break;
|
||||
case AreaEffectSimulation::AesType::AtUnknown:
|
||||
Q_ASSERT(false);
|
||||
WARNING_LOG(m_logger) << "Unknown AesType found for aesEntityId: " << aiv.aesTypeId();
|
||||
break;
|
||||
default:
|
||||
DEBUG_LOG(m_logger) << "Couldn't find AesItem to ChargeEffect (any more). Hiding the button";
|
||||
m_ui->pbDetails->hide();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface<AesExplosion::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtExplosionCluster:
|
||||
case AreaEffectSimulation::AesType::AtEffectCluster:
|
||||
{
|
||||
std::shared_ptr<AesExplosion::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesExplosion::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
|
||||
AesItem ai;
|
||||
m_aesDtc->aesItemFromId(aiv.aesItemId(), ai);
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), ai.effectSourceId(), this));
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface<AesExplosion::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtAirSupportImpact:
|
||||
case AreaEffectSimulation::AesType::AtDusSingleMine:
|
||||
case AreaEffectSimulation::AesType::AtExplosionAreaSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtMineAreaSingleMines:
|
||||
case AreaEffectSimulation::AesType::AtReconArea:
|
||||
case AreaEffectSimulation::AesType::AtTechnicalArea:
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingleCentral:
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingleCentralTrajectory:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterSingleTrajectory:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterGunToTargetLine:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterGunToTargetLine:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterSingleTrajectory:
|
||||
|
||||
m_ui->pbDetails->hide();
|
||||
break;
|
||||
case AreaEffectSimulation::AesType::AtUnknown:
|
||||
Q_ASSERT(false);
|
||||
WARNING_LOG(m_logger) << "Unknown AesType found for aesEntityId: " << aiv.aesTypeId();
|
||||
break;
|
||||
default:
|
||||
DEBUG_LOG(m_logger) << "Couldn't find AesItem to ChargeEffect (any more). Hiding the button";
|
||||
m_ui->pbDetails->hide();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<AesChargeEffect::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesChargeEffect::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
AreaEffectSimulation::BaseEdit* dialog = ifc->showEditWindow(m_ChargeEffectId, this);
|
||||
if (dialog)
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface ChargeEffect failed!";
|
||||
}
|
||||
{
|
||||
std::shared_ptr<AesChargeEffect::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesChargeEffect::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
AreaEffectSimulation::BaseEdit* dialog = ifc->showEditWindow(m_ChargeEffectId, this);
|
||||
if (dialog)
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface ChargeEffect failed!";
|
||||
}
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::onChargeEffectChanged(const ChargeEffect &data, DataModification modType)
|
||||
void AesChargeEffectItemInfo::onChargeEffectChanged(const ChargeEffect& data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " [onChargeEffectChanged] id: " << data.id();
|
||||
if (data.id() == m_ChargeEffectId && modType != DataModification::eRemoved)
|
||||
handleChargeEffect(data);
|
||||
DEBUG_LOG(m_logger) << " [onChargeEffectChanged] id: " << data.id();
|
||||
if (data.id() == m_ChargeEffectId && modType != DataModification::eRemoved)
|
||||
handleChargeEffect(data);
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::handleChargeEffect(const ChargeEffect &data)
|
||||
void AesChargeEffectItemInfo::handleChargeEffect(const ChargeEffect& data)
|
||||
{
|
||||
|
||||
m_ui->lblChargeEffectName->setText(QString::fromStdString(data.name()));
|
||||
|
||||
|
||||
m_ui->lblEffectStart->setText(DTG::toStringMSec(data.effectStart()));
|
||||
|
||||
m_ui->lblChargeEffectName->setText(QString::fromStdString(data.name()));
|
||||
|
||||
m_ui->lblEffectDuration->setVisible(data.effectDuration() > 0);
|
||||
m_ui->lbxEffectDuration->setVisible(data.effectDuration() > 0);
|
||||
m_ui->lblEffectStart->setText(DTG::toStringMSec(data.effectStart()));
|
||||
|
||||
m_ui->lblEffectDuration->setText(LtsWidgets::readableDuration(data.effectDuration()));
|
||||
m_ui->lblEffectDuration->setVisible(data.effectDuration() > 0);
|
||||
m_ui->lbxEffectDuration->setVisible(data.effectDuration() > 0);
|
||||
|
||||
|
||||
AreaEffectSimulation::AesEffectState st = data.state();
|
||||
m_ui->lblStatus->setText(AreaEffectSimulation::toString(st));
|
||||
m_ui->lblEffectDuration->setText(LtsWidgets::readableDuration(data.effectDuration()));
|
||||
|
||||
|
||||
m_ui->lblChargeTypeId->setText(QString::number(data.chargeTypeId()));
|
||||
AreaEffectSimulation::AesEffectState st = data.state();
|
||||
m_ui->lblStatus->setText(AreaEffectSimulation::toString(st));
|
||||
|
||||
|
||||
m_ui->lblChargeType->setText(m_pdmDtc->trChargeTypeShortName(data.chargeTypeId()));
|
||||
m_ui->lblChargeType->setToolTip(m_pdmDtc->trChargeTypeName(data.chargeTypeId()));
|
||||
m_ui->lblChargeTypeId->setText(QString::number(data.chargeTypeId()));
|
||||
|
||||
|
||||
m_ui->lblPosition->show();
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(data.position().lon(), data.position().lat());
|
||||
m_ui->lblPosition->setText(tr("Position: %1").arg(mgrs));
|
||||
m_ui->lblChargeType->setText(m_pdmDtc->trChargeTypeShortName(data.chargeTypeId()));
|
||||
m_ui->lblChargeType->setToolTip(m_pdmDtc->trChargeTypeName(data.chargeTypeId()));
|
||||
|
||||
m_ui->lblPosition->show();
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(data.position().lon(), data.position().lat());
|
||||
m_ui->lblPosition->setText(tr("Position: %1").arg(mgrs));
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+96
-106
@@ -1,160 +1,150 @@
|
||||
|
||||
|
||||
|
||||
#include "aes_danger_area_aes_item_info.h"
|
||||
#include <utility>
|
||||
|
||||
#include "ui_aes_danger_area_aes_item_info.h"
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
|
||||
#include <BCContamination/aes_bccontamination_gui_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
|
||||
DangerAreaAesItemInfo::DangerAreaAesItemInfo(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_dtc(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_ui(new Ui::DangerAreaAesItemInfo)
|
||||
, m_aesItemId(-1)
|
||||
DangerAreaAesItemInfo::DangerAreaAesItemInfo(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_dtc(nullptr), m_session(nullptr),
|
||||
m_ui(new Ui::DangerAreaAesItemInfo), m_aesItemId(-1)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
DangerAreaAesItemInfo::~DangerAreaAesItemInfo()
|
||||
{
|
||||
for (const auto &item : std::as_const(m_aesItems))
|
||||
delete item.item;
|
||||
delete m_ui;
|
||||
for (const auto& item : std::as_const(m_aesItems))
|
||||
delete item.item;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void DangerAreaAesItemInfo::retranslate()
|
||||
{
|
||||
|
||||
std::unique_ptr<AesItem> item(new BCContamination(m_dtc->bCContamination(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->bCContamination(m_aesItemId), tr("B/C-Contamination"));
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<AesItem> item(new BCContamination(m_dtc->bCContamination(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->bCContamination(m_aesItemId), tr("B/C-Contamination"));
|
||||
return;
|
||||
}
|
||||
|
||||
item.reset(new NContamination(m_dtc->nContamination(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->nContamination(m_aesItemId), tr("N-Contamination"));
|
||||
return;
|
||||
}
|
||||
item.reset(new NContamination(m_dtc->nContamination(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->nContamination(m_aesItemId), tr("N-Contamination"));
|
||||
return;
|
||||
}
|
||||
|
||||
item.reset(new ExplosionArea(m_dtc->explosionArea(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->explosionArea(m_aesItemId), tr("Explosion Area"));
|
||||
return;
|
||||
}
|
||||
|
||||
item.reset(new ExplosionArea(m_dtc->explosionArea(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->explosionArea(m_aesItemId), tr("Explosion Area"));
|
||||
return;
|
||||
}
|
||||
item.reset(new ExplosionSingle(m_dtc->explosionSingle(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->explosionSingle(m_aesItemId), tr("Single Explosion"));
|
||||
return;
|
||||
}
|
||||
|
||||
item.reset(new MineArea(m_dtc->mineArea(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->mineArea(m_aesItemId), tr("Mine Area"));
|
||||
return;
|
||||
}
|
||||
|
||||
item.reset(new ExplosionSingle(m_dtc->explosionSingle(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->explosionSingle(m_aesItemId), tr("Single Explosion"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
item.reset(new MineArea(m_dtc->mineArea(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->mineArea(m_aesItemId), tr("Mine Area"));
|
||||
return;
|
||||
}
|
||||
|
||||
translate(m_ui, tr("Unknown Aes Type"));
|
||||
translate(m_ui, tr("Unknown Aes Type"));
|
||||
}
|
||||
|
||||
bool DangerAreaAesItemInfo::init(const QSet<int> &dangerAreaIds, const QSet<int> &aesItemIds, LtsSession::LtsSession *session)
|
||||
bool DangerAreaAesItemInfo::init(const QSet<int>& dangerAreaIds, const QSet<int>& aesItemIds,
|
||||
LtsSession::LtsSession* session)
|
||||
{
|
||||
if (!init(session))
|
||||
return false;
|
||||
if (!init(session))
|
||||
return false;
|
||||
|
||||
for (int dangerAreaId : dangerAreaIds)
|
||||
m_dangerAreas.insert(dangerAreaId, m_dtc->dangerArea(dangerAreaId));
|
||||
for (int aesItemId : aesItemIds)
|
||||
insertAesItem(aesItemId);
|
||||
for (int dangerAreaId : dangerAreaIds)
|
||||
m_dangerAreas.insert(dangerAreaId, m_dtc->dangerArea(dangerAreaId));
|
||||
for (int aesItemId : aesItemIds)
|
||||
insertAesItem(aesItemId);
|
||||
|
||||
m_aesItemId = aesItemIds.empty() ? -1 : *aesItemIds.begin();
|
||||
setText();
|
||||
return true;
|
||||
m_aesItemId = aesItemIds.empty() ? -1 : *aesItemIds.begin();
|
||||
setText();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DangerAreaAesItemInfo::init(LtsSession::LtsSession *session)
|
||||
bool DangerAreaAesItemInfo::init(LtsSession::LtsSession* session)
|
||||
{
|
||||
if (m_session && session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
if (!m_session && !session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "No Session available!";
|
||||
return false;
|
||||
}
|
||||
if (!m_session)
|
||||
m_session = session;
|
||||
if (m_session && session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
if (!m_session && !session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "No Session available!";
|
||||
return false;
|
||||
}
|
||||
if (!m_session)
|
||||
m_session = session;
|
||||
|
||||
if(!m_dtc.get())
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_dtc.get())
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
|
||||
setText();
|
||||
return true;
|
||||
setText();
|
||||
return true;
|
||||
}
|
||||
|
||||
void DangerAreaAesItemInfo::insertAesItem(int aesItemId)
|
||||
{
|
||||
AesItem *item;
|
||||
item = new BCContamination(m_dtc->bCContamination(aesItemId));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
m_aesItems.insert(aesItemId, AesStruct(AesType::AtBCContamination, item));
|
||||
return;
|
||||
}
|
||||
delete item;
|
||||
AesItem* item;
|
||||
item = new BCContamination(m_dtc->bCContamination(aesItemId));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
m_aesItems.insert(aesItemId, AesStruct(AesType::AtBCContamination, item));
|
||||
return;
|
||||
}
|
||||
delete item;
|
||||
|
||||
WARNING_LOG(m_logger) << "AesItem with id " << aesItemId << " is not of any known type!";
|
||||
WARNING_LOG(m_logger) << "AesItem with id " << aesItemId << " is not of any known type!";
|
||||
}
|
||||
|
||||
void DangerAreaAesItemInfo::setText()
|
||||
{
|
||||
for (const DangerArea &dangerArea : std::as_const(m_dangerAreas))
|
||||
aesItemInfo(&dangerArea);
|
||||
for (const DangerArea& dangerArea : std::as_const(m_dangerAreas))
|
||||
aesItemInfo(&dangerArea);
|
||||
|
||||
|
||||
for(const AesStruct &aesStruct : std::as_const(m_aesItems))
|
||||
{
|
||||
if(aesStruct.item->effectStateId() == AreaEffectSimulation::AesEffectState::EsActivated)
|
||||
aesItemInfo(aesStruct.item);
|
||||
}
|
||||
for (const AesStruct& aesStruct : std::as_const(m_aesItems))
|
||||
{
|
||||
if (aesStruct.item->effectStateId() == AreaEffectSimulation::AesEffectState::EsActivated)
|
||||
aesItemInfo(aesStruct.item);
|
||||
}
|
||||
}
|
||||
|
||||
void DangerAreaAesItemInfo::aesItemInfo(const AesItem *item)
|
||||
void DangerAreaAesItemInfo::aesItemInfo(const AesItem* item)
|
||||
{
|
||||
|
||||
std::shared_ptr<AesBCContamination::ForeignGuiInterface> guiInterface;
|
||||
if (!m_session->getForeignGuiInterface<AesBCContamination::ForeignGuiInterface>(guiInterface) || !guiInterface)
|
||||
return;
|
||||
|
||||
LtsWidgets::LtsDialog *info = guiInterface->showInfoWindow(item);
|
||||
m_ui->mainLayout->addWidget(info);
|
||||
|
||||
std::shared_ptr<AesBCContamination::ForeignGuiInterface> guiInterface;
|
||||
if (!m_session->getForeignGuiInterface<AesBCContamination::ForeignGuiInterface>(guiInterface) || !guiInterface)
|
||||
return;
|
||||
|
||||
LtsWidgets::LtsDialog* info = guiInterface->showInfoWindow(item);
|
||||
m_ui->mainLayout->addWidget(info);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+1207
-1285
File diff suppressed because it is too large.
Load diff
Executable → Regular
+93
-102
@@ -1,131 +1,122 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
|
||||
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class AesInfoDialog;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
class AesInfoDialog : public LtsWidgets::LtsDialog
|
||||
, protected AreaEffectSimulation::Interface::Ftc::MineResetReplyHandler
|
||||
class AesInfoDialog : public LtsWidgets::LtsDialog,
|
||||
protected AreaEffectSimulation::Interface::Ftc::MineResetReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AesInfoDialog(int aesEntityId, AreaEffectSimulation::AesType aesType, QWidget *parent = nullptr);
|
||||
~AesInfoDialog();
|
||||
public:
|
||||
explicit AesInfoDialog(int aesEntityId, AreaEffectSimulation::AesType aesType, QWidget* parent = nullptr);
|
||||
~AesInfoDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc);
|
||||
bool init(LtsSession::LtsSession* session, const std::shared_ptr<Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc>& pdmDtc);
|
||||
|
||||
void onMineResetReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onMineResetReply(const Core::FunctionReplyObject& replyObject) override final
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
|
||||
void handleNContamination(const AesItemView &aesItemView);
|
||||
void handleNContamination(const AreaEffectSimulation::NContamination &data);
|
||||
void handleBCContamination(const AesItemView &aesItemView);
|
||||
void handleBCContamination(const AreaEffectSimulation::BCContamination &data);
|
||||
void handleExplosionArea(const AesItemView &aesItemView);
|
||||
void handleExplosionArea(const AreaEffectSimulation::ExplosionArea &data);
|
||||
void handleExplosionSingle(const AesItemView &aesItemView);
|
||||
void handleExplosionSingle(const AreaEffectSimulation::ExplosionSingle &data);
|
||||
void handleMineArea(const AesItemView &aesItemView);
|
||||
void handleMineArea(const AreaEffectSimulation::MineArea &data);
|
||||
void handleMineCorridor(const AesItemView &aesItemView);
|
||||
void handleMineCorridor(const AreaEffectSimulation::MineCorridor &data);
|
||||
void handleBoobyTrap(const AesItemView &aesItemView);
|
||||
void handleBoobyTrap(const AreaEffectSimulation::BoobyTrap &data);
|
||||
void handleOffRouteMine(const AesItemView &aesItemView);
|
||||
void handleOffRouteMine(const AreaEffectSimulation::OffRouteMine &data);
|
||||
void handleGasPipe(const AesItemView &aesItemView);
|
||||
void handleGasPipe(const AreaEffectSimulation::GasPipe &data);
|
||||
void handleDangerArea(const AesItemView &aesItemView);
|
||||
void handleDangerArea(const AreaEffectSimulation::DangerArea &data);
|
||||
void handleBorderline(const AesItemView &aesItemView);
|
||||
void handleBorderline(const AreaEffectSimulation::Borderline &data);
|
||||
void handleFunctionalArea(const AesItemView &aesItemView);
|
||||
void handleFunctionalArea(const AreaEffectSimulation::FunctionalArea &data);
|
||||
void handleAirSupportImpact(const AesItemView &aesItemView);
|
||||
void handleAirSupportImpact(const AreaEffectSimulation::AirSupportImpact &data);
|
||||
void handleMineAraeSingleMine();
|
||||
void handleMineAraeSingleMine(const Core::GeoPosition2D &position, const DusMine &mine);
|
||||
void handleSingleDusMine();
|
||||
void handleExplosionCluster(const AesItemView &aesItemView);
|
||||
void handleExplosionCluster(const AreaEffectSimulation::ExplosionCluster &data);
|
||||
void handleEffectCluster(const AesItemView &aesItemView);
|
||||
void handleEffectCluster(const AreaEffectSimulation::EffectCluster &data);
|
||||
void handleNContamination(const AesItemView& aesItemView);
|
||||
void handleNContamination(const AreaEffectSimulation::NContamination& data);
|
||||
void handleBCContamination(const AesItemView& aesItemView);
|
||||
void handleBCContamination(const AreaEffectSimulation::BCContamination& data);
|
||||
void handleExplosionArea(const AesItemView& aesItemView);
|
||||
void handleExplosionArea(const AreaEffectSimulation::ExplosionArea& data);
|
||||
void handleExplosionSingle(const AesItemView& aesItemView);
|
||||
void handleExplosionSingle(const AreaEffectSimulation::ExplosionSingle& data);
|
||||
void handleMineArea(const AesItemView& aesItemView);
|
||||
void handleMineArea(const AreaEffectSimulation::MineArea& data);
|
||||
void handleMineCorridor(const AesItemView& aesItemView);
|
||||
void handleMineCorridor(const AreaEffectSimulation::MineCorridor& data);
|
||||
void handleBoobyTrap(const AesItemView& aesItemView);
|
||||
void handleBoobyTrap(const AreaEffectSimulation::BoobyTrap& data);
|
||||
void handleOffRouteMine(const AesItemView& aesItemView);
|
||||
void handleOffRouteMine(const AreaEffectSimulation::OffRouteMine& data);
|
||||
void handleGasPipe(const AesItemView& aesItemView);
|
||||
void handleGasPipe(const AreaEffectSimulation::GasPipe& data);
|
||||
void handleDangerArea(const AesItemView& aesItemView);
|
||||
void handleDangerArea(const AreaEffectSimulation::DangerArea& data);
|
||||
void handleBorderline(const AesItemView& aesItemView);
|
||||
void handleBorderline(const AreaEffectSimulation::Borderline& data);
|
||||
void handleFunctionalArea(const AesItemView& aesItemView);
|
||||
void handleFunctionalArea(const AreaEffectSimulation::FunctionalArea& data);
|
||||
void handleAirSupportImpact(const AesItemView& aesItemView);
|
||||
void handleAirSupportImpact(const AreaEffectSimulation::AirSupportImpact& data);
|
||||
void handleMineAraeSingleMine();
|
||||
void handleMineAraeSingleMine(const Core::GeoPosition2D& position, const DusMine& mine);
|
||||
void handleSingleDusMine();
|
||||
void handleExplosionCluster(const AesItemView& aesItemView);
|
||||
void handleExplosionCluster(const AreaEffectSimulation::ExplosionCluster& data);
|
||||
void handleEffectCluster(const AesItemView& aesItemView);
|
||||
void handleEffectCluster(const AreaEffectSimulation::EffectCluster& data);
|
||||
|
||||
bool cbFunc(const AesItemView &aesItemView);
|
||||
bool cbFunc(const AesItemView& aesItemView);
|
||||
|
||||
void handleAesItem(const AesItem &aesData, AesType aesTypeId);
|
||||
void handleAesItem(const AesItem& aesData, AesType aesTypeId);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFindOnMap();
|
||||
void onShowDetails();
|
||||
bool onResetDusMines();
|
||||
private Q_SLOTS:
|
||||
void onFindOnMap();
|
||||
void onShowDetails();
|
||||
bool onResetDusMines();
|
||||
|
||||
void onNContaminationChanged(const AreaEffectSimulation::NContamination &data, DataModification modType);
|
||||
void onBCContaminationChanged(const AreaEffectSimulation::BCContamination &data, DataModification modType);
|
||||
void onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap &data, DataModification modType);
|
||||
void onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine &data, DataModification modType);
|
||||
void onExplosionAreaChanged(const AreaEffectSimulation::ExplosionArea &data, DataModification modType);
|
||||
void onExplosionSingleChanged(const AreaEffectSimulation::ExplosionSingle &data, DataModification modType);
|
||||
void onMineAreaChanged(const AreaEffectSimulation::MineArea &data, DataModification modType);
|
||||
void onMineCorridorChanged(const AreaEffectSimulation::MineCorridor &data, DataModification modType);
|
||||
void onGasPipeChanged(const GasPipe &data, DataModification modType);
|
||||
void onDangerAreaChanged(const AreaEffectSimulation::DangerArea &data, DataModification modType);
|
||||
void onBorderlineChanged(const AreaEffectSimulation::Borderline &data, DataModification modType);
|
||||
void onFunctionalAreaChanged(const AreaEffectSimulation::FunctionalArea &data, DataModification modType);
|
||||
void onAirSupportImpactChanged(const AirSupportImpact &data, DataModification modType);
|
||||
void onDusMineStateChanged(const DusMineState &data, DataModification modType);
|
||||
void onDusSingleMineChanged(const DusSingleMine &data, DataModification modType);
|
||||
void onExplosionClusterChanged(const ExplosionCluster &data, DataModification modType);
|
||||
void onEffectClusterChanged(const EffectCluster &data, DataModification modType);
|
||||
void onNContaminationChanged(const AreaEffectSimulation::NContamination& data, DataModification modType);
|
||||
void onBCContaminationChanged(const AreaEffectSimulation::BCContamination& data, DataModification modType);
|
||||
void onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap& data, DataModification modType);
|
||||
void onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine& data, DataModification modType);
|
||||
void onExplosionAreaChanged(const AreaEffectSimulation::ExplosionArea& data, DataModification modType);
|
||||
void onExplosionSingleChanged(const AreaEffectSimulation::ExplosionSingle& data, DataModification modType);
|
||||
void onMineAreaChanged(const AreaEffectSimulation::MineArea& data, DataModification modType);
|
||||
void onMineCorridorChanged(const AreaEffectSimulation::MineCorridor& data, DataModification modType);
|
||||
void onGasPipeChanged(const GasPipe& data, DataModification modType);
|
||||
void onDangerAreaChanged(const AreaEffectSimulation::DangerArea& data, DataModification modType);
|
||||
void onBorderlineChanged(const AreaEffectSimulation::Borderline& data, DataModification modType);
|
||||
void onFunctionalAreaChanged(const AreaEffectSimulation::FunctionalArea& data, DataModification modType);
|
||||
void onAirSupportImpactChanged(const AirSupportImpact& data, DataModification modType);
|
||||
void onDusMineStateChanged(const DusMineState& data, DataModification modType);
|
||||
void onDusSingleMineChanged(const DusSingleMine& data, DataModification modType);
|
||||
void onExplosionClusterChanged(const ExplosionCluster& data, DataModification modType);
|
||||
void onEffectClusterChanged(const EffectCluster& data, DataModification modType);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
int m_aesEntityId;
|
||||
QString m_aesEntityName;
|
||||
AreaEffectSimulation::AesType m_aesType;
|
||||
ProjectDataManagement::EffectSource m_aesEffectSource;
|
||||
int m_bcChargeTypeId;
|
||||
int m_singleExpChargeTypeId;
|
||||
int m_areaExpChargeTypeId;
|
||||
bool m_mineIsReactivatable;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
int m_aesEntityId;
|
||||
QString m_aesEntityName;
|
||||
AreaEffectSimulation::AesType m_aesType;
|
||||
ProjectDataManagement::EffectSource m_aesEffectSource;
|
||||
int m_bcChargeTypeId;
|
||||
int m_singleExpChargeTypeId;
|
||||
int m_areaExpChargeTypeId;
|
||||
bool m_mineIsReactivatable;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
LtsSession::LtsSession* m_session;
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
|
||||
|
||||
Ui::AesInfoDialog* m_ui;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
Ui::AesInfoDialog* m_ui;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
};
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+243
-253
@@ -1,351 +1,341 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include "aes_base_edit.h"
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <LtsWidgets/lts_date_time_edit.h>
|
||||
#include <LtsCoordTrans/lts_coord_widget.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <QSpinBox>
|
||||
#include <LtsCoordTrans/lts_coord_widget.h>
|
||||
#include <LtsWidgets/lts_date_time_edit.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <QJsonDocument>
|
||||
#include <QSpinBox>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
BaseEdit::BaseEdit(const QString &menuGroup, const QString &loggerName, QWidget *parent, LtsWidgets::ButtonCombination buttonCombination)
|
||||
: LtsWidgets::LtsDialog(parent, buttonCombination)
|
||||
, m_aesItem()
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_sitMapGuiIfc(nullptr)
|
||||
, m_ppmGuiCbxIfc(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(getLogger(loggerName))
|
||||
BaseEdit::BaseEdit(const QString& menuGroup, const QString& loggerName, QWidget* parent,
|
||||
LtsWidgets::ButtonCombination buttonCombination)
|
||||
: LtsWidgets::LtsDialog(parent, buttonCombination), m_aesItem(), m_dtc(nullptr), m_ftc(nullptr),
|
||||
m_sitMapGuiIfc(nullptr), m_ppmGuiCbxIfc(nullptr), m_session(nullptr), m_menuGroup(menuGroup),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this)), m_logger(getLogger(loggerName))
|
||||
{
|
||||
m_aesItem.id(0);
|
||||
connect(this, &BaseEdit::visibilityChanged, this, &BaseEdit::onVisibilityChanged);
|
||||
m_aesItem.id(0);
|
||||
connect(this, &BaseEdit::visibilityChanged, this, &BaseEdit::onVisibilityChanged);
|
||||
}
|
||||
|
||||
void BaseEdit::setCombobxToValueIfPossible(QComboBox *cbx, int val)
|
||||
void BaseEdit::setCombobxToValueIfPossible(QComboBox* cbx, int val)
|
||||
{
|
||||
int idx = cbx->findData(val);
|
||||
if (idx >= 0)
|
||||
cbx->setCurrentIndex(idx);
|
||||
int idx = cbx->findData(val);
|
||||
if (idx >= 0)
|
||||
cbx->setCurrentIndex(idx);
|
||||
}
|
||||
|
||||
void BaseEdit::onAesItemCreateReply(const Core::FunctionReplyObject &replyObject)
|
||||
void BaseEdit::onAesItemCreateReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
if (!replyObject.error() && m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
if (!replyObject.error() && m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
|
||||
void BaseEdit::onAesItemModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
void BaseEdit::onAesItemModifyReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
|
||||
if (!replyObject.error() && m_sitMapGuiIfc )
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
if (!replyObject.error() && m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
|
||||
bool BaseEdit::isModifiable() const
|
||||
{
|
||||
AesEffectState effectState = m_aesItem.effectStateId();
|
||||
return (effectState == AreaEffectSimulation::AesEffectState_def::EsPaused ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsActivated ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsPrepared ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsCreated ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsUnknown ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsReceived) &&
|
||||
(!m_session->isReplayPartition()) &&
|
||||
(m_session->app() != LtsAppDescriptor::App::OC);
|
||||
AesEffectState effectState = m_aesItem.effectStateId();
|
||||
return (effectState == AreaEffectSimulation::AesEffectState_def::EsPaused ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsActivated ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsPrepared ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsCreated ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsUnknown ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsReceived) &&
|
||||
(!m_session->isReplayPartition()) && (m_session->app() != LtsAppDescriptor::App::OC);
|
||||
}
|
||||
|
||||
bool BaseEdit::isOnlyNameModifiable() const
|
||||
{
|
||||
AesEffectState effectState = m_aesItem.effectStateId();
|
||||
return (effectState == AreaEffectSimulation::AesEffectState_def::EsPaused ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsActivated) &&
|
||||
(!m_session->isReplayPartition()) &&
|
||||
(m_session->app() != LtsAppDescriptor::App::OC);
|
||||
AesEffectState effectState = m_aesItem.effectStateId();
|
||||
return (effectState == AreaEffectSimulation::AesEffectState_def::EsPaused ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsActivated) &&
|
||||
(!m_session->isReplayPartition()) && (m_session->app() != LtsAppDescriptor::App::OC);
|
||||
}
|
||||
|
||||
void BaseEdit::correctSpinBoxValue()
|
||||
{
|
||||
QSpinBox *sb = qobject_cast<QSpinBox*>(sender());
|
||||
if (sb)
|
||||
return correctSpinBoxValueInternal(sb);
|
||||
QSpinBox* sb = qobject_cast<QSpinBox*>(sender());
|
||||
if (sb)
|
||||
return correctSpinBoxValueInternal(sb);
|
||||
|
||||
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
if (dsb)
|
||||
return correctSpinBoxValueInternal(dsb);
|
||||
QDoubleSpinBox* dsb = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
if (dsb)
|
||||
return correctSpinBoxValueInternal(dsb);
|
||||
}
|
||||
|
||||
void BaseEdit::onVisibilityChanged(bool visible)
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
if (!visible)
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
else
|
||||
showPreviewObject();
|
||||
if (!visible)
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
else
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
void BaseEdit::correctSpinBoxValueInternal(QSpinBox *sb)
|
||||
void BaseEdit::correctSpinBoxValueInternal(QSpinBox* sb)
|
||||
{
|
||||
if (!sb)
|
||||
return;
|
||||
if (!sb)
|
||||
return;
|
||||
|
||||
int step = sb->singleStep();
|
||||
if (step == 1)
|
||||
return;
|
||||
int step = sb->singleStep();
|
||||
if (step == 1)
|
||||
return;
|
||||
|
||||
int value = sb->value();
|
||||
int remainder = (value - sb->minimum()) % step;
|
||||
if (remainder == 0)
|
||||
return;
|
||||
int value = sb->value();
|
||||
int remainder = (value - sb->minimum()) % step;
|
||||
if (remainder == 0)
|
||||
return;
|
||||
|
||||
if (2 * remainder > step)
|
||||
value += (step - remainder);
|
||||
else
|
||||
value -= remainder;
|
||||
if (2 * remainder > step)
|
||||
value += (step - remainder);
|
||||
else
|
||||
value -= remainder;
|
||||
|
||||
if (value > sb->maximum())
|
||||
value -= step;
|
||||
if (value > sb->maximum())
|
||||
value -= step;
|
||||
|
||||
if(value < sb->minimum())
|
||||
value = sb->minimum();
|
||||
if (value < sb->minimum())
|
||||
value = sb->minimum();
|
||||
|
||||
sb->setValue(value);
|
||||
sb->setValue(value);
|
||||
}
|
||||
|
||||
void BaseEdit::correctSpinBoxValueInternal(QDoubleSpinBox *sb)
|
||||
void BaseEdit::correctSpinBoxValueInternal(QDoubleSpinBox* sb)
|
||||
{
|
||||
if (!sb)
|
||||
return;
|
||||
if (!sb)
|
||||
return;
|
||||
|
||||
double step = sb->singleStep();
|
||||
if (qFuzzyCompare(step, pow(10, sb->decimals())))
|
||||
return;
|
||||
double step = sb->singleStep();
|
||||
if (qFuzzyCompare(step, pow(10, sb->decimals())))
|
||||
return;
|
||||
|
||||
double value = sb->value();
|
||||
double remainder = fmod(value - sb->minimum(), step);
|
||||
if (qFuzzyCompare(remainder, 0))
|
||||
return;
|
||||
double value = sb->value();
|
||||
double remainder = fmod(value - sb->minimum(), step);
|
||||
if (qFuzzyCompare(remainder, 0))
|
||||
return;
|
||||
|
||||
if (2 * remainder > step)
|
||||
value += (step - remainder);
|
||||
else
|
||||
value -= remainder;
|
||||
if (2 * remainder > step)
|
||||
value += (step - remainder);
|
||||
else
|
||||
value -= remainder;
|
||||
|
||||
if (value > sb->maximum())
|
||||
value -= step;
|
||||
if (value > sb->maximum())
|
||||
value -= step;
|
||||
|
||||
if (value < sb->minimum())
|
||||
value = sb->minimum();
|
||||
if (value < sb->minimum())
|
||||
value = sb->minimum();
|
||||
|
||||
sb->setValue(value);
|
||||
sb->setValue(value);
|
||||
}
|
||||
|
||||
bool BaseEdit::hasValidEffectStart(LtsWidgets::LtsDateTimeEdit *dte) const
|
||||
bool BaseEdit::hasValidEffectStart(LtsWidgets::LtsDateTimeEdit* dte) const
|
||||
{
|
||||
if (isOnlyNameModifiable())
|
||||
return true;
|
||||
|
||||
if (dte->isCheckable() && !dte->isChecked())
|
||||
return true;
|
||||
const auto ms = dte->msecsSinceEpoch();
|
||||
return ms > m_session->partitionTime();
|
||||
if (isOnlyNameModifiable())
|
||||
return true;
|
||||
|
||||
if (dte->isCheckable() && !dte->isChecked())
|
||||
return true;
|
||||
const auto ms = dte->msecsSinceEpoch();
|
||||
return ms > m_session->partitionTime();
|
||||
}
|
||||
|
||||
void BaseEdit::setEffectStartEnabled(LtsWidgets::LtsDateTimeEdit *dte, bool enable)
|
||||
void BaseEdit::setEffectStartEnabled(LtsWidgets::LtsDateTimeEdit* dte, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
int exerciseId = m_session->exerciseId();
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> exmDtc;
|
||||
m_session->getDtc<ExerciseManagement::DataInterface>(exmDtc);
|
||||
ExerciseManagement::Exercise exercise = exmDtc->exercise(exerciseId);
|
||||
if (enable)
|
||||
{
|
||||
int exerciseId = m_session->exerciseId();
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> exmDtc;
|
||||
m_session->getDtc<ExerciseManagement::DataInterface>(exmDtc);
|
||||
ExerciseManagement::Exercise exercise = exmDtc->exercise(exerciseId);
|
||||
|
||||
|
||||
enable = (exercise.state() == ExerciseManagement::ExerciseState_def::Started ||
|
||||
exercise.state() == ExerciseManagement::ExerciseState_def::Paused);
|
||||
enable = (exercise.state() == ExerciseManagement::ExerciseState_def::Started ||
|
||||
exercise.state() == ExerciseManagement::ExerciseState_def::Paused);
|
||||
|
||||
|
||||
if (exercise.state() == ExerciseManagement::ExerciseState_def::Created)
|
||||
dte->setChecked(false);
|
||||
else
|
||||
dte->setChecked(dte->msecsSinceEpoch() > 0);
|
||||
}
|
||||
else
|
||||
dte->setChecked(dte->msecsSinceEpoch() > 0);
|
||||
|
||||
dte->setEnabled(enable);
|
||||
if (exercise.state() == ExerciseManagement::ExerciseState_def::Created)
|
||||
dte->setChecked(false);
|
||||
else
|
||||
dte->setChecked(dte->msecsSinceEpoch() > 0);
|
||||
}
|
||||
else
|
||||
dte->setChecked(dte->msecsSinceEpoch() > 0);
|
||||
|
||||
dte->setEnabled(enable);
|
||||
}
|
||||
|
||||
bool BaseEdit::has2DMap(bool showMsgBoxIfNot2D)
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return false;
|
||||
if (m_sitMapGuiIfc->mapMode() != SituationMap::MapMode::MapMode_2D)
|
||||
{
|
||||
if (showMsgBoxIfNot2D)
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Only available in 2D mode"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (!m_sitMapGuiIfc)
|
||||
return false;
|
||||
if (m_sitMapGuiIfc->mapMode() != SituationMap::MapMode::MapMode_2D)
|
||||
{
|
||||
if (showMsgBoxIfNot2D)
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Only available in 2D mode"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void BaseEdit::setCoordinates(const QVector<QPointF> &coords, bool reverse)
|
||||
void BaseEdit::setCoordinates(const QVector<QPointF>& coords, bool reverse)
|
||||
{
|
||||
|
||||
clearCoordinates();
|
||||
const auto cWidgets(coordWidgets());
|
||||
if (!reverse)
|
||||
{
|
||||
|
||||
clearCoordinates();
|
||||
const auto cWidgets(coordWidgets());
|
||||
if (!reverse)
|
||||
{
|
||||
for (size_t i = 0; i < cWidgets.size() && i < static_cast<size_t>(coords.size()); ++i)
|
||||
cWidgets.at(i)->setCoordinate(coords.at(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto copy(coords);
|
||||
std::reverse(std::begin(copy), std::end(copy));
|
||||
for (size_t i = 0; i < cWidgets.size() && i < static_cast<size_t>(copy.size()); ++i)
|
||||
cWidgets.at(i)->setCoordinate(copy.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
void BaseEdit::setCoordinates(const std::vector<Core::GeoPosition2D>& coords)
|
||||
{
|
||||
clearCoordinates();
|
||||
const auto cWidgets(coordWidgets());
|
||||
for (size_t i = 0; i < cWidgets.size() && i < static_cast<size_t>(coords.size()); ++i)
|
||||
cWidgets.at(i)->setCoordinate(coords.at(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto copy(coords);
|
||||
std::reverse(std::begin(copy), std::end(copy));
|
||||
for (size_t i = 0; i < cWidgets.size() && i < static_cast<size_t>(copy.size()); ++i)
|
||||
cWidgets.at(i)->setCoordinate(copy.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
void BaseEdit::setCoordinates(const std::vector<Core::GeoPosition2D> &coords)
|
||||
{
|
||||
clearCoordinates();
|
||||
const auto cWidgets(coordWidgets());
|
||||
for (size_t i = 0; i < cWidgets.size() && i < static_cast<size_t>(coords.size()); ++i)
|
||||
cWidgets.at(i)->setCoordinate(coords.at(i).lon(), coords.at(i).lat());
|
||||
cWidgets.at(i)->setCoordinate(coords.at(i).lon(), coords.at(i).lat());
|
||||
}
|
||||
|
||||
std::vector<Core::GeoPosition2D> BaseEdit::getCoordinates() const
|
||||
{
|
||||
std::vector<Core::GeoPosition2D> segments;
|
||||
const auto cWidgets(coordWidgets());
|
||||
segments.reserve(cWidgets.size());
|
||||
for (const auto cw : cWidgets)
|
||||
{
|
||||
const QPointF coord = cw->coordinate();
|
||||
if (coord.isNull())
|
||||
break;
|
||||
segments.emplace_back(Core::GeoPosition2D(coord.x(), coord.y()));
|
||||
}
|
||||
return segments;
|
||||
std::vector<Core::GeoPosition2D> segments;
|
||||
const auto cWidgets(coordWidgets());
|
||||
segments.reserve(cWidgets.size());
|
||||
for (const auto cw : cWidgets)
|
||||
{
|
||||
const QPointF coord = cw->coordinate();
|
||||
if (coord.isNull())
|
||||
break;
|
||||
segments.emplace_back(Core::GeoPosition2D(coord.x(), coord.y()));
|
||||
}
|
||||
return segments;
|
||||
}
|
||||
|
||||
QVector<QPointF> BaseEdit::getCoordinatesQPointF() const
|
||||
{
|
||||
QVector<QPointF> segments;
|
||||
const auto cWidgets(coordWidgets());
|
||||
segments.reserve(cWidgets.size());
|
||||
for (const auto *cw : cWidgets)
|
||||
{
|
||||
const QPointF coord = cw->coordinate();
|
||||
if (coord.isNull())
|
||||
break;
|
||||
segments.push_back(coord);
|
||||
}
|
||||
return segments;
|
||||
QVector<QPointF> segments;
|
||||
const auto cWidgets(coordWidgets());
|
||||
segments.reserve(cWidgets.size());
|
||||
for (const auto* cw : cWidgets)
|
||||
{
|
||||
const QPointF coord = cw->coordinate();
|
||||
if (coord.isNull())
|
||||
break;
|
||||
segments.push_back(coord);
|
||||
}
|
||||
return segments;
|
||||
}
|
||||
|
||||
void BaseEdit::clearCoordinates()
|
||||
{
|
||||
for (auto *cw : coordWidgets())
|
||||
cw->clear();
|
||||
for (auto* cw : coordWidgets())
|
||||
cw->clear();
|
||||
}
|
||||
|
||||
void BaseEdit::enabledCoordinates(bool enable)
|
||||
{
|
||||
for (auto *cw : coordWidgets())
|
||||
cw->setEnabled(enable);
|
||||
for (auto* cw : coordWidgets())
|
||||
cw->setEnabled(enable);
|
||||
}
|
||||
|
||||
|
||||
void BaseEdit::onAreaChanged(const AesItem &data, DataModification modType)
|
||||
void BaseEdit::onAreaChanged(const AesItem& data, DataModification modType)
|
||||
{
|
||||
|
||||
|
||||
if (data.id() != m_aesItem.id())
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved || data.effectStateId() == AesEffectState_def::EsRemoved)
|
||||
{
|
||||
|
||||
__unchange__();
|
||||
closeRequest();
|
||||
return;
|
||||
}
|
||||
m_aesItem = data;
|
||||
enableUiElements(isModifiable() && !isOnlyNameModifiable());
|
||||
}
|
||||
if (data.id() != m_aesItem.id())
|
||||
return;
|
||||
|
||||
bool BaseEdit::init(int aesItemId, LtsSession::LtsSession *session)
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
m_aesItem.id(aesItemId);
|
||||
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc))
|
||||
return false;
|
||||
|
||||
if (m_session->isReplayPartition() || (LtsAppDescriptor::App::OC == m_session->app()))
|
||||
setUnchangeable();
|
||||
|
||||
if (aesItemId == 0)
|
||||
{
|
||||
m_aesItem.effectSourceId(ProjectDataManagement::EffectSource_def::ES_Internal);
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Ok, tr("Add"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
double BaseEdit::distance(const Core::GeoPosition2D &p1, const Core::GeoPosition2D &p2)
|
||||
{
|
||||
LtsCoordTrans::UtmCoordinate start = LtsCoordTrans::UtmCoordinate::fromGeographic(p1.lon(), p1.lat());
|
||||
LtsCoordTrans::UtmCoordinate end = LtsCoordTrans::UtmCoordinate::fromGeographic(p2.lon(), p2.lat(), start.zone);
|
||||
double dx = start.x - end.x;
|
||||
double dy = start.y - end.y;
|
||||
return std::sqrt(dx*dx + dy*dy);
|
||||
}
|
||||
|
||||
bool BaseEdit::checkSegementLengths(QWidget *parent) const
|
||||
{
|
||||
auto segments = getCoordinates();
|
||||
for (auto i=0; i<((int) segments.size() - 1); ++i)
|
||||
{
|
||||
double dis = distance(segments[i], segments[i+1]);
|
||||
if (getMaxLength() != 0 && dis > getMaxLength())
|
||||
if (modType == DataModification::eRemoved || data.effectStateId() == AesEffectState_def::EsRemoved)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(parent, tr("The distance between Coordinate %1 and %2 is too long.\nThe segment is %3m long, but the maximum segment length is %4m.")
|
||||
.arg(i+1).arg(i+2).arg(QString::number(dis,'d',2),QString::number(getMaxLength(),'d',2)));
|
||||
return false;
|
||||
|
||||
__unchange__();
|
||||
closeRequest();
|
||||
return;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
m_aesItem = data;
|
||||
enableUiElements(isModifiable() && !isOnlyNameModifiable());
|
||||
}
|
||||
|
||||
}
|
||||
bool BaseEdit::init(int aesItemId, LtsSession::LtsSession* session)
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
m_aesItem.id(aesItemId);
|
||||
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc))
|
||||
return false;
|
||||
|
||||
if (m_session->isReplayPartition() || (LtsAppDescriptor::App::OC == m_session->app()))
|
||||
setUnchangeable();
|
||||
|
||||
if (aesItemId == 0)
|
||||
{
|
||||
m_aesItem.effectSourceId(ProjectDataManagement::EffectSource_def::ES_Internal);
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Ok, tr("Add"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
double BaseEdit::distance(const Core::GeoPosition2D& p1, const Core::GeoPosition2D& p2)
|
||||
{
|
||||
LtsCoordTrans::UtmCoordinate start = LtsCoordTrans::UtmCoordinate::fromGeographic(p1.lon(), p1.lat());
|
||||
LtsCoordTrans::UtmCoordinate end = LtsCoordTrans::UtmCoordinate::fromGeographic(p2.lon(), p2.lat(), start.zone);
|
||||
double dx = start.x - end.x;
|
||||
double dy = start.y - end.y;
|
||||
return std::sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
bool BaseEdit::checkSegementLengths(QWidget* parent) const
|
||||
{
|
||||
auto segments = getCoordinates();
|
||||
for (auto i = 0; i < ((int)segments.size() - 1); ++i)
|
||||
{
|
||||
double dis = distance(segments[i], segments[i + 1]);
|
||||
if (getMaxLength() != 0 && dis > getMaxLength())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(
|
||||
parent, tr("The distance between Coordinate %1 and %2 is too long.\nThe segment is %3m long, but the "
|
||||
"maximum segment length is %4m.")
|
||||
.arg(i + 1)
|
||||
.arg(i + 2)
|
||||
.arg(QString::number(dis, 'd', 2), QString::number(getMaxLength(), 'd', 2)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+233
-266
@@ -1,349 +1,316 @@
|
||||
|
||||
|
||||
|
||||
#include "aes_base_model.h"
|
||||
#include <utility>
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <QLocale>
|
||||
#include <utility>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
AesGuiBasHelpers::AesGuiBasHelpers() : m_aesDtc(nullptr), m_pdmDtc(nullptr), m_ppmDtc(nullptr) {}
|
||||
|
||||
|
||||
|
||||
AesGuiBasHelpers::AesGuiBasHelpers()
|
||||
: m_aesDtc(nullptr)
|
||||
, m_pdmDtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
{}
|
||||
|
||||
bool AesGuiBasHelpers::initModel(LtsSession::LtsSession *session)
|
||||
bool AesGuiBasHelpers::initModel(LtsSession::LtsSession* session)
|
||||
{
|
||||
if (m_aesDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
if (m_aesDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc);
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant AesGuiBasHelpers::stringFromPartyId(const dds::core::optional<int> &id) const
|
||||
QVariant AesGuiBasHelpers::stringFromPartyId(const dds::core::optional<int>& id) const
|
||||
{
|
||||
if (!id.is_set())
|
||||
return QObject::tr("---");
|
||||
auto it = m_partyNames.find(id.get());
|
||||
if (it != m_partyNames.end())
|
||||
return it.value();
|
||||
const QString name = ParticipantManagement::trPartyName(m_ppmDtc->party(id.get()).name());
|
||||
m_partyNames.insert(id.get(), name);
|
||||
return name;
|
||||
if (!id.is_set())
|
||||
return QObject::tr("---");
|
||||
auto it = m_partyNames.find(id.get());
|
||||
if (it != m_partyNames.end())
|
||||
return it.value();
|
||||
const QString name = ParticipantManagement::trPartyName(m_ppmDtc->party(id.get()).name());
|
||||
m_partyNames.insert(id.get(), name);
|
||||
return name;
|
||||
}
|
||||
|
||||
QIcon AesGuiBasHelpers::iconFromPartyId(const dds::core::optional<int> &id) const
|
||||
QIcon AesGuiBasHelpers::iconFromPartyId(const dds::core::optional<int>& id) const
|
||||
{
|
||||
if (!id.is_set() || !m_ppmGuiCbxIfc)
|
||||
return QIcon();
|
||||
auto it = m_partyIcons.find(id.get());
|
||||
if (it != m_partyIcons.end())
|
||||
return it.value();
|
||||
const QRgb col = QRgb(m_ppmDtc->party(id.get()).color());
|
||||
const QIcon icon = m_ppmGuiCbxIfc->pixmapFromParty(col);
|
||||
m_partyIcons.insert(id.get(), icon);
|
||||
return icon;
|
||||
if (!id.is_set() || !m_ppmGuiCbxIfc)
|
||||
return QIcon();
|
||||
auto it = m_partyIcons.find(id.get());
|
||||
if (it != m_partyIcons.end())
|
||||
return it.value();
|
||||
const QRgb col = QRgb(m_ppmDtc->party(id.get()).color());
|
||||
const QIcon icon = m_ppmGuiCbxIfc->pixmapFromParty(col);
|
||||
m_partyIcons.insert(id.get(), icon);
|
||||
return icon;
|
||||
}
|
||||
|
||||
QVariant AesGuiBasHelpers::hierarchyFromParticipantId(const dds::core::optional<int> &id) const
|
||||
QVariant AesGuiBasHelpers::hierarchyFromParticipantId(const dds::core::optional<int>& id) const
|
||||
{
|
||||
if (!id.is_set())
|
||||
return QObject::tr("---");
|
||||
auto it = m_participantHierarchy.find(id.get());
|
||||
if (it != m_participantHierarchy.end())
|
||||
return it.value();
|
||||
const QString name = m_ppmDtc->hierarchyFromParticipant(id.get());
|
||||
m_participantHierarchy.insert(id.get(), name);
|
||||
return name;
|
||||
if (!id.is_set())
|
||||
return QObject::tr("---");
|
||||
auto it = m_participantHierarchy.find(id.get());
|
||||
if (it != m_participantHierarchy.end())
|
||||
return it.value();
|
||||
const QString name = m_ppmDtc->hierarchyFromParticipant(id.get());
|
||||
m_participantHierarchy.insert(id.get(), name);
|
||||
return name;
|
||||
}
|
||||
|
||||
QVariant AesGuiBasHelpers::chargeTypeName(int chargeTypeId, bool shortName) const
|
||||
{
|
||||
if (shortName)
|
||||
{
|
||||
auto it = m_chargeTypeShortNames.find(chargeTypeId);
|
||||
if (it != m_chargeTypeShortNames.end())
|
||||
return it.value();
|
||||
const QString name = m_pdmDtc->trChargeTypeShortName(chargeTypeId, true);
|
||||
m_chargeTypeShortNames.insert(chargeTypeId, name);
|
||||
if (shortName)
|
||||
{
|
||||
auto it = m_chargeTypeShortNames.find(chargeTypeId);
|
||||
if (it != m_chargeTypeShortNames.end())
|
||||
return it.value();
|
||||
const QString name = m_pdmDtc->trChargeTypeShortName(chargeTypeId, true);
|
||||
m_chargeTypeShortNames.insert(chargeTypeId, name);
|
||||
return name;
|
||||
}
|
||||
|
||||
auto it = m_chargeTypeNames.find(chargeTypeId);
|
||||
if (it != m_chargeTypeNames.end())
|
||||
return it.value();
|
||||
const QString name = m_pdmDtc->trChargeTypeName(chargeTypeId, true);
|
||||
m_chargeTypeNames.insert(chargeTypeId, name);
|
||||
return name;
|
||||
}
|
||||
|
||||
auto it = m_chargeTypeNames.find(chargeTypeId);
|
||||
if (it != m_chargeTypeNames.end())
|
||||
return it.value();
|
||||
const QString name = m_pdmDtc->trChargeTypeName(chargeTypeId, true);
|
||||
m_chargeTypeNames.insert(chargeTypeId, name);
|
||||
return name;
|
||||
|
||||
}
|
||||
|
||||
QString AesGuiBasHelpers::simulationTypeText(bool isCentral)
|
||||
{
|
||||
return isCentral ? QObject::tr("central") : QObject::tr("peripheral");
|
||||
return isCentral ? QObject::tr("central") : QObject::tr("peripheral");
|
||||
}
|
||||
|
||||
void AesGuiBasHelpers::updateEffectStateComboboxFilterData(bool bWithPause)
|
||||
{
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
const auto effectStates = {
|
||||
AesEffectState::EsExpired,
|
||||
AesEffectState::EsCreated,
|
||||
AesEffectState::EsPrepared,
|
||||
AesEffectState::EsActivated,
|
||||
AesEffectState::EsPaused,
|
||||
AesEffectState::EsFired,
|
||||
AesEffectState::EsReceived
|
||||
};
|
||||
for (const auto es : effectStates) {
|
||||
if (!bWithPause && es == AesEffectState::EsPaused)
|
||||
continue;
|
||||
cfd.data = es;
|
||||
cfd.text = AreaEffectSimulation::toString(es);
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterEffectState = cfc.toVariant();
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
const auto effectStates = {AesEffectState::EsExpired, AesEffectState::EsCreated, AesEffectState::EsPrepared,
|
||||
AesEffectState::EsActivated, AesEffectState::EsPaused, AesEffectState::EsFired,
|
||||
AesEffectState::EsReceived};
|
||||
for (const auto es : effectStates)
|
||||
{
|
||||
if (!bWithPause && es == AesEffectState::EsPaused)
|
||||
continue;
|
||||
cfd.data = es;
|
||||
cfd.text = AreaEffectSimulation::toString(es);
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterEffectState = cfc.toVariant();
|
||||
}
|
||||
|
||||
void AesGuiBasHelpers::updateComboboxFilterData(const QSet<int> &availablePartyIds,
|
||||
const QSet<int> &availabelChargeIds)
|
||||
void AesGuiBasHelpers::updateComboboxFilterData(const QSet<int>& availablePartyIds, const QSet<int>& availabelChargeIds)
|
||||
{
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
for (const int i : std::as_const(availabelChargeIds))
|
||||
{
|
||||
cfd.data = i;
|
||||
cfd.text = chargeTypeName(i).toString();
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = true;
|
||||
m_cbxFilterChargeType = cfc.toVariant();
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
for (const int i : std::as_const(availabelChargeIds))
|
||||
{
|
||||
cfd.data = i;
|
||||
cfd.text = chargeTypeName(i).toString();
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = true;
|
||||
m_cbxFilterChargeType = cfc.toVariant();
|
||||
|
||||
cfc.data.clear();
|
||||
for (const int i : std::as_const(availablePartyIds))
|
||||
{
|
||||
cfd.data = i;
|
||||
cfd.text = ParticipantManagement::trPartyName(m_ppmDtc->party(i).name());
|
||||
cfd.icon = iconFromPartyId(i);
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterParty = cfc.toVariant();
|
||||
cfc.data.clear();
|
||||
for (const int i : std::as_const(availablePartyIds))
|
||||
{
|
||||
cfd.data = i;
|
||||
cfd.text = ParticipantManagement::trPartyName(m_ppmDtc->party(i).name());
|
||||
cfd.icon = iconFromPartyId(i);
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterParty = cfc.toVariant();
|
||||
}
|
||||
|
||||
void AreaEffectSimulation::AesGuiBasHelpers::updateSimulationTypeComboboxFilterData()
|
||||
{
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
|
||||
cfd.text = simulationTypeText(true);
|
||||
cfd.data = cfd.text;
|
||||
cfc.data.push_back(cfd);
|
||||
cfd.text = simulationTypeText(true);
|
||||
cfd.data = cfd.text;
|
||||
cfc.data.push_back(cfd);
|
||||
|
||||
cfd.text = simulationTypeText(false);
|
||||
cfd.data = cfd.text;
|
||||
cfc.data.push_back(cfd);
|
||||
cfd.text = simulationTypeText(false);
|
||||
cfd.data = cfd.text;
|
||||
cfc.data.push_back(cfd);
|
||||
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterSimulationType = cfc.toVariant();
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterSimulationType = cfc.toVariant();
|
||||
}
|
||||
|
||||
void AesGuiBasHelpers::fillAvailableChargeIds(ProjectDataManagement::GearClass gc)
|
||||
{
|
||||
m_availableChargeIds.clear();
|
||||
const QVector<ProjectDataManagement::ChargeType> availableCharges = m_pdmDtc->chargesForGearClass(gc);
|
||||
for (const auto &charge : availableCharges)
|
||||
m_availableChargeIds += charge.id();
|
||||
|
||||
if (m_availableChargeIds.isEmpty())
|
||||
m_availableChargeIds += 0;
|
||||
m_availableChargeIds.clear();
|
||||
const QVector<ProjectDataManagement::ChargeType> availableCharges = m_pdmDtc->chargesForGearClass(gc);
|
||||
for (const auto& charge : availableCharges)
|
||||
m_availableChargeIds += charge.id();
|
||||
|
||||
if (m_availableChargeIds.isEmpty())
|
||||
m_availableChargeIds += 0;
|
||||
}
|
||||
|
||||
void AesGuiBasHelpers::fillAvailableChargeIds(const QVector<ProjectDataManagement::GearClass> &gcs)
|
||||
void AesGuiBasHelpers::fillAvailableChargeIds(const QVector<ProjectDataManagement::GearClass>& gcs)
|
||||
{
|
||||
m_availableChargeIds.clear();
|
||||
m_availableChargeIds.clear();
|
||||
|
||||
for (auto gc : std::as_const(gcs))
|
||||
{
|
||||
const QVector<ProjectDataManagement::ChargeType> &availableCharges = m_pdmDtc->chargesForGearClass(gc);
|
||||
for (const auto &charge : std::as_const(availableCharges))
|
||||
m_availableChargeIds += charge.id();
|
||||
}
|
||||
|
||||
if (m_availableChargeIds.isEmpty())
|
||||
m_availableChargeIds += 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AesItemSortFilterProxyModel::AesItemSortFilterProxyModel(LtsSession::LtsSession *session, QObject *parent)
|
||||
: LtsWidgets::LtsColumnFilterProxyModel(parent)
|
||||
, m_session(session)
|
||||
, m_showExpired(false)
|
||||
, m_offset(5 * 60 * 1000)
|
||||
{
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc;
|
||||
if (m_session->getDtc<ParticipantManagement::DataInterface>(ppmDtc))
|
||||
{
|
||||
auto cb = [this](const ParticipantManagement::Party &party)
|
||||
for (auto gc : std::as_const(gcs))
|
||||
{
|
||||
m_partyColors[party.id()] = QColor::fromRgb(QRgb(party.color()));
|
||||
};
|
||||
ppmDtc->partys(cb);
|
||||
}
|
||||
const QVector<ProjectDataManagement::ChargeType>& availableCharges = m_pdmDtc->chargesForGearClass(gc);
|
||||
for (const auto& charge : std::as_const(availableCharges))
|
||||
m_availableChargeIds += charge.id();
|
||||
}
|
||||
|
||||
if (m_availableChargeIds.isEmpty())
|
||||
m_availableChargeIds += 0;
|
||||
}
|
||||
|
||||
AesItemSortFilterProxyModel::AesItemSortFilterProxyModel(LtsSession::LtsSession* session, QObject* parent)
|
||||
: LtsWidgets::LtsColumnFilterProxyModel(parent), m_session(session), m_showExpired(false), m_offset(5 * 60 * 1000)
|
||||
{
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc;
|
||||
if (m_session->getDtc<ParticipantManagement::DataInterface>(ppmDtc))
|
||||
{
|
||||
auto cb = [this](const ParticipantManagement::Party& party) {
|
||||
m_partyColors[party.id()] = QColor::fromRgb(QRgb(party.color()));
|
||||
};
|
||||
ppmDtc->partys(cb);
|
||||
}
|
||||
}
|
||||
|
||||
void AesItemSortFilterProxyModel::setShowExpired(bool showExpired)
|
||||
{
|
||||
if (m_showExpired == showExpired)
|
||||
return;
|
||||
if (m_showExpired == showExpired)
|
||||
return;
|
||||
|
||||
m_showExpired = showExpired;
|
||||
invalidateFilter();
|
||||
m_showExpired = showExpired;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void AesItemSortFilterProxyModel::setOffset(int offsetMsecs)
|
||||
{
|
||||
if (m_offset == offsetMsecs)
|
||||
return;
|
||||
if (m_offset == offsetMsecs)
|
||||
return;
|
||||
|
||||
m_offset = offsetMsecs;
|
||||
invalidateFilter();
|
||||
m_offset = offsetMsecs;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
bool AesItemSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
bool AesItemSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||
{
|
||||
bool bRet = checkFilter(source_row);
|
||||
if (!bRet)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
bool bRet = checkFilter(source_row);
|
||||
if (!bRet)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
}
|
||||
|
||||
bool AesItemSortFilterProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
bool AesItemSortFilterProxyModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const
|
||||
{
|
||||
if (source_left.column() != source_right.column())
|
||||
if (source_left.column() != source_right.column())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
|
||||
switch (source_left.column())
|
||||
{
|
||||
case AesGuiBasHelpers::BcEffectStart: {
|
||||
const auto effectStartLeft = aesEffectStart(source_left.row());
|
||||
const auto effectStartRight = aesEffectStart(source_right.row());
|
||||
if (effectStartLeft.is_set() && effectStartRight.is_set())
|
||||
return effectStartLeft.get() < effectStartRight.get();
|
||||
if (effectStartRight.is_set())
|
||||
return true;
|
||||
if (effectStartLeft.is_set())
|
||||
return false;
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectDuration: {
|
||||
const auto effectDurationLeft = aesEffectDuration(source_left.row());
|
||||
const auto effectDurationRight = aesEffectDuration(source_right.row());
|
||||
if (effectDurationLeft == effectDurationRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectDurationLeft < effectDurationRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectState: {
|
||||
const auto effectStateLeft = aesEffectStateId(source_left.row());
|
||||
const auto effectStateRight = aesEffectStateId(source_right.row());
|
||||
if (effectStateLeft == effectStateRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectStateLeft < effectStateRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectSource: {
|
||||
const auto effectSourceLeft = aesEffectSourceId(source_left.row());
|
||||
const auto effectSourceRight = aesEffectSourceId(source_right.row());
|
||||
if (effectSourceLeft == effectSourceRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectSourceLeft < effectSourceRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcParty: {
|
||||
const auto partyIdLeft = partyId(source_left.row());
|
||||
const auto partyIdRight = partyId(source_right.row());
|
||||
if (partyIdLeft == partyIdRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return partyIdLeft < partyIdRight;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
|
||||
switch (source_left.column())
|
||||
{
|
||||
case AesGuiBasHelpers::BcEffectStart:
|
||||
{
|
||||
const auto effectStartLeft = aesEffectStart(source_left.row());
|
||||
const auto effectStartRight = aesEffectStart(source_right.row());
|
||||
if (effectStartLeft.is_set() && effectStartRight.is_set())
|
||||
return effectStartLeft.get() < effectStartRight.get();
|
||||
if (effectStartRight.is_set())
|
||||
return true;
|
||||
if (effectStartLeft.is_set())
|
||||
return false;
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectDuration:
|
||||
{
|
||||
const auto effectDurationLeft = aesEffectDuration(source_left.row());
|
||||
const auto effectDurationRight = aesEffectDuration(source_right.row());
|
||||
if (effectDurationLeft == effectDurationRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectDurationLeft < effectDurationRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectState:
|
||||
{
|
||||
const auto effectStateLeft = aesEffectStateId(source_left.row());
|
||||
const auto effectStateRight = aesEffectStateId(source_right.row());
|
||||
if (effectStateLeft == effectStateRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectStateLeft < effectStateRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectSource:
|
||||
{
|
||||
const auto effectSourceLeft = aesEffectSourceId(source_left.row());
|
||||
const auto effectSourceRight = aesEffectSourceId(source_right.row());
|
||||
if (effectSourceLeft == effectSourceRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectSourceLeft < effectSourceRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcParty:
|
||||
{
|
||||
const auto partyIdLeft = partyId(source_left.row());
|
||||
const auto partyIdRight = partyId(source_right.row());
|
||||
if (partyIdLeft == partyIdRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return partyIdLeft < partyIdRight;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
|
||||
|
||||
bool AesItemSortFilterProxyModel::checkFilter(int source_row) const
|
||||
{
|
||||
int32_t party = partyId(source_row);
|
||||
if (party != -1 && !LtsSessionData::LtsSessionData::getInstance()->isVisibleParty(m_session->exerciseId(), party))
|
||||
int32_t party = partyId(source_row);
|
||||
if (party != -1 && !LtsSessionData::LtsSessionData::getInstance()->isVisibleParty(m_session->exerciseId(), party))
|
||||
return false;
|
||||
|
||||
const auto effectStateId = aesEffectStateId(source_row);
|
||||
if (effectStateId == AesEffectState_def::EsRemoved)
|
||||
return false;
|
||||
|
||||
if (showExpired())
|
||||
return true;
|
||||
|
||||
const int id = aesId(source_row);
|
||||
if (id <= 0)
|
||||
return false;
|
||||
|
||||
if (effectStateId != AreaEffectSimulation::AesEffectState::EsExpired &&
|
||||
effectStateId != AreaEffectSimulation::AesEffectState::EsRemoved)
|
||||
return true;
|
||||
|
||||
if (!m_session)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto effectStart = aesEffectStart(source_row);
|
||||
qint64 effectEnd = 0;
|
||||
if (effectStart.is_set())
|
||||
effectEnd = effectStart.get() + aesEffectDuration(source_row);
|
||||
|
||||
if (effectStart.is_set() && effectEnd + m_offset > m_session->partitionTime())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
const auto effectStateId = aesEffectStateId(source_row);
|
||||
if (effectStateId == AesEffectState_def::EsRemoved)
|
||||
return false;
|
||||
|
||||
|
||||
if (showExpired())
|
||||
return true;
|
||||
|
||||
const int id = aesId(source_row);
|
||||
if (id <= 0)
|
||||
return false;
|
||||
|
||||
|
||||
if (effectStateId != AreaEffectSimulation::AesEffectState::EsExpired && effectStateId != AreaEffectSimulation::AesEffectState::EsRemoved)
|
||||
return true;
|
||||
|
||||
if (!m_session)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto effectStart = aesEffectStart(source_row);
|
||||
qint64 effectEnd = 0;
|
||||
if (effectStart.is_set())
|
||||
effectEnd = effectStart.get() + aesEffectDuration(source_row);
|
||||
|
||||
|
||||
if (effectStart.is_set() &&
|
||||
effectEnd + m_offset > m_session->partitionTime())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+230
-212
@@ -1,300 +1,318 @@
|
||||
|
||||
|
||||
|
||||
#include "aes_itemlist.h"
|
||||
|
||||
#include "aes_base_model.h"
|
||||
#include "ui_aes_itemlist.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <Viewer/LtsDataView/lts_data_view.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QJsonDocument>
|
||||
#include <QKeyEvent>
|
||||
#include <QTreeView>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <Viewer/LtsDataView/lts_data_view.h>
|
||||
|
||||
static const auto ADLER_BTN = LtsWidgets::DialogButton::Export;
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
AesItemList::AesItemList(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ftc(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_showExpired(false)
|
||||
, m_bHasAddEditOperatorRights(true)
|
||||
, m_bHasAddAdlerOperatorRights(false)
|
||||
, m_session(nullptr)
|
||||
, m_ui(new Ui::AesItemList)
|
||||
AesItemList::AesItemList(const QString& menuGroup, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_ftc(nullptr), m_dtc(nullptr),
|
||||
m_menuGroup(menuGroup), m_requestHelper(new LtsUtils::RequestHelper(this)), m_showExpired(false),
|
||||
m_bHasAddEditOperatorRights(true), m_bHasAddAdlerOperatorRights(false), m_session(nullptr),
|
||||
m_ui(new Ui::AesItemList)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
QCheckBox *cbExpired = new QCheckBox(tr("Show expired"), m_ui->widget);
|
||||
cbExpired->setProperty("const", true);
|
||||
m_ui->widget->setCustomWidget(cbExpired);
|
||||
connect(cbExpired, &QCheckBox::toggled, this, &AesItemList::setShowExpired);
|
||||
QCheckBox* cbExpired = new QCheckBox(tr("Show expired"), m_ui->widget);
|
||||
cbExpired->setProperty("const", true);
|
||||
m_ui->widget->setCustomWidget(cbExpired);
|
||||
connect(cbExpired, &QCheckBox::toggled, this, &AesItemList::setShowExpired);
|
||||
}
|
||||
|
||||
AesItemList::~AesItemList() { delete m_ui; }
|
||||
|
||||
bool AesItemList::init(LtsSession::LtsSession *session)
|
||||
AesItemList::~AesItemList()
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &AesItemList::onPrint);
|
||||
if (m_session->app() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &AesItemList::onAddAesItem);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &AesItemList::onRemoveAesItem);
|
||||
}
|
||||
bool AesItemList::init(LtsSession::LtsSession* session)
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &AesItemList::onEditAesItem);
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &AesItemList::onPrint);
|
||||
if (m_session->app() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &AesItemList::onAddAesItem);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &AesItemList::onRemoveAesItem);
|
||||
}
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Center on Map"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this, &AesItemList::onCenterAesItem);
|
||||
m_buttonBox->getButton(ADLER_BTN)->hide();
|
||||
m_buttonBox->connectButton(ADLER_BTN, this, &AesItemList::onAdlerBtn);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &AesItemList::onEditAesItem);
|
||||
|
||||
QCheckBox *cb = qobject_cast<QCheckBox *>(m_ui->widget->customWidget());
|
||||
bool showExpired = (!cb || cb->isChecked());
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Center on Map"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this, &AesItemList::onCenterAesItem);
|
||||
m_buttonBox->getButton(ADLER_BTN)->hide();
|
||||
m_buttonBox->connectButton(ADLER_BTN, this, &AesItemList::onAdlerBtn);
|
||||
|
||||
createModel();
|
||||
model()->setShowExpired(showExpired);
|
||||
QCheckBox* cb = qobject_cast<QCheckBox*>(m_ui->widget->customWidget());
|
||||
bool showExpired = (!cb || cb->isChecked());
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &AesItemList::enaDisa);
|
||||
connect(m_session, &LtsSession::LtsSession::signalExerciseDataChanged, this, &AesItemList::enaDisa);
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::explosionClusterChanged, this, &AesItemList::onHandleAdler);
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::effectClusterChanged, this, &AesItemList::onHandleAdler);
|
||||
createModel();
|
||||
model()->setShowExpired(showExpired);
|
||||
|
||||
return true;
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &AesItemList::enaDisa);
|
||||
connect(m_session, &LtsSession::LtsSession::signalExerciseDataChanged, this, &AesItemList::enaDisa);
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::explosionClusterChanged, this,
|
||||
&AesItemList::onHandleAdler);
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::effectClusterChanged, this,
|
||||
&AesItemList::onHandleAdler);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AesItemList::enaDisa()
|
||||
{
|
||||
const int curSelRow = currentRow();
|
||||
onHandleAdler();
|
||||
LtsWidgets::ExerciseStates allowedStates = LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused;
|
||||
bool bEnableEditRemove = false;
|
||||
bool bIsAllowedInState = allowedStates.testFlag(m_session->exerciseState());
|
||||
bool isOc = (m_session->app() == LtsAppDescriptor::App::OC);
|
||||
const int curSelRow = currentRow();
|
||||
onHandleAdler();
|
||||
LtsWidgets::ExerciseStates allowedStates =
|
||||
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused;
|
||||
bool bEnableEditRemove = false;
|
||||
bool bIsAllowedInState = allowedStates.testFlag(m_session->exerciseState());
|
||||
bool isOc = (m_session->app() == LtsAppDescriptor::App::OC);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, !model()->isExpired(curSelRow));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, !model()->isExpired(curSelRow));
|
||||
|
||||
if (curSelRow >= 0)
|
||||
bEnableEditRemove = !model()->isExpired(curSelRow) && !model()->isExternal(curSelRow);
|
||||
if (!m_bHasAddEditOperatorRights)
|
||||
{
|
||||
bEnableEditRemove = false;
|
||||
bIsAllowedInState = false;
|
||||
}
|
||||
|
||||
if (!m_session->isReplayPartition())
|
||||
{
|
||||
if (!model()->isExternal(curSelRow))
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Edit"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bEnableEditRemove && bIsAllowedInState);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Show Details"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bIsAllowedInState);
|
||||
}
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, bEnableEditRemove && bIsAllowedInState);
|
||||
|
||||
|
||||
bool isEsAdler = false;
|
||||
if (curSelRow >= 0)
|
||||
bEnableEditRemove = !model()->isExpired(curSelRow) && !model()->isExternal(curSelRow);
|
||||
if (!m_bHasAddEditOperatorRights)
|
||||
{
|
||||
const ProjectDataManagement::EffectSource &es = model()->aesEffectSourceId(curSelRow);
|
||||
bEnableEditRemove = false;
|
||||
bIsAllowedInState = false;
|
||||
}
|
||||
|
||||
if (es == ProjectDataManagement::EffectSource::ES_ADLER || es == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
isEsAdler = true;
|
||||
if (!m_session->isReplayPartition())
|
||||
{
|
||||
if (!model()->isExternal(curSelRow))
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Edit"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bEnableEditRemove && bIsAllowedInState);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Show Details"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bIsAllowedInState);
|
||||
}
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, bIsAllowedInState && !isEsAdler);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, m_bHasAddAdlerOperatorRights && isEsAdler);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, !isOc);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, bEnableEditRemove && bIsAllowedInState);
|
||||
|
||||
bool isEsAdler = false;
|
||||
if (curSelRow >= 0)
|
||||
{
|
||||
const ProjectDataManagement::EffectSource& es = model()->aesEffectSourceId(curSelRow);
|
||||
|
||||
if (es == ProjectDataManagement::EffectSource::ES_ADLER ||
|
||||
es == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
isEsAdler = true;
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, bIsAllowedInState && !isEsAdler);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, m_bHasAddAdlerOperatorRights && isEsAdler);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, !isOc);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, bIsAllowedInState);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, m_bHasAddAdlerOperatorRights);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, !isOc);
|
||||
}
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Load)->setText(tr("Add ADLER"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, bIsAllowedInState);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, m_bHasAddAdlerOperatorRights);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, !isOc);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Add, false);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Show Details"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bEnableEditRemove);
|
||||
}
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Load)->setText(tr("Add ADLER"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Add, false);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Show Details"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bEnableEditRemove);
|
||||
}
|
||||
|
||||
if (bEnableEditRemove && bIsAllowedInState)
|
||||
{
|
||||
m_doubleClickConnection = connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &AesItemList::onEditAesItem, Qt::UniqueConnection);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_doubleClickConnection)
|
||||
disconnect(m_doubleClickConnection);
|
||||
}
|
||||
if (bEnableEditRemove && bIsAllowedInState)
|
||||
{
|
||||
m_doubleClickConnection = connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&AesItemList::onEditAesItem, Qt::UniqueConnection);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_doubleClickConnection)
|
||||
disconnect(m_doubleClickConnection);
|
||||
}
|
||||
}
|
||||
|
||||
void AesItemList::onPrint() { LtsPrinting::printView(m_session, this, m_ui->widget->treeView()); }
|
||||
void AesItemList::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
}
|
||||
|
||||
void AesItemList::onAdlerBtn()
|
||||
{
|
||||
AesEffectState aesEffectState = model()->aesEffectStateId(currentRow());
|
||||
ProjectDataManagement::EffectSource effectSource = model()->aesEffectSourceId(currentRow());
|
||||
AesEffectState aesEffectState = model()->aesEffectStateId(currentRow());
|
||||
ProjectDataManagement::EffectSource effectSource = model()->aesEffectSourceId(currentRow());
|
||||
|
||||
DEBUG_LOG(m_logger) << "onAdlerBtn aesEffectState=" << aesEffectState;
|
||||
DEBUG_LOG(m_logger) << "onAdlerBtn aesEffectState=" << aesEffectState;
|
||||
|
||||
switch (aesEffectState.underlying())
|
||||
{
|
||||
case AreaEffectSimulation::AesEffectState::EsReceived:
|
||||
{
|
||||
switch (effectSource.underlying())
|
||||
switch (aesEffectState.underlying())
|
||||
{
|
||||
case ProjectDataManagement::EffectSource::ES_ADLER:
|
||||
{
|
||||
AcknowledgeExternalAesItemRequest req;
|
||||
int aesId = model()->aesId(currentRow());
|
||||
req.aesId(aesId);
|
||||
m_requestHelper->startSingleRequest([req, this]() { return m_ftc->acknowledgeExternalAesItemRequest(req, this); });
|
||||
case AreaEffectSimulation::AesEffectState::EsReceived: {
|
||||
switch (effectSource.underlying())
|
||||
{
|
||||
case ProjectDataManagement::EffectSource::ES_ADLER: {
|
||||
AcknowledgeExternalAesItemRequest req;
|
||||
int aesId = model()->aesId(currentRow());
|
||||
req.aesId(aesId);
|
||||
m_requestHelper->startSingleRequest(
|
||||
[req, this]() { return m_ftc->acknowledgeExternalAesItemRequest(req, this); });
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ExplosionClusterReleaseReceivedRequest req;
|
||||
int aesId = model()->aesId(currentRow());
|
||||
req.id(aesId);
|
||||
m_requestHelper->startSingleRequest([req, this]() { return m_ftc->explosionClusterReleaseReceivedRequest(req, this); });
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ExplosionClusterReleaseReceivedRequest req;
|
||||
int aesId = model()->aesId(currentRow());
|
||||
req.id(aesId);
|
||||
m_requestHelper->startSingleRequest(
|
||||
[req, this]() { return m_ftc->explosionClusterReleaseReceivedRequest(req, this); });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesEffectState::EsCreated:
|
||||
case AreaEffectSimulation::AesEffectState::EsPrepared:
|
||||
{
|
||||
if (effectSource == ProjectDataManagement::EffectSource::ES_ADLER ||
|
||||
effectSource == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
{
|
||||
AreaEffectSimulation::SetAesItemEffectorStateRequest req;
|
||||
req.aesId(model()->aesId(currentRow()));
|
||||
req.newEffectorState(AesEffectorState::EsReadyToFire);
|
||||
DEBUG_LOG(m_logger) << "Send setAesItemEffectorStateRequest with aesId: " << req.aesId() << ", AesEffectorState: " << req.newEffectorState();
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesEffectState::EsCreated:
|
||||
case AreaEffectSimulation::AesEffectState::EsPrepared: {
|
||||
if (effectSource == ProjectDataManagement::EffectSource::ES_ADLER ||
|
||||
effectSource == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
{
|
||||
AreaEffectSimulation::SetAesItemEffectorStateRequest req;
|
||||
req.aesId(model()->aesId(currentRow()));
|
||||
req.newEffectorState(AesEffectorState::EsReadyToFire);
|
||||
DEBUG_LOG(m_logger) << "Send setAesItemEffectorStateRequest with aesId: " << req.aesId()
|
||||
<< ", AesEffectorState: " << req.newEffectorState();
|
||||
|
||||
m_requestHelper->startSingleRequest([req, this]() { return m_ftc->setAesItemEffectorStateRequest(req, this); });
|
||||
m_requestHelper->startSingleRequest(
|
||||
[req, this]() { return m_ftc->setAesItemEffectorStateRequest(req, this); });
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
m_buttonBox->getButton(ADLER_BTN)->hide();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
m_buttonBox->getButton(ADLER_BTN)->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AesItemList::onHandleAdler()
|
||||
{
|
||||
AesEffectState aesEffectState = model()->aesEffectStateId(currentRow());
|
||||
DEBUG_LOG(m_logger) << "onHandleAdler aesEffectState=" << aesEffectState;
|
||||
auto *adlerBtn = m_buttonBox->getButton(ADLER_BTN);
|
||||
AesEffectState aesEffectState = model()->aesEffectStateId(currentRow());
|
||||
DEBUG_LOG(m_logger) << "onHandleAdler aesEffectState=" << aesEffectState;
|
||||
auto* adlerBtn = m_buttonBox->getButton(ADLER_BTN);
|
||||
|
||||
switch (aesEffectState.underlying())
|
||||
{
|
||||
case AreaEffectSimulation::AesEffectState::EsReceived:
|
||||
{
|
||||
adlerBtn->setText(tr("Mark received"));
|
||||
adlerBtn->setIcon(QIcon(QStringLiteral("icon:mortar_ammunition_administration.svg")));
|
||||
adlerBtn->show();
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesEffectState::EsCreated:
|
||||
case AreaEffectSimulation::AesEffectState::EsPrepared:
|
||||
{
|
||||
ProjectDataManagement::EffectSource effectSource = model()->aesEffectSourceId(currentRow());
|
||||
if (effectSource.underlying() == ProjectDataManagement::EffectSource::ES_ADLER ||
|
||||
effectSource.underlying() == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
switch (aesEffectState.underlying())
|
||||
{
|
||||
const EffectCluster &ecData = m_dtc->effectCluster(model()->aesId(currentRow()));
|
||||
if (ecData.effectorState() == AreaEffectSimulation::AesEffectorState::EsNotReadyToFire)
|
||||
{
|
||||
adlerBtn->setText(tr("Ready To Fire"));
|
||||
adlerBtn->show();
|
||||
}
|
||||
else
|
||||
adlerBtn->hide();
|
||||
case AreaEffectSimulation::AesEffectState::EsReceived: {
|
||||
adlerBtn->setText(tr("Mark received"));
|
||||
adlerBtn->setIcon(QIcon(QStringLiteral("icon:mortar_ammunition_administration.svg")));
|
||||
adlerBtn->show();
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesEffectState::EsCreated:
|
||||
case AreaEffectSimulation::AesEffectState::EsPrepared: {
|
||||
ProjectDataManagement::EffectSource effectSource = model()->aesEffectSourceId(currentRow());
|
||||
if (effectSource.underlying() == ProjectDataManagement::EffectSource::ES_ADLER ||
|
||||
effectSource.underlying() == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
{
|
||||
const EffectCluster& ecData = m_dtc->effectCluster(model()->aesId(currentRow()));
|
||||
if (ecData.effectorState() == AreaEffectSimulation::AesEffectorState::EsNotReadyToFire)
|
||||
{
|
||||
adlerBtn->setText(tr("Ready To Fire"));
|
||||
adlerBtn->show();
|
||||
}
|
||||
else
|
||||
adlerBtn->hide();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
adlerBtn->hide();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
adlerBtn->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void AesItemList::onCenterAesItem()
|
||||
{
|
||||
int aesId = model()->aesId(currentRow());
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(ifc))
|
||||
ifc->centerMapToAesObject(aesId);
|
||||
int aesId = model()->aesId(currentRow());
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(ifc))
|
||||
ifc->centerMapToAesObject(aesId);
|
||||
}
|
||||
|
||||
void AesItemList::hideColumn(int col) { m_ui->widget->hideColumn(col); }
|
||||
void AesItemList::hideColumn(int col)
|
||||
{
|
||||
m_ui->widget->hideColumn(col);
|
||||
}
|
||||
|
||||
void AesItemList::showColumn(int col) { m_ui->widget->showColumn(col); }
|
||||
void AesItemList::showColumn(int col)
|
||||
{
|
||||
m_ui->widget->showColumn(col);
|
||||
}
|
||||
|
||||
int AesItemList::currentRow() const
|
||||
{
|
||||
const auto selRows = m_ui->widget->selectedRows();
|
||||
if (selRows.count() != 1)
|
||||
return -1;
|
||||
return selRows.first().row();
|
||||
const auto selRows = m_ui->widget->selectedRows();
|
||||
if (selRows.count() != 1)
|
||||
return -1;
|
||||
return selRows.first().row();
|
||||
}
|
||||
|
||||
void AesItemList::setDataViewModel(QAbstractItemModel *model, const std::function<LtsDataView::AbstractDisplayWidget *()> &customDisplayWidgetCreator)
|
||||
void AesItemList::setDataViewModel(
|
||||
QAbstractItemModel* model, const std::function<LtsDataView::AbstractDisplayWidget*()>& customDisplayWidgetCreator)
|
||||
{
|
||||
m_ui->widget->setModel(model, customDisplayWidgetCreator);
|
||||
m_ui->widget->setModel(model, customDisplayWidgetCreator);
|
||||
}
|
||||
|
||||
void AesItemList::setDataViewModel(QAbstractItemModel *model) { m_ui->widget->setModel(model); }
|
||||
void AesItemList::setDataViewModel(QAbstractItemModel* model)
|
||||
{
|
||||
m_ui->widget->setModel(model);
|
||||
}
|
||||
|
||||
void AesItemList::setShowExpired(bool show) { model()->setShowExpired(show); }
|
||||
void AesItemList::setShowExpired(bool show)
|
||||
{
|
||||
model()->setShowExpired(show);
|
||||
}
|
||||
|
||||
void AesItemList::setSortIndicator(int col) { m_ui->widget->setSortIndicator(col, Qt::AscendingOrder); }
|
||||
void AesItemList::setSortIndicator(int col)
|
||||
{
|
||||
m_ui->widget->setSortIndicator(col, Qt::AscendingOrder);
|
||||
}
|
||||
|
||||
void AesItemList::translateBase(const QString &windowTitle) { translate(m_ui, windowTitle); }
|
||||
void AesItemList::translateBase(const QString& windowTitle)
|
||||
{
|
||||
translate(m_ui, windowTitle);
|
||||
}
|
||||
|
||||
void AesItemList::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+55
-59
@@ -1,110 +1,106 @@
|
||||
|
||||
|
||||
|
||||
#include "aes_charge_administration_adler_list.h"
|
||||
#include "ui_aes_charge_administration_list.h"
|
||||
#include "aes_charge_administration_adler_model.h"
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsWidgets/lts_combo_box.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <QInputDialog>
|
||||
#include "aes_charge_administration_adler_model.h"
|
||||
#include "ui_aes_charge_administration_list.h"
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_combo_box.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <QInputDialog>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
ChargeAdministrationAdlerList::ChargeAdministrationAdlerList(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_model(nullptr)
|
||||
, m_sourceModel(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::ChargeAdministrationList)
|
||||
ChargeAdministrationAdlerList::ChargeAdministrationAdlerList(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_model(nullptr), m_sourceModel(nullptr),
|
||||
m_session(nullptr), m_requestHelper(new LtsUtils::RequestHelper(this)), m_ui(new Ui::ChargeAdministrationList)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->cbParty, static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ChargeAdministrationAdlerList::onPartyChanged);
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged), this,
|
||||
&ChargeAdministrationAdlerList::onPartyChanged);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Charge_Administration_Adler"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Charge_Administration_Adler"));
|
||||
}
|
||||
|
||||
ChargeAdministrationAdlerList::~ChargeAdministrationAdlerList()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerList::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Charge Administration Adler"));
|
||||
translate(m_ui, tr("Charge Administration Adler"));
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerList::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerList::onPartyChanged()
|
||||
{
|
||||
m_model->setParty(m_ui->cbParty->currentData().toInt());
|
||||
m_model->setParty(m_ui->cbParty->currentData().toInt());
|
||||
}
|
||||
|
||||
bool ChargeAdministrationAdlerList::init(LtsSession::LtsSession *session)
|
||||
bool ChargeAdministrationAdlerList::init(LtsSession::LtsSession* session)
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ChargeAdministrationAdlerList::onPrint);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ChargeAdministrationAdlerList::onPrint);
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> ppmGuiCbxIfc;
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(ppmGuiCbxIfc))
|
||||
return false;
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> ppmGuiCbxIfc;
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(ppmGuiCbxIfc))
|
||||
return false;
|
||||
|
||||
m_sourceModel = new ChargeAdministrationAdlerModel(this);
|
||||
m_sourceModel = new ChargeAdministrationAdlerModel(this);
|
||||
|
||||
if (!m_sourceModel->initModel(m_session))
|
||||
return false;
|
||||
if (!m_sourceModel->initModel(m_session))
|
||||
return false;
|
||||
|
||||
m_model = new ChargeAdministrationAdlerSortFilterProxyModel(this);
|
||||
m_model->setSourceModel(m_sourceModel);
|
||||
m_ui->widget->setModel(m_model);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColId, true);
|
||||
m_model = new ChargeAdministrationAdlerSortFilterProxyModel(this);
|
||||
m_model->setSourceModel(m_sourceModel);
|
||||
m_ui->widget->setModel(m_model);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColId, true);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
bool onlydebugMode =true;
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColTypeId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColChanged, onlydebugMode);
|
||||
bool onlydebugMode = true;
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColTypeId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColChanged, onlydebugMode);
|
||||
#endif
|
||||
|
||||
m_ui->widget->setSortIndicator(ChargeAdministrationAdlerModel::ColTypeName, Qt::AscendingOrder);
|
||||
m_ui->widget->setSortIndicator(ChargeAdministrationAdlerModel::ColTypeName, Qt::AscendingOrder);
|
||||
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
onPartyChanged();
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
onPartyChanged();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerList::onPrint()
|
||||
{
|
||||
QString header;
|
||||
header += QStringLiteral("<p>");
|
||||
header += tr("Party: %1").arg(m_ui->cbParty->currentText());
|
||||
header += QStringLiteral("<br/>");
|
||||
header += QStringLiteral("</p>");
|
||||
QString header;
|
||||
header += QStringLiteral("<p>");
|
||||
header += tr("Party: %1").arg(m_ui->cbParty->currentText());
|
||||
header += QStringLiteral("<br/>");
|
||||
header += QStringLiteral("</p>");
|
||||
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView(), header );
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView(), header);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+191
-198
@@ -1,263 +1,256 @@
|
||||
|
||||
|
||||
|
||||
#include "aes_charge_administration_adler_model.h"
|
||||
#include <utility>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsCore/json_object.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <utility>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
void ChargeAdministrationAdlerSortFilterProxyModel::setSourceModel(QAbstractItemModel *model)
|
||||
void ChargeAdministrationAdlerSortFilterProxyModel::setSourceModel(QAbstractItemModel* model)
|
||||
{
|
||||
m_sourceModel = qobject_cast<ChargeAdministrationAdlerModel*>(model);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(model);
|
||||
m_sourceModel = qobject_cast<ChargeAdministrationAdlerModel*>(model);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(model);
|
||||
}
|
||||
|
||||
bool ChargeAdministrationAdlerSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
bool ChargeAdministrationAdlerSortFilterProxyModel::filterAcceptsRow(int source_row,
|
||||
const QModelIndex& source_parent) const
|
||||
{
|
||||
if (!m_sourceModel || source_parent.isValid() || source_row < 0 || source_row >= m_sourceModel->rowCount())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
if (!m_sourceModel || source_parent.isValid() || source_row < 0 || source_row >= m_sourceModel->rowCount())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
const ChargeAdministrationAdler &item = m_sourceModel->m_vecData.at(source_row);
|
||||
if (item.partyId != m_party)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
const ChargeAdministrationAdler& item = m_sourceModel->m_vecData.at(source_row);
|
||||
if (item.partyId != m_party)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
}
|
||||
|
||||
int ChargeAdministrationAdlerSortFilterProxyModel::party() const
|
||||
{
|
||||
return m_party;
|
||||
return m_party;
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerSortFilterProxyModel::setParty(int party)
|
||||
{
|
||||
m_party = party;
|
||||
invalidateFilter();
|
||||
m_party = party;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ChargeAdministrationAdlerModel::ChargeAdministrationAdlerModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ChargeAdministrationAdler>({tr("Id"),
|
||||
tr("Charge Type Id"),
|
||||
tr("Changed"),
|
||||
tr("Charge Type Name"),
|
||||
tr("Total Stock"),
|
||||
tr("Gear Class")},
|
||||
parent)
|
||||
{}
|
||||
|
||||
bool ChargeAdministrationAdlerModel::initModel(LtsSession::LtsSession *session)
|
||||
ChargeAdministrationAdlerModel::ChargeAdministrationAdlerModel(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ChargeAdministrationAdler>(
|
||||
{tr("Id"), tr("Charge Type Id"), tr("Changed"), tr("Charge Type Name"), tr("Total Stock"), tr("Gear Class")},
|
||||
parent)
|
||||
{
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
|
||||
m_DynamicParticipantDataMap = m_ppmDtc->dynamicParticipantDatas();
|
||||
QMapIterator<qint32, ParticipantManagement::DynamicParticipantData> iter(m_DynamicParticipantDataMap);
|
||||
while(iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
updateParticipantChargeTypeMap(iter.value());
|
||||
}
|
||||
|
||||
QMap<qint32, ParticipantManagement::Party> parties;
|
||||
if (!m_ppmDtc->visibleParties(parties, LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(session->exerciseId())))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Could not retrieve visible Parties!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for (const ParticipantManagement::Party &p : std::as_const(parties))
|
||||
{
|
||||
updateItem(p.id());
|
||||
}
|
||||
|
||||
connect (m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::dynamicParticipantDataChanged,
|
||||
this, &ChargeAdministrationAdlerModel::onStateChanged);
|
||||
connect (m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged,
|
||||
this, &ChargeAdministrationAdlerModel::onParticipantChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerModel::onStateChanged(const ParticipantManagement::DynamicParticipantData &data, DataModification modType)
|
||||
bool ChargeAdministrationAdlerModel::initModel(LtsSession::LtsSession* session)
|
||||
{
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "+++++++++ DataModification --> " << modType;
|
||||
updateParticipantChargeTypeMap(data);
|
||||
|
||||
updateItem(m_ppmDtc->participant(data.participantId()).partyId());
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
|
||||
m_DynamicParticipantDataMap = m_ppmDtc->dynamicParticipantDatas();
|
||||
QMapIterator<qint32, ParticipantManagement::DynamicParticipantData> iter(m_DynamicParticipantDataMap);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
updateParticipantChargeTypeMap(iter.value());
|
||||
}
|
||||
|
||||
QMap<qint32, ParticipantManagement::Party> parties;
|
||||
if (!m_ppmDtc->visibleParties(
|
||||
parties, LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(session->exerciseId())))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Could not retrieve visible Parties!";
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const ParticipantManagement::Party& p : std::as_const(parties))
|
||||
{
|
||||
updateItem(p.id());
|
||||
}
|
||||
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::dynamicParticipantDataChanged, this,
|
||||
&ChargeAdministrationAdlerModel::onStateChanged);
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged, this,
|
||||
&ChargeAdministrationAdlerModel::onParticipantChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerModel::onParticipantChanged(const ParticipantManagement::Participant &data,
|
||||
void ChargeAdministrationAdlerModel::onStateChanged(const ParticipantManagement::DynamicParticipantData& data,
|
||||
DataModification modType)
|
||||
{
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified: {
|
||||
DEBUG_LOG(m_logger) << "+++++++++ DataModification --> " << modType;
|
||||
updateParticipantChargeTypeMap(data);
|
||||
|
||||
updateItem(m_ppmDtc->participant(data.participantId()).partyId());
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerModel::onParticipantChanged(const ParticipantManagement::Participant& data,
|
||||
DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType)
|
||||
qint32 typeId = data.typeId();
|
||||
qint32 participantId = data.id();
|
||||
Q_UNUSED(modType)
|
||||
qint32 typeId = data.typeId();
|
||||
qint32 participantId = data.id();
|
||||
|
||||
|
||||
if (!data.isDeleted() || (!m_ppmDtc->isAdlerType(typeId) &&
|
||||
(m_ppmDtc->type(typeId).typeClass().underlying() != ParticipantManagement::TypeClass::Unit)))
|
||||
return;
|
||||
if (!data.isDeleted() || (!m_ppmDtc->isAdlerType(typeId) && (m_ppmDtc->type(typeId).typeClass().underlying() !=
|
||||
ParticipantManagement::TypeClass::Unit)))
|
||||
return;
|
||||
|
||||
if (m_participantChargeTypeMap.contains(participantId))
|
||||
{
|
||||
|
||||
QList<qint32> keys = m_participantChargeTypeMap.value(participantId).chargeTypeTotalStockMap.keys();
|
||||
for ( int key : keys)
|
||||
if (m_participantChargeTypeMap.contains(participantId))
|
||||
{
|
||||
int row = findRowForChargeTypeId(key, m_participantChargeTypeMap.value(participantId).partyId);
|
||||
if (row != -1)
|
||||
removeRow(row);
|
||||
}
|
||||
|
||||
m_participantChargeTypeMap.remove(participantId);
|
||||
}
|
||||
|
||||
|
||||
updateItem(data.partyId());
|
||||
QList<qint32> keys = m_participantChargeTypeMap.value(participantId).chargeTypeTotalStockMap.keys();
|
||||
for (int key : keys)
|
||||
{
|
||||
int row = findRowForChargeTypeId(key, m_participantChargeTypeMap.value(participantId).partyId);
|
||||
if (row != -1)
|
||||
removeRow(row);
|
||||
}
|
||||
|
||||
m_participantChargeTypeMap.remove(participantId);
|
||||
}
|
||||
|
||||
updateItem(data.partyId());
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerModel::updateParticipantChargeTypeMap(const ParticipantManagement::DynamicParticipantData &data)
|
||||
void ChargeAdministrationAdlerModel::updateParticipantChargeTypeMap(
|
||||
const ParticipantManagement::DynamicParticipantData& data)
|
||||
{
|
||||
qint32 participantId = data.participantId();
|
||||
qint64 sampleTime = data.sampleTime();
|
||||
qint32 typeId = m_ppmDtc->participant(participantId).typeId();
|
||||
bool isDeleted = m_ppmDtc->participant(participantId).isDeleted();
|
||||
qint32 participantId = data.participantId();
|
||||
qint64 sampleTime = data.sampleTime();
|
||||
qint32 typeId = m_ppmDtc->participant(participantId).typeId();
|
||||
bool isDeleted = m_ppmDtc->participant(participantId).isDeleted();
|
||||
|
||||
if (isDeleted || (!m_ppmDtc->isAdlerType(typeId) &&
|
||||
(m_ppmDtc->type(typeId).typeClass().underlying() != ParticipantManagement::TypeClass::Unit)))
|
||||
return;
|
||||
if (isDeleted || (!m_ppmDtc->isAdlerType(typeId) &&
|
||||
(m_ppmDtc->type(typeId).typeClass().underlying() != ParticipantManagement::TypeClass::Unit)))
|
||||
return;
|
||||
|
||||
QMap<qint32, GearData> chargeTypeGearData;
|
||||
for (const ParticipantManagement::GearInformation &ct : data.gear())
|
||||
{
|
||||
if (m_pdmDtc->adlerChargeTypeName(ct.chargeTypeId()).isEmpty())
|
||||
continue;
|
||||
|
||||
GearData gearData;
|
||||
gearData.remain = ct.remain();
|
||||
gearData.lastUpdate = ct.lastUpdate();
|
||||
if (chargeTypeGearData.contains(ct.chargeTypeId()))
|
||||
QMap<qint32, GearData> chargeTypeGearData;
|
||||
for (const ParticipantManagement::GearInformation& ct : data.gear())
|
||||
{
|
||||
gearData.remain += chargeTypeGearData.value(ct.chargeTypeId()).remain;
|
||||
if (m_pdmDtc->adlerChargeTypeName(ct.chargeTypeId()).isEmpty())
|
||||
continue;
|
||||
|
||||
GearData gearData;
|
||||
gearData.remain = ct.remain();
|
||||
gearData.lastUpdate = ct.lastUpdate();
|
||||
if (chargeTypeGearData.contains(ct.chargeTypeId()))
|
||||
{
|
||||
gearData.remain += chargeTypeGearData.value(ct.chargeTypeId()).remain;
|
||||
}
|
||||
chargeTypeGearData.insert(ct.chargeTypeId(), gearData);
|
||||
}
|
||||
chargeTypeGearData.insert(ct.chargeTypeId(), gearData);
|
||||
}
|
||||
m_participantChargeTypeMap.insert(participantId,
|
||||
ChargeStruct(participantId, m_ppmDtc->participant(participantId).partyId(),
|
||||
sampleTime, chargeTypeGearData));
|
||||
m_participantChargeTypeMap.insert(
|
||||
participantId,
|
||||
ChargeStruct(participantId, m_ppmDtc->participant(participantId).partyId(), sampleTime, chargeTypeGearData));
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerModel::updateItem(int partyId)
|
||||
{
|
||||
QMap<qint32, GearData> chargeTypeGearData;
|
||||
qint64 sampleTime=0;
|
||||
ChargeAdministrationAdler item;
|
||||
QMap<qint32, GearData> chargeTypeGearData;
|
||||
qint64 sampleTime = 0;
|
||||
ChargeAdministrationAdler item;
|
||||
|
||||
for (const ChargeStruct &participantCharges : std::as_const(m_participantChargeTypeMap))
|
||||
{
|
||||
if (participantCharges.partyId != partyId)
|
||||
continue;
|
||||
DEBUG_LOG(m_logger) << "+++++++++ ParticipantId -> " << participantCharges.participantId << ", sampleTime ->" << sampleTime;
|
||||
for (auto it = participantCharges.chargeTypeTotalStockMap.cbegin(), end = participantCharges.chargeTypeTotalStockMap.cend(); it != end; ++it)
|
||||
for (const ChargeStruct& participantCharges : std::as_const(m_participantChargeTypeMap))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "+++++++++ chargeRemain ->" << it.key() << ": " << it.value().remain
|
||||
<< it.value().lastUpdate;
|
||||
GearData data;
|
||||
data.lastUpdate = it.value().lastUpdate;
|
||||
data.remain = it.value().remain;
|
||||
if (chargeTypeGearData.contains(it.key()))
|
||||
{
|
||||
data.remain += chargeTypeGearData.value(it.key()).remain;
|
||||
}
|
||||
if (chargeTypeGearData.contains(it.key()))
|
||||
if (chargeTypeGearData.value(it.key()).lastUpdate > data.lastUpdate)
|
||||
data.lastUpdate = chargeTypeGearData.value(it.key()).lastUpdate;
|
||||
if (participantCharges.partyId != partyId)
|
||||
continue;
|
||||
DEBUG_LOG(m_logger) << "+++++++++ ParticipantId -> " << participantCharges.participantId << ", sampleTime ->"
|
||||
<< sampleTime;
|
||||
for (auto it = participantCharges.chargeTypeTotalStockMap.cbegin(),
|
||||
end = participantCharges.chargeTypeTotalStockMap.cend();
|
||||
it != end; ++it)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "+++++++++ chargeRemain ->" << it.key() << ": " << it.value().remain
|
||||
<< it.value().lastUpdate;
|
||||
GearData data;
|
||||
data.lastUpdate = it.value().lastUpdate;
|
||||
data.remain = it.value().remain;
|
||||
if (chargeTypeGearData.contains(it.key()))
|
||||
{
|
||||
data.remain += chargeTypeGearData.value(it.key()).remain;
|
||||
}
|
||||
if (chargeTypeGearData.contains(it.key()))
|
||||
if (chargeTypeGearData.value(it.key()).lastUpdate > data.lastUpdate)
|
||||
data.lastUpdate = chargeTypeGearData.value(it.key()).lastUpdate;
|
||||
|
||||
chargeTypeGearData.insert(it.key(), data);
|
||||
chargeTypeGearData.insert(it.key(), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item.partyId = partyId;
|
||||
for (auto gearData = chargeTypeGearData.cbegin(), end = chargeTypeGearData.cend(); gearData != end; ++gearData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "### PartyId " << item.partyId << " insert item -> chargeTypeId: " << gearData.key() << ", amount: " << gearData.value().remain
|
||||
<< ", lastUpdate:" << gearData.value().lastUpdate;
|
||||
item.partyId = partyId;
|
||||
for (auto gearData = chargeTypeGearData.cbegin(), end = chargeTypeGearData.cend(); gearData != end; ++gearData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "### PartyId " << item.partyId << " insert item -> chargeTypeId: " << gearData.key()
|
||||
<< ", amount: " << gearData.value().remain
|
||||
<< ", lastUpdate:" << gearData.value().lastUpdate;
|
||||
|
||||
item.chargeTypeId = gearData.key();
|
||||
item.sampleTime = gearData.value().lastUpdate;
|
||||
item.amount = gearData.value().remain;
|
||||
int row = findRowForChargeTypeId(item.chargeTypeId, item.partyId);
|
||||
if (row < 0)
|
||||
insertRow(item);
|
||||
else
|
||||
setRowData(row, item);
|
||||
}
|
||||
item.chargeTypeId = gearData.key();
|
||||
item.sampleTime = gearData.value().lastUpdate;
|
||||
item.amount = gearData.value().remain;
|
||||
int row = findRowForChargeTypeId(item.chargeTypeId, item.partyId);
|
||||
if (row < 0)
|
||||
insertRow(item);
|
||||
else
|
||||
setRowData(row, item);
|
||||
}
|
||||
}
|
||||
|
||||
int ChargeAdministrationAdlerModel::findRowForChargeTypeId(qint32 typeId, qint32 partyId) const
|
||||
{
|
||||
for (int i = 0; i < m_vecData.size(); ++i)
|
||||
{
|
||||
if (m_vecData.at(i).chargeTypeId == typeId && m_vecData.at(i).partyId == partyId)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
for (int i = 0; i < m_vecData.size(); ++i)
|
||||
{
|
||||
if (m_vecData.at(i).chargeTypeId == typeId && m_vecData.at(i).partyId == partyId)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
QVariant ChargeAdministrationAdlerModel::data(const QModelIndex &index, int role) const
|
||||
QVariant ChargeAdministrationAdlerModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const ChargeAdministrationAdler& item = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case ColId:
|
||||
return item.id;
|
||||
case ColTypeId:
|
||||
return item.chargeTypeId;
|
||||
case ColChanged:
|
||||
return QDateTime::fromMSecsSinceEpoch(item.sampleTime);
|
||||
case ColTypeName:
|
||||
return m_pdmDtc->trChargeTypeShortName(item.chargeTypeId, true);
|
||||
case ColStock:
|
||||
return item.amount;
|
||||
case ColGearClass:
|
||||
return ProjectDataManagement::toString(m_pdmDtc->gearClassFromChargeTypeId(item.chargeTypeId));
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
const ChargeAdministrationAdler &item = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case ColId:
|
||||
return item.id;
|
||||
case ColTypeId:
|
||||
return item.chargeTypeId;
|
||||
case ColChanged:
|
||||
return QDateTime::fromMSecsSinceEpoch(item.sampleTime);
|
||||
case ColTypeName:
|
||||
return m_pdmDtc->trChargeTypeShortName(item.chargeTypeId, true);
|
||||
case ColStock:
|
||||
return item.amount;
|
||||
case ColGearClass:
|
||||
return ProjectDataManagement::toString(m_pdmDtc->gearClassFromChargeTypeId(item.chargeTypeId));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+119
-117
@@ -1,188 +1,190 @@
|
||||
|
||||
|
||||
|
||||
#include "aes_charge_administration_list.h"
|
||||
#include <utility>
|
||||
|
||||
#include "CustomView/aes_charge_administration.h"
|
||||
#include "aes_charge_administration_model.h"
|
||||
#include "aes_charge_edit.h"
|
||||
#include "ui_aes_charge_administration_list.h"
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_combo_box.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <QTreeView>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <utility>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
ChargeAdministrationList::ChargeAdministrationList(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_model(nullptr)
|
||||
, m_sourceModel(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::ChargeAdministrationList)
|
||||
ChargeAdministrationList::ChargeAdministrationList(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_model(nullptr), m_sourceModel(nullptr),
|
||||
m_session(nullptr), m_ftc(nullptr), m_requestHelper(new LtsUtils::RequestHelper(this)),
|
||||
m_ui(new Ui::ChargeAdministrationList)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this,
|
||||
&ChargeAdministrationList::onPartyChanged);
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged), this,
|
||||
&ChargeAdministrationList::onPartyChanged);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Charge_Administration"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Charge_Administration"));
|
||||
}
|
||||
|
||||
ChargeAdministrationList::~ChargeAdministrationList() { delete m_ui; }
|
||||
ChargeAdministrationList::~ChargeAdministrationList()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::retranslate() { translate(m_ui, tr("Charge Administration")); }
|
||||
void ChargeAdministrationList::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Charge Administration"));
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::enaDisa()
|
||||
{
|
||||
LtsWidgets::ExerciseStates allowedStates = LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused;
|
||||
bool bIsAllowedInState = allowedStates.testFlag(m_session->exerciseState());
|
||||
LtsWidgets::ExerciseStates allowedStates =
|
||||
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused;
|
||||
bool bIsAllowedInState = allowedStates.testFlag(m_session->exerciseState());
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bIsAllowedInState && m_ui->widget->selectedRows().count() > 0);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, bIsAllowedInState && m_ui->widget->selectedRows().count() > 0);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit,
|
||||
bIsAllowedInState && m_ui->widget->selectedRows().count() > 0);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove,
|
||||
bIsAllowedInState && m_ui->widget->selectedRows().count() > 0);
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::onPartyChanged() { m_model->setParty(m_ui->cbParty->currentData().toInt()); }
|
||||
void ChargeAdministrationList::onPartyChanged()
|
||||
{
|
||||
m_model->setParty(m_ui->cbParty->currentData().toInt());
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::onChargeAdministrationModifyReply(const Core::FunctionReplyObject &replyObject) { m_requestHelper->requestReply(replyObject); }
|
||||
void ChargeAdministrationList::onChargeAdministrationModifyReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool ChargeAdministrationList::init(LtsSession::LtsSession *session)
|
||||
bool ChargeAdministrationList::init(LtsSession::LtsSession* session)
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
|
||||
if (m_session->app() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ChargeAdministrationList::onEditCharge);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &ChargeAdministrationList::onEditCharge);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalEnterPressed, this, &ChargeAdministrationList::onEditCharge);
|
||||
}
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ChargeAdministrationList::onPrint);
|
||||
|
||||
|
||||
|
||||
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> ppmGuiCbxIfc;
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(ppmGuiCbxIfc))
|
||||
return false;
|
||||
|
||||
m_sourceModel = new ChargeAdministrationModel(this);
|
||||
|
||||
QVector<ChargeAdministrationModifyRequest> reqs;
|
||||
if (!m_sourceModel->initModel(m_session, reqs))
|
||||
return false;
|
||||
|
||||
if (!reqs.isEmpty())
|
||||
{
|
||||
for (const ChargeAdministrationModifyRequest &req : std::as_const(reqs))
|
||||
if (m_session)
|
||||
{
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->chargeAdministrationModifyRequest(req, this); });
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_requestHelper->startRequests();
|
||||
}
|
||||
m_session = session;
|
||||
|
||||
m_model = new ChargeAdministrationSortFilterProxyModel(this);
|
||||
m_model->setSourceModel(m_sourceModel);
|
||||
m_ui->widget->setModel(m_model, [this]() { return new CustomViewChargeAdministration(this); });
|
||||
if (m_session->app() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ChargeAdministrationList::onEditCharge);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&ChargeAdministrationList::onEditCharge);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalEnterPressed, this,
|
||||
&ChargeAdministrationList::onEditCharge);
|
||||
}
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &ChargeAdministrationList::enaDisa);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ChargeAdministrationList::onPrint);
|
||||
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> ppmGuiCbxIfc;
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(ppmGuiCbxIfc))
|
||||
return false;
|
||||
|
||||
m_sourceModel = new ChargeAdministrationModel(this);
|
||||
|
||||
QVector<ChargeAdministrationModifyRequest> reqs;
|
||||
if (!m_sourceModel->initModel(m_session, reqs))
|
||||
return false;
|
||||
|
||||
if (!reqs.isEmpty())
|
||||
{
|
||||
for (const ChargeAdministrationModifyRequest& req : std::as_const(reqs))
|
||||
{
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->chargeAdministrationModifyRequest(req, this); });
|
||||
}
|
||||
m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
m_model = new ChargeAdministrationSortFilterProxyModel(this);
|
||||
m_model->setSourceModel(m_sourceModel);
|
||||
m_ui->widget->setModel(m_model, [this]() { return new CustomViewChargeAdministration(this); });
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &ChargeAdministrationList::enaDisa);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
bool onlydebugMode = true;
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColTypeId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColChanged, onlydebugMode);
|
||||
bool onlydebugMode = true;
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColTypeId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColChanged, onlydebugMode);
|
||||
#endif
|
||||
|
||||
|
||||
m_ui->widget->setSortIndicator(ChargeAdministrationModel::ColTypeName, Qt::AscendingOrder);
|
||||
|
||||
m_ui->widget->setSortIndicator(ChargeAdministrationModel::ColTypeName, Qt::AscendingOrder);
|
||||
enaDisa();
|
||||
|
||||
enaDisa();
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
onPartyChanged();
|
||||
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
onPartyChanged();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::onPrint()
|
||||
{
|
||||
QString header;
|
||||
header += QStringLiteral("<p>");
|
||||
header += tr("Party: %1").arg(m_ui->cbParty->currentText());
|
||||
header += QStringLiteral("<br/>");
|
||||
header += QStringLiteral("</p>");
|
||||
QString header;
|
||||
header += QStringLiteral("<p>");
|
||||
header += tr("Party: %1").arg(m_ui->cbParty->currentText());
|
||||
header += QStringLiteral("<br/>");
|
||||
header += QStringLiteral("</p>");
|
||||
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView(), header);
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView(), header);
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::onEditCharge()
|
||||
{
|
||||
ChargeAdministration item = m_sourceModel->getRowData(m_ui->widget->currentIndex().row());
|
||||
ChargeAdministration item = m_sourceModel->getRowData(m_ui->widget->currentIndex().row());
|
||||
|
||||
if (item.id() < 0)
|
||||
return;
|
||||
if (item.id() < 0)
|
||||
return;
|
||||
|
||||
ProjectDataManagement::ChargeType ct = m_sourceModel->chargeType(item.chargeTypeId());
|
||||
ProjectDataManagement::ChargeType ct = m_sourceModel->chargeType(item.chargeTypeId());
|
||||
|
||||
const QModelIndex temp = m_ui->widget->currentIndex();
|
||||
const QModelIndex temp = m_ui->widget->currentIndex();
|
||||
|
||||
const QModelIndex mi = temp.sibling(temp.row(), ChargeAdministrationModel::ColTypeName);
|
||||
auto ce = new ChargeEdit(ct.id(), m_sourceModel->data(mi).toString(), item.amount(), this);
|
||||
connect(ce, &ChargeEdit::newStock, this, &ChargeAdministrationList::onChargeEditFinished);
|
||||
connect(ce, &ChargeEdit::newStock, ce, &ChargeEdit::deleteLater);
|
||||
ce->show();
|
||||
const QModelIndex mi = temp.sibling(temp.row(), ChargeAdministrationModel::ColTypeName);
|
||||
auto ce = new ChargeEdit(ct.id(), m_sourceModel->data(mi).toString(), item.amount(), this);
|
||||
connect(ce, &ChargeEdit::newStock, this, &ChargeAdministrationList::onChargeEditFinished);
|
||||
connect(ce, &ChargeEdit::newStock, ce, &ChargeEdit::deleteLater);
|
||||
ce->show();
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::onChargeEditFinished(int chargeId, int newStock)
|
||||
{
|
||||
ChargeAdministration item = m_sourceModel->getRowData(m_ui->widget->currentIndex().row());
|
||||
ChargeAdministration item = m_sourceModel->getRowData(m_ui->widget->currentIndex().row());
|
||||
|
||||
if (item.chargeTypeId() != chargeId)
|
||||
return;
|
||||
if (item.chargeTypeId() != chargeId)
|
||||
return;
|
||||
|
||||
if (item.amount() == newStock)
|
||||
return;
|
||||
item.amount(newStock);
|
||||
if (item.amount() == newStock)
|
||||
return;
|
||||
item.amount(newStock);
|
||||
|
||||
bool amountChangedByOperator = true;
|
||||
const ChargeAdministrationModifyRequest req(item.id(),
|
||||
item.chargeTypeId(),
|
||||
item.partyId(),
|
||||
item.effectSourceId(),
|
||||
item.amount(),
|
||||
amountChangedByOperator);
|
||||
bool amountChangedByOperator = true;
|
||||
const ChargeAdministrationModifyRequest req(item.id(), item.chargeTypeId(), item.partyId(), item.effectSourceId(),
|
||||
item.amount(), amountChangedByOperator);
|
||||
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->chargeAdministrationModifyRequest(req, this); });
|
||||
m_requestHelper->startRequests();
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->chargeAdministrationModifyRequest(req, this); });
|
||||
m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+121
-126
@@ -1,172 +1,167 @@
|
||||
|
||||
|
||||
|
||||
#include "aes_charge_administration_model.h"
|
||||
#include <utility>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsCore/json_object.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <utility>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ChargeAdministrationSortFilterProxyModel::setSourceModel(QAbstractItemModel *model)
|
||||
void ChargeAdministrationSortFilterProxyModel::setSourceModel(QAbstractItemModel* model)
|
||||
{
|
||||
m_sourceModel = qobject_cast<ChargeAdministrationModel *>(model);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(model);
|
||||
m_sourceModel = qobject_cast<ChargeAdministrationModel*>(model);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(model);
|
||||
}
|
||||
|
||||
bool ChargeAdministrationSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
bool ChargeAdministrationSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||
{
|
||||
if (!m_sourceModel || source_parent.isValid() || source_row < 0 || source_row >= m_sourceModel->rowCount())
|
||||
if (!m_sourceModel || source_parent.isValid() || source_row < 0 || source_row >= m_sourceModel->rowCount())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
const ChargeAdministration& item = m_sourceModel->m_vecData.at(source_row);
|
||||
if (item.partyId() != m_party)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
const ChargeAdministration &item = m_sourceModel->m_vecData.at(source_row);
|
||||
if (item.partyId() != m_party)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
}
|
||||
|
||||
int ChargeAdministrationSortFilterProxyModel::party() const { return m_party; }
|
||||
int ChargeAdministrationSortFilterProxyModel::party() const
|
||||
{
|
||||
return m_party;
|
||||
}
|
||||
|
||||
void ChargeAdministrationSortFilterProxyModel::setParty(int party)
|
||||
{
|
||||
m_party = party;
|
||||
invalidateFilter();
|
||||
m_party = party;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ChargeAdministrationModel::ChargeAdministrationModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ChargeAdministration>({tr("Id"),
|
||||
tr("Charge Type Id"),
|
||||
tr("Changed"),
|
||||
tr("Charge Type Name"),
|
||||
tr("Total Stock"),
|
||||
tr("Planned"),
|
||||
tr("Available"),
|
||||
tr("Used"),
|
||||
tr("Gear Class")},
|
||||
ChargeAdministrationModel::ChargeAdministrationModel(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ChargeAdministration>({tr("Id"), tr("Charge Type Id"), tr("Changed"),
|
||||
tr("Charge Type Name"), tr("Total Stock"), tr("Planned"),
|
||||
tr("Available"), tr("Used"), tr("Gear Class")},
|
||||
parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool ChargeAdministrationModel::initModel(LtsSession::LtsSession *session, QVector<ChargeAdministrationModifyRequest> &reqs)
|
||||
bool ChargeAdministrationModel::initModel(LtsSession::LtsSession* session,
|
||||
QVector<ChargeAdministrationModifyRequest>& reqs)
|
||||
{
|
||||
if (m_aesDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
return false;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc;
|
||||
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(ppmDtc))
|
||||
return false;
|
||||
|
||||
m_chargeTypeMap = m_pdmDtc->chargeTypes();
|
||||
|
||||
connect(m_aesDtc.get(), &Interface::Dtc::chargeAdministrationChanged, this, &ChargeAdministrationModel::onChargeAdministrationChanged);
|
||||
|
||||
QVector<QPair<int, int>> chargesInserted;
|
||||
auto cb = [this, &chargesInserted](const ChargeAdministration &item)
|
||||
{
|
||||
|
||||
const int chargeTypeId = item.chargeTypeId();
|
||||
if (m_pdmDtc->isAdlerChargeType(chargeTypeId))
|
||||
return;
|
||||
|
||||
insertRow(item);
|
||||
chargesInserted.append(qMakePair<int, int>(item.chargeTypeId(), item.partyId()));
|
||||
};
|
||||
m_aesDtc->chargeAdministrations(cb);
|
||||
|
||||
QMap<qint32, ParticipantManagement::Party> parties;
|
||||
if (!ppmDtc->visibleParties(parties, LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(session->exerciseId())))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not retrieve visible Parties!";
|
||||
return false;
|
||||
}
|
||||
|
||||
QVector<ProjectDataManagement::ChargeType> chargesForGearClass
|
||||
= m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Artillery) + m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Mortar);
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableRocket = ps->value(QStringLiteral("aes"), QStringLiteral("enableRocket"), false).toBool();
|
||||
if (enableRocket)
|
||||
chargesForGearClass += m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Rocket);
|
||||
for (const ParticipantManagement::Party &p : std::as_const(parties))
|
||||
{
|
||||
for (const ProjectDataManagement::ChargeType &ct : std::as_const(chargesForGearClass))
|
||||
if (m_aesDtc)
|
||||
{
|
||||
if (chargesInserted.contains(qMakePair(ct.id(), p.id())) || isDummy(ct) || m_pdmDtc->isAdlerChargeType(ct.id()))
|
||||
continue;
|
||||
|
||||
reqs << ChargeAdministrationModifyRequest(0, ct.id(), p.id(), ProjectDataManagement::EffectSource::ES_Internal, 0, true);
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
return false;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc;
|
||||
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(ppmDtc))
|
||||
return false;
|
||||
|
||||
m_chargeTypeMap = m_pdmDtc->chargeTypes();
|
||||
|
||||
connect(m_aesDtc.get(), &Interface::Dtc::chargeAdministrationChanged, this,
|
||||
&ChargeAdministrationModel::onChargeAdministrationChanged);
|
||||
|
||||
QVector<QPair<int, int>> chargesInserted;
|
||||
auto cb = [this, &chargesInserted](const ChargeAdministration& item) {
|
||||
const int chargeTypeId = item.chargeTypeId();
|
||||
if (m_pdmDtc->isAdlerChargeType(chargeTypeId))
|
||||
return;
|
||||
|
||||
insertRow(item);
|
||||
chargesInserted.append(qMakePair<int, int>(item.chargeTypeId(), item.partyId()));
|
||||
};
|
||||
m_aesDtc->chargeAdministrations(cb);
|
||||
|
||||
QMap<qint32, ParticipantManagement::Party> parties;
|
||||
if (!ppmDtc->visibleParties(
|
||||
parties, LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(session->exerciseId())))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not retrieve visible Parties!";
|
||||
return false;
|
||||
}
|
||||
|
||||
QVector<ProjectDataManagement::ChargeType> chargesForGearClass =
|
||||
m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Artillery) +
|
||||
m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Mortar);
|
||||
|
||||
LtsUtils::ProjectSettings* ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableRocket = ps->value(QStringLiteral("aes"), QStringLiteral("enableRocket"), false).toBool();
|
||||
if (enableRocket)
|
||||
chargesForGearClass += m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Rocket);
|
||||
for (const ParticipantManagement::Party& p : std::as_const(parties))
|
||||
{
|
||||
for (const ProjectDataManagement::ChargeType& ct : std::as_const(chargesForGearClass))
|
||||
{
|
||||
if (chargesInserted.contains(qMakePair(ct.id(), p.id())) || isDummy(ct) ||
|
||||
m_pdmDtc->isAdlerChargeType(ct.id()))
|
||||
continue;
|
||||
|
||||
reqs << ChargeAdministrationModifyRequest(0, ct.id(), p.id(),
|
||||
ProjectDataManagement::EffectSource::ES_Internal, 0, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChargeAdministrationModel::isDummy(const ProjectDataManagement::ChargeType &ct)
|
||||
bool ChargeAdministrationModel::isDummy(const ProjectDataManagement::ChargeType& ct)
|
||||
{
|
||||
return LtsUtils::JsonObject::fromJson(ct.properties()).valueOr<bool>("isDummy", false);
|
||||
return LtsUtils::JsonObject::fromJson(ct.properties()).valueOr<bool>("isDummy", false);
|
||||
}
|
||||
|
||||
QVariant ChargeAdministrationModel::data(const QModelIndex &index, int role) const
|
||||
QVariant ChargeAdministrationModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const ChargeAdministration& item = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case ColId:
|
||||
return item.id();
|
||||
case ColTypeId:
|
||||
return item.chargeTypeId();
|
||||
case ColChanged:
|
||||
return QDateTime::fromMSecsSinceEpoch(item.sampleTime());
|
||||
case ColTypeName:
|
||||
return m_pdmDtc->trChargeTypeShortName(item.chargeTypeId(), true);
|
||||
case ColStock:
|
||||
return item.amount();
|
||||
case ColAvailable:
|
||||
return item.amount() - item.planned();
|
||||
case ColPlanned:
|
||||
return item.planned();
|
||||
case ColUsed:
|
||||
return item.used();
|
||||
case ColGearClass:
|
||||
return ProjectDataManagement::toString(m_pdmDtc->gearClassFromChargeTypeId(item.chargeTypeId()));
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
const ChargeAdministration &item = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case ColId:
|
||||
return item.id();
|
||||
case ColTypeId:
|
||||
return item.chargeTypeId();
|
||||
case ColChanged:
|
||||
return QDateTime::fromMSecsSinceEpoch(item.sampleTime());
|
||||
case ColTypeName:
|
||||
return m_pdmDtc->trChargeTypeShortName(item.chargeTypeId(), true);
|
||||
case ColStock:
|
||||
return item.amount();
|
||||
case ColAvailable:
|
||||
return item.amount() - item.planned();
|
||||
case ColPlanned:
|
||||
return item.planned();
|
||||
case ColUsed:
|
||||
return item.used();
|
||||
case ColGearClass:
|
||||
return ProjectDataManagement::toString(m_pdmDtc->gearClassFromChargeTypeId(item.chargeTypeId()));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void ChargeAdministrationModel::onChargeAdministrationChanged(const ChargeAdministration &data, DataModification modType)
|
||||
void ChargeAdministrationModel::onChargeAdministrationChanged(const ChargeAdministration& data,
|
||||
DataModification modType)
|
||||
{
|
||||
|
||||
if (m_pdmDtc->isAdlerChargeType(data.chargeTypeId()))
|
||||
return;
|
||||
onDataChanged(data, modType);
|
||||
|
||||
if (m_pdmDtc->isAdlerChargeType(data.chargeTypeId()))
|
||||
return;
|
||||
onDataChanged(data, modType);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+207
-250
@@ -1,372 +1,329 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include "asm_edit_training_area_dialog.h"
|
||||
|
||||
#include "ui_asm_edit_training_area_dialog.h"
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
#include <LtsUtilsCore/dds_vector_to_pixmap.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Proxies/CombatNetRadio/helper.h>
|
||||
|
||||
static constexpr double s_minWidth{10};
|
||||
static constexpr double s_maxWidth{50000};
|
||||
|
||||
|
||||
static constexpr double s_minWidth {10};
|
||||
static constexpr double s_maxWidth {50000};
|
||||
|
||||
static constexpr double s_minHeight {10};
|
||||
static constexpr double s_maxHeight {50000};
|
||||
|
||||
static constexpr double s_minHeight{10};
|
||||
static constexpr double s_maxHeight{50000};
|
||||
|
||||
using namespace CombatNetRadio;
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
Core::GeoPosition2D convert(const QPointF &coord)
|
||||
Core::GeoPosition2D convert(const QPointF& coord)
|
||||
{
|
||||
return Core::GeoPosition2D(coord.x(), coord.y());
|
||||
return Core::GeoPosition2D(coord.x(), coord.y());
|
||||
}
|
||||
|
||||
QPointF convert(const Core::GeoPosition2D &geoPos)
|
||||
QPointF convert(const Core::GeoPosition2D& geoPos)
|
||||
{
|
||||
return QPointF(geoPos.lon(), geoPos.lat());
|
||||
return QPointF(geoPos.lon(), geoPos.lat());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AsmEditTrainingAreaDialog::AsmEditTrainingAreaDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::AsmEditTrainingAreaDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_menuGroup()
|
||||
AsmEditTrainingAreaDialog::AsmEditTrainingAreaDialog(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel),
|
||||
m_ui(new Ui::AsmEditTrainingAreaDialog), m_requestHelper(new LtsUtils::RequestHelper(this)), m_menuGroup()
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
|
||||
AsmEditTrainingAreaDialog::~AsmEditTrainingAreaDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void AsmEditTrainingAreaDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, m_dialogTitle);
|
||||
translate(m_ui, m_dialogTitle);
|
||||
}
|
||||
|
||||
|
||||
bool AsmEditTrainingAreaDialog::init(LtsSession::LtsSessionDataDds *session,
|
||||
const int &trainingAreaId,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
const QString &menuGroup)
|
||||
bool AsmEditTrainingAreaDialog::init(LtsSession::LtsSessionDataDds* session, const int& trainingAreaId,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface>& sitMapGuiIfc,
|
||||
const QString& menuGroup)
|
||||
{
|
||||
m_menuGroup = menuGroup;
|
||||
m_session = session;
|
||||
if (!m_session->getDtc<AssetManagement::DataInterface>(m_asmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "AsmEditTrainingAreaDialog::init() Could not enable DTC from ASM";
|
||||
return false;
|
||||
}
|
||||
if(!m_session->getFtc<AssetManagement::DataInterface>(m_asmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "AsmEditTrainingAreaDialog::init() Could not enable FTC from ASM";
|
||||
return false;
|
||||
}
|
||||
m_asmFtc->enableTrainingAreaRemove(true);
|
||||
m_asmFtc->enableTrainingAreaModify(true);
|
||||
|
||||
|
||||
|
||||
if (!sitMapGuiIfc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Invalid shared_ptr sitMapGuiIfc!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_trainingArea = AssetManagement::TrainingArea();
|
||||
AssetManagement::TrainingArea ta = AssetManagement::TrainingArea();
|
||||
if(trainingAreaId == 0)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " New training area ";
|
||||
ta.id() = 0;
|
||||
ta.name() = QStringLiteral("newArea").toStdString();
|
||||
ta.width() = 12800;
|
||||
ta.height() = 12800;
|
||||
m_dialogTitle = tr("New Training Area");
|
||||
}
|
||||
else
|
||||
{
|
||||
ta = m_asmDtc->trainingArea(trainingAreaId);
|
||||
if(ta.id()<= 0)
|
||||
m_menuGroup = menuGroup;
|
||||
m_session = session;
|
||||
if (!m_session->getDtc<AssetManagement::DataInterface>(m_asmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " training area not valid id: "<< trainingAreaId;
|
||||
return false;
|
||||
ERROR_LOG(m_logger) << "AsmEditTrainingAreaDialog::init() Could not enable DTC from ASM";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getFtc<AssetManagement::DataInterface>(m_asmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "AsmEditTrainingAreaDialog::init() Could not enable FTC from ASM";
|
||||
return false;
|
||||
}
|
||||
m_asmFtc->enableTrainingAreaRemove(true);
|
||||
m_asmFtc->enableTrainingAreaModify(true);
|
||||
|
||||
if (!sitMapGuiIfc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Invalid shared_ptr sitMapGuiIfc!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dialogTitle = tr("Edit Training Area: %1").arg(QString::fromStdString(ta.name()));
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " edit training area " <<trainingAreaId;
|
||||
}
|
||||
m_trainingArea = AssetManagement::TrainingArea();
|
||||
AssetManagement::TrainingArea ta = AssetManagement::TrainingArea();
|
||||
if (trainingAreaId == 0)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " New training area ";
|
||||
ta.id() = 0;
|
||||
ta.name() = QStringLiteral("newArea").toStdString();
|
||||
ta.width() = 12800;
|
||||
ta.height() = 12800;
|
||||
m_dialogTitle = tr("New Training Area");
|
||||
}
|
||||
else
|
||||
{
|
||||
ta = m_asmDtc->trainingArea(trainingAreaId);
|
||||
if (ta.id() <= 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " training area not valid id: " << trainingAreaId;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_trainingArea = ta;
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
if (m_sitMapGuiIfc)
|
||||
{
|
||||
connect(m_ui->pbPosition, &QPushButton::clicked, this, &AsmEditTrainingAreaDialog::getPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
}
|
||||
m_ui->name_lineEdit->setText(QString::fromStdString(m_trainingArea.name()));
|
||||
m_dialogTitle = tr("Edit Training Area: %1").arg(QString::fromStdString(ta.name()));
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " edit training area " << trainingAreaId;
|
||||
}
|
||||
|
||||
connect(m_ui->pbClear, &QPushButton::clicked,
|
||||
m_ui->positionEdit, &LtsCoordWidget::LtsCoordWidget::clear);
|
||||
m_trainingArea = ta;
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
if (m_sitMapGuiIfc)
|
||||
{
|
||||
connect(m_ui->pbPosition, &QPushButton::clicked, this, &AsmEditTrainingAreaDialog::getPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
}
|
||||
m_ui->name_lineEdit->setText(QString::fromStdString(m_trainingArea.name()));
|
||||
|
||||
onEditClicked();
|
||||
|
||||
connect(m_ui->pbClear, &QPushButton::clicked, m_ui->positionEdit, &LtsCoordWidget::LtsCoordWidget::clear);
|
||||
|
||||
setData();
|
||||
enaDisa();
|
||||
onEditClicked();
|
||||
|
||||
return true;
|
||||
setData();
|
||||
enaDisa();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AsmEditTrainingAreaDialog::enaDisa()
|
||||
{
|
||||
m_ui->pbPosition->setEnabled(m_sitMapGuiIfc.get());
|
||||
m_ui->pbPosition->setEnabled(m_sitMapGuiIfc.get());
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool AsmEditTrainingAreaDialog::has2DMap()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return false;
|
||||
if (m_sitMapGuiIfc->mapMode() != SituationMap::MapMode::MapMode_2D)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Only available in 2D mode"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (!m_sitMapGuiIfc)
|
||||
return false;
|
||||
if (m_sitMapGuiIfc->mapMode() != SituationMap::MapMode::MapMode_2D)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Only available in 2D mode"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AsmEditTrainingAreaDialog::getPosition()
|
||||
{
|
||||
const SituationMap::MapMode mode = m_sitMapGuiIfc->mapMode();
|
||||
const SituationMap::MapMode mode = m_sitMapGuiIfc->mapMode();
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case SituationMap::MapMode::MapMode_2D:
|
||||
m_sitMapGuiIfc->getRectangleNorth(this,
|
||||
SLOT(onRectData(QPointF,double,double,QPolygonF)),
|
||||
nullptr,
|
||||
s_minWidth,
|
||||
s_maxWidth,
|
||||
s_minHeight,
|
||||
s_maxHeight,
|
||||
m_ui->positionEdit->coordinate(),
|
||||
m_ui->sbWidth->value(),
|
||||
m_ui->sbHeight->value());
|
||||
|
||||
break;
|
||||
case SituationMap::MapMode::MapMode_3D:
|
||||
m_sitMapGuiIfc->getCoordinate(this, SLOT(onCoordinate(QPointF)), nullptr);
|
||||
break;
|
||||
case SituationMap::MapMode::Undefined:
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " ModeMode == Undefined ";
|
||||
break;
|
||||
}
|
||||
switch (mode)
|
||||
{
|
||||
case SituationMap::MapMode::MapMode_2D:
|
||||
m_sitMapGuiIfc->getRectangleNorth(this, SLOT(onRectData(QPointF, double, double, QPolygonF)), nullptr,
|
||||
s_minWidth, s_maxWidth, s_minHeight, s_maxHeight,
|
||||
m_ui->positionEdit->coordinate(), m_ui->sbWidth->value(),
|
||||
m_ui->sbHeight->value());
|
||||
|
||||
break;
|
||||
case SituationMap::MapMode::MapMode_3D:
|
||||
m_sitMapGuiIfc->getCoordinate(this, SLOT(onCoordinate(QPointF)), nullptr);
|
||||
break;
|
||||
case SituationMap::MapMode::Undefined:
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " ModeMode == Undefined ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AsmEditTrainingAreaDialog::onRectData(const QPointF ¢erPoint, double width, double height, const QPolygonF &coordinates)
|
||||
void AsmEditTrainingAreaDialog::onRectData(const QPointF& centerPoint, double width, double height,
|
||||
const QPolygonF& coordinates)
|
||||
{
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(centerPoint.x(), centerPoint.y());
|
||||
const QPointF &btmLeft = utmCoordinate.geographic(-1*(width/2.0), -1*(height/2.0));
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate =
|
||||
LtsCoordTrans::UtmCoordinate::fromGeographic(centerPoint.x(), centerPoint.y());
|
||||
const QPointF& btmLeft = utmCoordinate.geographic(-1 * (width / 2.0), -1 * (height / 2.0));
|
||||
|
||||
m_previewPolygon = coordinates;
|
||||
m_ui->positionEdit->setCoordinate(centerPoint.x(),centerPoint.y());
|
||||
m_ui->positionEdit->setCoordinate(centerPoint.x(), centerPoint.y());
|
||||
m_ui->sbWidth->setValue(width);
|
||||
m_ui->sbHeight->setValue(height);
|
||||
m_trainingArea.height() = height;
|
||||
m_trainingArea.width() = width;
|
||||
m_trainingArea.bottomLeft() = convert(btmLeft);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Pos X: " << centerPoint.x() << " Y: " << centerPoint.y() << " W: " << width << " H: " << height;
|
||||
DEBUG_LOG(m_logger) << "Pos X: " << centerPoint.x() << " Y: " << centerPoint.y() << " W: " << width
|
||||
<< " H: " << height;
|
||||
|
||||
showPreviewObject();
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
void AsmEditTrainingAreaDialog::onCoordinate(const QPointF ¢erPoint)
|
||||
void AsmEditTrainingAreaDialog::onCoordinate(const QPointF& centerPoint)
|
||||
{
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(centerPoint.x(), centerPoint.y());
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate =
|
||||
LtsCoordTrans::UtmCoordinate::fromGeographic(centerPoint.x(), centerPoint.y());
|
||||
|
||||
const double height = m_ui->sbHeight->value();
|
||||
const double width = m_ui->sbWidth->value();
|
||||
const QPointF btmLeft = utmCoordinate.geographic(-1*(width/2.0), -1*(height/2.0));
|
||||
const double height = m_ui->sbHeight->value();
|
||||
const double width = m_ui->sbWidth->value();
|
||||
const QPointF btmLeft = utmCoordinate.geographic(-1 * (width / 2.0), -1 * (height / 2.0));
|
||||
|
||||
m_ui->positionEdit->setCoordinate(centerPoint.x(),centerPoint.y());
|
||||
m_ui->positionEdit->setCoordinate(centerPoint.x(), centerPoint.y());
|
||||
|
||||
{
|
||||
const QPointF topLeft = utmCoordinate.geographic(-1*(width/2.0), 1*(height/2.0));
|
||||
const QPointF topRight = utmCoordinate.geographic( 1*(width/2.0), 1*(height/2.0));
|
||||
const QPointF btmRight = utmCoordinate.geographic( 1*(width/2.0),-1*(height/2.0));
|
||||
{
|
||||
const QPointF topLeft = utmCoordinate.geographic(-1 * (width / 2.0), 1 * (height / 2.0));
|
||||
const QPointF topRight = utmCoordinate.geographic(1 * (width / 2.0), 1 * (height / 2.0));
|
||||
const QPointF btmRight = utmCoordinate.geographic(1 * (width / 2.0), -1 * (height / 2.0));
|
||||
|
||||
m_previewPolygon.clear();
|
||||
m_previewPolygon.append(btmLeft);
|
||||
m_previewPolygon.append(topLeft);
|
||||
m_previewPolygon.append(topRight);
|
||||
m_previewPolygon.append(btmRight);
|
||||
}
|
||||
m_previewPolygon.clear();
|
||||
m_previewPolygon.append(btmLeft);
|
||||
m_previewPolygon.append(topLeft);
|
||||
m_previewPolygon.append(topRight);
|
||||
m_previewPolygon.append(btmRight);
|
||||
}
|
||||
|
||||
m_ui->sbWidth->setValue(width);
|
||||
m_ui->sbHeight->setValue(height);
|
||||
m_trainingArea.height() = height;
|
||||
m_trainingArea.width() = width;
|
||||
m_trainingArea.bottomLeft() = convert(btmLeft);
|
||||
m_ui->sbWidth->setValue(width);
|
||||
m_ui->sbHeight->setValue(height);
|
||||
m_trainingArea.height() = height;
|
||||
m_trainingArea.width() = width;
|
||||
m_trainingArea.bottomLeft() = convert(btmLeft);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Pos X: " << centerPoint.x() << " Y: " << centerPoint.y() << " W: " << width << " H: " << height;
|
||||
|
||||
showPreviewObject();
|
||||
DEBUG_LOG(m_logger) << "Pos X: " << centerPoint.x() << " Y: " << centerPoint.y() << " W: " << width
|
||||
<< " H: " << height;
|
||||
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AsmEditTrainingAreaDialog::onEditClicked()
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START Editing..";
|
||||
if (!m_sitMapGuiIfc || m_trainingArea.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "onEditClicked: sitMapGuiIfc or trainingArea_id: "<<m_trainingArea.id()<<" invalid! ";
|
||||
return;
|
||||
}
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START Editing..";
|
||||
if (!m_sitMapGuiIfc || m_trainingArea.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "onEditClicked: sitMapGuiIfc or trainingArea_id: " << m_trainingArea.id()
|
||||
<< " invalid! ";
|
||||
return;
|
||||
}
|
||||
|
||||
m_sitMapGuiIfc->getRectangleNorth(this,
|
||||
SLOT(onRectData(QPointF,double,double,QPolygonF)),
|
||||
nullptr,
|
||||
s_minWidth,
|
||||
s_maxWidth,
|
||||
s_minHeight,
|
||||
s_maxHeight,
|
||||
m_ui->positionEdit->coordinate(),
|
||||
m_ui->sbWidth->value(),
|
||||
m_ui->sbHeight->value());
|
||||
m_sitMapGuiIfc->getRectangleNorth(this, SLOT(onRectData(QPointF, double, double, QPolygonF)), nullptr, s_minWidth,
|
||||
s_maxWidth, s_minHeight, s_maxHeight, m_ui->positionEdit->coordinate(),
|
||||
m_ui->sbWidth->value(), m_ui->sbHeight->value());
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END Edit";
|
||||
|
||||
onSelectionChanged();
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END Edit";
|
||||
|
||||
onSelectionChanged();
|
||||
}
|
||||
|
||||
void AsmEditTrainingAreaDialog::onSelectionChanged()
|
||||
{
|
||||
m_previewPolygon= getTrainingArea(m_trainingArea);
|
||||
showPreviewObject();
|
||||
m_previewPolygon = getTrainingArea(m_trainingArea);
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
void AsmEditTrainingAreaDialog::showPreviewObject()
|
||||
{
|
||||
if (!m_sitMapGuiIfc || m_previewPolygon.size() == 0)
|
||||
{
|
||||
TRACE_LOG(m_logger) << " AsmEditTrainingAreaDialog::showPreviewObject(): m_sitMapGuiIfc invalid or polygon empty ";
|
||||
return;
|
||||
}
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, true);
|
||||
if (!m_sitMapGuiIfc || m_previewPolygon.size() == 0)
|
||||
{
|
||||
TRACE_LOG(m_logger)
|
||||
<< " AsmEditTrainingAreaDialog::showPreviewObject(): m_sitMapGuiIfc invalid or polygon empty ";
|
||||
return;
|
||||
}
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, true);
|
||||
}
|
||||
|
||||
QPointF AsmEditTrainingAreaDialog::getCentPos(TrainingArea ta)
|
||||
{
|
||||
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(ta.bottomLeft().lon(),
|
||||
ta.bottomLeft().lat());
|
||||
|
||||
QPointF centerPoint = utmCoordinate.geographic((ta.width() / 2.0), ta.height() / 2.0);
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " coord: x: "<< centerPoint.x() <<" y: "<< centerPoint.y();
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate =
|
||||
LtsCoordTrans::UtmCoordinate::fromGeographic(ta.bottomLeft().lon(), ta.bottomLeft().lat());
|
||||
|
||||
return centerPoint;
|
||||
QPointF centerPoint = utmCoordinate.geographic((ta.width() / 2.0), ta.height() / 2.0);
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " coord: x: " << centerPoint.x() << " y: " << centerPoint.y();
|
||||
|
||||
return centerPoint;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool AsmEditTrainingAreaDialog::apply()
|
||||
{
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(m_ui->positionEdit->coordinate().x(),
|
||||
m_ui->positionEdit->coordinate().y());
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(
|
||||
m_ui->positionEdit->coordinate().x(), m_ui->positionEdit->coordinate().y());
|
||||
|
||||
if(!m_asmFtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Can not retrieve AssetManagement::FTC";
|
||||
return false;
|
||||
}
|
||||
double height = m_ui->sbHeight->value();
|
||||
double width = m_ui->sbWidth->value();
|
||||
const QPointF btmLeft = utmCoordinate.geographic(-1*(width/2.0), -1*(height/2.0));
|
||||
if (!m_asmFtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Can not retrieve AssetManagement::FTC";
|
||||
return false;
|
||||
}
|
||||
double height = m_ui->sbHeight->value();
|
||||
double width = m_ui->sbWidth->value();
|
||||
const QPointF btmLeft = utmCoordinate.geographic(-1 * (width / 2.0), -1 * (height / 2.0));
|
||||
|
||||
TrainingArea req = m_trainingArea;
|
||||
TrainingArea req = m_trainingArea;
|
||||
|
||||
req.name() = m_ui->name_lineEdit->text().toStdString();
|
||||
req.width() = m_ui->sbWidth->value();
|
||||
req.height() = m_ui->sbHeight->value();
|
||||
req.bottomLeft(convert(btmLeft));
|
||||
req.name() = m_ui->name_lineEdit->text().toStdString();
|
||||
req.width() = m_ui->sbWidth->value();
|
||||
req.height() = m_ui->sbHeight->value();
|
||||
req.bottomLeft(convert(btmLeft));
|
||||
|
||||
bool success = m_requestHelper->startSingleRequest([this, req]()
|
||||
{
|
||||
return m_asmFtc->trainingAreaModifyRequest(req, this);
|
||||
});
|
||||
bool success =
|
||||
m_requestHelper->startSingleRequest([this, req]() { return m_asmFtc->trainingAreaModifyRequest(req, this); });
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " scucess=" << success;
|
||||
return success;
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " scucess=" << success;
|
||||
return success;
|
||||
}
|
||||
|
||||
void AsmEditTrainingAreaDialog::setData()
|
||||
{
|
||||
if(m_trainingArea.id() > 0)
|
||||
{
|
||||
m_ui->name_lineEdit->setText(QString::fromStdString(m_trainingArea.name()));
|
||||
QPointF coord = getCentPos(m_trainingArea);
|
||||
m_ui->positionEdit->setCoordinate(coord.x(), coord.y());
|
||||
m_ui->sbWidth->setValue(m_trainingArea.width());
|
||||
m_ui->sbHeight->setValue(m_trainingArea.height());
|
||||
}
|
||||
if (m_trainingArea.id() > 0)
|
||||
{
|
||||
m_ui->name_lineEdit->setText(QString::fromStdString(m_trainingArea.name()));
|
||||
QPointF coord = getCentPos(m_trainingArea);
|
||||
m_ui->positionEdit->setCoordinate(coord.x(), coord.y());
|
||||
m_ui->sbWidth->setValue(m_trainingArea.width());
|
||||
m_ui->sbHeight->setValue(m_trainingArea.height());
|
||||
}
|
||||
}
|
||||
|
||||
QPolygonF AsmEditTrainingAreaDialog::getTrainingArea(const TrainingArea &ta)
|
||||
QPolygonF AsmEditTrainingAreaDialog::getTrainingArea(const TrainingArea& ta)
|
||||
{
|
||||
QPolygonF polygonF;
|
||||
if(!m_asmDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << " m_asmDtc is not valid!";
|
||||
return{};
|
||||
}
|
||||
AssetManagement::TrainingArea ddsTrainingArea = ta;
|
||||
|
||||
QPolygonF polygonF;
|
||||
if (!m_asmDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << " m_asmDtc is not valid!";
|
||||
return {};
|
||||
}
|
||||
AssetManagement::TrainingArea ddsTrainingArea = ta;
|
||||
|
||||
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(ddsTrainingArea.bottomLeft().lon(), ddsTrainingArea.bottomLeft().lat());
|
||||
polygonF.push_back(QPointF((ddsTrainingArea.bottomLeft().lon()),(ddsTrainingArea.bottomLeft().lat())));
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(
|
||||
ddsTrainingArea.bottomLeft().lon(), ddsTrainingArea.bottomLeft().lat());
|
||||
polygonF.push_back(QPointF((ddsTrainingArea.bottomLeft().lon()), (ddsTrainingArea.bottomLeft().lat())));
|
||||
|
||||
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width()));
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width()));
|
||||
|
||||
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width(), ddsTrainingArea.height()));
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width(), ddsTrainingArea.height()));
|
||||
|
||||
|
||||
polygonF.push_back(utmCoordinate.geographic(0, ddsTrainingArea.height()));
|
||||
polygonF.push_back(utmCoordinate.geographic(0, ddsTrainingArea.height()));
|
||||
|
||||
return polygonF;
|
||||
return polygonF;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace AssetManagement
|
||||
Executable → Regular
+53
-53
@@ -1,18 +1,16 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AssetManagement/asm_dtc.h>
|
||||
#include <AssetManagement/asm_ftc.h>
|
||||
#include <AssetManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -22,64 +20,66 @@ class AsmEditTrainingAreaDialog;
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class AsmEditTrainingAreaDialog final : public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::TrainingAreaModifyReplyHandler
|
||||
, protected Interface::Ftc::TrainingAreaRemoveReplyHandler
|
||||
class AsmEditTrainingAreaDialog final : public LtsWidgets::LtsDialog,
|
||||
protected Interface::Ftc::TrainingAreaModifyReplyHandler,
|
||||
protected Interface::Ftc::TrainingAreaRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AsmEditTrainingAreaDialog(QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit AsmEditTrainingAreaDialog(QWidget* parent = nullptr);
|
||||
|
||||
bool init(LtsSession::LtsSessionDataDds *session,
|
||||
const int &trainingAreaId, const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
const QString &menuGroup);
|
||||
bool init(LtsSession::LtsSessionDataDds* session, const int& trainingAreaId,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface>& sitMapGuiIfc, const QString& menuGroup);
|
||||
|
||||
~AsmEditTrainingAreaDialog();
|
||||
~AsmEditTrainingAreaDialog();
|
||||
|
||||
private slots:
|
||||
void getPosition();
|
||||
void onRectData(const QPointF ¢erPoint, double width, double height, const QPolygonF &coordinates);
|
||||
void onCoordinate(const QPointF ¢erPoint);
|
||||
void onEditClicked();
|
||||
void onSelectionChanged();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void onTrainingAreaModifyReply(const Core::FunctionReplyObject &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
void onTrainingAreaRemoveReply(const Core::FunctionReplyObject &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
private slots:
|
||||
void getPosition();
|
||||
void onRectData(const QPointF& centerPoint, double width, double height, const QPolygonF& coordinates);
|
||||
void onCoordinate(const QPointF& centerPoint);
|
||||
void onEditClicked();
|
||||
void onSelectionChanged();
|
||||
|
||||
bool has2DMap();
|
||||
void enaDisa();
|
||||
void showPreviewObject();
|
||||
QPointF getCentPos(AssetManagement::TrainingArea ta);
|
||||
bool apply() override;
|
||||
void setData();
|
||||
QPolygonF getTrainingArea(const AssetManagement::TrainingArea &ta);
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
|
||||
Ui::AsmEditTrainingAreaDialog *m_ui{nullptr};
|
||||
LtsSession::LtsSessionDataDds *m_session{nullptr};
|
||||
|
||||
QPointF m_Coordinates;
|
||||
bool m_rubberbandEditMode{false};
|
||||
void onTrainingAreaModifyReply(const Core::FunctionReplyObject& reply) override final
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
std::shared_ptr<AssetManagement::Interface::Ftc> m_asmFtc;
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
|
||||
void onTrainingAreaRemoveReply(const Core::FunctionReplyObject& reply) override final
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
bool has2DMap();
|
||||
void enaDisa();
|
||||
void showPreviewObject();
|
||||
QPointF getCentPos(AssetManagement::TrainingArea ta);
|
||||
bool apply() override;
|
||||
void setData();
|
||||
QPolygonF getTrainingArea(const AssetManagement::TrainingArea& ta);
|
||||
|
||||
LtsUtils::RequestHelper *m_requestHelper{nullptr};
|
||||
QString m_dialogTitle{};
|
||||
Ui::AsmEditTrainingAreaDialog* m_ui{nullptr};
|
||||
LtsSession::LtsSessionDataDds* m_session{nullptr};
|
||||
|
||||
QString m_menuGroup;
|
||||
QString m_trainingAreaName{};
|
||||
AssetManagement::TrainingArea m_trainingArea;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
QPolygonF m_previewPolygon;
|
||||
bool m_taExist{false};
|
||||
QPointF m_Coordinates;
|
||||
bool m_rubberbandEditMode{false};
|
||||
|
||||
std::shared_ptr<AssetManagement::Interface::Ftc> m_asmFtc;
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
|
||||
|
||||
LtsUtils::RequestHelper* m_requestHelper{nullptr};
|
||||
QString m_dialogTitle{};
|
||||
|
||||
QString m_menuGroup;
|
||||
QString m_trainingAreaName{};
|
||||
AssetManagement::TrainingArea m_trainingArea;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
QPolygonF m_previewPolygon;
|
||||
bool m_taExist{false};
|
||||
};
|
||||
}
|
||||
} // namespace AssetManagement
|
||||
Executable → Regular
+185
-200
@@ -1,301 +1,286 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include "asm_training_area_dialog.h"
|
||||
#include "ui_asm_training_area_dialog.h"
|
||||
|
||||
#include "asm_edit_training_area_dialog.h"
|
||||
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include "ui_asm_training_area_dialog.h"
|
||||
|
||||
#include <AssetManagement/asm_ftc_types.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <Proxies/CombatNetRadio/helper.h>
|
||||
#include <AssetManagement/asm_ftc_types.h>
|
||||
|
||||
using namespace CombatNetRadio;
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
AsmTrainingAreaDialog::AsmTrainingAreaDialog(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ui(new Ui::AsmTrainingAreaDialog)
|
||||
, m_session(nullptr)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
AsmTrainingAreaDialog::AsmTrainingAreaDialog(const QString& menuGroup, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_ui(new Ui::AsmTrainingAreaDialog),
|
||||
m_session(nullptr), m_menuGroup(menuGroup), m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setOnlineHelpFilename(QStringLiteral("Asset_Management-Training_Area"));
|
||||
m_ui->setupUi(this);
|
||||
setOnlineHelpFilename(QStringLiteral("Asset_Management-Training_Area"));
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &AsmTrainingAreaDialog::onAddTrainingArea);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &AsmTrainingAreaDialog::onEditTrainingArea);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &AsmTrainingAreaDialog::onRemoveTrainingArea);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &AsmTrainingAreaDialog::onAddTrainingArea);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &AsmTrainingAreaDialog::onEditTrainingArea);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &AsmTrainingAreaDialog::onRemoveTrainingArea);
|
||||
|
||||
connect(m_ui->trainingAreaView, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &AsmTrainingAreaDialog::onSelectionChanged);
|
||||
enaDisa();
|
||||
connect(m_ui->trainingAreaView, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&AsmTrainingAreaDialog::onSelectionChanged);
|
||||
enaDisa();
|
||||
}
|
||||
|
||||
AsmTrainingAreaDialog::~AsmTrainingAreaDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Training Area Overview"));
|
||||
translate(m_ui, tr("Training Area Overview"));
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->trainingAreaView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->trainingAreaView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool AsmTrainingAreaDialog::init(LtsSession::LtsSessionDataDds *session, const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc)
|
||||
bool AsmTrainingAreaDialog::init(LtsSession::LtsSessionDataDds* session,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface>& sitMapGuiIfc)
|
||||
{
|
||||
m_session = session;
|
||||
m_session = session;
|
||||
|
||||
if (!m_session->getDtc<AssetManagement::DataInterface>(m_asmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable DTC from ASM";
|
||||
return false;
|
||||
}
|
||||
if(!m_session->getFtc<AssetManagement::DataInterface>(m_asmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable FTC from ASM";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getDtc<AssetManagement::DataInterface>(m_asmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable DTC from ASM";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getFtc<AssetManagement::DataInterface>(m_asmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable FTC from ASM";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
if(!m_sitMapGuiIfc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "m_sitMapGuiIfc is invalid ";
|
||||
return false;
|
||||
}
|
||||
bool bRet = true;
|
||||
bRet &= m_asmDtc->enableTrainingArea(true);
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
if (!m_sitMapGuiIfc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "m_sitMapGuiIfc is invalid ";
|
||||
return false;
|
||||
}
|
||||
bool bRet = true;
|
||||
bRet &= m_asmDtc->enableTrainingArea(true);
|
||||
|
||||
bRet &= m_asmFtc->enableTrainingAreaModify(true);
|
||||
bRet &= m_asmFtc->enableTrainingAreaRemove(true);
|
||||
bRet &= m_asmFtc->enableTrainingAreaModify(true);
|
||||
bRet &= m_asmFtc->enableTrainingAreaRemove(true);
|
||||
|
||||
if(!bRet)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable dtc or ftc from ASM";
|
||||
return false;
|
||||
}
|
||||
if (!bRet)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable dtc or ftc from ASM";
|
||||
return false;
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "Ftc && Dtc enabled from ASM";
|
||||
INFO_LOG(m_logger) << "Ftc && Dtc enabled from ASM";
|
||||
|
||||
delete m_model;
|
||||
m_model = new AsmTrainingAreaDialogModel(this);
|
||||
m_model->initModel(m_asmDtc, false);
|
||||
m_ui->trainingAreaView->setModel(m_model);
|
||||
connect(m_ui->trainingAreaView, &LtsDataView::LtsDataView::signalDoubleClicked, this, &AsmTrainingAreaDialog::onEditTrainingArea);
|
||||
delete m_model;
|
||||
m_model = new AsmTrainingAreaDialogModel(this);
|
||||
m_model->initModel(m_asmDtc, false);
|
||||
m_ui->trainingAreaView->setModel(m_model);
|
||||
connect(m_ui->trainingAreaView, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&AsmTrainingAreaDialog::onEditTrainingArea);
|
||||
|
||||
|
||||
showAllTrainingAreas();
|
||||
showAllTrainingAreas();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::enaDisa()
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
QModelIndexList indexList = m_ui->trainingAreaView->selectedRows();
|
||||
if (indexList.size() == 0)
|
||||
return;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, (indexList.size() == 1) );
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, (indexList.size() == 1) );
|
||||
QModelIndexList indexList = m_ui->trainingAreaView->selectedRows();
|
||||
if (indexList.size() == 0)
|
||||
return;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, (indexList.size() == 1));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, (indexList.size() == 1));
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::onAddTrainingArea()
|
||||
{
|
||||
const QString identifier = QStringLiteral("AsmAddTrainingArea");
|
||||
const QString identifier = QStringLiteral("AsmAddTrainingArea");
|
||||
|
||||
if(!focusDialog(m_menuGroup,identifier, LtsWidgets::LayoutArea::eDialogTab))
|
||||
{
|
||||
|
||||
AsmEditTrainingAreaDialog *dialog = new AsmEditTrainingAreaDialog(this);
|
||||
|
||||
if(!dialog->init(m_session,0,m_sitMapGuiIfc,m_menuGroup))
|
||||
if (!focusDialog(m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab))
|
||||
{
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
connect(this, &AsmTrainingAreaDialog::destroyed, dialog, &QObject::deleteLater);
|
||||
addDialog(dialog, m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " adding temp training Area ";
|
||||
AsmEditTrainingAreaDialog* dialog = new AsmEditTrainingAreaDialog(this);
|
||||
|
||||
if (!dialog->init(m_session, 0, m_sitMapGuiIfc, m_menuGroup))
|
||||
{
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
connect(this, &AsmTrainingAreaDialog::destroyed, dialog, &QObject::deleteLater);
|
||||
addDialog(dialog, m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " adding temp training Area ";
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::onRemoveTrainingArea()
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START" ;
|
||||
QModelIndexList indexList = m_ui->trainingAreaView->selectedRows();
|
||||
if (indexList.size() == 0)
|
||||
return;
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
QModelIndexList indexList = m_ui->trainingAreaView->selectedRows();
|
||||
if (indexList.size() == 0)
|
||||
return;
|
||||
|
||||
TrainingArea req = m_model->getRowData(indexList.front().row());
|
||||
if (req.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " invalid id:bt"<< req.id();
|
||||
return;
|
||||
}
|
||||
if (!m_viewedTaIds.contains(req.id()))
|
||||
{
|
||||
bool success = m_requestHelper->startSingleRequest([this, req]()
|
||||
TrainingArea req = m_model->getRowData(indexList.front().row());
|
||||
if (req.id() < 0)
|
||||
{
|
||||
return m_asmFtc->trainingAreaRemoveRequest(TrainingAreaRemoveRequest(req.id()), this);
|
||||
});
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " invalid id:bt" << req.id();
|
||||
return;
|
||||
}
|
||||
if (!m_viewedTaIds.contains(req.id()))
|
||||
{
|
||||
bool success = m_requestHelper->startSingleRequest(
|
||||
[this, req]() { return m_asmFtc->trainingAreaRemoveRequest(TrainingAreaRemoveRequest(req.id()), this); });
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " success = " << success;
|
||||
}
|
||||
else
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Warning"),
|
||||
tr("Cannot remove currently edited Training Area"));
|
||||
}
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " success = " << success;
|
||||
}
|
||||
else
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Warning"),
|
||||
tr("Cannot remove currently edited Training Area"));
|
||||
}
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::onEditTrainingArea()
|
||||
{
|
||||
QModelIndexList indexList = m_ui->trainingAreaView->selectedRows();
|
||||
if (indexList.size() == 0)
|
||||
return;
|
||||
TrainingArea taItem = m_model->getRowData(indexList.front().row());
|
||||
if (taItem.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "onEditTrainingArea invalid id = "<< taItem.id();
|
||||
return;
|
||||
}
|
||||
QModelIndexList indexList = m_ui->trainingAreaView->selectedRows();
|
||||
if (indexList.size() == 0)
|
||||
return;
|
||||
TrainingArea taItem = m_model->getRowData(indexList.front().row());
|
||||
if (taItem.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "onEditTrainingArea invalid id = " << taItem.id();
|
||||
return;
|
||||
}
|
||||
|
||||
const QString identifier = QStringLiteral("AsmEditTrainingArea_%1").arg(taItem.id());
|
||||
if(focusDialog(m_menuGroup,identifier, LtsWidgets::LayoutArea::eDialogTab))
|
||||
{
|
||||
return;
|
||||
}
|
||||
const QString identifier = QStringLiteral("AsmEditTrainingArea_%1").arg(taItem.id());
|
||||
if (focusDialog(m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AsmEditTrainingAreaDialog *dialog = new AsmEditTrainingAreaDialog(this);
|
||||
AsmEditTrainingAreaDialog* dialog = new AsmEditTrainingAreaDialog(this);
|
||||
|
||||
if(!dialog->init(m_session,taItem.id(),m_sitMapGuiIfc,m_menuGroup))
|
||||
{
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
if (!dialog->init(m_session, taItem.id(), m_sitMapGuiIfc, m_menuGroup))
|
||||
{
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
|
||||
connect(this, &AsmTrainingAreaDialog::destroyed, dialog, &QObject::deleteLater);
|
||||
|
||||
connect(dialog, &AsmEditTrainingAreaDialog::destroyed, this, [this](){
|
||||
clearSelection(); });
|
||||
addDialog(dialog, m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
connect(this, &AsmTrainingAreaDialog::destroyed, dialog, &QObject::deleteLater);
|
||||
|
||||
connect(dialog, &AsmEditTrainingAreaDialog::destroyed, this, [this]() { clearSelection(); });
|
||||
addDialog(dialog, m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::onSelectionChanged()
|
||||
{
|
||||
enaDisa();
|
||||
DEBUG_LOG(m_logger) << "onSelectionChanged() called !";
|
||||
const QModelIndex curIdx = m_ui->trainingAreaView->currentIndex();
|
||||
if (!curIdx.isValid())
|
||||
return;
|
||||
enaDisa();
|
||||
DEBUG_LOG(m_logger) << "onSelectionChanged() called !";
|
||||
const QModelIndex curIdx = m_ui->trainingAreaView->currentIndex();
|
||||
if (!curIdx.isValid())
|
||||
return;
|
||||
|
||||
AssetManagement::TrainingArea taItem = m_model->getRowData(curIdx.row());
|
||||
DEBUG_LOG(m_logger) << "onSelectionChanged() selected training area id: "<<taItem.id();
|
||||
if(taItem.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "onEditTrainingArea invalid id"<< taItem.id();
|
||||
return;
|
||||
}
|
||||
|
||||
m_previewPolygon = getTrainingArea(taItem.id());
|
||||
showPreviewObject();
|
||||
AssetManagement::TrainingArea taItem = m_model->getRowData(curIdx.row());
|
||||
DEBUG_LOG(m_logger) << "onSelectionChanged() selected training area id: " << taItem.id();
|
||||
if (taItem.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "onEditTrainingArea invalid id" << taItem.id();
|
||||
return;
|
||||
}
|
||||
|
||||
m_previewPolygon = getTrainingArea(taItem.id());
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::clearSelection()
|
||||
{
|
||||
m_ui->trainingAreaView->clearSelection();
|
||||
if(m_sitMapGuiIfc)
|
||||
{
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
m_ui->trainingAreaView->clearSelection();
|
||||
if (m_sitMapGuiIfc)
|
||||
{
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
}
|
||||
|
||||
QPolygonF AsmTrainingAreaDialog::getTrainingArea(int trainingAreaId)
|
||||
{
|
||||
if(!m_asmDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " m_asmDtc is not valid!";
|
||||
return {};
|
||||
}
|
||||
const AssetManagement::TrainingArea &ddsTrainingArea = m_asmDtc->trainingArea(trainingAreaId);
|
||||
if (ddsTrainingArea.id() != trainingAreaId)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " TrainingArea not found, trainingAreaId = " << trainingAreaId;
|
||||
return {};
|
||||
}
|
||||
if (!m_asmDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " m_asmDtc is not valid!";
|
||||
return {};
|
||||
}
|
||||
const AssetManagement::TrainingArea& ddsTrainingArea = m_asmDtc->trainingArea(trainingAreaId);
|
||||
if (ddsTrainingArea.id() != trainingAreaId)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " TrainingArea not found, trainingAreaId = " << trainingAreaId;
|
||||
return {};
|
||||
}
|
||||
|
||||
return getTrainingArea(ddsTrainingArea);
|
||||
return getTrainingArea(ddsTrainingArea);
|
||||
}
|
||||
|
||||
QPolygonF AsmTrainingAreaDialog::getTrainingArea(const TrainingArea &ddsTrainingArea)
|
||||
QPolygonF AsmTrainingAreaDialog::getTrainingArea(const TrainingArea& ddsTrainingArea)
|
||||
{
|
||||
QPolygonF polygonF;
|
||||
QPolygonF polygonF;
|
||||
|
||||
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(ddsTrainingArea.bottomLeft().lon(), ddsTrainingArea.bottomLeft().lat());
|
||||
polygonF.push_back(QPointF((ddsTrainingArea.bottomLeft().lon()),(ddsTrainingArea.bottomLeft().lat())));
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(
|
||||
ddsTrainingArea.bottomLeft().lon(), ddsTrainingArea.bottomLeft().lat());
|
||||
polygonF.push_back(QPointF((ddsTrainingArea.bottomLeft().lon()), (ddsTrainingArea.bottomLeft().lat())));
|
||||
|
||||
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width()));
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width()));
|
||||
|
||||
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width(), ddsTrainingArea.height()));
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width(), ddsTrainingArea.height()));
|
||||
|
||||
|
||||
polygonF.push_back(utmCoordinate.geographic(0, ddsTrainingArea.height()));
|
||||
polygonF.push_back(utmCoordinate.geographic(0, ddsTrainingArea.height()));
|
||||
|
||||
return polygonF;
|
||||
return polygonF;
|
||||
}
|
||||
|
||||
|
||||
void AsmTrainingAreaDialog::showAllTrainingAreas()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
QVector<QPolygonF> polyVec;
|
||||
const int rowCount = m_model->rowCount();
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
{
|
||||
const TrainingArea ¤tArea = m_model->getRowData(row);
|
||||
INFO_LOG(m_logger) << " row = " << row << " ; currentArea = " << currentArea;
|
||||
const QPolygonF &poly = getTrainingArea(currentArea);
|
||||
polyVec.append(poly);
|
||||
}
|
||||
if (!polyVec.isEmpty())
|
||||
m_sitMapGuiIfc->displayPreviewObjects(this, polyVec, true);
|
||||
QVector<QPolygonF> polyVec;
|
||||
const int rowCount = m_model->rowCount();
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
{
|
||||
const TrainingArea& currentArea = m_model->getRowData(row);
|
||||
INFO_LOG(m_logger) << " row = " << row << " ; currentArea = " << currentArea;
|
||||
const QPolygonF& poly = getTrainingArea(currentArea);
|
||||
polyVec.append(poly);
|
||||
}
|
||||
if (!polyVec.isEmpty())
|
||||
m_sitMapGuiIfc->displayPreviewObjects(this, polyVec, true);
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::showPreviewObject()
|
||||
{
|
||||
if (!this->m_sitMapGuiIfc || m_previewPolygon.size() == 0)
|
||||
{
|
||||
TRACE_LOG(m_logger) << " showPreviewObject(): m_sitMapGuiIfc invalid or polygon empty ";
|
||||
return;
|
||||
}
|
||||
this->m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, true);
|
||||
if (!this->m_sitMapGuiIfc || m_previewPolygon.size() == 0)
|
||||
{
|
||||
TRACE_LOG(m_logger) << " showPreviewObject(): m_sitMapGuiIfc invalid or polygon empty ";
|
||||
return;
|
||||
}
|
||||
this->m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, true);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AssetManagement
|
||||
Executable → Regular
+54
-47
@@ -1,74 +1,81 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include "asm_training_area_model.h"
|
||||
|
||||
#include <AssetManagement/asm_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <AssetManagement/logger.h>
|
||||
#include <AssetManagement/asm_dtc.h>
|
||||
#include <AssetManagement/asm_ftc.h>
|
||||
|
||||
#include "asm_training_area_model.h"
|
||||
#include <AssetManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AsmTrainingAreaDialog;
|
||||
}
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
class AsmTrainingAreaDialog : public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::TrainingAreaModifyReplyHandler
|
||||
, protected Interface::Ftc::TrainingAreaRemoveReplyHandler
|
||||
class AsmTrainingAreaDialog : public LtsWidgets::LtsDialog,
|
||||
protected Interface::Ftc::TrainingAreaModifyReplyHandler,
|
||||
protected Interface::Ftc::TrainingAreaRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AsmTrainingAreaDialog(const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~AsmTrainingAreaDialog();
|
||||
public:
|
||||
explicit AsmTrainingAreaDialog(const QString& menuGroup, QWidget* parent = nullptr);
|
||||
~AsmTrainingAreaDialog();
|
||||
|
||||
bool init(LtsSession::LtsSessionDataDds *session,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc);
|
||||
QPolygonF getTrainingArea(int trainingAreaId);
|
||||
QPolygonF getTrainingArea(const TrainingArea &ddsTrainingArea);
|
||||
void showAllTrainingAreas();
|
||||
void showPreviewObject();
|
||||
void clearSelection();
|
||||
bool init(LtsSession::LtsSessionDataDds* session,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface>& sitMapGuiIfc);
|
||||
QPolygonF getTrainingArea(int trainingAreaId);
|
||||
QPolygonF getTrainingArea(const TrainingArea& ddsTrainingArea);
|
||||
void showAllTrainingAreas();
|
||||
void showPreviewObject();
|
||||
void clearSelection();
|
||||
|
||||
private slots:
|
||||
void enaDisa();
|
||||
void onAddTrainingArea();
|
||||
void onEditTrainingArea();
|
||||
void onRemoveTrainingArea();
|
||||
void onSelectionChanged();
|
||||
private slots:
|
||||
void enaDisa();
|
||||
void onAddTrainingArea();
|
||||
void onEditTrainingArea();
|
||||
void onRemoveTrainingArea();
|
||||
void onSelectionChanged();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void onTrainingAreaModifyReply(const Core::FunctionReplyObject &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
void onTrainingAreaRemoveReply(const Core::FunctionReplyObject &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
void tableColumnOrganiserSetting() override;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
|
||||
Ui::AsmTrainingAreaDialog *m_ui;
|
||||
AsmTrainingAreaDialogModel *m_model{nullptr};
|
||||
LtsSession::LtsSessionDataDds *m_session;
|
||||
QString m_menuGroup;
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
|
||||
std::shared_ptr<AssetManagement::Interface::Ftc> m_asmFtc;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
QPolygonF m_previewPolygon;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
QSet<int> m_viewedTaIds{};
|
||||
void onTrainingAreaModifyReply(const Core::FunctionReplyObject& reply) override final
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
void onTrainingAreaRemoveReply(const Core::FunctionReplyObject& reply) override final
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
Ui::AsmTrainingAreaDialog* m_ui;
|
||||
AsmTrainingAreaDialogModel* m_model{nullptr};
|
||||
LtsSession::LtsSessionDataDds* m_session;
|
||||
QString m_menuGroup;
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
|
||||
std::shared_ptr<AssetManagement::Interface::Ftc> m_asmFtc;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
QPolygonF m_previewPolygon;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
QSet<int> m_viewedTaIds{};
|
||||
};
|
||||
}
|
||||
} // namespace AssetManagement
|
||||
Executable → Regular
+48
-59
@@ -1,75 +1,64 @@
|
||||
#include "asm_training_area_model.h"
|
||||
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
AsmTrainingAreaDialogModel::AsmTrainingAreaDialogModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AssetManagement::TrainingArea>({tr("Id"),
|
||||
tr("Name"),
|
||||
tr("Botton Left x"),
|
||||
tr("Bottom Left y"),
|
||||
tr("Height"),
|
||||
tr("Width")},
|
||||
|
||||
parent)
|
||||
,m_asmDtc(nullptr)
|
||||
{}
|
||||
AsmTrainingAreaDialogModel::AsmTrainingAreaDialogModel(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AssetManagement::TrainingArea>(
|
||||
{tr("Id"), tr("Name"), tr("Botton Left x"), tr("Bottom Left y"), tr("Height"), tr("Width")},
|
||||
|
||||
AsmTrainingAreaDialogModel::~AsmTrainingAreaDialogModel()
|
||||
{}
|
||||
|
||||
bool AsmTrainingAreaDialogModel::initModel(const std::shared_ptr<Interface::Dtc> &dtc, bool hideRemoved)
|
||||
parent),
|
||||
m_asmDtc(nullptr)
|
||||
{
|
||||
m_asmDtc = dtc;
|
||||
m_hideRemoved = hideRemoved;
|
||||
|
||||
if (m_asmDtc)
|
||||
{
|
||||
connect(m_asmDtc.get(), &Interface::Dtc::trainingAreaChanged, this, &AsmTrainingAreaDialogModel::onDataChanged);
|
||||
|
||||
m_asmDtc->trainingAreas([this](const AssetManagement::TrainingArea &data)
|
||||
{
|
||||
onDataChanged(data, DataModification::eAdded);
|
||||
});
|
||||
|
||||
} else {
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " no m_asmDtc";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant AsmTrainingAreaDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
AsmTrainingAreaDialogModel::~AsmTrainingAreaDialogModel() {}
|
||||
|
||||
const AssetManagement::TrainingArea &asmTrainingArea = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
bool AsmTrainingAreaDialogModel::initModel(const std::shared_ptr<Interface::Dtc>& dtc, bool hideRemoved)
|
||||
{
|
||||
m_asmDtc = dtc;
|
||||
m_hideRemoved = hideRemoved;
|
||||
|
||||
if (m_asmDtc)
|
||||
{
|
||||
case Id:
|
||||
return asmTrainingArea.id();
|
||||
case Name:
|
||||
return QString::fromStdString(asmTrainingArea.name());
|
||||
case BottomLeft_x:
|
||||
return asmTrainingArea.bottomLeft().lon();
|
||||
case BottomLeft_y:
|
||||
return asmTrainingArea.bottomLeft().lat();
|
||||
case Height:
|
||||
return asmTrainingArea.height();
|
||||
case Width:
|
||||
return asmTrainingArea.width();
|
||||
|
||||
|
||||
connect(m_asmDtc.get(), &Interface::Dtc::trainingAreaChanged, this, &AsmTrainingAreaDialogModel::onDataChanged);
|
||||
|
||||
m_asmDtc->trainingAreas(
|
||||
[this](const AssetManagement::TrainingArea& data) { onDataChanged(data, DataModification::eAdded); });
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
else
|
||||
{
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " no m_asmDtc";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant AsmTrainingAreaDialogModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
|
||||
|
||||
const AssetManagement::TrainingArea& asmTrainingArea = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return asmTrainingArea.id();
|
||||
case Name:
|
||||
return QString::fromStdString(asmTrainingArea.name());
|
||||
case BottomLeft_x:
|
||||
return asmTrainingArea.bottomLeft().lon();
|
||||
case BottomLeft_y:
|
||||
return asmTrainingArea.bottomLeft().lat();
|
||||
case Height:
|
||||
return asmTrainingArea.height();
|
||||
case Width:
|
||||
return asmTrainingArea.width();
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
} // namespace AssetManagement
|
||||
Executable → Regular
+22
-31
@@ -1,47 +1,38 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <AssetManagement/asm_dtc.h>
|
||||
#include <AssetManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
class AsmTrainingAreaDialogModel
|
||||
: public LtsWidgets::LtsAbstractTableModel<AssetManagement::TrainingArea>
|
||||
class AsmTrainingAreaDialogModel : public LtsWidgets::LtsAbstractTableModel<AssetManagement::TrainingArea>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
Name,
|
||||
BottomLeft_x,
|
||||
BottomLeft_y,
|
||||
Height,
|
||||
Width,
|
||||
Image,
|
||||
};
|
||||
public:
|
||||
enum Columns {
|
||||
Id,
|
||||
Name,
|
||||
BottomLeft_x,
|
||||
BottomLeft_y,
|
||||
Height,
|
||||
Width,
|
||||
Image,
|
||||
};
|
||||
|
||||
explicit AsmTrainingAreaDialogModel(QObject *parent = nullptr);
|
||||
~AsmTrainingAreaDialogModel();
|
||||
bool initModel(const std::shared_ptr<AssetManagement::Interface::Dtc> &asmDtc, bool hideRemoved);
|
||||
explicit AsmTrainingAreaDialogModel(QObject* parent = nullptr);
|
||||
~AsmTrainingAreaDialogModel();
|
||||
bool initModel(const std::shared_ptr<AssetManagement::Interface::Dtc>& asmDtc, bool hideRemoved);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override final;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override final;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool m_hideRemoved;
|
||||
std::shared_ptr<Interface::Dtc> m_asmDtc;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool m_hideRemoved;
|
||||
std::shared_ptr<Interface::Dtc> m_asmDtc;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace AssetManagement
|
||||
Executable → Regular
+174
-195
@@ -1,71 +1,60 @@
|
||||
|
||||
|
||||
|
||||
#include "audio_settings_avail_streams_model.h"
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
#include <QFont>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
QDataStream &operator<<(QDataStream &ds, const StreamData &sd)
|
||||
QDataStream& operator<<(QDataStream& ds, const StreamData& sd)
|
||||
{
|
||||
ds << sd.topicId << sd.name << sd.bIsCnr;
|
||||
return ds;
|
||||
}
|
||||
QDataStream &operator>>(QDataStream &ds, StreamData &sd)
|
||||
{
|
||||
ds >> sd.topicId >> sd.name >> sd.bIsCnr ;
|
||||
return ds;
|
||||
ds << sd.topicId << sd.name << sd.bIsCnr;
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AvailStreamsModel::AvailStreamsModel(Interface::Dtc *avmDtc,
|
||||
int32_t exerciseId,
|
||||
QObject *parent)
|
||||
: NGLTreeModel(parent, new NGLTreeItem(QVariant()), {tr("Available")})
|
||||
, m_exerciseId(exerciseId)
|
||||
, m_avmDtc(avmDtc)
|
||||
, m_cnrRoot(new NGLTreeItem(QVariant()))
|
||||
, m_tvcRoot(new NGLTreeItem(QVariant()))
|
||||
, m_changes(false)
|
||||
QDataStream& operator>>(QDataStream& ds, StreamData& sd)
|
||||
{
|
||||
Q_ASSERT(avmDtc);
|
||||
|
||||
qRegisterMetaTypeStreamOperators<StreamData>();
|
||||
|
||||
setMimeType(StreamData::mimeType());
|
||||
|
||||
StreamData data;
|
||||
data.name = tr("CNR");
|
||||
data.bIsCnr = true;
|
||||
m_cnrRoot->setData(QVariant::fromValue(data));
|
||||
m_rootItem->appendChild(m_cnrRoot);
|
||||
|
||||
data.name = tr("TVC");
|
||||
data.bIsCnr = false;
|
||||
m_tvcRoot->setData(QVariant::fromValue(data));
|
||||
m_rootItem->appendChild(m_tvcRoot);
|
||||
ds >> sd.topicId >> sd.name >> sd.bIsCnr;
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AvailStreamsModel::setStreamChanged(const QVector<StreamData> &streams)
|
||||
AvailStreamsModel::AvailStreamsModel(Interface::Dtc* avmDtc, int32_t exerciseId, QObject* parent)
|
||||
: NGLTreeModel(parent, new NGLTreeItem(QVariant()), {tr("Available")}), m_exerciseId(exerciseId), m_avmDtc(avmDtc),
|
||||
m_cnrRoot(new NGLTreeItem(QVariant())), m_tvcRoot(new NGLTreeItem(QVariant())), m_changes(false)
|
||||
{
|
||||
for (const StreamData &d : streams)
|
||||
if (!m_changedStreams.contains(QPair<bool,int>(d.bIsCnr, d.topicId)))
|
||||
m_changedStreams += QPair<bool,int>(d.bIsCnr, d.topicId);
|
||||
emit modelDataChanged();
|
||||
Q_ASSERT(avmDtc);
|
||||
|
||||
qRegisterMetaTypeStreamOperators<StreamData>();
|
||||
|
||||
setMimeType(StreamData::mimeType());
|
||||
|
||||
StreamData data;
|
||||
data.name = tr("CNR");
|
||||
data.bIsCnr = true;
|
||||
m_cnrRoot->setData(QVariant::fromValue(data));
|
||||
m_rootItem->appendChild(m_cnrRoot);
|
||||
|
||||
data.name = tr("TVC");
|
||||
data.bIsCnr = false;
|
||||
m_tvcRoot->setData(QVariant::fromValue(data));
|
||||
m_rootItem->appendChild(m_tvcRoot);
|
||||
}
|
||||
|
||||
void AvailStreamsModel::setStreamChanged(const QVector<StreamData>& streams)
|
||||
{
|
||||
for (const StreamData& d : streams)
|
||||
if (!m_changedStreams.contains(QPair<bool, int>(d.bIsCnr, d.topicId)))
|
||||
m_changedStreams += QPair<bool, int>(d.bIsCnr, d.topicId);
|
||||
emit modelDataChanged();
|
||||
}
|
||||
|
||||
bool AvailStreamsModel::initModel()
|
||||
{
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::cnrConfigChanged,
|
||||
this, &AvailStreamsModel::onCnrConfigChanged, Qt::UniqueConnection);
|
||||
m_avmDtc->cnrConfigs([this](const AudioVideoManagement::CnrConfig & ch) { onCnrConfigChanged(ch, DataModification::eAdded); });
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::cnrConfigChanged, this,
|
||||
&AvailStreamsModel::onCnrConfigChanged, Qt::UniqueConnection);
|
||||
m_avmDtc->cnrConfigs(
|
||||
[this](const AudioVideoManagement::CnrConfig& ch) { onCnrConfigChanged(ch, DataModification::eAdded); });
|
||||
|
||||
#if 0
|
||||
AudioVideoManagement::CnrConfig data;
|
||||
@@ -85,200 +74,190 @@ bool AvailStreamsModel::initModel()
|
||||
onTvcConfigChanged(data2, DataModification::eAdded);
|
||||
#endif
|
||||
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::tvcConfigChanged,
|
||||
this, &AvailStreamsModel::onTvcConfigChanged, Qt::UniqueConnection);
|
||||
m_avmDtc->tvcConfigs([this](const AudioVideoManagement::TvcConfig & ch) { onTvcConfigChanged(ch, DataModification::eAdded); });
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::tvcConfigChanged, this,
|
||||
&AvailStreamsModel::onTvcConfigChanged, Qt::UniqueConnection);
|
||||
m_avmDtc->tvcConfigs(
|
||||
[this](const AudioVideoManagement::TvcConfig& ch) { onTvcConfigChanged(ch, DataModification::eAdded); });
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
Qt::ItemFlags AvailStreamsModel::flags(const QModelIndex &index) const
|
||||
Qt::ItemFlags AvailStreamsModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
Qt::ItemFlags f = NGLTreeModel::flags(index) | Qt::ItemIsDropEnabled;
|
||||
if (!index.parent().isValid())
|
||||
f &= ~Qt::ItemIsDragEnabled;
|
||||
Qt::ItemFlags f = NGLTreeModel::flags(index) | Qt::ItemIsDropEnabled;
|
||||
if (!index.parent().isValid())
|
||||
f &= ~Qt::ItemIsDragEnabled;
|
||||
|
||||
return f;
|
||||
return f;
|
||||
}
|
||||
|
||||
QVariant AvailStreamsModel::data(const QModelIndex &index, int role) const
|
||||
QVariant AvailStreamsModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
switch (role)
|
||||
{
|
||||
NGLTreeItem *item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
DEBUG_LOG(m_logger) << data.name;
|
||||
return data.name;
|
||||
case Qt::DisplayRole: {
|
||||
NGLTreeItem* item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
DEBUG_LOG(m_logger) << data.name;
|
||||
return data.name;
|
||||
}
|
||||
|
||||
case Qt::FontRole: {
|
||||
NGLTreeItem* item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
if (!m_changedStreams.contains(QPair<bool, int>(data.bIsCnr, data.topicId)))
|
||||
return {};
|
||||
QFont f;
|
||||
f.setBold(true);
|
||||
return f;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case Qt::FontRole:
|
||||
{
|
||||
NGLTreeItem *item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
if (!m_changedStreams.contains(QPair<bool,int>(data.bIsCnr, data.topicId)))
|
||||
return {};
|
||||
QFont f;
|
||||
f.setBold(true);
|
||||
return f;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NGLTreeModel::data(index, role);
|
||||
return NGLTreeModel::data(index, role);
|
||||
}
|
||||
|
||||
bool AvailStreamsModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
|
||||
bool AvailStreamsModel::canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(data);
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
if (action != supportedDropActions())
|
||||
return false;
|
||||
return true;
|
||||
Q_UNUSED(data);
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
if (action != supportedDropActions())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AvailStreamsModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent)
|
||||
bool AvailStreamsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
Q_UNUSED(action);
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
|
||||
const QVector<NGLTreeItem *> droppedItems = getMimeDataItems(data, m_mimeType);
|
||||
QVector<StreamData> streams;
|
||||
streams.reserve(droppedItems.size());
|
||||
for (const NGLTreeItem *item : droppedItems)
|
||||
streams += item->data().value<StreamData>();
|
||||
qDeleteAll(droppedItems);
|
||||
emit droppedStreamNames(streams);
|
||||
m_changes = true;
|
||||
return true;
|
||||
const QVector<NGLTreeItem*> droppedItems = getMimeDataItems(data, m_mimeType);
|
||||
QVector<StreamData> streams;
|
||||
streams.reserve(droppedItems.size());
|
||||
for (const NGLTreeItem* item : droppedItems)
|
||||
streams += item->data().value<StreamData>();
|
||||
qDeleteAll(droppedItems);
|
||||
emit droppedStreamNames(streams);
|
||||
m_changes = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void AvailStreamsModel::onCnrConfigChanged(const AudioVideoManagement::CnrConfig &data, DataModification modType)
|
||||
void AvailStreamsModel::onCnrConfigChanged(const AudioVideoManagement::CnrConfig& data, DataModification modType)
|
||||
{
|
||||
insertUpdateData(data, modType, m_cnrRoot);
|
||||
insertUpdateData(data, modType, m_cnrRoot);
|
||||
}
|
||||
|
||||
void AvailStreamsModel::onTvcConfigChanged(const AudioVideoManagement::TvcConfig &data, DataModification modType)
|
||||
void AvailStreamsModel::onTvcConfigChanged(const AudioVideoManagement::TvcConfig& data, DataModification modType)
|
||||
{
|
||||
insertUpdateData(data, modType, m_tvcRoot);
|
||||
insertUpdateData(data, modType, m_tvcRoot);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void AvailStreamsModel::insertUpdateData(const T &config, DataModification modType, NGLTreeItem *parent)
|
||||
void AvailStreamsModel::insertUpdateData(const T& config, DataModification modType, NGLTreeItem* parent)
|
||||
{
|
||||
DataModification action = modType;
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
|
||||
|
||||
if (config.exerciseId().is_set() && config.exerciseId().get() != m_exerciseId)
|
||||
action = DataModification::eRemoved;
|
||||
}
|
||||
|
||||
StreamData newData(config);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
if (config.exerciseId().is_set() && config.exerciseId().get() != m_exerciseId)
|
||||
break;
|
||||
Q_FALLTHROUGH();
|
||||
case DataModification::eModified:
|
||||
{
|
||||
bool bFound = false;
|
||||
for (int i = 0; i < parent->childCount(); ++i)
|
||||
DataModification action = modType;
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
NGLTreeItem *child = parent->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
if (data == newData)
|
||||
{
|
||||
bFound = true;
|
||||
setItemData(indexFromItem(child), QVariant::fromValue(newData), child->icon());
|
||||
emit updateEntry(newData);
|
||||
break;
|
||||
}
|
||||
|
||||
if (config.exerciseId().is_set() && config.exerciseId().get() != m_exerciseId)
|
||||
action = DataModification::eRemoved;
|
||||
}
|
||||
if (!bFound)
|
||||
|
||||
StreamData newData(config);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
NGLTreeItem *child = new NGLTreeItem(QVariant::fromValue(newData));
|
||||
insertRow(parent->childCount(), indexFromItem(parent), child);
|
||||
case DataModification::eAdded:
|
||||
if (config.exerciseId().is_set() && config.exerciseId().get() != m_exerciseId)
|
||||
break;
|
||||
Q_FALLTHROUGH();
|
||||
case DataModification::eModified: {
|
||||
bool bFound = false;
|
||||
for (int i = 0; i < parent->childCount(); ++i)
|
||||
{
|
||||
NGLTreeItem* child = parent->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
if (data == newData)
|
||||
{
|
||||
bFound = true;
|
||||
setItemData(indexFromItem(child), QVariant::fromValue(newData), child->icon());
|
||||
emit updateEntry(newData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bFound)
|
||||
{
|
||||
NGLTreeItem* child = new NGLTreeItem(QVariant::fromValue(newData));
|
||||
insertRow(parent->childCount(), indexFromItem(parent), child);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved: {
|
||||
for (int i = 0; i < parent->childCount(); ++i)
|
||||
{
|
||||
NGLTreeItem* child = parent->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
if (data == newData)
|
||||
{
|
||||
removeRows(i, 1, indexFromItem(parent));
|
||||
emit removeEntry(newData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
for (int i = 0; i < parent->childCount(); ++i)
|
||||
{
|
||||
NGLTreeItem *child = parent->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
if (data == newData)
|
||||
{
|
||||
removeRows(i, 1, indexFromItem(parent));
|
||||
emit removeEntry(newData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AvailStreamsFilter::AvailStreamsFilter(AvailStreamsModel *sourceModel, QObject *parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
, m_sourceModel(sourceModel)
|
||||
AvailStreamsFilter::AvailStreamsFilter(AvailStreamsModel* sourceModel, QObject* parent)
|
||||
: QSortFilterProxyModel(parent), m_sourceModel(sourceModel)
|
||||
{
|
||||
Q_ASSERT(sourceModel);
|
||||
setSourceModel(m_sourceModel);
|
||||
Q_ASSERT(sourceModel);
|
||||
setSourceModel(m_sourceModel);
|
||||
}
|
||||
|
||||
void AvailStreamsFilter::addAllocatedStreams(const QVector<StreamData> &streams)
|
||||
void AvailStreamsFilter::addAllocatedStreams(const QVector<StreamData>& streams)
|
||||
{
|
||||
m_allocatedStreams.insert(streams.begin(), streams.end());
|
||||
invalidateFilter();
|
||||
m_allocatedStreams.insert(streams.begin(), streams.end());
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void AvailStreamsFilter::setAllocatedStreams(const QVector<StreamData> &streams)
|
||||
void AvailStreamsFilter::setAllocatedStreams(const QVector<StreamData>& streams)
|
||||
{
|
||||
m_allocatedStreams.clear();
|
||||
m_allocatedStreams.insert(streams.begin(), streams.end());
|
||||
invalidateFilter();
|
||||
m_allocatedStreams.clear();
|
||||
m_allocatedStreams.insert(streams.begin(), streams.end());
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void AvailStreamsFilter::removeAllocatedStreams(const QVector<StreamData> &streams)
|
||||
void AvailStreamsFilter::removeAllocatedStreams(const QVector<StreamData>& streams)
|
||||
{
|
||||
for (const StreamData &stream : streams)
|
||||
m_allocatedStreams.erase(stream);
|
||||
invalidateFilter();
|
||||
for (const StreamData& stream : streams)
|
||||
m_allocatedStreams.erase(stream);
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
bool AvailStreamsFilter::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
bool AvailStreamsFilter::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||
{
|
||||
if (!m_sourceModel || !source_parent.isValid())
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
if (!m_sourceModel || !source_parent.isValid())
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
NGLTreeItem *parent = m_sourceModel->privateData(source_parent);
|
||||
if (!parent)
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
NGLTreeItem *child = parent->child(source_row);
|
||||
if (!child)
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
NGLTreeItem* parent = m_sourceModel->privateData(source_parent);
|
||||
if (!parent)
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
NGLTreeItem* child = parent->child(source_row);
|
||||
if (!child)
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
return m_allocatedStreams.count(data) == 0;
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
return m_allocatedStreams.count(data) == 0;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+66
-50
@@ -1,13 +1,13 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
#include "audio_stream_type.h"
|
||||
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QVector>
|
||||
#include "audio_stream_type.h"
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
|
||||
@@ -15,68 +15,84 @@ namespace AudioVideoManagement
|
||||
{
|
||||
class AvailStreamsModel final : public NGLTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AvailStreamsModel(AudioVideoManagement::Interface::Dtc *avmDtc, int32_t exerciseId,
|
||||
QObject *parent = nullptr);
|
||||
~AvailStreamsModel() = default;
|
||||
bool getChangeState() {bool result = m_changes; m_changes = false; return result;}
|
||||
void resetChangeState() {m_changes = false;m_changedStreams.clear();}
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AvailStreamsModel(AudioVideoManagement::Interface::Dtc* avmDtc, int32_t exerciseId,
|
||||
QObject* parent = nullptr);
|
||||
~AvailStreamsModel() = default;
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
bool getChangeState()
|
||||
{
|
||||
bool result = m_changes;
|
||||
m_changes = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Qt::DropActions supportedDropActions() const override { return Qt::MoveAction; }
|
||||
Qt::DropActions supportedDragActions() const override { return Qt::CopyAction; }
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction, int, int, const QModelIndex &) override;
|
||||
void setStreamChanged(const QVector<StreamData> &streams);
|
||||
void resetChangeState()
|
||||
{
|
||||
m_changes = false;
|
||||
m_changedStreams.clear();
|
||||
}
|
||||
|
||||
bool initModel();
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
|
||||
signals:
|
||||
void droppedStreamNames(const QVector<AudioVideoManagement::StreamData> &streamNamesDropped);
|
||||
void updateEntry(const AudioVideoManagement::StreamData &stream);
|
||||
void removeEntry(const AudioVideoManagement::StreamData &stream);
|
||||
Qt::DropActions supportedDropActions() const override
|
||||
{
|
||||
return Qt::MoveAction;
|
||||
}
|
||||
|
||||
private slots:
|
||||
void onCnrConfigChanged(const AudioVideoManagement::CnrConfig &data, DataModification modType);
|
||||
void onTvcConfigChanged(const AudioVideoManagement::TvcConfig &data, DataModification modType);
|
||||
Qt::DropActions supportedDragActions() const override
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
}
|
||||
|
||||
private:
|
||||
bool canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction, int, int, const QModelIndex&) override;
|
||||
void setStreamChanged(const QVector<StreamData>& streams);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
template <typename T>
|
||||
void insertUpdateData(const T &data, DataModification modType, NGLTreeItem *parent);
|
||||
bool initModel();
|
||||
|
||||
int32_t m_exerciseId;
|
||||
AudioVideoManagement::Interface::Dtc *m_avmDtc;
|
||||
NGLTreeItem *m_cnrRoot;
|
||||
NGLTreeItem *m_tvcRoot;
|
||||
bool m_changes;
|
||||
QVector<QPair<bool , int> > m_changedStreams;
|
||||
signals:
|
||||
void droppedStreamNames(const QVector<AudioVideoManagement::StreamData>& streamNamesDropped);
|
||||
void updateEntry(const AudioVideoManagement::StreamData& stream);
|
||||
void removeEntry(const AudioVideoManagement::StreamData& stream);
|
||||
|
||||
private slots:
|
||||
void onCnrConfigChanged(const AudioVideoManagement::CnrConfig& data, DataModification modType);
|
||||
void onTvcConfigChanged(const AudioVideoManagement::TvcConfig& data, DataModification modType);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
template <typename T> void insertUpdateData(const T& data, DataModification modType, NGLTreeItem* parent);
|
||||
|
||||
int32_t m_exerciseId;
|
||||
AudioVideoManagement::Interface::Dtc* m_avmDtc;
|
||||
NGLTreeItem* m_cnrRoot;
|
||||
NGLTreeItem* m_tvcRoot;
|
||||
bool m_changes;
|
||||
QVector<QPair<bool, int>> m_changedStreams;
|
||||
};
|
||||
|
||||
class AvailStreamsFilter final : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AvailStreamsFilter(AvailStreamsModel *sourceModel, QObject *parent);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AvailStreamsFilter(AvailStreamsModel* sourceModel, QObject* parent);
|
||||
|
||||
void addAllocatedStreams(const QVector<StreamData> &streams);
|
||||
void setAllocatedStreams(const QVector<StreamData> &streams);
|
||||
void removeAllocatedStreams(const QVector<StreamData> &streams);
|
||||
void addAllocatedStreams(const QVector<StreamData>& streams);
|
||||
void setAllocatedStreams(const QVector<StreamData>& streams);
|
||||
void removeAllocatedStreams(const QVector<StreamData>& streams);
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
|
||||
|
||||
private:
|
||||
|
||||
using QSortFilterProxyModel::setSourceModel;
|
||||
private:
|
||||
using QSortFilterProxyModel::setSourceModel;
|
||||
|
||||
AvailStreamsModel *m_sourceModel;
|
||||
std::set<StreamData> m_allocatedStreams;
|
||||
AvailStreamsModel* m_sourceModel;
|
||||
std::set<StreamData> m_allocatedStreams;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+292
-322
@@ -1,434 +1,404 @@
|
||||
|
||||
|
||||
|
||||
#include "audio_settings_dialog.h"
|
||||
#include <utility>
|
||||
#include "ui_audio_settings_dialog.h"
|
||||
|
||||
#include "audio_settings_avail_streams_model.h"
|
||||
#include "audio_settings_used_streams_model.h"
|
||||
#include "audio_stream_type.h"
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include "ui_audio_settings_dialog.h"
|
||||
|
||||
#include <AudioVideoManagement/avm_ftc_types.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <utility>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
AudioSettingsDialog::AudioSettingsDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::AudioSettingsDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
AudioSettingsDialog::AudioSettingsDialog(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_ui(new Ui::AudioSettingsDialog),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
m_ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Voice_Communication_Access"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Voice_Communication_Access"));
|
||||
}
|
||||
|
||||
AudioSettingsDialog::~AudioSettingsDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool AudioSettingsDialog::init(OperatorManagement::Interface::Dtc *opmDtc,
|
||||
Interface::Dtc *avmDtc,
|
||||
Interface::Ftc *avmFtc,
|
||||
LtsSession::LtsSessionDataDds *session)
|
||||
bool AudioSettingsDialog::init(OperatorManagement::Interface::Dtc* opmDtc, Interface::Dtc* avmDtc,
|
||||
Interface::Ftc* avmFtc, LtsSession::LtsSessionDataDds* session)
|
||||
{
|
||||
Q_ASSERT(opmDtc);
|
||||
Q_ASSERT(avmDtc);
|
||||
Q_ASSERT(avmFtc);
|
||||
Q_ASSERT(session);
|
||||
Q_ASSERT(opmDtc);
|
||||
Q_ASSERT(avmDtc);
|
||||
Q_ASSERT(avmFtc);
|
||||
Q_ASSERT(session);
|
||||
|
||||
setUnchangeable(true);
|
||||
setUnchangeable(true);
|
||||
|
||||
m_session = session;
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
|
||||
|
||||
m_session = session;
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
|
||||
m_modelAvailable = new AvailStreamsModel(avmDtc, m_session->exerciseId(), this);
|
||||
if (!m_modelAvailable->initModel())
|
||||
return false;
|
||||
m_modelAvailable = new AvailStreamsModel(avmDtc, m_session->exerciseId(), this);
|
||||
if (!m_modelAvailable->initModel())
|
||||
return false;
|
||||
|
||||
m_filterAvailable = new AvailStreamsFilter(m_modelAvailable, this);
|
||||
m_modelAllocated = new AllocatedStreamsModel(this);
|
||||
m_filterAvailable = new AvailStreamsFilter(m_modelAvailable, this);
|
||||
m_modelAllocated = new AllocatedStreamsModel(this);
|
||||
|
||||
connect(m_modelAvailable, &AvailStreamsModel::droppedStreamNames, this, &AudioSettingsDialog::onDroppedInAvailable);
|
||||
connect(m_modelAllocated, &AllocatedStreamsModel::droppedStreamNames, this, &AudioSettingsDialog::onDroppedInAllocated);
|
||||
connect(m_modelAvailable, &AvailStreamsModel::droppedStreamNames, this, &AudioSettingsDialog::onDroppedInAvailable);
|
||||
connect(m_modelAllocated, &AllocatedStreamsModel::droppedStreamNames, this,
|
||||
&AudioSettingsDialog::onDroppedInAllocated);
|
||||
|
||||
connect(m_modelAvailable, &AvailStreamsModel::updateEntry, m_modelAllocated, &AllocatedStreamsModel::updateEntry);
|
||||
connect(m_modelAvailable, &AvailStreamsModel::removeEntry, this, &AudioSettingsDialog::onEntryRemoved);
|
||||
connect(m_modelAvailable, &AvailStreamsModel::updateEntry, m_modelAllocated, &AllocatedStreamsModel::updateEntry);
|
||||
connect(m_modelAvailable, &AvailStreamsModel::removeEntry, this, &AudioSettingsDialog::onEntryRemoved);
|
||||
|
||||
|
||||
m_ui->treeViewAvailable->setModel(m_filterAvailable);
|
||||
m_ui->treeViewAvailable->expandAll();
|
||||
m_ui->treeViewAllocated->setModel(m_modelAllocated);
|
||||
m_ui->treeViewAvailable->setModel(m_filterAvailable);
|
||||
m_ui->treeViewAvailable->expandAll();
|
||||
m_ui->treeViewAllocated->setModel(m_modelAllocated);
|
||||
|
||||
|
||||
connect(opmDtc, &OperatorManagement::Interface::Dtc::userChanged,
|
||||
this, &AudioSettingsDialog::onOperatorChanged);
|
||||
auto cbOperator = [this](const OperatorManagement::User & u)
|
||||
{
|
||||
onOperatorChanged(u, DataModification::eAdded);
|
||||
};
|
||||
opmDtc->users(cbOperator);
|
||||
connect(opmDtc, &OperatorManagement::Interface::Dtc::userChanged, this, &AudioSettingsDialog::onOperatorChanged);
|
||||
auto cbOperator = [this](const OperatorManagement::User& u) { onOperatorChanged(u, DataModification::eAdded); };
|
||||
opmDtc->users(cbOperator);
|
||||
|
||||
fillOperatorBox();
|
||||
fillOperatorBox();
|
||||
|
||||
connect(m_avmDtc, &Interface::Dtc::cnrTvcProfileChanged,
|
||||
this, &AudioSettingsDialog::onCnrTvcProfileChanged);
|
||||
auto cbRadioCircuits = [this](const CnrTvcProfile & rc)
|
||||
{
|
||||
onCnrTvcProfileChanged(rc, DataModification::eAdded);
|
||||
};
|
||||
m_avmDtc->cnrTvcProfiles(cbRadioCircuits);
|
||||
connect(m_avmDtc, &Interface::Dtc::cnrTvcProfileChanged, this, &AudioSettingsDialog::onCnrTvcProfileChanged);
|
||||
auto cbRadioCircuits = [this](const CnrTvcProfile& rc) { onCnrTvcProfileChanged(rc, DataModification::eAdded); };
|
||||
m_avmDtc->cnrTvcProfiles(cbRadioCircuits);
|
||||
|
||||
connect(m_ui->pushButtonUp, &QPushButton::clicked, this, &AudioSettingsDialog::onUpButtonClicked);
|
||||
connect(m_ui->pushButtonDown, &QPushButton::clicked, this, &AudioSettingsDialog::onDownButtonClicked);
|
||||
connect(m_ui->operatorComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &AudioSettingsDialog::onSelectionOperatorChanged);
|
||||
connect(m_ui->treeViewAllocated->selectionModel(), &QItemSelectionModel::selectionChanged, this, &AudioSettingsDialog::onSelectionChangedAllocation);
|
||||
|
||||
connect(m_ui->pushButtonUp, &QPushButton::clicked, this, &AudioSettingsDialog::onUpButtonClicked);
|
||||
connect(m_ui->pushButtonDown, &QPushButton::clicked, this, &AudioSettingsDialog::onDownButtonClicked);
|
||||
connect(m_ui->operatorComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
&AudioSettingsDialog::onSelectionOperatorChanged);
|
||||
connect(m_ui->treeViewAllocated->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&AudioSettingsDialog::onSelectionChangedAllocation);
|
||||
|
||||
m_ui->treeViewAllocated->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
m_ui->treeViewAvailable->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
m_ui->treeViewAllocated->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
m_ui->treeViewAvailable->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
|
||||
m_ui->treeViewAllocated->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_ui->treeViewAvailable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_ui->treeViewAllocated->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_ui->treeViewAvailable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
|
||||
|
||||
|
||||
m_ui->pushButtonUp->setEnabled(false);
|
||||
m_ui->pushButtonDown->setEnabled(false);
|
||||
|
||||
m_ui->pushButtonUp->setEnabled(false);
|
||||
m_ui->pushButtonDown->setEnabled(false);
|
||||
m_avmFtc->enableAll();
|
||||
|
||||
m_avmFtc->enableAll();
|
||||
|
||||
int opId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
if (m_ui->operatorComboBox->currentIndex() != m_ui->operatorComboBox->findData(opId))
|
||||
m_ui->operatorComboBox->setCurrentIndex(m_ui->operatorComboBox->findData(opId));
|
||||
else
|
||||
onSelectionOperatorChanged(0);
|
||||
setUnchangeable(false);
|
||||
return true;
|
||||
}
|
||||
int opId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
if (m_ui->operatorComboBox->currentIndex() != m_ui->operatorComboBox->findData(opId))
|
||||
m_ui->operatorComboBox->setCurrentIndex(m_ui->operatorComboBox->findData(opId));
|
||||
else
|
||||
onSelectionOperatorChanged(0);
|
||||
setUnchangeable(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Voice Communication Access"));
|
||||
}
|
||||
translate(m_ui, tr("Voice Communication Access"));
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onOperatorChanged(const OperatorManagement::User &data, DataModification modType)
|
||||
void AudioSettingsDialog::onOperatorChanged(const OperatorManagement::User& data, DataModification modType)
|
||||
{
|
||||
|
||||
DEBUG_LOG(m_logger) << "************** onOperatorChanged ";
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eRemoved:
|
||||
|
||||
DEBUG_LOG(m_logger) << "************** onOperatorChanged ";
|
||||
switch (modType)
|
||||
{
|
||||
Q_ASSERT(m_operatorMap.contains(data.id()));
|
||||
case DataModification::eRemoved: {
|
||||
Q_ASSERT(m_operatorMap.contains(data.id()));
|
||||
|
||||
|
||||
if (m_ui->operatorComboBox->currentData().toInt() == data.id())
|
||||
{
|
||||
__unchange__();
|
||||
m_modelAllocated->resetChangeState();
|
||||
m_modelAvailable->resetChangeState();
|
||||
m_filterAvailable->invalidate();
|
||||
}
|
||||
if (m_ui->operatorComboBox->currentData().toInt() == data.id())
|
||||
{
|
||||
__unchange__();
|
||||
m_modelAllocated->resetChangeState();
|
||||
m_modelAvailable->resetChangeState();
|
||||
m_filterAvailable->invalidate();
|
||||
}
|
||||
|
||||
m_operatorMap.remove(data.id());
|
||||
m_ui->operatorComboBox->removeItem(m_ui->operatorComboBox->findData(data.id()));
|
||||
break;
|
||||
m_operatorMap.remove(data.id());
|
||||
m_ui->operatorComboBox->removeItem(m_ui->operatorComboBox->findData(data.id()));
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eAdded: {
|
||||
Q_ASSERT(!m_operatorMap.contains(data.id()));
|
||||
const QString operatorName = QString::fromStdString(data.name());
|
||||
m_operatorMap.insert(data.id(), operatorName);
|
||||
m_ui->operatorComboBox->addItem(operatorName, data.id());
|
||||
m_ui->operatorComboBox->model()->sort(0);
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eModified: {
|
||||
Q_ASSERT(m_operatorMap.contains(data.id()));
|
||||
const QString operatorName = QString::fromStdString(data.name());
|
||||
m_operatorMap.insert(data.id(), operatorName);
|
||||
int i = m_ui->operatorComboBox->findData(data.id());
|
||||
Q_ASSERT(i != -1);
|
||||
m_ui->operatorComboBox->setItemText(i, operatorName);
|
||||
m_ui->operatorComboBox->model()->sort(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case DataModification::eAdded:
|
||||
{
|
||||
Q_ASSERT(!m_operatorMap.contains(data.id()));
|
||||
const QString operatorName = QString::fromStdString(data.name());
|
||||
m_operatorMap.insert(data.id(), operatorName);
|
||||
m_ui->operatorComboBox->addItem(operatorName, data.id());
|
||||
m_ui->operatorComboBox->model()->sort(0);
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eModified:
|
||||
{
|
||||
Q_ASSERT(m_operatorMap.contains(data.id()));
|
||||
const QString operatorName = QString::fromStdString(data.name());
|
||||
m_operatorMap.insert(data.id(), operatorName);
|
||||
int i = m_ui->operatorComboBox->findData(data.id());
|
||||
Q_ASSERT(i != -1);
|
||||
m_ui->operatorComboBox->setItemText(i, operatorName);
|
||||
m_ui->operatorComboBox->model()->sort(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onCnrTvcProfileChanged(const CnrTvcProfile &data, DataModification modType)
|
||||
void AudioSettingsDialog::onCnrTvcProfileChanged(const CnrTvcProfile& data, DataModification modType)
|
||||
{
|
||||
if (m_session->exerciseId() == data.exerciseId())
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
if (m_session->exerciseId() == data.exerciseId())
|
||||
{
|
||||
m_cnrTvcProfileMap.remove(data.id());
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
m_cnrTvcProfileMap.remove(data.id());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cnrTvcProfileMap.insert(data.id(), data);
|
||||
fillOperatorList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cnrTvcProfileMap.insert(data.id(), data);
|
||||
fillOperatorList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::fillOperatorList()
|
||||
{
|
||||
QVector<StreamData> newStreamData;
|
||||
QVector<StreamData> newStreamData;
|
||||
|
||||
for (const auto &rc : std::as_const(m_cnrTvcProfileMap))
|
||||
{
|
||||
if ((rc.exerciseId() != m_session->exerciseId())
|
||||
|| (rc.operatorId() != m_ui->operatorComboBox->currentData().toInt()))
|
||||
continue;
|
||||
for (const auto& rc : std::as_const(m_cnrTvcProfileMap))
|
||||
{
|
||||
if ((rc.exerciseId() != m_session->exerciseId()) ||
|
||||
(rc.operatorId() != m_ui->operatorComboBox->currentData().toInt()))
|
||||
continue;
|
||||
|
||||
|
||||
newStreamData.reserve(rc.data().size());
|
||||
for (const CnrTvcProfileData &profileEntry : rc.data())
|
||||
newStreamData += toStreamData(profileEntry);
|
||||
newStreamData.reserve(rc.data().size());
|
||||
for (const CnrTvcProfileData& profileEntry : rc.data())
|
||||
newStreamData += toStreamData(profileEntry);
|
||||
|
||||
break;
|
||||
}
|
||||
m_modelAllocated->setNewStreamData(newStreamData);
|
||||
m_filterAvailable->setAllocatedStreams(newStreamData);
|
||||
}
|
||||
break;
|
||||
}
|
||||
m_modelAllocated->setNewStreamData(newStreamData);
|
||||
m_filterAvailable->setAllocatedStreams(newStreamData);
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::fillOperatorBox()
|
||||
{
|
||||
m_ui->operatorComboBox->clear();
|
||||
QMap<int, QString>::iterator i = m_operatorMap.begin();
|
||||
while (i != m_operatorMap.end())
|
||||
{
|
||||
m_ui->operatorComboBox->addItem(i.value(), i.key());
|
||||
++i;
|
||||
}
|
||||
m_ui->operatorComboBox->model()->sort(0);
|
||||
m_ui->operatorComboBox->clear();
|
||||
QMap<int, QString>::iterator i = m_operatorMap.begin();
|
||||
while (i != m_operatorMap.end())
|
||||
{
|
||||
m_ui->operatorComboBox->addItem(i.value(), i.key());
|
||||
++i;
|
||||
}
|
||||
m_ui->operatorComboBox->model()->sort(0);
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onUpButtonClicked()
|
||||
{
|
||||
const QModelIndexList mil = m_ui->treeViewAllocated->selectionModel()->selectedIndexes();
|
||||
if (mil.isEmpty())
|
||||
return;
|
||||
m_modelAllocated->changeOrder(mil.first(), true);
|
||||
const QModelIndexList mil = m_ui->treeViewAllocated->selectionModel()->selectedIndexes();
|
||||
if (mil.isEmpty())
|
||||
return;
|
||||
m_modelAllocated->changeOrder(mil.first(), true);
|
||||
|
||||
if (mil.first().row() > 0)
|
||||
{
|
||||
const QModelIndex newRow = m_modelAllocated->index(mil.first().row() - 1, 0);
|
||||
m_ui->treeViewAllocated->setCurrentIndex(newRow);
|
||||
}
|
||||
if (mil.first().row() > 0)
|
||||
{
|
||||
const QModelIndex newRow = m_modelAllocated->index(mil.first().row() - 1, 0);
|
||||
m_ui->treeViewAllocated->setCurrentIndex(newRow);
|
||||
}
|
||||
|
||||
slotChangesMade();
|
||||
}
|
||||
slotChangesMade();
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onDownButtonClicked()
|
||||
{
|
||||
const QModelIndexList mil = m_ui->treeViewAllocated->selectionModel()->selectedIndexes();
|
||||
if (mil.isEmpty())
|
||||
return;
|
||||
m_modelAllocated->changeOrder(mil.first(), false);
|
||||
const QModelIndex newRow = m_modelAllocated->index(mil.first().row() + 1, 0);
|
||||
m_ui->treeViewAllocated->setCurrentIndex(newRow);
|
||||
slotChangesMade();
|
||||
}
|
||||
const QModelIndexList mil = m_ui->treeViewAllocated->selectionModel()->selectedIndexes();
|
||||
if (mil.isEmpty())
|
||||
return;
|
||||
m_modelAllocated->changeOrder(mil.first(), false);
|
||||
const QModelIndex newRow = m_modelAllocated->index(mil.first().row() + 1, 0);
|
||||
m_ui->treeViewAllocated->setCurrentIndex(newRow);
|
||||
slotChangesMade();
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onSelectionChangedAllocation(const QItemSelection &selected, const QItemSelection &deselected)
|
||||
void AudioSettingsDialog::onSelectionChangedAllocation(const QItemSelection& selected, const QItemSelection& deselected)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onSelectionChangedAllocation selected.isEmpty()=" << selected.isEmpty();
|
||||
Q_UNUSED(deselected);
|
||||
QModelIndex first = m_ui->treeViewAllocated->model()->index(0, 0);
|
||||
int rowCnt = m_ui->treeViewAllocated->model()->rowCount();
|
||||
QModelIndex last = m_ui->treeViewAllocated->model()->index(rowCnt - 1, 0);
|
||||
QModelIndexList selectedRows = m_ui->treeViewAllocated->selectionModel()->selectedIndexes();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
if (cntSelectedRows > 1)
|
||||
{
|
||||
m_ui->pushButtonUp->setEnabled(false);
|
||||
m_ui->pushButtonDown->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (selected.size() > 0)
|
||||
{
|
||||
m_ui->pushButtonUp->setEnabled(selected.first().indexes().first() != first);
|
||||
m_ui->pushButtonDown->setEnabled(selected.first().indexes().first() != last);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "onSelectionChangedAllocation selected.isEmpty()=" << selected.isEmpty();
|
||||
Q_UNUSED(deselected);
|
||||
QModelIndex first = m_ui->treeViewAllocated->model()->index(0, 0);
|
||||
int rowCnt = m_ui->treeViewAllocated->model()->rowCount();
|
||||
QModelIndex last = m_ui->treeViewAllocated->model()->index(rowCnt - 1, 0);
|
||||
QModelIndexList selectedRows = m_ui->treeViewAllocated->selectionModel()->selectedIndexes();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
if (cntSelectedRows > 1)
|
||||
{
|
||||
m_ui->pushButtonUp->setEnabled(false);
|
||||
m_ui->pushButtonDown->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (selected.size() > 0)
|
||||
{
|
||||
m_ui->pushButtonUp->setEnabled(selected.first().indexes().first() != first);
|
||||
m_ui->pushButtonDown->setEnabled(selected.first().indexes().first() != last);
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioSettingsDialog::apply()
|
||||
{
|
||||
if (m_modelAllocated->getStreamDataVector().isEmpty())
|
||||
applyRemove();
|
||||
else
|
||||
applyModify();
|
||||
m_modelAllocated->resetChangeState();
|
||||
m_modelAvailable->resetChangeState();
|
||||
m_filterAvailable->invalidate();
|
||||
return true;
|
||||
if (m_modelAllocated->getStreamDataVector().isEmpty())
|
||||
applyRemove();
|
||||
else
|
||||
applyModify();
|
||||
m_modelAllocated->resetChangeState();
|
||||
m_modelAvailable->resetChangeState();
|
||||
m_filterAvailable->invalidate();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioSettingsDialog::applyRemove()
|
||||
{
|
||||
RemoveCnrTvcProfileRequest removeRequest;
|
||||
DEBUG_LOG(m_logger) << "AudioSettingsDialog::applyRemove";
|
||||
RemoveCnrTvcProfileRequest removeRequest;
|
||||
DEBUG_LOG(m_logger) << "AudioSettingsDialog::applyRemove";
|
||||
|
||||
for (const auto& profile : std::as_const(m_cnrTvcProfileMap))
|
||||
{
|
||||
if (profile.operatorId() != m_operatorId)
|
||||
continue;
|
||||
removeRequest.id(profile.id());
|
||||
break;
|
||||
}
|
||||
if (removeRequest.id() <= 0)
|
||||
return true;
|
||||
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, removeRequest]() { return m_avmFtc->removeCnrTvcProfileRequest(removeRequest, this); });
|
||||
|
||||
for (const auto &profile : std::as_const(m_cnrTvcProfileMap))
|
||||
{
|
||||
if (profile.operatorId() != m_operatorId)
|
||||
continue;
|
||||
removeRequest.id(profile.id());
|
||||
break;
|
||||
}
|
||||
if (removeRequest.id() <= 0)
|
||||
return true;
|
||||
|
||||
m_requestHelper->startSingleRequest([this, removeRequest]()
|
||||
{
|
||||
return m_avmFtc->removeCnrTvcProfileRequest(removeRequest, this);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioSettingsDialog::applyModify()
|
||||
{
|
||||
ModifyCnrTvcProfileRequest modifyRequest;
|
||||
DEBUG_LOG(m_logger) << "AudioSettingsDialog::applyModify";
|
||||
ModifyCnrTvcProfileRequest modifyRequest;
|
||||
DEBUG_LOG(m_logger) << "AudioSettingsDialog::applyModify";
|
||||
|
||||
for (const auto &profile : std::as_const(m_cnrTvcProfileMap))
|
||||
{
|
||||
if (profile.operatorId() != m_operatorId)
|
||||
continue;
|
||||
modifyRequest.id(profile.id());
|
||||
break;
|
||||
}
|
||||
for (const auto& profile : std::as_const(m_cnrTvcProfileMap))
|
||||
{
|
||||
if (profile.operatorId() != m_operatorId)
|
||||
continue;
|
||||
modifyRequest.id(profile.id());
|
||||
break;
|
||||
}
|
||||
|
||||
modifyRequest.exerciseId(m_session->exerciseId());
|
||||
modifyRequest.operatorId(m_operatorId);
|
||||
modifyRequest.exerciseId(m_session->exerciseId());
|
||||
modifyRequest.operatorId(m_operatorId);
|
||||
|
||||
const QVector<StreamData> allocatedList = m_modelAllocated->getStreamDataVector();
|
||||
modifyRequest.data().reserve(allocatedList.size());
|
||||
for (const StreamData &stream : allocatedList)
|
||||
{
|
||||
CnrTvcProfileData circuitData;
|
||||
circuitData.radioSystemId(stream.bIsCnr ? RadioSystem::Cnr : RadioSystem::Tvc);
|
||||
circuitData.radioCircuitId(stream.topicId);
|
||||
modifyRequest.data().push_back(std::move(circuitData));
|
||||
}
|
||||
const QVector<StreamData> allocatedList = m_modelAllocated->getStreamDataVector();
|
||||
modifyRequest.data().reserve(allocatedList.size());
|
||||
for (const StreamData& stream : allocatedList)
|
||||
{
|
||||
CnrTvcProfileData circuitData;
|
||||
circuitData.radioSystemId(stream.bIsCnr ? RadioSystem::Cnr : RadioSystem::Tvc);
|
||||
circuitData.radioCircuitId(stream.topicId);
|
||||
modifyRequest.data().push_back(std::move(circuitData));
|
||||
}
|
||||
|
||||
m_requestHelper->startSingleRequest([this, modifyRequest]()
|
||||
{
|
||||
return m_avmFtc->modifyCnrTvcProfileRequest(modifyRequest, this);
|
||||
});
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, modifyRequest]() { return m_avmFtc->modifyCnrTvcProfileRequest(modifyRequest, this); });
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onModifyCnrTvcProfileReply(const Core::FunctionReplyObject &replyObject)
|
||||
void AudioSettingsDialog::onModifyCnrTvcProfileReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
__unchange__();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
__unchange__();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onRemoveCnrTvcProfileReply(const Core::FunctionReplyObject &replyObject)
|
||||
void AudioSettingsDialog::onRemoveCnrTvcProfileReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
__unchange__();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
__unchange__();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onSelectionOperatorChanged(const int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
if (hasUnsavedChanges() ||
|
||||
m_modelAllocated->getChangeState() ||
|
||||
m_modelAvailable->getChangeState())
|
||||
{
|
||||
switch (askApplyDiscardCancel())
|
||||
Q_UNUSED(index);
|
||||
if (hasUnsavedChanges() || m_modelAllocated->getChangeState() || m_modelAvailable->getChangeState())
|
||||
{
|
||||
case LtsWidgets::Button::Apply:
|
||||
if (!apply())
|
||||
return;
|
||||
break;
|
||||
case LtsWidgets::Button::Cancel:
|
||||
{
|
||||
|
||||
|
||||
|
||||
switch (askApplyDiscardCancel())
|
||||
{
|
||||
QSignalBlocker blockSignals(m_ui->operatorComboBox);
|
||||
m_ui->operatorComboBox->setCurrentIndex(m_ui->operatorComboBox->findData(m_operatorId));
|
||||
case LtsWidgets::Button::Apply:
|
||||
if (!apply())
|
||||
return;
|
||||
break;
|
||||
case LtsWidgets::Button::Cancel: {
|
||||
|
||||
{
|
||||
QSignalBlocker blockSignals(m_ui->operatorComboBox);
|
||||
m_ui->operatorComboBox->setCurrentIndex(m_ui->operatorComboBox->findData(m_operatorId));
|
||||
}
|
||||
return;
|
||||
}
|
||||
case LtsWidgets::Button::Discard:
|
||||
__unchange__();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case LtsWidgets::Button::Discard:
|
||||
__unchange__();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_ui->pushButtonUp->setEnabled(false);
|
||||
m_ui->pushButtonDown->setEnabled(false);
|
||||
m_operatorId = m_ui->operatorComboBox->currentData().toInt();
|
||||
DEBUG_LOG(m_logger) << "onSelectionOperatorChanged" << " operatorStr=" << m_ui->operatorComboBox->currentText() << " m_operatorId= " << m_operatorId;
|
||||
fillOperatorList();
|
||||
m_modelAllocated->resetChangeState();
|
||||
m_modelAvailable->resetChangeState();
|
||||
m_filterAvailable->invalidate();
|
||||
m_ui->pushButtonUp->setEnabled(false);
|
||||
m_ui->pushButtonDown->setEnabled(false);
|
||||
m_operatorId = m_ui->operatorComboBox->currentData().toInt();
|
||||
DEBUG_LOG(m_logger) << "onSelectionOperatorChanged" << " operatorStr=" << m_ui->operatorComboBox->currentText()
|
||||
<< " m_operatorId= " << m_operatorId;
|
||||
fillOperatorList();
|
||||
m_modelAllocated->resetChangeState();
|
||||
m_modelAvailable->resetChangeState();
|
||||
m_filterAvailable->invalidate();
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onDroppedInAllocated(const QVector<StreamData> &streams)
|
||||
void AudioSettingsDialog::onDroppedInAllocated(const QVector<StreamData>& streams)
|
||||
{
|
||||
slotChangesMade();
|
||||
m_filterAvailable->addAllocatedStreams(streams);
|
||||
m_modelAllocated->setStreamChanged(streams);
|
||||
m_modelAvailable->setStreamChanged(streams);
|
||||
slotChangesMade();
|
||||
m_filterAvailable->addAllocatedStreams(streams);
|
||||
m_modelAllocated->setStreamChanged(streams);
|
||||
m_modelAvailable->setStreamChanged(streams);
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onDroppedInAvailable(const QVector<StreamData> &streams)
|
||||
void AudioSettingsDialog::onDroppedInAvailable(const QVector<StreamData>& streams)
|
||||
{
|
||||
slotChangesMade();
|
||||
m_filterAvailable->removeAllocatedStreams(streams);
|
||||
m_modelAllocated->setStreamChanged(streams);
|
||||
m_modelAvailable->setStreamChanged(streams);
|
||||
slotChangesMade();
|
||||
m_filterAvailable->removeAllocatedStreams(streams);
|
||||
m_modelAllocated->setStreamChanged(streams);
|
||||
m_modelAvailable->setStreamChanged(streams);
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onEntryRemoved(const StreamData &stream)
|
||||
void AudioSettingsDialog::onEntryRemoved(const StreamData& stream)
|
||||
{
|
||||
m_modelAllocated->removeEntry(stream);
|
||||
m_filterAvailable->removeAllocatedStreams({stream});
|
||||
m_modelAllocated->removeEntry(stream);
|
||||
m_filterAvailable->removeAllocatedStreams({stream});
|
||||
}
|
||||
|
||||
StreamData AudioSettingsDialog::toStreamData(const CnrTvcProfileData &profileEntry) const
|
||||
StreamData AudioSettingsDialog::toStreamData(const CnrTvcProfileData& profileEntry) const
|
||||
{
|
||||
int configId = profileEntry.radioCircuitId();
|
||||
StreamData streamData;
|
||||
streamData.topicId = configId;
|
||||
int configId = profileEntry.radioCircuitId();
|
||||
StreamData streamData;
|
||||
streamData.topicId = configId;
|
||||
|
||||
if (profileEntry.radioSystemId() == RadioSystem::Cnr)
|
||||
{
|
||||
streamData.name = QString::fromStdString(m_avmDtc->cnrConfig(configId).radioCircuit());
|
||||
streamData.bIsCnr = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
streamData.name = QString::fromStdString(m_avmDtc->tvcConfig(configId).radioCircuit());
|
||||
streamData.bIsCnr = false;
|
||||
}
|
||||
if (profileEntry.radioSystemId() == RadioSystem::Cnr)
|
||||
{
|
||||
streamData.name = QString::fromStdString(m_avmDtc->cnrConfig(configId).radioCircuit());
|
||||
streamData.bIsCnr = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
streamData.name = QString::fromStdString(m_avmDtc->tvcConfig(configId).radioCircuit());
|
||||
streamData.bIsCnr = false;
|
||||
}
|
||||
|
||||
return streamData;
|
||||
return streamData;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+120
-134
@@ -1,179 +1,165 @@
|
||||
|
||||
|
||||
|
||||
#include "audio_settings_used_streams_model.h"
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
#include <QMimeData>
|
||||
|
||||
#include <QFont>
|
||||
#include <QMimeData>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
AllocatedStreamsModel::AllocatedStreamsModel(QObject *parent)
|
||||
: NGLTreeModel(parent, new NGLTreeItem(QVariant(QLatin1String("root"))), { tr("Allocated") })
|
||||
AllocatedStreamsModel::AllocatedStreamsModel(QObject* parent)
|
||||
: NGLTreeModel(parent, new NGLTreeItem(QVariant(QLatin1String("root"))), {tr("Allocated")})
|
||||
{
|
||||
setMimeType(StreamData::mimeType());
|
||||
setMimeType(StreamData::mimeType());
|
||||
}
|
||||
|
||||
Qt::ItemFlags AllocatedStreamsModel::flags(const QModelIndex &index) const
|
||||
Qt::ItemFlags AllocatedStreamsModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
return NGLTreeModel::flags(index) | Qt::ItemIsDropEnabled;
|
||||
return NGLTreeModel::flags(index) | Qt::ItemIsDropEnabled;
|
||||
}
|
||||
|
||||
QVariant AllocatedStreamsModel::data(const QModelIndex &index, int role) const
|
||||
QVariant AllocatedStreamsModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
switch (role)
|
||||
{
|
||||
NGLTreeItem *item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
DEBUG_LOG(m_logger) << data.name;
|
||||
return data.name;
|
||||
case Qt::DisplayRole: {
|
||||
NGLTreeItem* item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
DEBUG_LOG(m_logger) << data.name;
|
||||
return data.name;
|
||||
}
|
||||
|
||||
case Qt::FontRole: {
|
||||
NGLTreeItem* item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
if (!m_changedStreams.contains(QPair<bool, int>(data.bIsCnr, data.topicId)))
|
||||
return {};
|
||||
QFont f;
|
||||
f.setBold(true);
|
||||
return f;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case Qt::FontRole:
|
||||
{
|
||||
NGLTreeItem *item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
if (!m_changedStreams.contains(QPair<bool,int>(data.bIsCnr, data.topicId)))
|
||||
return {};
|
||||
QFont f;
|
||||
f.setBold(true);
|
||||
return f;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NGLTreeModel::data(index, role);
|
||||
return NGLTreeModel::data(index, role);
|
||||
}
|
||||
|
||||
|
||||
void AllocatedStreamsModel::setStreamChanged(const QVector<StreamData> &streams)
|
||||
void AllocatedStreamsModel::setStreamChanged(const QVector<StreamData>& streams)
|
||||
{
|
||||
for (const StreamData &d : streams)
|
||||
if (!m_changedStreams.contains(QPair<bool,int>(d.bIsCnr, d.topicId)))
|
||||
m_changedStreams += QPair<bool,int>(d.bIsCnr, d.topicId);
|
||||
emit modelDataChanged();
|
||||
for (const StreamData& d : streams)
|
||||
if (!m_changedStreams.contains(QPair<bool, int>(d.bIsCnr, d.topicId)))
|
||||
m_changedStreams += QPair<bool, int>(d.bIsCnr, d.topicId);
|
||||
emit modelDataChanged();
|
||||
}
|
||||
|
||||
|
||||
bool AllocatedStreamsModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
|
||||
bool AllocatedStreamsModel::canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(data);
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
if (action != supportedDropActions())
|
||||
return false;
|
||||
return true;
|
||||
Q_UNUSED(data);
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
if (action != supportedDropActions())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool AllocatedStreamsModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent)
|
||||
bool AllocatedStreamsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent)
|
||||
{
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
|
||||
const QVector<NGLTreeItem *> droppedItems = getMimeDataItems(data, m_mimeType);
|
||||
QVector<StreamData> streams;
|
||||
streams.reserve(droppedItems.size());
|
||||
for (const NGLTreeItem *item : droppedItems)
|
||||
streams += item->data().value<StreamData>();
|
||||
qDeleteAll(droppedItems);
|
||||
emit droppedStreamNames(streams);
|
||||
m_changes = true;
|
||||
DEBUG_LOG(m_logger) << data->data(QStringLiteral("NGLTreeModel/dragDrop"));
|
||||
return NGLTreeModel::dropMimeData(data, action, row, 0, QModelIndex());
|
||||
const QVector<NGLTreeItem*> droppedItems = getMimeDataItems(data, m_mimeType);
|
||||
QVector<StreamData> streams;
|
||||
streams.reserve(droppedItems.size());
|
||||
for (const NGLTreeItem* item : droppedItems)
|
||||
streams += item->data().value<StreamData>();
|
||||
qDeleteAll(droppedItems);
|
||||
emit droppedStreamNames(streams);
|
||||
m_changes = true;
|
||||
DEBUG_LOG(m_logger) << data->data(QStringLiteral("NGLTreeModel/dragDrop"));
|
||||
return NGLTreeModel::dropMimeData(data, action, row, 0, QModelIndex());
|
||||
}
|
||||
|
||||
|
||||
void AllocatedStreamsModel::setNewStreamData(const QVector<StreamData> &newData)
|
||||
void AllocatedStreamsModel::setNewStreamData(const QVector<StreamData>& newData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "set new stream data, count: " << newData.size();
|
||||
resetModel();
|
||||
for (const StreamData &sd : newData)
|
||||
m_rootItem->appendChild(new NGLTreeItem(QVariant::fromValue(sd)));
|
||||
DEBUG_LOG(m_logger) << "set new stream data, count: " << newData.size();
|
||||
resetModel();
|
||||
for (const StreamData& sd : newData)
|
||||
m_rootItem->appendChild(new NGLTreeItem(QVariant::fromValue(sd)));
|
||||
|
||||
emit modelDataChanged();
|
||||
emit modelDataChanged();
|
||||
}
|
||||
|
||||
QVector<StreamData> AllocatedStreamsModel::getStreamDataVector() const
|
||||
{
|
||||
QVector<StreamData> result;
|
||||
result.reserve(m_rootItem->childCount());
|
||||
for (int i = 0; i < m_rootItem->childCount(); i++)
|
||||
{
|
||||
const NGLTreeItem *item = m_rootItem->child(i);
|
||||
const StreamData sd = item->data().value<StreamData>();
|
||||
result.append(sd);
|
||||
DEBUG_LOG(m_logger) << "result.append(sd.name):" << sd.name;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "getStreamDataVector() size: " << result.size();
|
||||
return result;
|
||||
}
|
||||
|
||||
void AllocatedStreamsModel::changeOrder(const QModelIndex &idx, bool up)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "changeOrder "
|
||||
<< " index = " << idx.row()
|
||||
<< " up = " << up
|
||||
<< " m_rootItem->childCount()= " << m_rootItem->childCount();
|
||||
if (up)
|
||||
{
|
||||
moveRow(idx.parent(), idx.row(),
|
||||
idx.parent(), idx.row() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
moveRow(idx.parent(), idx.row(),
|
||||
idx.parent(), idx.row() + 1);
|
||||
}
|
||||
emit modelDataChanged();
|
||||
}
|
||||
|
||||
|
||||
void AllocatedStreamsModel::updateEntry(const StreamData &stream)
|
||||
{
|
||||
for (int i = 0; i < m_rootItem->childCount(); i++)
|
||||
{
|
||||
NGLTreeItem *child = m_rootItem->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
|
||||
if (data == stream)
|
||||
QVector<StreamData> result;
|
||||
result.reserve(m_rootItem->childCount());
|
||||
for (int i = 0; i < m_rootItem->childCount(); i++)
|
||||
{
|
||||
setItemData(indexFromItem(child), QVariant::fromValue(stream), child->icon());
|
||||
break;
|
||||
const NGLTreeItem* item = m_rootItem->child(i);
|
||||
const StreamData sd = item->data().value<StreamData>();
|
||||
result.append(sd);
|
||||
DEBUG_LOG(m_logger) << "result.append(sd.name):" << sd.name;
|
||||
}
|
||||
}
|
||||
|
||||
emit modelDataChanged();
|
||||
DEBUG_LOG(m_logger) << "getStreamDataVector() size: " << result.size();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void AllocatedStreamsModel::removeEntry(const StreamData &stream)
|
||||
void AllocatedStreamsModel::changeOrder(const QModelIndex& idx, bool up)
|
||||
{
|
||||
for (int i = 0; i < m_rootItem->childCount(); i++)
|
||||
{
|
||||
NGLTreeItem *child = m_rootItem->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
if (data == stream)
|
||||
DEBUG_LOG(m_logger) << "changeOrder "
|
||||
<< " index = " << idx.row() << " up = " << up
|
||||
<< " m_rootItem->childCount()= " << m_rootItem->childCount();
|
||||
if (up)
|
||||
{
|
||||
removeRows(i, 1, indexFromItem(m_rootItem));
|
||||
break;
|
||||
moveRow(idx.parent(), idx.row(), idx.parent(), idx.row() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
emit modelDataChanged();
|
||||
else
|
||||
{
|
||||
moveRow(idx.parent(), idx.row(), idx.parent(), idx.row() + 1);
|
||||
}
|
||||
emit modelDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
void AllocatedStreamsModel::updateEntry(const StreamData& stream)
|
||||
{
|
||||
for (int i = 0; i < m_rootItem->childCount(); i++)
|
||||
{
|
||||
NGLTreeItem* child = m_rootItem->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
|
||||
if (data == stream)
|
||||
{
|
||||
setItemData(indexFromItem(child), QVariant::fromValue(stream), child->icon());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
emit modelDataChanged();
|
||||
}
|
||||
|
||||
void AllocatedStreamsModel::removeEntry(const StreamData& stream)
|
||||
{
|
||||
for (int i = 0; i < m_rootItem->childCount(); i++)
|
||||
{
|
||||
NGLTreeItem* child = m_rootItem->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
if (data == stream)
|
||||
{
|
||||
removeRows(i, 1, indexFromItem(m_rootItem));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
emit modelDataChanged();
|
||||
}
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+47
-28
@@ -1,49 +1,68 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include "audio_stream_type.h"
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class AllocatedStreamsModel final : public NGLTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AllocatedStreamsModel(QObject *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AllocatedStreamsModel(QObject* parent = nullptr);
|
||||
|
||||
bool getChangeState() {bool result = m_changes; m_changes = false; return result;}
|
||||
void resetChangeState() {m_changes = false;m_changedStreams.clear();}
|
||||
bool getChangeState()
|
||||
{
|
||||
bool result = m_changes;
|
||||
m_changes = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
Qt::DropActions supportedDropActions() const override { return Qt::CopyAction; }
|
||||
Qt::DropActions supportedDragActions() const override { return Qt::MoveAction; }
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) override;
|
||||
void setStreamChanged(const QVector<StreamData> &streams);
|
||||
void resetChangeState()
|
||||
{
|
||||
m_changes = false;
|
||||
m_changedStreams.clear();
|
||||
}
|
||||
|
||||
void setNewStreamData(const QVector<StreamData> &newData);
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
QVector<StreamData> getStreamDataVector() const;
|
||||
Qt::DropActions supportedDropActions() const override
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
}
|
||||
|
||||
void changeOrder(const QModelIndex &idx, bool up);
|
||||
void updateEntry(const StreamData &stream);
|
||||
void removeEntry(const StreamData &stream);
|
||||
Qt::DropActions supportedDragActions() const override
|
||||
{
|
||||
return Qt::MoveAction;
|
||||
}
|
||||
|
||||
signals:
|
||||
void droppedStreamNames(const QVector<AudioVideoManagement::StreamData> &streamNamesDropped);
|
||||
bool canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) override;
|
||||
void setStreamChanged(const QVector<StreamData>& streams);
|
||||
|
||||
private:
|
||||
void setNewStreamData(const QVector<StreamData>& newData);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool m_changes{false};
|
||||
QVector<QPair<bool , int> > m_changedStreams;
|
||||
QVector<StreamData> getStreamDataVector() const;
|
||||
|
||||
void changeOrder(const QModelIndex& idx, bool up);
|
||||
void updateEntry(const StreamData& stream);
|
||||
void removeEntry(const StreamData& stream);
|
||||
|
||||
signals:
|
||||
void droppedStreamNames(const QVector<AudioVideoManagement::StreamData>& streamNamesDropped);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool m_changes{false};
|
||||
QVector<QPair<bool, int>> m_changedStreams;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+47
-53
@@ -1,13 +1,11 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
|
||||
#include <QJsonArray>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
@@ -15,67 +13,63 @@ namespace AudioVideoManagement
|
||||
|
||||
class AvsSequence
|
||||
{
|
||||
public:
|
||||
QString internalStreamName;
|
||||
AvaSpeed speed{100};
|
||||
AvaVolume volume{0};
|
||||
AvaTimePoint start;
|
||||
AvaDuration duration;
|
||||
bool pint = false;
|
||||
QString description;
|
||||
public:
|
||||
QString internalStreamName;
|
||||
AvaSpeed speed{100};
|
||||
AvaVolume volume{0};
|
||||
AvaTimePoint start;
|
||||
AvaDuration duration;
|
||||
bool pint = false;
|
||||
QString description;
|
||||
};
|
||||
|
||||
|
||||
class AvmSequenceModel final : public LtsWidgets::LtsAbstractTableModel<AvsSequence>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Order = 0,
|
||||
Start,
|
||||
End,
|
||||
Duration,
|
||||
Streams,
|
||||
Speed,
|
||||
Volume,
|
||||
Description
|
||||
};
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns { Order = 0, Start, End, Duration, Streams, Speed, Volume, Description };
|
||||
|
||||
explicit AvmSequenceModel(QObject *parent = nullptr);
|
||||
void moveUp(const QModelIndex &idx);
|
||||
void moveDown(const QModelIndex &idx);
|
||||
bool initModel(const QJsonArray &data);
|
||||
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
|
||||
QJsonArray getSequencesAsJsonArray() const;
|
||||
QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
|
||||
QVector<int> highlightedRows() const { return m_highlightedRows; }
|
||||
void setHighlightedRow(int highlighted, bool reset = true);
|
||||
explicit AvmSequenceModel(QObject* parent = nullptr);
|
||||
void moveUp(const QModelIndex& idx);
|
||||
void moveDown(const QModelIndex& idx);
|
||||
bool initModel(const QJsonArray& data);
|
||||
bool moveRows(const QModelIndex& sourceParent, int sourceRow, int count, const QModelIndex& destinationParent,
|
||||
int destinationChild) override;
|
||||
QJsonArray getSequencesAsJsonArray() const;
|
||||
QVariant data(const QModelIndex& idx, int role = Qt::DisplayRole) const override;
|
||||
|
||||
friend class AvmSequenceProxyModel;
|
||||
QVector<int> highlightedRows() const
|
||||
{
|
||||
return m_highlightedRows;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void setTimezoneHoursOffset(int timezoneHoursOffset);
|
||||
void setHighlightedRow(int highlighted, bool reset = true);
|
||||
|
||||
private:
|
||||
friend class AvmSequenceProxyModel;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
QString dateTimeToStringx(const QDateTime &dt) const;
|
||||
QString msecsSinceEpochToStringx(qint64 msecs) const;
|
||||
public slots:
|
||||
void setTimezoneHoursOffset(int timezoneHoursOffset);
|
||||
|
||||
QVector<int> m_highlightedRows;
|
||||
int m_timezoneHoursOffset = 0;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
QString dateTimeToStringx(const QDateTime& dt) const;
|
||||
QString msecsSinceEpochToStringx(qint64 msecs) const;
|
||||
|
||||
QVector<int> m_highlightedRows;
|
||||
int m_timezoneHoursOffset = 0;
|
||||
};
|
||||
|
||||
class AvmSequenceProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
private:
|
||||
AvmSequenceModel *m_sourceModel = nullptr;
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel* sourceModel) override;
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override;
|
||||
|
||||
private:
|
||||
AvmSequenceModel* m_sourceModel = nullptr;
|
||||
};
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+423
-483
File diff suppressed because it is too large.
Load diff
Executable → Regular
+45
-44
@@ -1,10 +1,9 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "avm_sequence_model.h"
|
||||
#include "../avm_playback_menu.h"
|
||||
#include "avm_sequence_model.h"
|
||||
|
||||
#include <AudioVideoManagement/ava_control.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
@@ -12,63 +11,65 @@
|
||||
#include <Plugins/AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
#include <TopicEditorBase/topic_editor_base.h>
|
||||
|
||||
|
||||
namespace Ui { class AVTopicEditor; }
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AVTopicEditor;
|
||||
}
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class TopicEditor : public TopicEditorBase::TopicEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TopicEditor(LtsSession::LtsSession *session, const TopicEditorBase::TopicData &data, QWidget *parent = nullptr);
|
||||
~TopicEditor();
|
||||
public:
|
||||
explicit TopicEditor(LtsSession::LtsSession* session, const TopicEditorBase::TopicData& data,
|
||||
QWidget* parent = nullptr);
|
||||
~TopicEditor();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void updateInternalData() override final;
|
||||
void retranslate() override final;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void updateInternalData() override final;
|
||||
void retranslate() override final;
|
||||
|
||||
AvsSequence createSequence(const AvaTimePoint &start, const AvaTimePoint &end) const;
|
||||
AvsSequence createCurrentSequence() const;
|
||||
void refreshDurationText();
|
||||
void setDurationText(qint64 length);
|
||||
qint64 calcTrackLength(const QJsonArray &arr) const;
|
||||
void playbackDlgNotAvailable(const QString &msg);
|
||||
AvsSequence createSequence(const AvaTimePoint& start, const AvaTimePoint& end) const;
|
||||
AvsSequence createCurrentSequence() const;
|
||||
void refreshDurationText();
|
||||
void setDurationText(qint64 length);
|
||||
qint64 calcTrackLength(const QJsonArray& arr) const;
|
||||
void playbackDlgNotAvailable(const QString& msg);
|
||||
|
||||
private slots:
|
||||
bool apply2() override final;
|
||||
private slots:
|
||||
bool apply2() override final;
|
||||
|
||||
void onEditSequence();
|
||||
void onTimeChanged();
|
||||
void onApplySequence();
|
||||
void onAddSequence();
|
||||
void onDeleteSequences();
|
||||
void onSequenceUp();
|
||||
void onSequenceDown();
|
||||
void onSetTopicButtonStates(bool enable);
|
||||
void onEnaDisa();
|
||||
void onMarkerSelected(const QString &description);
|
||||
void onEditSequence();
|
||||
void onTimeChanged();
|
||||
void onApplySequence();
|
||||
void onAddSequence();
|
||||
void onDeleteSequences();
|
||||
void onSequenceUp();
|
||||
void onSequenceDown();
|
||||
void onSetTopicButtonStates(bool enable);
|
||||
void onEnaDisa();
|
||||
void onMarkerSelected(const QString& description);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
const int s_durationLimit{86400000};
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
const int s_durationLimit{86400000};
|
||||
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
std::shared_ptr<AudioVideoManagement::DataInterface> m_avmDataIfc{nullptr};
|
||||
LtsSession::LtsSession* m_session{nullptr};
|
||||
std::shared_ptr<AudioVideoManagement::DataInterface> m_avmDataIfc{nullptr};
|
||||
|
||||
AvmSequenceModel *m_model{nullptr};
|
||||
AvmSequenceProxyModel *m_proxyModel{nullptr};
|
||||
AvmPlaybackMenu *m_playbackMenu{nullptr};
|
||||
AvmSequenceModel* m_model{nullptr};
|
||||
AvmSequenceProxyModel* m_proxyModel{nullptr};
|
||||
AvmPlaybackMenu* m_playbackMenu{nullptr};
|
||||
|
||||
bool m_isAudio{false};
|
||||
qint64 m_topicStartTime{0};
|
||||
QString m_topicStreamName;
|
||||
bool m_isAudio{false};
|
||||
qint64 m_topicStartTime{0};
|
||||
QString m_topicStreamName;
|
||||
|
||||
Ui::AVTopicEditor *m_ui{nullptr};
|
||||
Ui::AVTopicEditor* m_ui{nullptr};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+195
-239
@@ -1,317 +1,273 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_available_streams_model.h"
|
||||
|
||||
#include <AudioVideoManagement/stream_name_mapping.h>
|
||||
#include <InfrastructureManagement/ism.hpp>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
#include <QSet>
|
||||
#include <QMimeData>
|
||||
#include <QCollator>
|
||||
#include <QMimeData>
|
||||
#include <QSet>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool isMountingPointOfInterest(const InfrastructureManagement::StructureElement &se, bool isAudio)
|
||||
bool isMountingPointOfInterest(const InfrastructureManagement::StructureElement& se, bool isAudio)
|
||||
{
|
||||
if (se.structureElementTypeId() != InfrastructureManagement::StructureElementType::MountingPoint)
|
||||
if (se.structureElementTypeId() != InfrastructureManagement::StructureElementType::MountingPoint)
|
||||
return false;
|
||||
|
||||
if (se.mountingPointTypeId() == InfrastructureManagement::MountingPointType::IndoorCamera ||
|
||||
se.mountingPointTypeId() == InfrastructureManagement::MountingPointType::OutdoorCamera)
|
||||
return true;
|
||||
|
||||
if (isAudio && se.mountingPointTypeId() == InfrastructureManagement::MountingPointType::AnnouncementUnit)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
|
||||
if (se.mountingPointTypeId() == InfrastructureManagement::MountingPointType::IndoorCamera ||
|
||||
se.mountingPointTypeId() == InfrastructureManagement::MountingPointType::OutdoorCamera)
|
||||
return true;
|
||||
|
||||
if (isAudio && se.mountingPointTypeId() == InfrastructureManagement::MountingPointType::AnnouncementUnit)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
const QString AvailableStreamsModel::s_MimeType = QStringLiteral("AvailStreamsModel/DragDrop");
|
||||
|
||||
|
||||
|
||||
struct sorter
|
||||
{
|
||||
bool operator()(const StreamModelData &i, const StreamModelData &j)
|
||||
{
|
||||
QCollator col;
|
||||
col.setNumericMode(true);
|
||||
return col.compare(j.name, i.name) > 0 ;
|
||||
}
|
||||
bool operator()(const StreamModelData& i, const StreamModelData& j)
|
||||
{
|
||||
QCollator col;
|
||||
col.setNumericMode(true);
|
||||
return col.compare(j.name, i.name) > 0;
|
||||
}
|
||||
} sortStuff;
|
||||
|
||||
|
||||
AvailableStreamsModel::AvailableStreamsModel(const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
LtsSession::LtsSession *session,
|
||||
StreamNameMapping *streamNameMapping,
|
||||
QObject *parent,
|
||||
bool isAudio) : NGLTreeModel(parent, new NGLTreeItem(QVariant(), QIcon()),,
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {tr("Available Streams")})
|
||||
, m_isAudio(isAudio)
|
||||
, m_avmDtc(avmDtc)
|
||||
, m_ismDtc(ismDtc)
|
||||
, m_session(session)
|
||||
, m_streamNameMapping(streamNameMapping)
|
||||
AvailableStreamsModel::AvailableStreamsModel(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
LtsSession::LtsSession* session, StreamNameMapping* streamNameMapping,
|
||||
QObject* parent, bool isAudio)
|
||||
: NGLTreeModel(parent, new NGLTreeItem(QVariant(), QIcon()), ,
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()){tr("Available Streams")}),
|
||||
m_isAudio(isAudio), m_avmDtc(avmDtc), m_ismDtc(ismDtc), m_session(session), m_streamNameMapping(streamNameMapping)
|
||||
{
|
||||
Q_ASSERT(ismDtc);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
qRegisterMetaTypeStreamOperators<StreamModelData>("StreamModelData");
|
||||
qRegisterMetaType<StreamModelData>("StreamModelData");
|
||||
Q_ASSERT(ismDtc);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
qRegisterMetaTypeStreamOperators<StreamModelData>("StreamModelData");
|
||||
qRegisterMetaType<StreamModelData>("StreamModelData");
|
||||
|
||||
setMimeType(s_MimeType);
|
||||
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::mainStructureElementChanged,
|
||||
this, [ this]()
|
||||
{
|
||||
setMimeType(s_MimeType);
|
||||
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::mainStructureElementChanged, this,
|
||||
[this]() { initModel(); });
|
||||
|
||||
connect(m_streamNameMapping, &StreamNameMapping::changed, this, [this]() { initModel(); });
|
||||
|
||||
if (!m_isAudio)
|
||||
{
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::videoTeamChanged, this,
|
||||
[this]() { initModel(); });
|
||||
}
|
||||
initModel();
|
||||
});
|
||||
|
||||
connect(m_streamNameMapping, &StreamNameMapping::changed,
|
||||
this, [ this]()
|
||||
{
|
||||
initModel();
|
||||
});
|
||||
|
||||
if (!m_isAudio)
|
||||
{
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::videoTeamChanged,
|
||||
this, [ this]()
|
||||
{
|
||||
initModel();
|
||||
});
|
||||
}
|
||||
initModel();
|
||||
}
|
||||
|
||||
QVariant AvailableStreamsModel::data(const QModelIndex &index, int role) const
|
||||
QVariant AvailableStreamsModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
NGLTreeItem *item = privateData(index);
|
||||
if (!item->data().canConvert<StreamModelData>())
|
||||
return QVariant();
|
||||
NGLTreeItem* item = privateData(index);
|
||||
if (!item->data().canConvert<StreamModelData>())
|
||||
return QVariant();
|
||||
|
||||
const StreamModelData availStream = item->data().value<StreamModelData>();
|
||||
const StreamModelData availStream = item->data().value<StreamModelData>();
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
switch (index.column())
|
||||
switch (role)
|
||||
{
|
||||
case 0 :
|
||||
return availStream.name;
|
||||
default:
|
||||
return QStringLiteral("??");
|
||||
case Qt::DisplayRole: {
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
return availStream.name;
|
||||
default:
|
||||
return QStringLiteral("??");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Qt::DecorationRole: {
|
||||
switch (index.column())
|
||||
{
|
||||
case 0: {
|
||||
static const QIcon folder(QStringLiteral("icon:evaluation_folder.svg"));
|
||||
static const QIcon camera(QStringLiteral("icon:camera_control.svg"));
|
||||
return availStream.isGroup ? folder : camera;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Qt::DecorationRole:
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
static const QIcon folder(QStringLiteral("icon:evaluation_folder.svg"));
|
||||
static const QIcon camera(QStringLiteral("icon:camera_control.svg"));
|
||||
return availStream.isGroup ? folder : camera;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NGLTreeModel::data(index, role);
|
||||
return NGLTreeModel::data(index, role);
|
||||
}
|
||||
|
||||
|
||||
Qt::ItemFlags AvailableStreamsModel::flags(const QModelIndex &index) const
|
||||
Qt::ItemFlags AvailableStreamsModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
Qt::ItemFlags defaultFlags = NGLTreeModel::flags(index);
|
||||
NGLTreeItem *item = privateData(index);
|
||||
Qt::ItemFlags defaultFlags = NGLTreeModel::flags(index);
|
||||
NGLTreeItem* item = privateData(index);
|
||||
|
||||
if (item == m_rootItem)
|
||||
return defaultFlags;
|
||||
if (item == m_rootItem)
|
||||
return defaultFlags;
|
||||
|
||||
return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
|
||||
return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
|
||||
}
|
||||
|
||||
|
||||
QMimeData *AvailableStreamsModel::mimeData(const QModelIndexList &indexes) const
|
||||
QMimeData* AvailableStreamsModel::mimeData(const QModelIndexList& indexes) const
|
||||
{
|
||||
|
||||
QMimeData *pData = NGLTreeModel::mimeData(indexes);
|
||||
pData->setText(data(indexes[0]).toString());
|
||||
return pData;
|
||||
|
||||
QMimeData* pData = NGLTreeModel::mimeData(indexes);
|
||||
pData->setText(data(indexes[0]).toString());
|
||||
return pData;
|
||||
}
|
||||
|
||||
|
||||
bool AvailableStreamsModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent)
|
||||
bool AvailableStreamsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent)
|
||||
{
|
||||
INFO_LOG(m_logger) << "dropMimeData: action = " << action
|
||||
<< ", row = " << row
|
||||
<< ", parent: valid = " << parent.isValid();
|
||||
INFO_LOG(m_logger) << "dropMimeData: action = " << action << ", row = " << row
|
||||
<< ", parent: valid = " << parent.isValid();
|
||||
|
||||
if (action == Qt::IgnoreAction)
|
||||
return true;
|
||||
if (action == Qt::IgnoreAction)
|
||||
return true;
|
||||
|
||||
if (!data->hasFormat(s_MimeType))
|
||||
return false;
|
||||
if (!data->hasFormat(s_MimeType))
|
||||
return false;
|
||||
|
||||
if ((action != Qt::MoveAction) && (action != Qt::CopyAction))
|
||||
return false;
|
||||
if ((action != Qt::MoveAction) && (action != Qt::CopyAction))
|
||||
return false;
|
||||
|
||||
return NGLTreeModel::dropMimeData(data, action, row, column, parent);
|
||||
return NGLTreeModel::dropMimeData(data, action, row, column, parent);
|
||||
}
|
||||
|
||||
|
||||
void AvailableStreamsModel::initModel()
|
||||
{
|
||||
beginResetModel();
|
||||
INFO_LOG(m_logger) << "initModel";
|
||||
|
||||
|
||||
m_rootItem->removeAllChildren();
|
||||
|
||||
StreamModelData availStream;
|
||||
availStream.id = 0;
|
||||
availStream.name = tr("New group");
|
||||
availStream.parentId = -1;
|
||||
availStream.isGroup = true;
|
||||
beginResetModel();
|
||||
INFO_LOG(m_logger) << "initModel";
|
||||
|
||||
QVariant data;
|
||||
data.setValue(availStream);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
m_rootItem->removeAllChildren();
|
||||
|
||||
std::vector<StreamModelData> toAddIndoor;
|
||||
std::vector<StreamModelData> toAddOutdoor;
|
||||
StreamModelData availStream;
|
||||
availStream.id = 0;
|
||||
availStream.name = tr("New group");
|
||||
availStream.parentId = -1;
|
||||
availStream.isGroup = true;
|
||||
|
||||
std::vector<StreamModelData> toAddMvs;
|
||||
QVariant data;
|
||||
data.setValue(availStream);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
|
||||
std::vector<StreamModelData> toAddIndoor;
|
||||
std::vector<StreamModelData> toAddOutdoor;
|
||||
|
||||
const auto &mountedAssets = m_ismDtc->mountingPointAssets();
|
||||
const auto &buildings = m_ismDtc->mainStructureElements();
|
||||
for (const auto &building : buildings)
|
||||
{
|
||||
for (const auto &mountingPoint : building.elements())
|
||||
std::vector<StreamModelData> toAddMvs;
|
||||
|
||||
const auto& mountedAssets = m_ismDtc->mountingPointAssets();
|
||||
const auto& buildings = m_ismDtc->mainStructureElements();
|
||||
for (const auto& building : buildings)
|
||||
{
|
||||
if (!isMountingPointOfInterest(mountingPoint, m_isAudio))
|
||||
continue;
|
||||
|
||||
|
||||
bool isMounted = false;
|
||||
for (const auto &mountedAsset : mountedAssets)
|
||||
{
|
||||
if (mountedAsset.structureElementId() == mountingPoint.id())
|
||||
for (const auto& mountingPoint : building.elements())
|
||||
{
|
||||
isMounted = true;
|
||||
break;
|
||||
if (!isMountingPointOfInterest(mountingPoint, m_isAudio))
|
||||
continue;
|
||||
|
||||
bool isMounted = false;
|
||||
for (const auto& mountedAsset : mountedAssets)
|
||||
{
|
||||
if (mountedAsset.structureElementId() == mountingPoint.id())
|
||||
{
|
||||
isMounted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isMounted)
|
||||
continue;
|
||||
StreamModelData item;
|
||||
item.name = m_streamNameMapping->displayName(mountingPoint.id());
|
||||
item.mountingPointId = mountingPoint.id();
|
||||
item.isGroup = false;
|
||||
|
||||
if (mountingPoint.mountingPointTypeId() == InfrastructureManagement::MountingPointType::IndoorCamera)
|
||||
toAddIndoor.push_back(item);
|
||||
else
|
||||
toAddOutdoor.push_back(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isMounted)
|
||||
continue;
|
||||
StreamModelData item;
|
||||
item.name = m_streamNameMapping->displayName(mountingPoint.id());
|
||||
item.mountingPointId = mountingPoint.id();
|
||||
item.isGroup = false;
|
||||
|
||||
|
||||
if (mountingPoint.mountingPointTypeId() == InfrastructureManagement::MountingPointType::IndoorCamera)
|
||||
toAddIndoor.push_back(item);
|
||||
else
|
||||
toAddOutdoor.push_back(item);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!m_isAudio)
|
||||
{
|
||||
const auto &mvsStreams = m_avmDtc->videoTeams();
|
||||
for (const auto &videoTeam : mvsStreams)
|
||||
if (!m_isAudio)
|
||||
{
|
||||
if (videoTeam.exerciseId() != m_session->exerciseId())
|
||||
continue;
|
||||
DEBUG_LOG(m_logger) << "add new videoteam" << videoTeam;
|
||||
StreamModelData item;
|
||||
item.name = QString::fromStdString(videoTeam.streamName().c_str());
|
||||
item.mountingPointId = -1 * videoTeam.id();
|
||||
item.isGroup = false;
|
||||
const auto& mvsStreams = m_avmDtc->videoTeams();
|
||||
for (const auto& videoTeam : mvsStreams)
|
||||
{
|
||||
if (videoTeam.exerciseId() != m_session->exerciseId())
|
||||
continue;
|
||||
DEBUG_LOG(m_logger) << "add new videoteam" << videoTeam;
|
||||
StreamModelData item;
|
||||
item.name = QString::fromStdString(videoTeam.streamName().c_str());
|
||||
item.mountingPointId = -1 * videoTeam.id();
|
||||
item.isGroup = false;
|
||||
|
||||
|
||||
toAddMvs.push_back(item);
|
||||
|
||||
toAddMvs.push_back(item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
std::sort(toAddOutdoor.begin(), toAddOutdoor.end(), sortStuff);
|
||||
for (const auto& item : toAddOutdoor)
|
||||
{
|
||||
data.setValue(item);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
}
|
||||
|
||||
|
||||
std::sort(toAddIndoor.begin(), toAddIndoor.end(), sortStuff);
|
||||
for (const auto& item : toAddIndoor)
|
||||
{
|
||||
data.setValue(item);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
}
|
||||
|
||||
|
||||
std::sort(toAddOutdoor.begin(), toAddOutdoor.end(), sortStuff);
|
||||
for (const auto &item : toAddOutdoor)
|
||||
{
|
||||
data.setValue(item);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
}
|
||||
|
||||
std::sort(toAddIndoor.begin(), toAddIndoor.end(), sortStuff);
|
||||
for (const auto &item : toAddIndoor)
|
||||
{
|
||||
data.setValue(item);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
}
|
||||
|
||||
std::sort(toAddMvs.begin(), toAddMvs.end(), sortStuff);
|
||||
for (const auto &item : toAddMvs)
|
||||
{
|
||||
data.setValue(item);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
}
|
||||
endResetModel();
|
||||
std::sort(toAddMvs.begin(), toAddMvs.end(), sortStuff);
|
||||
for (const auto& item : toAddMvs)
|
||||
{
|
||||
data.setValue(item);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
}
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
StreamModelData StreamModelData::createFromServiceItem(const AvMenuEntry &entry, StreamNameMapping *streamNameMapping, const QMap<int, VideoTeam> &videoTeamList)
|
||||
StreamModelData StreamModelData::createFromServiceItem(const AvMenuEntry& entry, StreamNameMapping* streamNameMapping,
|
||||
const QMap<int, VideoTeam>& videoTeamList)
|
||||
{
|
||||
StreamModelData data;
|
||||
data.id = entry.id();
|
||||
data.parentId = entry.parentId();
|
||||
data.isGroup = entry.isGroup();
|
||||
if (entry.isGroup())
|
||||
data.name = QString::fromStdString(entry.name().get());
|
||||
else
|
||||
{
|
||||
if (entry.mountingPointId().is_set() && (entry.mountingPointId().get() > 0))
|
||||
{
|
||||
data.mountingPointId = entry.mountingPointId().get();
|
||||
data.name = streamNameMapping->displayName(entry.mountingPointId().get());
|
||||
}
|
||||
StreamModelData data;
|
||||
data.id = entry.id();
|
||||
data.parentId = entry.parentId();
|
||||
data.isGroup = entry.isGroup();
|
||||
if (entry.isGroup())
|
||||
data.name = QString::fromStdString(entry.name().get());
|
||||
else
|
||||
{
|
||||
data.mountingPointId = entry.mountingPointId().get();
|
||||
data.name = QString::fromStdString(videoTeamList.value(entry.mountingPointId().get() * -1).streamName());
|
||||
if (entry.mountingPointId().is_set() && (entry.mountingPointId().get() > 0))
|
||||
{
|
||||
data.mountingPointId = entry.mountingPointId().get();
|
||||
data.name = streamNameMapping->displayName(entry.mountingPointId().get());
|
||||
}
|
||||
else
|
||||
{
|
||||
data.mountingPointId = entry.mountingPointId().get();
|
||||
data.name = QString::fromStdString(videoTeamList.value(entry.mountingPointId().get() * -1).streamName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+46
-63
@@ -2,103 +2,86 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm.hpp>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <QDataStream>
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
|
||||
class NGLTreeItem;
|
||||
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace InfrastructureManagement
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class StreamNameMapping;
|
||||
|
||||
|
||||
|
||||
struct StreamModelData
|
||||
{
|
||||
qint64 id = 0;
|
||||
qint64 parentId = 0;
|
||||
bool isGroup = false;
|
||||
QString name;
|
||||
qint32 mountingPointId = 0;
|
||||
qint64 id = 0;
|
||||
qint64 parentId = 0;
|
||||
bool isGroup = false;
|
||||
QString name;
|
||||
qint32 mountingPointId = 0;
|
||||
|
||||
static StreamModelData createFromServiceItem(const AvMenuEntry &entry, StreamNameMapping *streamNameMapping, const QMap<int, VideoTeam> &videoTeamList);
|
||||
static StreamModelData createFromServiceItem(const AvMenuEntry& entry, StreamNameMapping* streamNameMapping,
|
||||
const QMap<int, VideoTeam>& videoTeamList);
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out,
|
||||
const StreamModelData &myObj)
|
||||
{
|
||||
out << myObj.id
|
||||
<< myObj.parentId
|
||||
<< myObj.isGroup
|
||||
<< myObj.name
|
||||
<< myObj.mountingPointId;
|
||||
return out;
|
||||
}
|
||||
friend QDataStream& operator<<(QDataStream& out, const StreamModelData& myObj)
|
||||
{
|
||||
out << myObj.id << myObj.parentId << myObj.isGroup << myObj.name << myObj.mountingPointId;
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in,
|
||||
StreamModelData &myObj)
|
||||
{
|
||||
in >> myObj.id
|
||||
>> myObj.parentId
|
||||
>> myObj.isGroup
|
||||
>> myObj.name
|
||||
>> myObj.mountingPointId;
|
||||
friend QDataStream& operator>>(QDataStream& in, StreamModelData& myObj)
|
||||
{
|
||||
in >> myObj.id >> myObj.parentId >> myObj.isGroup >> myObj.name >> myObj.mountingPointId;
|
||||
|
||||
return in;
|
||||
}
|
||||
return in;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class AvailableStreamsModel : public NGLTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const QString s_MimeType;
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const QString s_MimeType;
|
||||
|
||||
AvailableStreamsModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
LtsSession::LtsSession *session,
|
||||
StreamNameMapping *streamNameMapping,
|
||||
QObject *parent,
|
||||
bool isAudio);
|
||||
AvailableStreamsModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
LtsSession::LtsSession* session, StreamNameMapping* streamNameMapping, QObject* parent,
|
||||
bool isAudio);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) override;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
QMimeData* mimeData(const QModelIndexList& indexes) const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) override;
|
||||
|
||||
Qt::DropActions supportedDragActions() const override { return Qt::CopyAction; }
|
||||
Qt::DropActions supportedDragActions() const override
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void initModel();
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void initModel();
|
||||
|
||||
const bool m_isAudio;
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
LtsSession::LtsSession *m_session;
|
||||
StreamNameMapping *m_streamNameMapping;
|
||||
const bool m_isAudio;
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
LtsSession::LtsSession* m_session;
|
||||
StreamNameMapping* m_streamNameMapping;
|
||||
};
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Q_DECLARE_METATYPE(AudioVideoManagement::StreamModelData)
|
||||
|
||||
Executable → Regular
+64
-77
@@ -1,121 +1,108 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_choose_menu.h"
|
||||
#include "ui_avm_choose_menu.h"
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/avm.hpp>
|
||||
#include <AudioVideoManagement/avs_menus.h>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include "ui_avm_choose_menu.h"
|
||||
|
||||
#include <AudioVideoManagement/avm.hpp>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/avs_menus.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
ChooseMenu::ChooseMenu(Interface::Dtc *dtc, AvsMenus *avsMenus, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_dtc(dtc)
|
||||
, m_avsMenus(avsMenus)
|
||||
, m_ui(new Ui::ChooseMenuStruct)
|
||||
ChooseMenu::ChooseMenu(Interface::Dtc* dtc, AvsMenus* avsMenus, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_dtc(dtc), m_avsMenus(avsMenus),
|
||||
m_ui(new Ui::ChooseMenuStruct)
|
||||
{
|
||||
Q_ASSERT(dtc);
|
||||
Q_ASSERT(avsMenus);
|
||||
Q_ASSERT(dtc);
|
||||
Q_ASSERT(avsMenus);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(dtc, &Interface::Dtc::menuStructChanged, this, &ChooseMenu::onMenuStructChanged);
|
||||
m_dtc->menuStructs([this](const MenuStruct & menu) { onMenuStructChanged(menu, DataModification::eAdded);});
|
||||
selectCurrent();
|
||||
connect(dtc, &Interface::Dtc::menuStructChanged, this, &ChooseMenu::onMenuStructChanged);
|
||||
m_dtc->menuStructs([this](const MenuStruct& menu) { onMenuStructChanged(menu, DataModification::eAdded); });
|
||||
selectCurrent();
|
||||
|
||||
connect(m_ui->cbAudio, &QComboBox::currentTextChanged, this, &ChooseMenu::slotChangesMade);
|
||||
connect(m_ui->cbVideo, &QComboBox::currentTextChanged, this, &ChooseMenu::slotChangesMade);
|
||||
connect(m_ui->cbAudio, &QComboBox::currentTextChanged, this, &ChooseMenu::slotChangesMade);
|
||||
connect(m_ui->cbVideo, &QComboBox::currentTextChanged, this, &ChooseMenu::slotChangesMade);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Choose_AV_Menu"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Choose_AV_Menu"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
ChooseMenu::~ChooseMenu()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ChooseMenu::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Choose AV Menu"));
|
||||
translate(m_ui, tr("Choose AV Menu"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ChooseMenu::onMenuStructChanged(const MenuStruct &data, DataModification modType)
|
||||
void ChooseMenu::onMenuStructChanged(const MenuStruct& data, DataModification modType)
|
||||
{
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
{
|
||||
if (data.isAudio())
|
||||
m_ui->cbAudio->addItem(QString::fromStdString(data.name()), data.id());
|
||||
else
|
||||
m_ui->cbVideo->addItem(QString::fromStdString(data.name()), data.id());
|
||||
break;
|
||||
}
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded: {
|
||||
if (data.isAudio())
|
||||
m_ui->cbAudio->addItem(QString::fromStdString(data.name()), data.id());
|
||||
else
|
||||
m_ui->cbVideo->addItem(QString::fromStdString(data.name()), data.id());
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
if (data.isAudio())
|
||||
{
|
||||
int index = m_ui->cbAudio->findData(data.id());
|
||||
m_ui->cbAudio->removeItem(index);
|
||||
case DataModification::eRemoved: {
|
||||
if (data.isAudio())
|
||||
{
|
||||
int index = m_ui->cbAudio->findData(data.id());
|
||||
m_ui->cbAudio->removeItem(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = m_ui->cbVideo->findData(data.id());
|
||||
m_ui->cbVideo->removeItem(index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DataModification::eModified:
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = m_ui->cbVideo->findData(data.id());
|
||||
m_ui->cbVideo->removeItem(index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DataModification::eModified:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ChooseMenu::apply()
|
||||
{
|
||||
int menuId = m_ui->cbAudio->currentData().toInt();
|
||||
INFO_LOG(m_logger) << "MenuId Audio: " << menuId;
|
||||
m_avsMenus->setAnnouncementMenu(menuId);
|
||||
int menuId = m_ui->cbAudio->currentData().toInt();
|
||||
INFO_LOG(m_logger) << "MenuId Audio: " << menuId;
|
||||
m_avsMenus->setAnnouncementMenu(menuId);
|
||||
|
||||
menuId = m_ui->cbVideo->currentData().toInt();
|
||||
INFO_LOG(m_logger) << "MenuId Video: " << menuId;
|
||||
m_avsMenus->setVideoMenu(menuId);
|
||||
|
||||
return true;
|
||||
menuId = m_ui->cbVideo->currentData().toInt();
|
||||
INFO_LOG(m_logger) << "MenuId Video: " << menuId;
|
||||
m_avsMenus->setVideoMenu(menuId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChooseMenu::selectCurrent()
|
||||
{
|
||||
selectMenu(m_avsMenus->currentAnnouncementMenu(), m_ui->cbAudio);
|
||||
selectMenu(m_avsMenus->currentVideoMenu(), m_ui->cbVideo);
|
||||
selectMenu(m_avsMenus->currentAnnouncementMenu(), m_ui->cbAudio);
|
||||
selectMenu(m_avsMenus->currentVideoMenu(), m_ui->cbVideo);
|
||||
}
|
||||
|
||||
void ChooseMenu::selectMenu(int menuId, QComboBox *cb)
|
||||
void ChooseMenu::selectMenu(int menuId, QComboBox* cb)
|
||||
{
|
||||
Q_ASSERT(cb);
|
||||
Q_ASSERT(cb);
|
||||
|
||||
if (menuId < 0)
|
||||
return;
|
||||
if (menuId < 0)
|
||||
return;
|
||||
|
||||
int index = cb->findData(menuId);
|
||||
if (index < 0)
|
||||
return;
|
||||
int index = cb->findData(menuId);
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
cb->setCurrentIndex(index);
|
||||
cb->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+17
-20
@@ -1,11 +1,9 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
enum class DataModification;
|
||||
|
||||
@@ -32,26 +30,25 @@ class AvsMenus;
|
||||
|
||||
class ChooseMenu : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChooseMenu(Interface::Dtc *dtc, AvsMenus *avsMenus, QWidget *parent = nullptr);
|
||||
~ChooseMenu() override;
|
||||
public:
|
||||
ChooseMenu(Interface::Dtc* dtc, AvsMenus* avsMenus, QWidget* parent = nullptr);
|
||||
~ChooseMenu() override;
|
||||
|
||||
private slots:
|
||||
void onMenuStructChanged(const MenuStruct &data, DataModification modType);
|
||||
private slots:
|
||||
void onMenuStructChanged(const MenuStruct& data, DataModification modType);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
bool apply() override final;
|
||||
void selectCurrent();
|
||||
void selectMenu(int menuId, QComboBox* cb);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
bool apply() override final;
|
||||
void selectCurrent();
|
||||
void selectMenu(int menuId, QComboBox *cb);
|
||||
|
||||
Interface::Dtc *m_dtc;
|
||||
AvsMenus *m_avsMenus;
|
||||
Ui::ChooseMenuStruct *m_ui;
|
||||
Interface::Dtc* m_dtc;
|
||||
AvsMenus* m_avsMenus;
|
||||
Ui::ChooseMenuStruct* m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+77
-101
@@ -1,152 +1,128 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_menu_edit.h"
|
||||
|
||||
#include "ui_avm_menu_edit.h"
|
||||
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
MenuEdit::MenuEdit(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ftc(nullptr)
|
||||
, m_ui(new Ui::MenuEdit)
|
||||
, m_availStreamsModel(nullptr)
|
||||
, m_usedStreamsModel(nullptr)
|
||||
, m_isAudio(false)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
MenuEdit::MenuEdit(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_ftc(nullptr),
|
||||
m_ui(new Ui::MenuEdit), m_availStreamsModel(nullptr), m_usedStreamsModel(nullptr), m_isAudio(false),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
}
|
||||
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
MenuEdit::~MenuEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void MenuEdit::retranslate()
|
||||
{
|
||||
if (m_isAudio)
|
||||
translate(m_ui, tr("Edit Audio Menu: %1").arg(m_name));
|
||||
else
|
||||
translate(m_ui, tr("Edit Video Menu: %1").arg(m_name));
|
||||
}
|
||||
if (m_isAudio)
|
||||
translate(m_ui, tr("Edit Audio Menu: %1").arg(m_name));
|
||||
else
|
||||
translate(m_ui, tr("Edit Video Menu: %1").arg(m_name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool MenuEdit::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
StreamNameMapping *streamNameMapping,
|
||||
const MenuStruct &ms)
|
||||
bool MenuEdit::init(LtsSession::LtsSession* session, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
StreamNameMapping* streamNameMapping, const MenuStruct& ms)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "MenuEdit::init()";
|
||||
DEBUG_LOG(m_logger) << "MenuEdit::init()";
|
||||
|
||||
if (!ftc || !dtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "MenuEdit::init() Invalid shared_ptr!";
|
||||
return false;
|
||||
}
|
||||
if (!ftc || !dtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "MenuEdit::init() Invalid shared_ptr!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ftc = ftc;
|
||||
m_isAudio = ms.isAudio();
|
||||
m_name = QString::fromStdString(ms.name());
|
||||
m_ftc = ftc;
|
||||
m_isAudio = ms.isAudio();
|
||||
m_name = QString::fromStdString(ms.name());
|
||||
|
||||
m_availStreamsModel = new AvailableStreamsModel(dtc, ismDtc, session, streamNameMapping, this, m_isAudio);
|
||||
m_ui->availTreeView->setModel(m_availStreamsModel);
|
||||
m_availStreamsModel = new AvailableStreamsModel(dtc, ismDtc, session, streamNameMapping, this, m_isAudio);
|
||||
m_ui->availTreeView->setModel(m_availStreamsModel);
|
||||
|
||||
m_usedStreamsModel = new UsedStreamsModel(dtc, ismDtc, ms, streamNameMapping, this);
|
||||
m_ui->menuTreeView->setModel(m_usedStreamsModel);
|
||||
m_ui->menuTreeView->expandAll();
|
||||
m_usedStreamsModel = new UsedStreamsModel(dtc, ismDtc, ms, streamNameMapping, this);
|
||||
m_ui->menuTreeView->setModel(m_usedStreamsModel);
|
||||
m_ui->menuTreeView->expandAll();
|
||||
|
||||
connect(m_ui->menuTreeView, &QTreeView::clicked,
|
||||
this, &MenuEdit::onStreamSelected);
|
||||
connect(m_usedStreamsModel, &UsedStreamsModel::modelDataChanged,
|
||||
this, &MenuEdit::slotChangesMade);
|
||||
connect(m_ui->menuTreeView, &QTreeView::clicked, this, &MenuEdit::onStreamSelected);
|
||||
connect(m_usedStreamsModel, &UsedStreamsModel::modelDataChanged, this, &MenuEdit::slotChangesMade);
|
||||
|
||||
connect(m_usedStreamsModel, &UsedStreamsModel::modelDataChanged,
|
||||
this, &MenuEdit::onModelDataChanged);
|
||||
connect(m_usedStreamsModel, &UsedStreamsModel::modelDataChanged, this, &MenuEdit::onModelDataChanged);
|
||||
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove);
|
||||
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Remove), &QPushButton::clicked,
|
||||
this, &MenuEdit::onRemove);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove);
|
||||
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Remove), &QPushButton::clicked, this, &MenuEdit::onRemove);
|
||||
|
||||
onStreamSelected(QModelIndex());
|
||||
onStreamSelected(QModelIndex());
|
||||
|
||||
|
||||
if (m_isAudio)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Audio_Menu"));
|
||||
else
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Video_Menu"));
|
||||
if (m_isAudio)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Audio_Menu"));
|
||||
else
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Video_Menu"));
|
||||
|
||||
if (ms.id() <= 0)
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Apply, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
if (ms.id() <= 0)
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Apply, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MenuEdit::apply()
|
||||
{
|
||||
MenuStruct ms = m_usedStreamsModel->getMenuStruct();
|
||||
ms.isAudio(m_isAudio);
|
||||
MenuStruct ms = m_usedStreamsModel->getMenuStruct();
|
||||
ms.isAudio(m_isAudio);
|
||||
|
||||
bool ret = m_requestHelper->startSingleRequest([this, ms]()
|
||||
{
|
||||
|
||||
return m_ftc->modifyMenuStructRequest(ms, this);
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
bool ret = m_requestHelper->startSingleRequest([this, ms]() { return m_ftc->modifyMenuStructRequest(ms, this); });
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void MenuEdit::onRemove()
|
||||
{
|
||||
|
||||
|
||||
if (0 == m_ui->menuTreeView->selectionModel()->selectedIndexes().size())
|
||||
{
|
||||
|
||||
QModelIndex index = m_ui->menuTreeView->currentIndex();
|
||||
if (!index.isValid())
|
||||
return;
|
||||
slotChangesMade();
|
||||
|
||||
DEBUG_LOG(m_logger) << "index row: " << index.row();
|
||||
m_usedStreamsModel->removeRow(index.row(), index.parent());
|
||||
}
|
||||
else
|
||||
{
|
||||
while (m_ui->menuTreeView->selectionModel()->selectedIndexes().size() > 0)
|
||||
if (0 == m_ui->menuTreeView->selectionModel()->selectedIndexes().size())
|
||||
{
|
||||
QModelIndex index = m_ui->menuTreeView->selectionModel()->selectedIndexes().front();
|
||||
if (!index.isValid())
|
||||
return;
|
||||
slotChangesMade();
|
||||
|
||||
DEBUG_LOG(m_logger) << "index row: " << index.row();
|
||||
m_usedStreamsModel->removeRow(index.row(), index.parent());
|
||||
QModelIndex index = m_ui->menuTreeView->currentIndex();
|
||||
if (!index.isValid())
|
||||
return;
|
||||
slotChangesMade();
|
||||
|
||||
DEBUG_LOG(m_logger) << "index row: " << index.row();
|
||||
m_usedStreamsModel->removeRow(index.row(), index.parent());
|
||||
}
|
||||
else
|
||||
{
|
||||
while (m_ui->menuTreeView->selectionModel()->selectedIndexes().size() > 0)
|
||||
{
|
||||
QModelIndex index = m_ui->menuTreeView->selectionModel()->selectedIndexes().front();
|
||||
if (!index.isValid())
|
||||
return;
|
||||
slotChangesMade();
|
||||
|
||||
DEBUG_LOG(m_logger) << "index row: " << index.row();
|
||||
m_usedStreamsModel->removeRow(index.row(), index.parent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MenuEdit::onModelDataChanged()
|
||||
{
|
||||
INFO_LOG(m_logger) << "onModelDataChanged";
|
||||
m_ui->menuTreeView->expandAll();
|
||||
INFO_LOG(m_logger) << "onModelDataChanged";
|
||||
m_ui->menuTreeView->expandAll();
|
||||
}
|
||||
|
||||
void MenuEdit::onStreamSelected(const QModelIndex &idx)
|
||||
void MenuEdit::onStreamSelected(const QModelIndex& idx)
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, idx.isValid());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, idx.isValid());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+35
-40
@@ -1,32 +1,28 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "avm_available_streams_model.h"
|
||||
#include "avm_used_streams_model.h"
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Services/AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Services/AudioVideoManagement/avm_ftc.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MenuEdit;
|
||||
}
|
||||
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace InfrastructureManagement
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
@@ -34,46 +30,45 @@ namespace AudioVideoManagement
|
||||
class StreamNameMapping;
|
||||
|
||||
class MenuEdit : public LtsWidgets::LtsDialog,
|
||||
protected AudioVideoManagement::Interface::Ftc::ModifyMenuStructReplyHandler
|
||||
protected AudioVideoManagement::Interface::Ftc::ModifyMenuStructReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MenuEdit(QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit MenuEdit(QWidget* parent = nullptr);
|
||||
|
||||
~MenuEdit();
|
||||
~MenuEdit();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
StreamNameMapping *streamNameMapping,
|
||||
const MenuStruct &ms);
|
||||
bool init(LtsSession::LtsSession* session, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
StreamNameMapping* streamNameMapping, const MenuStruct& ms);
|
||||
|
||||
|
||||
void onModifyMenuStructReply(const Core::FunctionReplyObject &replyObject) override { m_requestHelper->requestReply(replyObject); }
|
||||
void onModifyMenuStructReply(const Core::FunctionReplyObject& replyObject) override
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
public slots:
|
||||
void onRemove();
|
||||
void onModelDataChanged();
|
||||
void onStreamSelected(const QModelIndex &idx);
|
||||
public slots:
|
||||
void onRemove();
|
||||
void onModelDataChanged();
|
||||
void onStreamSelected(const QModelIndex& idx);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
bool apply() override final;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
bool apply() override final;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_ftc;
|
||||
Ui::MenuEdit* m_ui;
|
||||
AvailableStreamsModel* m_availStreamsModel;
|
||||
UsedStreamsModel* m_usedStreamsModel;
|
||||
bool m_isAudio;
|
||||
QString m_name;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_ftc;
|
||||
Ui::MenuEdit *m_ui;
|
||||
AvailableStreamsModel *m_availStreamsModel;
|
||||
UsedStreamsModel *m_usedStreamsModel;
|
||||
bool m_isAudio;
|
||||
QString m_name;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
AudioVideoManagement::MenuStruct m_lastDdsMenuStruct;
|
||||
AudioVideoManagement::MenuStruct m_modifiedMenuStruct;
|
||||
AudioVideoManagement::MenuStruct m_lastDdsMenuStruct;
|
||||
AudioVideoManagement::MenuStruct m_modifiedMenuStruct;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+126
-162
@@ -1,245 +1,209 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_menu_edit_view.h"
|
||||
#include "ui_avm_menu_edit_view.h"
|
||||
|
||||
#include "avm_menu_edit.h"
|
||||
#include "avm_new_menu_struct.h"
|
||||
#include "ui_avm_menu_edit_view.h"
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session_manager.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
MenuEditView::MenuEditView(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_model(nullptr)
|
||||
, m_isAudio(false)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_session(session)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::MenuEditView)
|
||||
MenuEditView::MenuEditView(const QString& menuGroup, LtsSession::LtsSession* session, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_menuGroup(menuGroup), m_model(nullptr),
|
||||
m_isAudio(false), m_dtc(nullptr), m_ftc(nullptr), m_session(session),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this)), m_ui(new Ui::MenuEditView)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &MenuEditView::onSelectionChanged);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &MenuEditView::onSelectionChanged);
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &MenuEditView::onEditMenuStruct);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &MenuEditView::onEditMenuStruct);
|
||||
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &MenuEditView::onEditMenuStruct);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &MenuEditView::onRemoveMenuStruct);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &MenuEditView::onAddMenuStruct);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &MenuEditView::onPrint);
|
||||
|
||||
}
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &MenuEditView::onEditMenuStruct);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &MenuEditView::onRemoveMenuStruct);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &MenuEditView::onAddMenuStruct);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &MenuEditView::onPrint);
|
||||
}
|
||||
|
||||
MenuEditView::~MenuEditView()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void MenuEditView::retranslate()
|
||||
{
|
||||
if (m_isAudio)
|
||||
translate(m_ui, tr("Audio Menu"));
|
||||
else
|
||||
translate(m_ui, tr("Video Menu"));
|
||||
}
|
||||
if (m_isAudio)
|
||||
translate(m_ui, tr("Audio Menu"));
|
||||
else
|
||||
translate(m_ui, tr("Video Menu"));
|
||||
}
|
||||
|
||||
|
||||
bool MenuEditView::init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
StreamNameMapping *streamNameMapping,
|
||||
bool isAudio)
|
||||
bool MenuEditView::init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
StreamNameMapping* streamNameMapping, bool isAudio)
|
||||
{
|
||||
Q_ASSERT(dtc);
|
||||
Q_ASSERT(ftc);
|
||||
Q_ASSERT(ismDtc);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
Q_ASSERT(dtc);
|
||||
Q_ASSERT(ftc);
|
||||
Q_ASSERT(ismDtc);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_ismDtc = ismDtc;
|
||||
m_streamNameMapping = streamNameMapping;
|
||||
m_model = new MenuViewModel(this);
|
||||
m_model->initModel(m_dtc, isAudio);
|
||||
m_ui->widget->setModel(m_model);
|
||||
m_isAudio = isAudio;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_ismDtc = ismDtc;
|
||||
m_streamNameMapping = streamNameMapping;
|
||||
m_model = new MenuViewModel(this);
|
||||
m_model->initModel(m_dtc, isAudio);
|
||||
m_ui->widget->setModel(m_model);
|
||||
m_isAudio = isAudio;
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(0);
|
||||
m_ui->widget->hideColumn(0);
|
||||
#endif
|
||||
|
||||
m_ui->widget->setSortIndicator(1, Qt::AscendingOrder);
|
||||
m_ui->widget->setSortIndicator(1, Qt::AscendingOrder);
|
||||
|
||||
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&MenuEditView::onImportButtonClicked,
|
||||
&MenuEditView::onExportButtonClicked);
|
||||
m_buttonBox->connectLibraryButton(this, &MenuEditView::onImportButtonClicked, &MenuEditView::onExportButtonClicked);
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
if (m_isAudio)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Audio_Menu"));
|
||||
else
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Video_Menu"));
|
||||
|
||||
return true;
|
||||
}
|
||||
if (m_isAudio)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Audio_Menu"));
|
||||
else
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Video_Menu"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MenuEditView::onSelectionChanged()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
int row = idx.row();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, (row >= 0));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, (row >= 0));
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
int row = idx.row();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, (row >= 0));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, (row >= 0));
|
||||
}
|
||||
|
||||
void MenuEditView::onAddMenuStruct()
|
||||
{
|
||||
NewMenuStruct *newDialog = new NewMenuStruct(this);
|
||||
NewMenuStruct* newDialog = new NewMenuStruct(this);
|
||||
|
||||
connect(newDialog, &NewMenuStruct::newName, this, [this](const QString & name)
|
||||
{
|
||||
MenuStruct ms;
|
||||
ms.name(name.toStdString());
|
||||
ms.isAudio(m_isAudio);
|
||||
MenuEdit *dialog = new MenuEdit(this);
|
||||
dialog->init(m_session, m_dtc, m_ftc, m_ismDtc, m_streamNameMapping, ms);
|
||||
connect(newDialog, &NewMenuStruct::newName, this, [this](const QString& name) {
|
||||
MenuStruct ms;
|
||||
ms.name(name.toStdString());
|
||||
ms.isAudio(m_isAudio);
|
||||
MenuEdit* dialog = new MenuEdit(this);
|
||||
dialog->init(m_session, m_dtc, m_ftc, m_ismDtc, m_streamNameMapping, ms);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("avmNewMenu") + name, LtsWidgets::LayoutArea::eDialogTab);
|
||||
});
|
||||
newDialog->show();
|
||||
|
||||
connect(newDialog, &NewMenuStruct::accepted, newDialog, &NewMenuStruct::deleteLater);
|
||||
|
||||
}
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("avmNewMenu") + name, LtsWidgets::LayoutArea::eDialogTab);
|
||||
});
|
||||
newDialog->show();
|
||||
|
||||
connect(newDialog, &NewMenuStruct::accepted, newDialog, &NewMenuStruct::deleteLater);
|
||||
}
|
||||
|
||||
void MenuEditView::onEditMenuStruct()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
AudioVideoManagement::MenuStruct ms = m_model->getRowData(row);
|
||||
ms.isAudio(m_isAudio);
|
||||
AudioVideoManagement::MenuStruct ms = m_model->getRowData(row);
|
||||
ms.isAudio(m_isAudio);
|
||||
|
||||
DEBUG_LOG(m_logger) << "---onEditMenuStruct () "
|
||||
<< " id: " << ms.id()
|
||||
<< " name: " << ms.name();
|
||||
DEBUG_LOG(m_logger) << "---onEditMenuStruct () "
|
||||
<< " id: " << ms.id() << " name: " << ms.name();
|
||||
|
||||
MenuEdit *dialog = new MenuEdit(this);
|
||||
dialog->init(m_session, m_dtc, m_ftc, m_ismDtc, m_streamNameMapping, ms);
|
||||
MenuEdit* dialog = new MenuEdit(this);
|
||||
dialog->init(m_session, m_dtc, m_ftc, m_ismDtc, m_streamNameMapping, ms);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("avmMenuEdit") + QString::number(ms.id()), LtsWidgets::LayoutArea::eDialogTab);
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("avmMenuEdit") + QString::number(ms.id()),
|
||||
LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
|
||||
void MenuEditView::onRemoveMenuStruct()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
const AudioVideoManagement::MenuStruct ms = m_model->getRowData(idx.row());
|
||||
const Core::RemoveElementRequest req(ms.id());
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->removeMenuStructRequest(req, this);
|
||||
});
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
const AudioVideoManagement::MenuStruct ms = m_model->getRowData(idx.row());
|
||||
const Core::RemoveElementRequest req(ms.id());
|
||||
m_requestHelper->startSingleRequest([req, this]() { return m_ftc->removeMenuStructRequest(req, this); });
|
||||
|
||||
if (m_model->rowCount() == 0)
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
}
|
||||
if (m_model->rowCount() == 0)
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
}
|
||||
}
|
||||
|
||||
void MenuEditView::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
}
|
||||
|
||||
void MenuEditView::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MenuEditView::onExportButtonClicked()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
QByteArray byteArray = m_model->modelToJson(row);
|
||||
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
QByteArray byteArray = m_model->modelToJson(row);
|
||||
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
}
|
||||
|
||||
void MenuEditView::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(), FileManagement::toString(FileManagement::XmlType::AVMMenuEditView));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMMenuEditView)))
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(),
|
||||
FileManagement::toString(FileManagement::XmlType::AVMMenuEditView));
|
||||
if (fileId > 0)
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("Invalid xml file content"),
|
||||
windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes,
|
||||
texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QVector<AudioVideoManagement::MenuStruct> menuStructs = m_model->jsonToMenuStructs(content);
|
||||
for (const AudioVideoManagement::MenuStruct &request : menuStructs)
|
||||
{
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMMenuEditView)))
|
||||
{
|
||||
return m_ftc->modifyMenuStructRequest(request, this);
|
||||
});
|
||||
}
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Invalid xml file content"), windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal, LtsWidgets::Button::Yes, texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QVector<AudioVideoManagement::MenuStruct> menuStructs = m_model->jsonToMenuStructs(content);
|
||||
for (const AudioVideoManagement::MenuStruct& request : menuStructs)
|
||||
{
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_ftc->modifyMenuStructRequest(request, this); });
|
||||
}
|
||||
}
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
}
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+47
-45
@@ -1,31 +1,28 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "avm_menu_view_model.h"
|
||||
|
||||
#include <Services/AudioVideoManagement/avm_dtc.h>
|
||||
#include <Services/AudioVideoManagement/avm_ftc.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <Services/AudioVideoManagement/avm_dtc.h>
|
||||
#include <Services/AudioVideoManagement/avm_ftc.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MenuEditView;
|
||||
}
|
||||
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace InfrastructureManagement
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
@@ -33,51 +30,56 @@ namespace AudioVideoManagement
|
||||
class StreamNameMapping;
|
||||
|
||||
class MenuEditView : public LtsWidgets::LtsDialog,
|
||||
protected AudioVideoManagement::Interface::Ftc::ModifyMenuStructReplyHandler,
|
||||
protected AudioVideoManagement::Interface::Ftc::RemoveMenuStructReplyHandler
|
||||
protected AudioVideoManagement::Interface::Ftc::ModifyMenuStructReplyHandler,
|
||||
protected AudioVideoManagement::Interface::Ftc::RemoveMenuStructReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MenuEditView(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~MenuEditView();
|
||||
bool init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
StreamNameMapping *streamNameMapping,
|
||||
bool isAudio);
|
||||
public:
|
||||
explicit MenuEditView(const QString& menuGroup, LtsSession::LtsSession* session, QWidget* parent = nullptr);
|
||||
~MenuEditView();
|
||||
bool init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
StreamNameMapping* streamNameMapping, bool isAudio);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onAddMenuStruct();
|
||||
void onEditMenuStruct();
|
||||
void onRemoveMenuStruct();
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onAddMenuStruct();
|
||||
void onEditMenuStruct();
|
||||
void onRemoveMenuStruct();
|
||||
void onModifyMenuStructReply(const Core::FunctionReplyObject& replyObject) override final
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void onModifyMenuStructReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onRemoveMenuStructReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onRemoveMenuStructReply(const Core::FunctionReplyObject& replyObject) override final
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void onPrint();
|
||||
void tableColumnOrganiserSetting() override;
|
||||
void onPrint();
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private slots:
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
private slots:
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
private:
|
||||
QString m_menuGroup;
|
||||
MenuViewModel *m_model;
|
||||
bool m_isAudio;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
StreamNameMapping *m_streamNameMapping{nullptr};
|
||||
LtsSession::LtsSession *m_session;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
Ui::MenuEditView *m_ui;
|
||||
private:
|
||||
QString m_menuGroup;
|
||||
MenuViewModel* m_model;
|
||||
bool m_isAudio;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
StreamNameMapping* m_streamNameMapping{nullptr};
|
||||
LtsSession::LtsSession* m_session;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
Ui::MenuEditView* m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+99
-113
@@ -1,150 +1,136 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_menu_view_model.h"
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
MenuViewModel::MenuViewModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AudioVideoManagement::MenuStruct>({tr("Id"),
|
||||
tr("Name")},
|
||||
parent)
|
||||
, m_isAudio(false)
|
||||
, m_dtc(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
bool MenuViewModel::initModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc, bool isAudio)
|
||||
MenuViewModel::MenuViewModel(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AudioVideoManagement::MenuStruct>({tr("Id"), tr("Name")}, parent),
|
||||
m_isAudio(false), m_dtc(nullptr)
|
||||
{
|
||||
m_isAudio = isAudio;
|
||||
m_dtc = dtc;
|
||||
|
||||
connect(m_dtc.get(), &AudioVideoManagement::Interface::Dtc::menuStructChanged,
|
||||
this, &MenuViewModel::onDataChanged);
|
||||
|
||||
|
||||
m_dtc->menuStructs([this](const AudioVideoManagement::MenuStruct &ms) { insertRow(ms); });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVariant MenuViewModel::data(const QModelIndex &index, int role) const
|
||||
bool MenuViewModel::initModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc, bool isAudio)
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
m_isAudio = isAudio;
|
||||
m_dtc = dtc;
|
||||
|
||||
connect(m_dtc.get(), &AudioVideoManagement::Interface::Dtc::menuStructChanged, this, &MenuViewModel::onDataChanged);
|
||||
|
||||
m_dtc->menuStructs([this](const AudioVideoManagement::MenuStruct& ms) { insertRow(ms); });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant MenuViewModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const AudioVideoManagement::MenuStruct& ms = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
return ms.id();
|
||||
case 1:
|
||||
return QString::fromStdString(ms.name());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
||||
const AudioVideoManagement::MenuStruct &ms = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
return ms.id();
|
||||
case 1:
|
||||
return QString::fromStdString(ms.name());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool MenuViewModel::isFiltered(const MenuStruct &data, DataModification modType) const
|
||||
bool MenuViewModel::isFiltered(const MenuStruct& data, DataModification modType) const
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
if (data.isAudio() != m_isAudio)
|
||||
return true;
|
||||
if (data.isDefault())
|
||||
return true;
|
||||
return false;
|
||||
Q_UNUSED(modType);
|
||||
if (data.isAudio() != m_isAudio)
|
||||
return true;
|
||||
if (data.isDefault())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray MenuViewModel::modelToJson(int row) const
|
||||
{
|
||||
if (row < 0 || row >= m_vecData.size())
|
||||
return QByteArray("{}");
|
||||
if (row < 0 || row >= m_vecData.size())
|
||||
return QByteArray("{}");
|
||||
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AVMMenuEditView);
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AVMMenuEditView);
|
||||
|
||||
DEBUG_LOG(m_logger) << "row =" << ": " << row;
|
||||
const AudioVideoManagement::MenuStruct &menuStruct = m_vecData.at(row);
|
||||
DEBUG_LOG(m_logger) << "row =" << ": " << row;
|
||||
const AudioVideoManagement::MenuStruct& menuStruct = m_vecData.at(row);
|
||||
|
||||
obj[QStringLiteral("id")] = 0;
|
||||
obj[QStringLiteral("isAudio")] = menuStruct.isAudio();
|
||||
obj[QStringLiteral("isDefault")] = menuStruct.isDefault();
|
||||
obj[QStringLiteral("name")] = QString::fromStdString(menuStruct.name());
|
||||
obj[QStringLiteral("id")] = 0;
|
||||
obj[QStringLiteral("isAudio")] = menuStruct.isAudio();
|
||||
obj[QStringLiteral("isDefault")] = menuStruct.isDefault();
|
||||
obj[QStringLiteral("name")] = QString::fromStdString(menuStruct.name());
|
||||
|
||||
|
||||
QJsonArray arrData;
|
||||
for (const AudioVideoManagement::AvMenuEntry &avMenuEntry : menuStruct.menuEntries())
|
||||
{
|
||||
QJsonObject innerData;
|
||||
innerData[QStringLiteral("id")] = avMenuEntry.id();
|
||||
innerData[QStringLiteral("isGroup")] = avMenuEntry.isGroup();
|
||||
if (avMenuEntry.mountingPointId().is_set())
|
||||
innerData[QStringLiteral("mountingPointId")] = avMenuEntry.mountingPointId().get();
|
||||
if (avMenuEntry.name().is_set())
|
||||
innerData[QStringLiteral("name")] = QString::fromStdString(avMenuEntry.name().get());
|
||||
innerData[QStringLiteral("parentId")] = avMenuEntry.parentId();
|
||||
innerData[QStringLiteral("rowId")] = avMenuEntry.rowId();
|
||||
QJsonArray arrData;
|
||||
for (const AudioVideoManagement::AvMenuEntry& avMenuEntry : menuStruct.menuEntries())
|
||||
{
|
||||
QJsonObject innerData;
|
||||
innerData[QStringLiteral("id")] = avMenuEntry.id();
|
||||
innerData[QStringLiteral("isGroup")] = avMenuEntry.isGroup();
|
||||
if (avMenuEntry.mountingPointId().is_set())
|
||||
innerData[QStringLiteral("mountingPointId")] = avMenuEntry.mountingPointId().get();
|
||||
if (avMenuEntry.name().is_set())
|
||||
innerData[QStringLiteral("name")] = QString::fromStdString(avMenuEntry.name().get());
|
||||
innerData[QStringLiteral("parentId")] = avMenuEntry.parentId();
|
||||
innerData[QStringLiteral("rowId")] = avMenuEntry.rowId();
|
||||
|
||||
arrData += innerData;
|
||||
}
|
||||
obj[QStringLiteral("menuEntries")] = arrData;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
arrData += innerData;
|
||||
}
|
||||
obj[QStringLiteral("menuEntries")] = arrData;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
QVector<AudioVideoManagement::MenuStruct> MenuViewModel::jsonToMenuStructs(const QByteArray &content) const
|
||||
QVector<AudioVideoManagement::MenuStruct> MenuViewModel::jsonToMenuStructs(const QByteArray& content) const
|
||||
{
|
||||
|
||||
QVector<AudioVideoManagement::MenuStruct> result;
|
||||
AudioVideoManagement::MenuStruct menuStruct;
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject obj(doc.object());
|
||||
menuStruct.id(0);
|
||||
menuStruct.isAudio(obj[QStringLiteral("isAudio")].toBool());
|
||||
menuStruct.isDefault(obj[QStringLiteral("isDefault")].toBool());
|
||||
menuStruct.name(obj[QStringLiteral("name")].toString().toStdString());
|
||||
|
||||
|
||||
QVector<AudioVideoManagement::MenuStruct> result;
|
||||
AudioVideoManagement::MenuStruct menuStruct;
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject obj(doc.object());
|
||||
menuStruct.id(0);
|
||||
menuStruct.isAudio(obj[QStringLiteral("isAudio")].toBool());
|
||||
menuStruct.isDefault(obj[QStringLiteral("isDefault")].toBool());
|
||||
menuStruct.name(obj[QStringLiteral("name")].toString().toStdString());
|
||||
|
||||
const QJsonArray arrEntry(obj.value(QStringLiteral("menuEntries")).toArray());
|
||||
menuStruct.menuEntries().resize(arrEntry.size());
|
||||
INFO_LOG(m_logger) << "arrEntry.size()=" << arrEntry.size();
|
||||
for (int j = 0; j < arrEntry.size(); ++j)
|
||||
{
|
||||
const QJsonObject objEntry(arrEntry.at(j).toObject());
|
||||
AudioVideoManagement::AvMenuEntry avMenuEntry;
|
||||
const QJsonArray arrEntry(obj.value(QStringLiteral("menuEntries")).toArray());
|
||||
menuStruct.menuEntries().resize(arrEntry.size());
|
||||
INFO_LOG(m_logger) << "arrEntry.size()=" << arrEntry.size();
|
||||
for (int j = 0; j < arrEntry.size(); ++j)
|
||||
{
|
||||
const QJsonObject objEntry(arrEntry.at(j).toObject());
|
||||
AudioVideoManagement::AvMenuEntry avMenuEntry;
|
||||
|
||||
avMenuEntry.id(-10000000 + objEntry[QStringLiteral("id")].toInt());
|
||||
avMenuEntry.isGroup(objEntry[QStringLiteral("isGroup")].toBool());
|
||||
avMenuEntry.mountingPointId(objEntry[QStringLiteral("mountingPointId")].toInt());
|
||||
if (objEntry.contains(QStringLiteral("name")))
|
||||
avMenuEntry.name().set(objEntry[QStringLiteral("name")].toString().toStdString());
|
||||
if (objEntry[QStringLiteral("isGroup")].toBool())
|
||||
avMenuEntry.parentId(0);
|
||||
else
|
||||
avMenuEntry.parentId(-10000000 + objEntry[QStringLiteral("parentId")].toInt());
|
||||
avMenuEntry.rowId(objEntry[QStringLiteral("rowId")].toInt());
|
||||
avMenuEntry.id(-10000000 + objEntry[QStringLiteral("id")].toInt());
|
||||
avMenuEntry.isGroup(objEntry[QStringLiteral("isGroup")].toBool());
|
||||
avMenuEntry.mountingPointId(objEntry[QStringLiteral("mountingPointId")].toInt());
|
||||
if (objEntry.contains(QStringLiteral("name")))
|
||||
avMenuEntry.name().set(objEntry[QStringLiteral("name")].toString().toStdString());
|
||||
if (objEntry[QStringLiteral("isGroup")].toBool())
|
||||
avMenuEntry.parentId(0);
|
||||
else
|
||||
avMenuEntry.parentId(-10000000 + objEntry[QStringLiteral("parentId")].toInt());
|
||||
avMenuEntry.rowId(objEntry[QStringLiteral("rowId")].toInt());
|
||||
|
||||
menuStruct.menuEntries()[j] = avMenuEntry;
|
||||
}
|
||||
|
||||
result.append(menuStruct);
|
||||
menuStruct.menuEntries()[j] = avMenuEntry;
|
||||
}
|
||||
|
||||
return result;
|
||||
result.append(menuStruct);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
qt6-after/qt6-migrated-legatus/Lts/Plugins/AudioVideoManagement/Gui/AVMenuEdit/avm_menu_view_model.h
Executable → Regular
+15
-19
@@ -1,35 +1,31 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
class MenuViewModel final : public LtsWidgets::LtsAbstractTableModel<AudioVideoManagement::MenuStruct>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MenuViewModel(QObject *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MenuViewModel(QObject* parent = nullptr);
|
||||
|
||||
bool initModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc, bool isAudio);
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
QByteArray modelToJson(int row) const;
|
||||
QVector<AudioVideoManagement::MenuStruct> jsonToMenuStructs(const QByteArray &content) const;
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool isFiltered(const MenuStruct &data, DataModification modType) const override final;
|
||||
bool initModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc, bool isAudio);
|
||||
QVariant data(const QModelIndex&, int) const override final;
|
||||
QByteArray modelToJson(int row) const;
|
||||
QVector<AudioVideoManagement::MenuStruct> jsonToMenuStructs(const QByteArray& content) const;
|
||||
|
||||
private:
|
||||
bool m_isAudio;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_dtc;
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool isFiltered(const MenuStruct& data, DataModification modType) const override final;
|
||||
|
||||
private:
|
||||
bool m_isAudio;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_dtc;
|
||||
};
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
qt6-after/qt6-migrated-legatus/Lts/Plugins/AudioVideoManagement/Gui/AVMenuEdit/avm_new_menu_struct.h
Executable → Regular
+13
-15
@@ -1,37 +1,35 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class NewMenuStruct;
|
||||
}
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class NewMenuStruct : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NewMenuStruct(QWidget *parent = nullptr);
|
||||
~NewMenuStruct();
|
||||
public:
|
||||
explicit NewMenuStruct(QWidget* parent = nullptr);
|
||||
~NewMenuStruct();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onSetNewName();
|
||||
private Q_SLOTS:
|
||||
void onSetNewName();
|
||||
|
||||
Q_SIGNALS:
|
||||
void newName(const QString &);
|
||||
Q_SIGNALS:
|
||||
void newName(const QString&);
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
Ui::NewMenuStruct *m_ui;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
Ui::NewMenuStruct* m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
qt6-after/qt6-migrated-legatus/Lts/Plugins/AudioVideoManagement/Gui/AVMenuEdit/avm_playback_menu.cpp
Executable → Regular
+1039
-1179
File diff suppressed because it is too large.
Load diff
Executable → Regular
+143
-149
@@ -1,33 +1,31 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ui_avm_playback_menu.h"
|
||||
#include "interval_model.h"
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
#include "ui_avm_playback_menu.h"
|
||||
|
||||
#include <AudioVideoManagement/Shared/playback_app.h>
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <MarkerManagement/mrk_ftc.h>
|
||||
#include <QString>
|
||||
#include <boost/optional.hpp>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace MarkerManagement
|
||||
{
|
||||
class MarkerManagementDialogModel;
|
||||
class MarkerSortFilterProxyModel;
|
||||
class ForeignDataInterface;
|
||||
}
|
||||
} // namespace MarkerManagement
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
@@ -37,180 +35,176 @@ class AvsSequence;
|
||||
class StreamNameMapping;
|
||||
class AvmPlaybackMenu;
|
||||
|
||||
|
||||
class QueryTimeline : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
friend class AvmPlaybackMenu;
|
||||
Q_OBJECT
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
friend class AvmPlaybackMenu;
|
||||
|
||||
QueryTimeline(const AvaStream &stream, const AvaTimePoint &start, const AvaTimePoint &end, AvaControl *control);
|
||||
QueryTimeline(const AvaStream& stream, const AvaTimePoint& start, const AvaTimePoint& end, AvaControl* control);
|
||||
|
||||
AvaControl *m_avaCtrl { nullptr };
|
||||
AvaControl* m_avaCtrl{nullptr};
|
||||
|
||||
private slots:
|
||||
|
||||
private slots:
|
||||
|
||||
signals:
|
||||
void signalTimelineComplete(const AvaTimeline &timeline);
|
||||
signals:
|
||||
void signalTimelineComplete(const AvaTimeline& timeline);
|
||||
};
|
||||
|
||||
|
||||
class AvmPlaybackMenu : public QWidget,
|
||||
protected MarkerManagement::Interface::Ftc::MarkerModifyReplyHandler
|
||||
class AvmPlaybackMenu : public QWidget, protected MarkerManagement::Interface::Ftc::MarkerModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AvmPlaybackMenu(QWidget *parent = nullptr);
|
||||
~AvmPlaybackMenu();
|
||||
public:
|
||||
explicit AvmPlaybackMenu(QWidget* parent = nullptr);
|
||||
~AvmPlaybackMenu();
|
||||
|
||||
bool init(LtsSession::LtsSession *session, AvaSession *avaSession, PlaybackAppHandle &&appHandle,
|
||||
StreamNameMapping* streamNameMapping, bool isAudio, bool insideTopicEditor,
|
||||
const boost::optional<QString> &streamName = boost::none,
|
||||
const boost::optional<AvaTimePoint> &startTime = boost::none, bool setInitialSearchContentMarkers = true);
|
||||
bool init(LtsSession::LtsSession* session, AvaSession* avaSession, PlaybackAppHandle&& appHandle,
|
||||
StreamNameMapping* streamNameMapping, bool isAudio, bool insideTopicEditor,
|
||||
const boost::optional<QString>& streamName = boost::none,
|
||||
const boost::optional<AvaTimePoint>& startTime = boost::none, bool setInitialSearchContentMarkers = true);
|
||||
|
||||
void setPlaybackPreset(const QString &streamName, const AvaTimePoint &startTime, bool autostartPresetAfterInit);
|
||||
void setMarkerPreset(int markerId, bool autostartPresetAfterInit);
|
||||
void setPlaybackPreset(const QString& streamName, const AvaTimePoint& startTime, bool autostartPresetAfterInit);
|
||||
void setMarkerPreset(int markerId, bool autostartPresetAfterInit);
|
||||
|
||||
QueryTimeline *queryTimeline(const AvaTimePoint &start, const AvaTimePoint &end);
|
||||
QueryTimeline* queryTimeline(const AvaTimePoint& start, const AvaTimePoint& end);
|
||||
|
||||
void onMarkerModifyReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onMarkerModifyReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
|
||||
void retranslate();
|
||||
void retranslate();
|
||||
|
||||
|
||||
void setStreamTime(qint64 time);
|
||||
void hideStreamSelection();
|
||||
qint64 getCurrentTime() const;
|
||||
AvaSpeed getSpeed() const;
|
||||
void setSpeed(AvaSpeed newSpeed);
|
||||
int getVolume() const;
|
||||
void setVolume(int newVolume);
|
||||
void setStreamByName(const QString &name);
|
||||
|
||||
QString getInternalStreamName() const;
|
||||
void setStreamName(const QString &internalStreamName);
|
||||
bool getSkipPause() const;
|
||||
void setSkipPause(bool bSkip);
|
||||
void startPlayback(bool usePresets = false);
|
||||
void setSavedPos(qint64 msecs);
|
||||
int currentOffset() const { return m_currentOffset; }
|
||||
void selectMarker(const MarkerManagement::Marker &marker);
|
||||
void selectMarker(int markerId);
|
||||
void setStreamTime(qint64 time);
|
||||
void hideStreamSelection();
|
||||
qint64 getCurrentTime() const;
|
||||
AvaSpeed getSpeed() const;
|
||||
void setSpeed(AvaSpeed newSpeed);
|
||||
int getVolume() const;
|
||||
void setVolume(int newVolume);
|
||||
void setStreamByName(const QString& name);
|
||||
|
||||
signals:
|
||||
void signalSetOverlay(QWidget *widget);
|
||||
void signalUnsetOverlay();
|
||||
QString getInternalStreamName() const;
|
||||
void setStreamName(const QString& internalStreamName);
|
||||
bool getSkipPause() const;
|
||||
void setSkipPause(bool bSkip);
|
||||
void startPlayback(bool usePresets = false);
|
||||
void setSavedPos(qint64 msecs);
|
||||
|
||||
void setTopicButtonStates(bool enable);
|
||||
void markerSelected(const QString &description);
|
||||
int currentOffset() const
|
||||
{
|
||||
return m_currentOffset;
|
||||
}
|
||||
|
||||
|
||||
void signalSetStart(qint64 start);
|
||||
void signalSetEnd(qint64 end);
|
||||
void signalCurrentStreamChanged(const QString &displayName);
|
||||
void signalTimezoneChanged(int timezoneHoursOffset);
|
||||
void selectMarker(const MarkerManagement::Marker& marker);
|
||||
void selectMarker(int markerId);
|
||||
|
||||
public slots:
|
||||
void onStreamSelectionChanged(const QVector<AvaStream> &selectedStreams);
|
||||
signals:
|
||||
void signalSetOverlay(QWidget* widget);
|
||||
void signalUnsetOverlay();
|
||||
|
||||
private slots:
|
||||
void onSessionEstablished();
|
||||
void onDisconnected();
|
||||
void setTopicButtonStates(bool enable);
|
||||
void markerSelected(const QString& description);
|
||||
|
||||
void onStreamListReceived(const QVector<AvaStream> &streams);
|
||||
void onTimelineComplete(const AvaTimeline &timeline);
|
||||
void onStreamPositionReceived(const QString &dialogId, const QString &streamName, AvaTimePoint);
|
||||
void onVolumeReceived(AvaVolume db);
|
||||
void onCommandQueueEmpty();
|
||||
void signalSetStart(qint64 start);
|
||||
void signalSetEnd(qint64 end);
|
||||
void signalCurrentStreamChanged(const QString& displayName);
|
||||
void signalTimezoneChanged(int timezoneHoursOffset);
|
||||
|
||||
void onUiTimeChanged(AvaTimePoint t);
|
||||
void onIntervalActivated(const QModelIndex &index);
|
||||
void onMarkerClicked(const QModelIndex &index);
|
||||
void onSetMarkerClicked();
|
||||
void onStartClicked();
|
||||
void onPauseClicked();
|
||||
void onStopClicked();
|
||||
void onSkipPauseClicked();
|
||||
void onAllStreams();
|
||||
void onIntervalBackwardClicked();
|
||||
void onIntervalForwardClicked();
|
||||
void onSpeedChanged();
|
||||
void onVolumeChanged(int percent);
|
||||
void onCurrentIntervalChanged(bool hasPreviousInterval, bool hasNextInterval, const QModelIndex &rowIndex);
|
||||
void onStreamSelected();
|
||||
void onMarkerStreamSelected();
|
||||
void onStreamNameMappingChanged();
|
||||
void onAddStreamClip();
|
||||
void onAddStreamMarker();
|
||||
void onRemoveSelectedStreams();
|
||||
void onTabChanged(int index);
|
||||
void onPauseFromPlaybackApp();
|
||||
void onResumeFromPlaybackApp();
|
||||
public slots:
|
||||
void onStreamSelectionChanged(const QVector<AvaStream>& selectedStreams);
|
||||
|
||||
private slots:
|
||||
void onSessionEstablished();
|
||||
void onDisconnected();
|
||||
|
||||
private:
|
||||
enum class ButtonStates
|
||||
{
|
||||
AllOff,
|
||||
Started,
|
||||
Paused,
|
||||
Stopped
|
||||
};
|
||||
void onStreamListReceived(const QVector<AvaStream>& streams);
|
||||
void onTimelineComplete(const AvaTimeline& timeline);
|
||||
void onStreamPositionReceived(const QString& dialogId, const QString& streamName, AvaTimePoint);
|
||||
void onVolumeReceived(AvaVolume db);
|
||||
void onCommandQueueEmpty();
|
||||
|
||||
void processPresets();
|
||||
void preselectStream(const QString &fallbackInternalStreamName);
|
||||
AvaSpeed currentSpeed() const;
|
||||
void setButtonStates(ButtonStates);
|
||||
void enableAll(bool enabled = true);
|
||||
void disableAll() { enableAll(false); }
|
||||
bool trySelectedStreams();
|
||||
void addStream(QComboBox *cb);
|
||||
void onUiTimeChanged(AvaTimePoint t);
|
||||
void onIntervalActivated(const QModelIndex& index);
|
||||
void onMarkerClicked(const QModelIndex& index);
|
||||
void onSetMarkerClicked();
|
||||
void onStartClicked();
|
||||
void onPauseClicked();
|
||||
void onStopClicked();
|
||||
void onSkipPauseClicked();
|
||||
void onAllStreams();
|
||||
void onIntervalBackwardClicked();
|
||||
void onIntervalForwardClicked();
|
||||
void onSpeedChanged();
|
||||
void onVolumeChanged(int percent);
|
||||
void onCurrentIntervalChanged(bool hasPreviousInterval, bool hasNextInterval, const QModelIndex& rowIndex);
|
||||
void onStreamSelected();
|
||||
void onMarkerStreamSelected();
|
||||
void onStreamNameMappingChanged();
|
||||
void onAddStreamClip();
|
||||
void onAddStreamMarker();
|
||||
void onRemoveSelectedStreams();
|
||||
void onTabChanged(int index);
|
||||
void onPauseFromPlaybackApp();
|
||||
void onResumeFromPlaybackApp();
|
||||
|
||||
void applyAvsPos();
|
||||
void applyAvsVolume();
|
||||
|
||||
private:
|
||||
enum class ButtonStates { AllOff, Started, Paused, Stopped };
|
||||
|
||||
PlaybackAppHandle m_playbackApp;
|
||||
bool m_isAudio = false;
|
||||
StreamNameMapping *m_streamNameMapping = nullptr;
|
||||
boost::optional<QString> m_presetStreamName;
|
||||
boost::optional<int> m_markerIdPreset;
|
||||
boost::optional<AvaTimePoint> m_presetStartTime;
|
||||
void processPresets();
|
||||
void preselectStream(const QString& fallbackInternalStreamName);
|
||||
AvaSpeed currentSpeed() const;
|
||||
void setButtonStates(ButtonStates);
|
||||
void enableAll(bool enabled = true);
|
||||
|
||||
class TimelineBuilder;
|
||||
std::unique_ptr<TimelineBuilder> m_timelineBuilder;
|
||||
void disableAll()
|
||||
{
|
||||
enableAll(false);
|
||||
}
|
||||
|
||||
std::unique_ptr<Ui::Playback> m_ui;
|
||||
bool trySelectedStreams();
|
||||
void addStream(QComboBox* cb);
|
||||
|
||||
class TimeControl;
|
||||
std::unique_ptr<TimeControl> m_timeControl;
|
||||
void applyAvsPos();
|
||||
void applyAvsVolume();
|
||||
|
||||
boost::optional<QVector<AvaStream>> m_selectedStreams;
|
||||
IntervalModel m_intervalModel;
|
||||
boost::optional<AvaTimePoint> m_savedPos;
|
||||
std::unique_ptr<MarkerManagement::MarkerManagementDialogModel> m_markerModel;
|
||||
std::unique_ptr<MarkerManagement::MarkerSortFilterProxyModel> m_markerProxy;
|
||||
AvaControl *m_avaCtrl = nullptr;
|
||||
LtsSession::LtsSession *m_session = nullptr;
|
||||
bool m_skipEmpty = true;
|
||||
ButtonStates m_currentButtonState;
|
||||
std::shared_ptr<MarkerManagement::ForeignDataInterface> m_mrkDataIfc;
|
||||
boost::optional<AvaTimePoint> m_lastAvsPos;
|
||||
boost::optional<AvaVolume> m_lastAvsVolume;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
QVector<AvaStream> m_streams;
|
||||
boost::optional<AvaStream> m_currentStream;
|
||||
bool m_autostartOnce { false };
|
||||
int m_maxSelectedStreams = 12;
|
||||
bool m_queryTimelineActive { false };
|
||||
int m_currentOffset = 0;
|
||||
PlaybackAppHandle m_playbackApp;
|
||||
bool m_isAudio = false;
|
||||
StreamNameMapping* m_streamNameMapping = nullptr;
|
||||
boost::optional<QString> m_presetStreamName;
|
||||
boost::optional<int> m_markerIdPreset;
|
||||
boost::optional<AvaTimePoint> m_presetStartTime;
|
||||
|
||||
bool m_videoScreenSelectionDone { false };
|
||||
bool m_timelineIsComplete { false };
|
||||
ButtonStates m_buttonStateBeforePlaybackAppPause { ButtonStates::AllOff };
|
||||
class TimelineBuilder;
|
||||
std::unique_ptr<TimelineBuilder> m_timelineBuilder;
|
||||
|
||||
std::unique_ptr<Ui::Playback> m_ui;
|
||||
|
||||
class TimeControl;
|
||||
std::unique_ptr<TimeControl> m_timeControl;
|
||||
|
||||
boost::optional<QVector<AvaStream>> m_selectedStreams;
|
||||
IntervalModel m_intervalModel;
|
||||
boost::optional<AvaTimePoint> m_savedPos;
|
||||
std::unique_ptr<MarkerManagement::MarkerManagementDialogModel> m_markerModel;
|
||||
std::unique_ptr<MarkerManagement::MarkerSortFilterProxyModel> m_markerProxy;
|
||||
AvaControl* m_avaCtrl = nullptr;
|
||||
LtsSession::LtsSession* m_session = nullptr;
|
||||
bool m_skipEmpty = true;
|
||||
ButtonStates m_currentButtonState;
|
||||
std::shared_ptr<MarkerManagement::ForeignDataInterface> m_mrkDataIfc;
|
||||
boost::optional<AvaTimePoint> m_lastAvsPos;
|
||||
boost::optional<AvaVolume> m_lastAvsVolume;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
QVector<AvaStream> m_streams;
|
||||
boost::optional<AvaStream> m_currentStream;
|
||||
bool m_autostartOnce{false};
|
||||
int m_maxSelectedStreams = 12;
|
||||
bool m_queryTimelineActive{false};
|
||||
int m_currentOffset = 0;
|
||||
|
||||
bool m_videoScreenSelectionDone{false};
|
||||
bool m_timelineIsComplete{false};
|
||||
ButtonStates m_buttonStateBeforePlaybackAppPause{ButtonStates::AllOff};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+18
-18
@@ -1,38 +1,38 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ui_avm_playback_menu_dialog.h"
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
|
||||
#include <AudioVideoManagement/Shared/playback_app.h>
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class AvmPlaybackMenuDialog;
|
||||
}
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class AvmPlaybackMenuDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AvmPlaybackMenuDialog(bool isAudio, QWidget *parent);
|
||||
AudioVideoManagement::AvmPlaybackMenu *avmPlaybackMenu();
|
||||
Q_OBJECT
|
||||
public:
|
||||
AvmPlaybackMenuDialog(bool isAudio, QWidget* parent);
|
||||
AudioVideoManagement::AvmPlaybackMenu* avmPlaybackMenu();
|
||||
|
||||
~AvmPlaybackMenuDialog();
|
||||
~AvmPlaybackMenuDialog();
|
||||
|
||||
void retranslate() override;
|
||||
void retranslate() override;
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool m_isAudio;
|
||||
Ui::AvmPlaybackMenuDialog *m_ui;
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool m_isAudio;
|
||||
Ui::AvmPlaybackMenuDialog* m_ui;
|
||||
};
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+500
-542
File diff suppressed because it is too large.
Load diff
Executable → Regular
+49
-50
@@ -2,12 +2,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include "avm_available_streams_model.h"
|
||||
|
||||
#include <AudioVideoManagement/avm.hpp>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
#include "avm_available_streams_model.h"
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
@@ -15,63 +16,61 @@ namespace AudioVideoManagement
|
||||
class MenuStruct;
|
||||
class StreamNameMapping;
|
||||
|
||||
|
||||
|
||||
class UsedStreamsModel final : public NGLTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UsedStreamsModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc,
|
||||
const MenuStruct &ms,
|
||||
StreamNameMapping *streamNameMapping,
|
||||
QObject *parent);
|
||||
Q_OBJECT
|
||||
public:
|
||||
UsedStreamsModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc, const MenuStruct& ms,
|
||||
StreamNameMapping* streamNameMapping, QObject* parent);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex &idx, const QVariant &value,
|
||||
int role = Qt::EditRole) override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) override;
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) const override;
|
||||
QStringList mimeTypes() const override;
|
||||
Qt::DropActions supportedDragActions() const override { return Qt::MoveAction; }
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex& idx, const QVariant& value, int role = Qt::EditRole) override;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
QMimeData* mimeData(const QModelIndexList& indexes) const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) override;
|
||||
bool canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) const override;
|
||||
QStringList mimeTypes() const override;
|
||||
|
||||
Qt::DropActions supportedDragActions() const override
|
||||
{
|
||||
return Qt::MoveAction;
|
||||
}
|
||||
|
||||
MenuStruct getMenuStruct() const;
|
||||
bool initModel();
|
||||
MenuStruct getMenuStruct() const;
|
||||
bool initModel();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
NGLTreeItem* createItem(const QVariant& data, const QIcon& icon) const override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
NGLTreeItem *createItem(const QVariant &data, const QIcon &icon) const override;
|
||||
private slots:
|
||||
void onDataChanged(const InfrastructureManagement::MainStructureElement& data, const DataModification modType);
|
||||
void onDataChangedMvs(const AudioVideoManagement::VideoTeam& data, const DataModification modType);
|
||||
void onStreamNameDataChanged(int32_t mountingPointId, const QString& internalName, const QString& displayName);
|
||||
|
||||
private slots:
|
||||
void onDataChanged(const InfrastructureManagement::MainStructureElement &data,
|
||||
const DataModification modType);
|
||||
void onDataChangedMvs(const AudioVideoManagement::VideoTeam &data,
|
||||
const DataModification modType);
|
||||
void onStreamNameDataChanged(int32_t mountingPointId, const QString &internalName, const QString &displayName);
|
||||
private:
|
||||
void updateStreamNames(const int mountingPointId, const QString &newName, NGLTreeItem *item);
|
||||
private:
|
||||
void updateStreamNames(const int mountingPointId, const QString& newName, NGLTreeItem* item);
|
||||
|
||||
void fixUpData(NGLTreeItem *item);
|
||||
void fixUpData(NGLTreeItem* item);
|
||||
|
||||
static const QString s_MimeTypeOI;
|
||||
QString mimeType(const QModelIndex &index) const;
|
||||
void insertNGLTreeItemChild(NGLTreeItem *item, NGLTreeItem *parent, bool asCopy);
|
||||
void insertChildren(NGLTreeItem *parent, int parentId, const std::vector<AudioVideoManagement::AvMenuEntry> &entries);
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
NGLTreeItem *getItemToCheck(const QModelIndex &index, const QModelIndex &parentIndex) const;
|
||||
bool checkSingleItem(NGLTreeItem * target, StreamModelData & toCheck) const;
|
||||
bool checkDrop(const QMimeData *data, const QModelIndex &index, const QModelIndex &parentIndex, Qt::DropAction action) const;
|
||||
QSet<int> fillTakenCameras(NGLTreeItem *getItem) const;
|
||||
int m_dummyId;
|
||||
MenuStruct m_menuStruct;
|
||||
StreamNameMapping *m_streamNameMapping;
|
||||
static const QString s_MimeTypeOI;
|
||||
QString mimeType(const QModelIndex& index) const;
|
||||
void insertNGLTreeItemChild(NGLTreeItem* item, NGLTreeItem* parent, bool asCopy);
|
||||
void insertChildren(NGLTreeItem* parent, int parentId,
|
||||
const std::vector<AudioVideoManagement::AvMenuEntry>& entries);
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
NGLTreeItem* getItemToCheck(const QModelIndex& index, const QModelIndex& parentIndex) const;
|
||||
bool checkSingleItem(NGLTreeItem* target, StreamModelData& toCheck) const;
|
||||
bool checkDrop(const QMimeData* data, const QModelIndex& index, const QModelIndex& parentIndex,
|
||||
Qt::DropAction action) const;
|
||||
QSet<int> fillTakenCameras(NGLTreeItem* getItem) const;
|
||||
int m_dummyId;
|
||||
MenuStruct m_menuStruct;
|
||||
StreamNameMapping* m_streamNameMapping;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+338
-361
@@ -1,464 +1,441 @@
|
||||
|
||||
|
||||
|
||||
#include "topic_replay.h"
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
#include <AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
|
||||
#include <AudioVideoManagement/ava_control.h>
|
||||
#include <AudioVideoManagement/ava_session.h>
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
#include <AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
#include <AudioVideoManagement/vd_control.h>
|
||||
#include <AudioVideoManagement/vd_session.h>
|
||||
#include <TopicEditorBase/topic_editor_base.h>
|
||||
#include <LtsUtilsCore/json_object.h>
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <QWidget>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QJsonDocument>
|
||||
#include <QDir>
|
||||
#include <QtGlobal>
|
||||
#include <QRect>
|
||||
#include <QDebug>
|
||||
#include <vector>
|
||||
#include <QWidget>
|
||||
#include <QtGlobal>
|
||||
#include <TopicEditorBase/topic_editor_base.h>
|
||||
#include <chrono>
|
||||
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <vector>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class TopicReplay::ExportScript : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExportScript(const QString &topLevelExportDir, TopicEditorBase::ExportNotifier *exportStep);
|
||||
public:
|
||||
ExportScript(const QString& topLevelExportDir, TopicEditorBase::ExportNotifier* exportStep);
|
||||
|
||||
public slots:
|
||||
void avScriptFinished(const QString &exportDir, AvaStreamType streamType, bool success);
|
||||
public slots:
|
||||
void avScriptFinished(const QString& exportDir, AvaStreamType streamType, bool success);
|
||||
|
||||
private:
|
||||
QString audioVideoPlaylistErstellen(const QString &dir, AvaStreamType streamType);
|
||||
bool writeFile(const QByteArray &data, const QString &fileName);
|
||||
private:
|
||||
QString audioVideoPlaylistErstellen(const QString& dir, AvaStreamType streamType);
|
||||
bool writeFile(const QByteArray& data, const QString& fileName);
|
||||
|
||||
QString m_topLevelExportDir;
|
||||
TopicEditorBase::ExportNotifier *m_exportStep;
|
||||
QString m_topLevelExportDir;
|
||||
TopicEditorBase::ExportNotifier* m_exportStep;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TopicReplay::TopicReplay(DataInterface *dataIfc, bool isAudio)
|
||||
: m_isAudio(isAudio)
|
||||
, m_dataIfc(dataIfc)
|
||||
TopicReplay::TopicReplay(DataInterface* dataIfc, bool isAudio) : m_isAudio(isAudio), m_dataIfc(dataIfc)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::TopicReplay()";
|
||||
Q_ASSERT(dataIfc);
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::TopicReplay()";
|
||||
Q_ASSERT(dataIfc);
|
||||
}
|
||||
|
||||
TopicReplay::~TopicReplay()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::~TopicReplay()";
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::~TopicReplay()";
|
||||
|
||||
if (m_isPlaying)
|
||||
playbackStop();
|
||||
if (m_isPlaying)
|
||||
playbackStop();
|
||||
}
|
||||
|
||||
QWidget *TopicReplay::createWidget()
|
||||
QWidget* TopicReplay::createWidget()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::createWidget()";
|
||||
Q_ASSERT(!m_screenPlacementHelper);
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::createWidget()";
|
||||
Q_ASSERT(!m_screenPlacementHelper);
|
||||
|
||||
if (m_isAudio)
|
||||
return nullptr;
|
||||
if (m_isAudio)
|
||||
return nullptr;
|
||||
|
||||
m_screenPlacementHelper.reset(new ScreenPlacementHelper());
|
||||
connect(m_screenPlacementHelper.data(), &ScreenPlacementHelper::widgetPlaced, this, &TopicReplay::onWidgetPlaced);
|
||||
return m_screenPlacementHelper.data();
|
||||
m_screenPlacementHelper.reset(new ScreenPlacementHelper());
|
||||
connect(m_screenPlacementHelper.data(), &ScreenPlacementHelper::widgetPlaced, this, &TopicReplay::onWidgetPlaced);
|
||||
return m_screenPlacementHelper.data();
|
||||
}
|
||||
|
||||
|
||||
void TopicReplay::slotSetScriptResponse(const AudioVideoManagement::AvaStreamInfo &streamInfo, AudioVideoManagement::AvaStreamState streamState)
|
||||
void TopicReplay::slotSetScriptResponse(const AudioVideoManagement::AvaStreamInfo& streamInfo,
|
||||
AudioVideoManagement::AvaStreamState streamState)
|
||||
{
|
||||
if (streamState == AudioVideoManagement::AvaStreamState::NotPossible)
|
||||
ERROR_LOG(m_logger) << "Script could not be set";
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Script set!";
|
||||
if (streamState == AudioVideoManagement::AvaStreamState::NotPossible)
|
||||
ERROR_LOG(m_logger) << "Script could not be set";
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Script set!";
|
||||
|
||||
ERROR_LOG(m_logger) << "streamInfo: start" << streamInfo.duration.count();
|
||||
ERROR_LOG(m_logger) << "streamState: " << static_cast<int>(streamState);
|
||||
ERROR_LOG(m_logger) << "streamInfo: start" << streamInfo.duration.count();
|
||||
ERROR_LOG(m_logger) << "streamState: " << static_cast<int>(streamState);
|
||||
}
|
||||
|
||||
|
||||
bool TopicReplay::playbackInit(const QJsonObject &attributes)
|
||||
bool TopicReplay::playbackInit(const QJsonObject& attributes)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackInit()";
|
||||
DEBUG_LOG(m_logger) << QJsonDocument(attributes).toJson();
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackInit()";
|
||||
DEBUG_LOG(m_logger) << QJsonDocument(attributes).toJson();
|
||||
|
||||
if (m_screenPlacementHelper && !m_isAudio)
|
||||
m_screenPlacementHelper->show();
|
||||
if (m_screenPlacementHelper && !m_isAudio)
|
||||
m_screenPlacementHelper->show();
|
||||
|
||||
m_playbackAttributes = attributes;
|
||||
m_playbackAttributes = attributes;
|
||||
|
||||
|
||||
AvaControl *ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "no ava control!";
|
||||
return false;
|
||||
}
|
||||
AvaControl* ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "no ava control!";
|
||||
return false;
|
||||
}
|
||||
|
||||
AvaTopicData topicData(m_playbackAttributes);
|
||||
AvaTopicData topicData(m_playbackAttributes);
|
||||
|
||||
if (!topicData.isValid)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "topicData is invalid";
|
||||
return false;
|
||||
}
|
||||
if (!topicData.isValid)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "topicData is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_scriptName = topicData.scriptName();
|
||||
m_scriptName = topicData.scriptName();
|
||||
|
||||
Q_ASSERT(topicData.isAudio() == m_isAudio);
|
||||
Q_ASSERT(topicData.isAudio() == m_isAudio);
|
||||
|
||||
PlaybackApp *app = m_isAudio ? m_dataIfc->audioPresentationApp() : m_dataIfc->videoPresentationApp();
|
||||
if (app == nullptr || app->inUse())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "app invalid or in use!";
|
||||
return false;
|
||||
}
|
||||
PlaybackApp* app = m_isAudio ? m_dataIfc->audioPresentationApp() : m_dataIfc->videoPresentationApp();
|
||||
if (app == nullptr || app->inUse())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "app invalid or in use!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (!m_dialogGeometry)
|
||||
{
|
||||
if (m_isAudio)
|
||||
m_appHandle = PlaybackAppHandle(app);
|
||||
if (!m_dialogGeometry)
|
||||
{
|
||||
if (m_isAudio)
|
||||
m_appHandle = PlaybackAppHandle(app);
|
||||
else
|
||||
m_appHandle = PlaybackAppHandle(app, QRect(0, 0, 0, 0));
|
||||
}
|
||||
else
|
||||
m_appHandle = PlaybackAppHandle(app, QRect(0, 0, 0, 0));
|
||||
}
|
||||
else
|
||||
m_appHandle = PlaybackAppHandle(app, *m_dialogGeometry);
|
||||
m_appHandle = PlaybackAppHandle(app, *m_dialogGeometry);
|
||||
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app after creating appHandle!";
|
||||
return false;
|
||||
}
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app after creating appHandle!";
|
||||
return false;
|
||||
}
|
||||
|
||||
NGL::Settings s({});
|
||||
bool isLocal = s.isDatabaseConnectionLocal();
|
||||
|
||||
NGL::Settings s({});
|
||||
bool isLocal = s.isDatabaseConnectionLocal();
|
||||
DEBUG_LOG(m_logger) << "isLocal? " << isLocal;
|
||||
|
||||
DEBUG_LOG(m_logger) << "isLocal? " << isLocal;
|
||||
|
||||
AvaScriptSource source;
|
||||
if (isLocal)
|
||||
{
|
||||
if (m_isAudio)
|
||||
source = AvaScriptSource::LocalAudio;
|
||||
AvaScriptSource source;
|
||||
if (isLocal)
|
||||
{
|
||||
if (m_isAudio)
|
||||
source = AvaScriptSource::LocalAudio;
|
||||
else
|
||||
source = AvaScriptSource::LocalVideo;
|
||||
}
|
||||
else
|
||||
source = AvaScriptSource::LocalVideo;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_isAudio)
|
||||
source = AvaScriptSource::ServerAudio;
|
||||
else
|
||||
source = AvaScriptSource::ServerVideo;
|
||||
}
|
||||
{
|
||||
if (m_isAudio)
|
||||
source = AvaScriptSource::ServerAudio;
|
||||
else
|
||||
source = AvaScriptSource::ServerVideo;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "source: " << static_cast<int>(source);
|
||||
DEBUG_LOG(m_logger) << "source: " << static_cast<int>(source);
|
||||
|
||||
ctrl->setScript(m_appHandle.dialogId(), m_scriptName,
|
||||
source, topicData.streamList(),
|
||||
LtsUtils::createConnection(ctrl, &AudioVideoManagement::AvaControl::setScriptResponse,
|
||||
this, &TopicReplay::slotSetScriptResponse));
|
||||
ctrl->setScript(m_appHandle.dialogId(), m_scriptName, source, topicData.streamList(),
|
||||
LtsUtils::createConnection(ctrl, &AudioVideoManagement::AvaControl::setScriptResponse, this,
|
||||
&TopicReplay::slotSetScriptResponse));
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TopicReplay::playbackStart(int secondsOffset)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackStart()";
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackStart()";
|
||||
|
||||
if (m_screenPlacementHelper && !m_isAudio)
|
||||
m_screenPlacementHelper->show();
|
||||
if (m_screenPlacementHelper && !m_isAudio)
|
||||
m_screenPlacementHelper->show();
|
||||
|
||||
AvaControl *ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "ctrl == nullptr";
|
||||
return false;
|
||||
}
|
||||
AvaControl* ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "ctrl == nullptr";
|
||||
return false;
|
||||
}
|
||||
|
||||
AvaTimePoint p{AvaDuration{std::chrono::seconds(secondsOffset)}};
|
||||
AvaTimePoint p{AvaDuration{std::chrono::seconds(secondsOffset)}};
|
||||
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app!";
|
||||
return false;
|
||||
}
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app!";
|
||||
return false;
|
||||
}
|
||||
|
||||
ctrl->setAbsPositionScript(m_appHandle.dialogId(), m_scriptName, p);
|
||||
ctrl->startScript(m_appHandle.dialogId(), m_scriptName);
|
||||
ctrl->setAbsPositionScript(m_appHandle.dialogId(), m_scriptName, p);
|
||||
ctrl->startScript(m_appHandle.dialogId(), m_scriptName);
|
||||
|
||||
m_isPlaying = true;
|
||||
DEBUG_LOG(m_logger) << "m_isPlaying = true";
|
||||
return true;
|
||||
m_isPlaying = true;
|
||||
DEBUG_LOG(m_logger) << "m_isPlaying = true";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TopicReplay::playbackPause()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackPause()";
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackPause()";
|
||||
|
||||
if (m_screenPlacementHelper)
|
||||
m_screenPlacementHelper->hide();
|
||||
if (m_screenPlacementHelper)
|
||||
m_screenPlacementHelper->hide();
|
||||
|
||||
if (!m_isPlaying)
|
||||
if (!m_isPlaying)
|
||||
return true;
|
||||
|
||||
AvaControl* ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "no ctrl!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app!";
|
||||
return false;
|
||||
}
|
||||
|
||||
ctrl->pauseScript(m_appHandle.dialogId(), m_scriptName);
|
||||
return true;
|
||||
|
||||
AvaControl *ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "no ctrl!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app!";
|
||||
return false;
|
||||
}
|
||||
|
||||
ctrl->pauseScript(m_appHandle.dialogId(), m_scriptName);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TopicReplay::playbackStop()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackStop()";
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackStop()";
|
||||
|
||||
if (m_screenPlacementHelper)
|
||||
m_screenPlacementHelper->hide();
|
||||
if (m_screenPlacementHelper)
|
||||
m_screenPlacementHelper->hide();
|
||||
|
||||
if (!m_isPlaying)
|
||||
if (!m_isPlaying)
|
||||
return true;
|
||||
|
||||
AvaControl* ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "no ctrl!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app!";
|
||||
return false;
|
||||
}
|
||||
|
||||
ctrl->stopScript(m_appHandle.dialogId(), m_scriptName);
|
||||
ctrl->releaseScript(m_appHandle.dialogId(), m_scriptName);
|
||||
|
||||
m_isPlaying = false;
|
||||
return true;
|
||||
|
||||
AvaControl *ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "no ctrl!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app!";
|
||||
return false;
|
||||
}
|
||||
|
||||
ctrl->stopScript(m_appHandle.dialogId(), m_scriptName);
|
||||
ctrl->releaseScript(m_appHandle.dialogId(), m_scriptName);
|
||||
|
||||
m_isPlaying = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TopicReplay::exportTopic(const QJsonObject &attributes,
|
||||
const QString &folderPath,
|
||||
TopicEditorBase::ExportNotifier *exportNotifier)
|
||||
bool TopicReplay::exportTopic(const QJsonObject& attributes, const QString& folderPath,
|
||||
TopicEditorBase::ExportNotifier* exportNotifier)
|
||||
{
|
||||
Q_ASSERT(!m_exportScript);
|
||||
Q_ASSERT(!m_exportScript);
|
||||
|
||||
VdControl *ctrl = getVdControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "ctrl missing!";
|
||||
exportNotifier->setExportFailed();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_exportScript.reset(new ExportScript(folderPath, exportNotifier));
|
||||
|
||||
AvaTopicData topicData(attributes);
|
||||
m_scriptName = topicData.scriptName();
|
||||
|
||||
if (!topicData.isValid)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "topicData is invalid";
|
||||
exportNotifier->setExportFailed();
|
||||
return false;
|
||||
}
|
||||
|
||||
QFileInfo fileInfo(QDir(folderPath).filePath(topicData.scriptName()));
|
||||
|
||||
Q_ASSERT(topicData.isAudio() == m_isAudio);
|
||||
|
||||
ctrl->vdSetScript(m_scriptName,
|
||||
m_isAudio ? AvaStreamType::Audio : AvaStreamType::Video,
|
||||
0, topicData.streamList(), fileInfo.baseName(), fileInfo.absolutePath(),
|
||||
this, &TopicReplay::avScriptFinished);
|
||||
return true;
|
||||
}
|
||||
|
||||
void TopicReplay::onWidgetPlaced(const QRect &geometry)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "TopicReplay::onWidgetPlaced() - geo: " << geometry.x() << "/" << geometry.y()
|
||||
<< " m_isAudio=" << m_isAudio;
|
||||
|
||||
m_dialogGeometry = geometry;
|
||||
|
||||
if (m_isAudio)
|
||||
return;
|
||||
|
||||
PlaybackApp *app = m_isAudio ? m_dataIfc->audioPresentationApp() : m_dataIfc->videoPresentationApp();
|
||||
if (app == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "app missing!";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!app->inUse())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "app not in use - waiting for playbackInit to aquire it";
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "setGeometry";
|
||||
app->setGeometry(*m_dialogGeometry);
|
||||
}
|
||||
|
||||
AvaControl *TopicReplay::getAvaControl()
|
||||
{
|
||||
if (!m_dataIfc->hasAvsSession())
|
||||
return nullptr;
|
||||
|
||||
AvaSession *avaSession = m_dataIfc->avaSession();
|
||||
if (!avaSession->isEstablished())
|
||||
return nullptr;
|
||||
|
||||
return avaSession->control();
|
||||
}
|
||||
|
||||
VdControl *TopicReplay::getVdControl()
|
||||
{
|
||||
if (!m_dataIfc->hasAvsSession())
|
||||
return nullptr;
|
||||
|
||||
VdSession *vdSession = m_dataIfc->vdSession();
|
||||
if (!vdSession->isEstablished())
|
||||
return nullptr;
|
||||
|
||||
return vdSession->control();
|
||||
}
|
||||
|
||||
void TopicReplay::avScriptFinished(const QString &exportDir, AvaStreamType streamType, bool success)
|
||||
{
|
||||
VdControl *ctrl = getVdControl();
|
||||
ctrl->vdReleaseScript(m_scriptName);
|
||||
m_exportScript->avScriptFinished(exportDir, streamType, success);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TopicReplay::ExportScript::ExportScript(const QString &topLevelExportDir, TopicEditorBase::ExportNotifier *exportStep)
|
||||
: m_topLevelExportDir(topLevelExportDir)
|
||||
, m_exportStep(exportStep)
|
||||
{
|
||||
connect(exportStep, &QObject::destroyed, this, [this]()
|
||||
{
|
||||
if (static_cast<TopicEditorBase::ExportNotifier *>(sender()) != m_exportStep)
|
||||
return;
|
||||
m_exportStep = nullptr;
|
||||
});
|
||||
Q_ASSERT(exportStep);
|
||||
}
|
||||
|
||||
void TopicReplay::ExportScript::avScriptFinished(const QString &exportDir, AvaStreamType streamType, bool success)
|
||||
{
|
||||
QString absPathToPlaylist = audioVideoPlaylistErstellen(exportDir, streamType);
|
||||
|
||||
QDir toplevelExportDir(m_topLevelExportDir);
|
||||
QString relativePathToPlaylist = toplevelExportDir.relativeFilePath(absPathToPlaylist);
|
||||
|
||||
if (m_exportStep == nullptr)
|
||||
return;
|
||||
|
||||
if (success)
|
||||
m_exportStep->setExportSuccessful(relativePathToPlaylist);
|
||||
else
|
||||
m_exportStep->setExportFailed();
|
||||
}
|
||||
|
||||
QString TopicReplay::ExportScript::audioVideoPlaylistErstellen(const QString &dir, AvaStreamType streamType)
|
||||
{
|
||||
QDir avDir(dir);
|
||||
const QFileInfoList dateienList = avDir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
|
||||
|
||||
QByteArray dataForFile;
|
||||
QString data;
|
||||
dataForFile.append("[playlist]\n");
|
||||
|
||||
int numberOfEntries = 0;
|
||||
int i = 1;
|
||||
const QString tmpl1(QStringLiteral("File %1=%2\n"));
|
||||
const QString tmpl2(QStringLiteral("# File %1=%2\n"));
|
||||
for (const QFileInfo &fileInfo : dateienList)
|
||||
{
|
||||
if (streamType == AvaStreamType::Video && fileInfo.suffix() == QLatin1String(".wav"))
|
||||
VdControl* ctrl = getVdControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
data += tmpl2.arg(QString::number(i), fileInfo.fileName());
|
||||
i--;
|
||||
ERROR_LOG(m_logger) << "ctrl missing!";
|
||||
exportNotifier->setExportFailed();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_exportScript.reset(new ExportScript(folderPath, exportNotifier));
|
||||
|
||||
AvaTopicData topicData(attributes);
|
||||
m_scriptName = topicData.scriptName();
|
||||
|
||||
if (!topicData.isValid)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "topicData is invalid";
|
||||
exportNotifier->setExportFailed();
|
||||
return false;
|
||||
}
|
||||
|
||||
QFileInfo fileInfo(QDir(folderPath).filePath(topicData.scriptName()));
|
||||
|
||||
Q_ASSERT(topicData.isAudio() == m_isAudio);
|
||||
|
||||
ctrl->vdSetScript(m_scriptName, m_isAudio ? AvaStreamType::Audio : AvaStreamType::Video, 0, topicData.streamList(),
|
||||
fileInfo.baseName(), fileInfo.absolutePath(), this, &TopicReplay::avScriptFinished);
|
||||
return true;
|
||||
}
|
||||
|
||||
void TopicReplay::onWidgetPlaced(const QRect& geometry)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "TopicReplay::onWidgetPlaced() - geo: " << geometry.x() << "/" << geometry.y()
|
||||
<< " m_isAudio=" << m_isAudio;
|
||||
|
||||
m_dialogGeometry = geometry;
|
||||
|
||||
if (m_isAudio)
|
||||
return;
|
||||
|
||||
PlaybackApp* app = m_isAudio ? m_dataIfc->audioPresentationApp() : m_dataIfc->videoPresentationApp();
|
||||
if (app == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "app missing!";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!app->inUse())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "app not in use - waiting for playbackInit to aquire it";
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "setGeometry";
|
||||
app->setGeometry(*m_dialogGeometry);
|
||||
}
|
||||
|
||||
AvaControl* TopicReplay::getAvaControl()
|
||||
{
|
||||
if (!m_dataIfc->hasAvsSession())
|
||||
return nullptr;
|
||||
|
||||
AvaSession* avaSession = m_dataIfc->avaSession();
|
||||
if (!avaSession->isEstablished())
|
||||
return nullptr;
|
||||
|
||||
return avaSession->control();
|
||||
}
|
||||
|
||||
VdControl* TopicReplay::getVdControl()
|
||||
{
|
||||
if (!m_dataIfc->hasAvsSession())
|
||||
return nullptr;
|
||||
|
||||
VdSession* vdSession = m_dataIfc->vdSession();
|
||||
if (!vdSession->isEstablished())
|
||||
return nullptr;
|
||||
|
||||
return vdSession->control();
|
||||
}
|
||||
|
||||
void TopicReplay::avScriptFinished(const QString& exportDir, AvaStreamType streamType, bool success)
|
||||
{
|
||||
VdControl* ctrl = getVdControl();
|
||||
ctrl->vdReleaseScript(m_scriptName);
|
||||
m_exportScript->avScriptFinished(exportDir, streamType, success);
|
||||
}
|
||||
|
||||
TopicReplay::ExportScript::ExportScript(const QString& topLevelExportDir, TopicEditorBase::ExportNotifier* exportStep)
|
||||
: m_topLevelExportDir(topLevelExportDir), m_exportStep(exportStep)
|
||||
{
|
||||
connect(exportStep, &QObject::destroyed, this, [this]() {
|
||||
if (static_cast<TopicEditorBase::ExportNotifier*>(sender()) != m_exportStep)
|
||||
return;
|
||||
m_exportStep = nullptr;
|
||||
});
|
||||
Q_ASSERT(exportStep);
|
||||
}
|
||||
|
||||
void TopicReplay::ExportScript::avScriptFinished(const QString& exportDir, AvaStreamType streamType, bool success)
|
||||
{
|
||||
QString absPathToPlaylist = audioVideoPlaylistErstellen(exportDir, streamType);
|
||||
|
||||
QDir toplevelExportDir(m_topLevelExportDir);
|
||||
QString relativePathToPlaylist = toplevelExportDir.relativeFilePath(absPathToPlaylist);
|
||||
|
||||
if (m_exportStep == nullptr)
|
||||
return;
|
||||
|
||||
if (success)
|
||||
m_exportStep->setExportSuccessful(relativePathToPlaylist);
|
||||
else
|
||||
{
|
||||
data += tmpl1.arg(QString::number(i), fileInfo.fileName());
|
||||
numberOfEntries++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
QString numberOfEntriesString = QStringLiteral("NumberOfEntries=") + QString::number(numberOfEntries) + QStringLiteral("\n");
|
||||
dataForFile.append(numberOfEntriesString.toUtf8());
|
||||
dataForFile.append(data.toUtf8());
|
||||
|
||||
QString fileName;
|
||||
switch (streamType)
|
||||
{
|
||||
case AvaStreamType::Audio:
|
||||
fileName = avDir.filePath(QStringLiteral("audio.pls"));
|
||||
break;
|
||||
|
||||
case AvaStreamType::Video:
|
||||
fileName = avDir.filePath(QStringLiteral("video.pls"));
|
||||
break;
|
||||
}
|
||||
|
||||
writeFile(dataForFile, fileName);
|
||||
return fileName;
|
||||
m_exportStep->setExportFailed();
|
||||
}
|
||||
|
||||
bool TopicReplay::ExportScript::writeFile(const QByteArray &data, const QString &fileName)
|
||||
QString TopicReplay::ExportScript::audioVideoPlaylistErstellen(const QString& dir, AvaStreamType streamType)
|
||||
{
|
||||
QFile file(fileName);
|
||||
QDir avDir(dir);
|
||||
const QFileInfoList dateienList = avDir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
|
||||
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||
return false;
|
||||
QByteArray dataForFile;
|
||||
QString data;
|
||||
dataForFile.append("[playlist]\n");
|
||||
|
||||
if (file.write(data) == -1)
|
||||
{
|
||||
file.close();
|
||||
return false;
|
||||
}
|
||||
int numberOfEntries = 0;
|
||||
int i = 1;
|
||||
const QString tmpl1(QStringLiteral("File %1=%2\n"));
|
||||
const QString tmpl2(QStringLiteral("# File %1=%2\n"));
|
||||
for (const QFileInfo& fileInfo : dateienList)
|
||||
{
|
||||
if (streamType == AvaStreamType::Video && fileInfo.suffix() == QLatin1String(".wav"))
|
||||
{
|
||||
data += tmpl2.arg(QString::number(i), fileInfo.fileName());
|
||||
i--;
|
||||
}
|
||||
else
|
||||
{
|
||||
data += tmpl1.arg(QString::number(i), fileInfo.fileName());
|
||||
numberOfEntries++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
file.close();
|
||||
QString numberOfEntriesString =
|
||||
QStringLiteral("NumberOfEntries=") + QString::number(numberOfEntries) + QStringLiteral("\n");
|
||||
dataForFile.append(numberOfEntriesString.toUtf8());
|
||||
dataForFile.append(data.toUtf8());
|
||||
|
||||
return true;
|
||||
QString fileName;
|
||||
switch (streamType)
|
||||
{
|
||||
case AvaStreamType::Audio:
|
||||
fileName = avDir.filePath(QStringLiteral("audio.pls"));
|
||||
break;
|
||||
|
||||
case AvaStreamType::Video:
|
||||
fileName = avDir.filePath(QStringLiteral("video.pls"));
|
||||
break;
|
||||
}
|
||||
|
||||
writeFile(dataForFile, fileName);
|
||||
return fileName;
|
||||
}
|
||||
|
||||
}
|
||||
bool TopicReplay::ExportScript::writeFile(const QByteArray& data, const QString& fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||
return false;
|
||||
|
||||
if (file.write(data) == -1)
|
||||
{
|
||||
file.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
#include "topic_replay.moc"
|
||||
Executable → Regular
+133
-158
@@ -1,252 +1,227 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_combat_net_radio_dialog.h"
|
||||
#include "ui_avm_combat_net_radio_dialog.h"
|
||||
|
||||
#include "avm_cnr_json_helper.h"
|
||||
#include "avm_combat_net_radio_dialog_model.h"
|
||||
#include "avm_edit_combat_net_radio_dialog.h"
|
||||
#include "avm_cnr_json_helper.h"
|
||||
#include "avm_load_combat_net_radio_dialog.h"
|
||||
#include "ui_avm_combat_net_radio_dialog.h"
|
||||
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
CombatNetRadioDialog::CombatNetRadioDialog(LtsSession::LtsSession *session, const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::CombatNetRadioDialog)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
CombatNetRadioDialog::CombatNetRadioDialog(LtsSession::LtsSession* session, const QString& menuGroup, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_session(session),
|
||||
m_ui(new Ui::CombatNetRadioDialog), m_menuGroup(menuGroup), m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setUnchangeable(true);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &CombatNetRadioDialog::onPrint);
|
||||
m_ui->setupUi(this);
|
||||
setUnchangeable(true);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &CombatNetRadioDialog::onPrint);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Combat_Net_Radio_Configuration"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Combat_Net_Radio_Configuration"));
|
||||
}
|
||||
|
||||
CombatNetRadioDialog::~CombatNetRadioDialog() = default;
|
||||
|
||||
void CombatNetRadioDialog::retranslate()
|
||||
{
|
||||
translate(m_ui.get(), tr("Configure Combat Net Radio"));
|
||||
translate(m_ui.get(), tr("Configure Combat Net Radio"));
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool CombatNetRadioDialog::init(const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc)
|
||||
bool CombatNetRadioDialog::init(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc)
|
||||
{
|
||||
if (!(avmDtc->enableCnrChannel() &&
|
||||
avmDtc->enableCnrConfig() &&
|
||||
ppmDtc->enableParty() &&
|
||||
ppmDtc->enableParticipant() &&
|
||||
ppmDtc->enableType() &&
|
||||
avmFtc->enableModifyCnrConfig() &&
|
||||
avmFtc->enableRemoveCnrConfig()))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable topics";
|
||||
return false;
|
||||
}
|
||||
if (!(avmDtc->enableCnrChannel() && avmDtc->enableCnrConfig() && ppmDtc->enableParty() &&
|
||||
ppmDtc->enableParticipant() && ppmDtc->enableType() && avmFtc->enableModifyCnrConfig() &&
|
||||
avmFtc->enableRemoveCnrConfig()))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable topics";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_model.reset(new CombatNetRadioDialogModel(m_session->exerciseId(), this));
|
||||
m_filter.reset(new CombatNetRadioDialogFilter(m_session->exerciseId(), m_model.get()));
|
||||
m_model.reset(new CombatNetRadioDialogModel(m_session->exerciseId(), this));
|
||||
m_filter.reset(new CombatNetRadioDialogFilter(m_session->exerciseId(), m_model.get()));
|
||||
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_exmDtc = exmDtc;
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_exmDtc = exmDtc;
|
||||
|
||||
m_avmDtc->waitForHistoricalDataCnrChannel(3000);
|
||||
m_ppmDtc->waitForHistoricalDataParty(3000);
|
||||
m_avmDtc->waitForHistoricalDataCnrChannel(3000);
|
||||
m_ppmDtc->waitForHistoricalDataParty(3000);
|
||||
|
||||
if (!m_model->init(avmDtc, ppmDtc))
|
||||
{
|
||||
m_filter.reset();
|
||||
m_model.reset();
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
if (!m_model->init(avmDtc, ppmDtc))
|
||||
{
|
||||
m_filter.reset();
|
||||
m_model.reset();
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ui->dataView->setModel(m_filter.get());
|
||||
m_ui->dataView->setModel(m_filter.get());
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &CombatNetRadioDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &CombatNetRadioDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &CombatNetRadioDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &CombatNetRadioDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &CombatNetRadioDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &CombatNetRadioDialog::onRemoveClicked);
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &CombatNetRadioDialog::onSelectionChanged);
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&CombatNetRadioDialog::onSelectionChanged);
|
||||
|
||||
onSelectionChanged();
|
||||
onSelectionChanged();
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &CombatNetRadioDialog::onEditClicked);
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked, this, &CombatNetRadioDialog::onEditClicked);
|
||||
|
||||
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&CombatNetRadioDialog::onImportButtonClicked,
|
||||
&CombatNetRadioDialog::onExportButtonClicked);
|
||||
m_buttonBox->connectLibraryButton(this, &CombatNetRadioDialog::onImportButtonClicked,
|
||||
&CombatNetRadioDialog::onExportButtonClicked);
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onRemoveCnrConfigReply(const Core::FunctionReplyObject &replyObject)
|
||||
void CombatNetRadioDialog::onRemoveCnrConfigReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onModifyCnrConfigReply(const Core::FunctionReplyObject &replyObject)
|
||||
void CombatNetRadioDialog::onModifyCnrConfigReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onAddClicked()
|
||||
{
|
||||
EditCombatNetRadioDialog *dialog = new EditCombatNetRadioDialog(m_session->exerciseId(), m_session, m_ppmDtc, m_avmDtc, m_avmFtc, m_exmDtc, this);
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("NewCNRConfig"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
EditCombatNetRadioDialog* dialog =
|
||||
new EditCombatNetRadioDialog(m_session->exerciseId(), m_session, m_ppmDtc, m_avmDtc, m_avmFtc, m_exmDtc, this);
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("NewCNRConfig"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onEditClicked()
|
||||
{
|
||||
|
||||
if (!m_buttonBox->isButtonEnabled(LtsWidgets::DialogButton::Edit))
|
||||
return;
|
||||
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
if (!m_buttonBox->isButtonEnabled(LtsWidgets::DialogButton::Edit))
|
||||
return;
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
CnrConfig config = m_model->data(currentIndex, Qt::UserRole).value<CnrConfig>();
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
EditCombatNetRadioDialog *dialog = new EditCombatNetRadioDialog(config,
|
||||
m_session->exerciseId(),
|
||||
m_session,
|
||||
m_ppmDtc,
|
||||
m_avmDtc,
|
||||
m_avmFtc,
|
||||
m_exmDtc,
|
||||
this);
|
||||
CnrConfig config = m_model->data(currentIndex, Qt::UserRole).value<CnrConfig>();
|
||||
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditCNRConfig%1").arg(config.id()), LtsWidgets::LayoutArea::eDialogTab);
|
||||
EditCombatNetRadioDialog* dialog = new EditCombatNetRadioDialog(config, m_session->exerciseId(), m_session,
|
||||
m_ppmDtc, m_avmDtc, m_avmFtc, m_exmDtc, this);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditCNRConfig%1").arg(config.id()),
|
||||
LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onRemoveClicked()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
Core::RemoveElementRequest request(m_model->data(currentIndex, Qt::UserRole).value<CnrConfig>().id());
|
||||
Core::RemoveElementRequest request(m_model->data(currentIndex, Qt::UserRole).value<CnrConfig>().id());
|
||||
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_avmFtc->removeCnrConfigRequest(request, this);
|
||||
});
|
||||
m_requestHelper->startSingleRequest([this, request]() { return m_avmFtc->removeCnrConfigRequest(request, this); });
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onSelectionChanged()
|
||||
{
|
||||
bool rowSelected = m_ui->dataView->selectionModel()->selectedRows().size() > 0;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, rowSelected);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, rowSelected);
|
||||
bool rowSelected = m_ui->dataView->selectionModel()->selectedRows().size() > 0;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, rowSelected);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, rowSelected);
|
||||
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
CnrConfig config = m_model->data(currentIndex, Qt::UserRole).value<CnrConfig>();
|
||||
bool enabled = rowSelected && (config.exerciseId().is_set() || m_session->partitionType() == IDL::PartitionType::Global);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, enabled);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, enabled);
|
||||
CnrConfig config = m_model->data(currentIndex, Qt::UserRole).value<CnrConfig>();
|
||||
bool enabled =
|
||||
rowSelected && (config.exerciseId().is_set() || m_session->partitionType() == IDL::PartitionType::Global);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, enabled);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, enabled);
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView());
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView());
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = m_filter->modelToJson();
|
||||
QByteArray byteArray = m_filter->modelToJson();
|
||||
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(), FileManagement::toString(FileManagement::XmlType::AVMCombatNetRadio));
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(),
|
||||
FileManagement::toString(FileManagement::XmlType::AVMCombatNetRadio));
|
||||
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMCombatNetRadio)))
|
||||
if (fileId > 0)
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("Invalid xml file content"),
|
||||
windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes,
|
||||
texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadCombatNetRadioDialog loadingDialog(content, m_session) ;
|
||||
loadingDialog.exec();
|
||||
|
||||
if (loadingDialog.isApplied())
|
||||
{
|
||||
const QVector<Core::RemoveElementRequest> removeRequests = loadingDialog.removeRequests();
|
||||
|
||||
for (const auto &removeRequest : removeRequests)
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMCombatNetRadio)))
|
||||
{
|
||||
m_requestHelper->addRequest([this, removeRequest]()
|
||||
{
|
||||
return m_avmFtc->removeCnrConfigRequest(removeRequest, this);
|
||||
});
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Invalid xml file content"), windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal, LtsWidgets::Button::Yes, texts);
|
||||
}
|
||||
|
||||
const QVector<ModifyCnrConfigRequest> modifyRequests = loadingDialog.modifyRequests();
|
||||
|
||||
for (const auto &modifyRequest : modifyRequests)
|
||||
else
|
||||
{
|
||||
m_requestHelper->addRequest([this, modifyRequest]()
|
||||
{
|
||||
return m_avmFtc->modifyCnrConfigRequest(modifyRequest, this);
|
||||
});
|
||||
}
|
||||
LoadCombatNetRadioDialog loadingDialog(content, m_session);
|
||||
loadingDialog.exec();
|
||||
|
||||
if (modifyRequests.size() || removeRequests.size())
|
||||
(void) m_requestHelper->startRequests();
|
||||
}
|
||||
if (loadingDialog.isApplied())
|
||||
{
|
||||
const QVector<Core::RemoveElementRequest> removeRequests = loadingDialog.removeRequests();
|
||||
|
||||
for (const auto& removeRequest : removeRequests)
|
||||
{
|
||||
m_requestHelper->addRequest(
|
||||
[this, removeRequest]() { return m_avmFtc->removeCnrConfigRequest(removeRequest, this); });
|
||||
}
|
||||
|
||||
const QVector<ModifyCnrConfigRequest> modifyRequests = loadingDialog.modifyRequests();
|
||||
|
||||
for (const auto& modifyRequest : modifyRequests)
|
||||
{
|
||||
m_requestHelper->addRequest(
|
||||
[this, modifyRequest]() { return m_avmFtc->modifyCnrConfigRequest(modifyRequest, this); });
|
||||
}
|
||||
|
||||
if (modifyRequests.size() || removeRequests.size())
|
||||
(void)m_requestHelper->startRequests();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+44
-46
@@ -1,14 +1,11 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
@@ -27,7 +24,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
@@ -35,7 +32,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
@@ -43,58 +40,59 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class CombatNetRadioDialogModel;
|
||||
class CombatNetRadioDialogFilter;
|
||||
|
||||
class CombatNetRadioDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::RemoveCnrConfigReplyHandler
|
||||
, protected Interface::Ftc::ModifyCnrConfigReplyHandler
|
||||
class CombatNetRadioDialog : public LtsWidgets::LtsDialog,
|
||||
protected Interface::Ftc::RemoveCnrConfigReplyHandler,
|
||||
protected Interface::Ftc::ModifyCnrConfigReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CombatNetRadioDialog(LtsSession::LtsSession *session, const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~CombatNetRadioDialog();
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CombatNetRadioDialog(LtsSession::LtsSession* session, const QString& menuGroup, QWidget* parent = nullptr);
|
||||
~CombatNetRadioDialog();
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &avmDtc, const std::shared_ptr<Interface::Ftc> &avmFtc, const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc, ExerciseManagement::Interface::Dtc *exmDtc);
|
||||
bool init(const std::shared_ptr<Interface::Dtc>& avmDtc, const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc);
|
||||
|
||||
void onRemoveCnrConfigReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onModifyCnrConfigReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onRemoveCnrConfigReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
void onModifyCnrConfigReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::unique_ptr<CombatNetRadioDialogModel> m_model;
|
||||
std::unique_ptr<CombatNetRadioDialogFilter> m_filter;
|
||||
std::unique_ptr<Ui::CombatNetRadioDialog> m_ui;
|
||||
QString m_menuGroup;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
ExerciseManagement::Interface::Dtc *m_exmDtc{nullptr};
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
};
|
||||
}
|
||||
private:
|
||||
LtsSession::LtsSession* m_session;
|
||||
std::unique_ptr<CombatNetRadioDialogModel> m_model;
|
||||
std::unique_ptr<CombatNetRadioDialogFilter> m_filter;
|
||||
std::unique_ptr<Ui::CombatNetRadioDialog> m_ui;
|
||||
QString m_menuGroup;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
ExerciseManagement::Interface::Dtc* m_exmDtc{nullptr};
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+103
-111
@@ -1,153 +1,145 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_combat_net_radio_dialog_model.h"
|
||||
#include <utility>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
|
||||
#include "avm_cnr_json_helper.h"
|
||||
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <utility>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
CombatNetRadioDialogModel::CombatNetRadioDialogModel(int32_t exerciseId, QObject *parent)
|
||||
: LtsAbstractTableModel<CnrConfig>(
|
||||
{
|
||||
tr("Channel Number"),
|
||||
tr("Radio Circuit"),
|
||||
tr("Code Word"),
|
||||
tr("Party"),
|
||||
tr("Unit"),
|
||||
tr("Global")
|
||||
}, parent)
|
||||
, m_exerciseId(exerciseId)
|
||||
CombatNetRadioDialogModel::CombatNetRadioDialogModel(int32_t exerciseId, QObject* parent)
|
||||
: LtsAbstractTableModel<CnrConfig>(
|
||||
{tr("Channel Number"), tr("Radio Circuit"), tr("Code Word"), tr("Party"), tr("Unit"), tr("Global")}, parent),
|
||||
m_exerciseId(exerciseId)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant CombatNetRadioDialogModel::data(const QModelIndex &index, int role) const
|
||||
QVariant CombatNetRadioDialogModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if ((role != Qt::BackgroundRole &&role != Qt::DisplayRole && role != Qt::UserRole) || !indexIsValid(index))
|
||||
if ((role != Qt::BackgroundRole && role != Qt::DisplayRole && role != Qt::UserRole) || !indexIsValid(index))
|
||||
return {};
|
||||
|
||||
const CnrConfig& config = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case CHANNEL:
|
||||
INFO_LOG(m_logger) << "CombatNetRadioDialogModel::data role =" << role << " row = " << index.row();
|
||||
return QString::fromStdString(m_cnrChannels.value(config.cnrChannelId()).name());
|
||||
case RADIO_CIRCUIT:
|
||||
return QString::fromStdString(config.radioCircuit());
|
||||
case CALL_SIGN:
|
||||
return QString::fromStdString(config.callSign());
|
||||
case PARTY:
|
||||
if (config.exerciseId().is_set() || config.partyId() > 0)
|
||||
return ParticipantManagement::trPartyName(m_parties.value(config.partyId()).name());
|
||||
else
|
||||
return QStringLiteral("-");
|
||||
case UNIT: {
|
||||
if (!config.unitId().is_set())
|
||||
return {};
|
||||
const int unitId = config.unitId().get();
|
||||
const auto unit = m_units.value(config.unitId().get());
|
||||
if (unit.id() != unitId)
|
||||
return {};
|
||||
|
||||
INFO_LOG(m_logger) << " config.unitId()=" << unitId << " Str=" << unit.name();
|
||||
|
||||
QString unitStr;
|
||||
if (unit.designator().size() > 0)
|
||||
unitStr = QString::fromStdString(unit.designator()) + QLatin1Char('/');
|
||||
unitStr.append(QString::fromStdString(unit.tacticalIdentifier()));
|
||||
INFO_LOG(m_logger) << "unitStr = " << unitStr;
|
||||
|
||||
return unitStr;
|
||||
}
|
||||
case GLOBAL:
|
||||
return config.exerciseId().is_set() ? tr("No") : tr("Yes");
|
||||
}
|
||||
}
|
||||
else if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (config.exerciseId().is_set() && config.exerciseId().get() == m_exerciseId)
|
||||
return {};
|
||||
if (!config.exerciseId().is_set() && m_exerciseId <= 0)
|
||||
return {};
|
||||
return QColor(Qt::gray);
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
return QVariant::fromValue(config);
|
||||
|
||||
return {};
|
||||
|
||||
const CnrConfig &config = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case CHANNEL:
|
||||
INFO_LOG(m_logger)<<"CombatNetRadioDialogModel::data role =" << role
|
||||
<< " row = " << index.row();
|
||||
return QString::fromStdString(m_cnrChannels.value(config.cnrChannelId()).name());
|
||||
case RADIO_CIRCUIT:
|
||||
return QString::fromStdString(config.radioCircuit());
|
||||
case CALL_SIGN:
|
||||
return QString::fromStdString(config.callSign());
|
||||
case PARTY:
|
||||
if(config.exerciseId().is_set() || config.partyId() > 0)
|
||||
return ParticipantManagement::trPartyName(m_parties.value(config.partyId()).name());
|
||||
else
|
||||
return QStringLiteral("-");
|
||||
case UNIT:
|
||||
{
|
||||
if (!config.unitId().is_set())
|
||||
return {};
|
||||
const int unitId = config.unitId().get();
|
||||
const auto unit = m_units.value(config.unitId().get());
|
||||
if (unit.id() != unitId)
|
||||
return {};
|
||||
|
||||
INFO_LOG(m_logger) << " config.unitId()=" << unitId
|
||||
<< " Str=" << unit.name();
|
||||
|
||||
QString unitStr;
|
||||
if (unit.designator().size() > 0)
|
||||
unitStr = QString::fromStdString(unit.designator()) + QLatin1Char('/');
|
||||
unitStr.append(QString::fromStdString(unit.tacticalIdentifier()));
|
||||
INFO_LOG(m_logger) << "unitStr = " << unitStr;
|
||||
|
||||
return unitStr;
|
||||
}
|
||||
case GLOBAL:
|
||||
return config.exerciseId().is_set() ? tr("No") : tr("Yes");
|
||||
}
|
||||
}
|
||||
else if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (config.exerciseId().is_set() && config.exerciseId().get() == m_exerciseId)
|
||||
return {};
|
||||
if (!config.exerciseId().is_set() && m_exerciseId <= 0)
|
||||
return {};
|
||||
return QColor(Qt::gray);
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
return QVariant::fromValue(config);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
bool CombatNetRadioDialogModel::init(const std::shared_ptr<Interface::Dtc> &avmDtc, const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc)
|
||||
bool CombatNetRadioDialogModel::init(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc)
|
||||
{
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmDtc = avmDtc;
|
||||
|
||||
m_cnrChannels = avmDtc->cnrChannels();
|
||||
m_cnrChannels = avmDtc->cnrChannels();
|
||||
|
||||
if (!ppmDtc->visibleParties(m_parties, LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(m_exerciseId)))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not retrieve visible Parties!";
|
||||
return false;
|
||||
}
|
||||
m_units = ppmDtc->units();
|
||||
if (!ppmDtc->visibleParties(m_parties,
|
||||
LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(m_exerciseId)))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not retrieve visible Parties!";
|
||||
return false;
|
||||
}
|
||||
m_units = ppmDtc->units();
|
||||
|
||||
connect(m_avmDtc.get(), &Interface::Dtc::cnrConfigChanged, this, &CombatNetRadioDialogModel::onDataChanged);
|
||||
m_avmDtc->cnrConfigs([this](const CnrConfig &c) { insertRow(c); });
|
||||
connect(m_avmDtc.get(), &Interface::Dtc::cnrConfigChanged, this, &CombatNetRadioDialogModel::onDataChanged);
|
||||
m_avmDtc->cnrConfigs([this](const CnrConfig& c) { insertRow(c); });
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CombatNetRadioDialogModel::onlyGlobals()
|
||||
{
|
||||
for(const CnrConfig &config : std::as_const(m_vecData))
|
||||
{
|
||||
if(config.exerciseId().is_set() && config.exerciseId().get() == m_exerciseId)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
for (const CnrConfig& config : std::as_const(m_vecData))
|
||||
{
|
||||
if (config.exerciseId().is_set() && config.exerciseId().get() == m_exerciseId)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray CombatNetRadioDialogFilter::modelToJson() const
|
||||
{
|
||||
QVector<CnrConfig> configs;
|
||||
configs.reserve(rowCount());
|
||||
QVector<CnrConfig> configs;
|
||||
configs.reserve(rowCount());
|
||||
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
int sourceRow = mapToSource(index(row, 0)).row();
|
||||
configs.append(m_sourceModel->getRowData(sourceRow));
|
||||
}
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
int sourceRow = mapToSource(index(row, 0)).row();
|
||||
configs.append(m_sourceModel->getRowData(sourceRow));
|
||||
}
|
||||
|
||||
return cnrConfigVectorToJson(configs, m_exerciseId);
|
||||
return cnrConfigVectorToJson(configs, m_exerciseId);
|
||||
}
|
||||
|
||||
CombatNetRadioDialogFilter::CombatNetRadioDialogFilter(int32_t exerciseId, CombatNetRadioDialogModel *sourceModel)
|
||||
: m_exerciseId(exerciseId)
|
||||
, m_sourceModel(sourceModel)
|
||||
CombatNetRadioDialogFilter::CombatNetRadioDialogFilter(int32_t exerciseId, CombatNetRadioDialogModel* sourceModel)
|
||||
: m_exerciseId(exerciseId), m_sourceModel(sourceModel)
|
||||
{
|
||||
Q_ASSERT(sourceModel);
|
||||
setSourceModel(sourceModel);
|
||||
Q_ASSERT(sourceModel);
|
||||
setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool CombatNetRadioDialogFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
bool CombatNetRadioDialogFilter::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
|
||||
{
|
||||
CnrConfig cnrConfig = m_sourceModel->getRowData(sourceRow);
|
||||
CnrConfig cnrConfig = m_sourceModel->getRowData(sourceRow);
|
||||
|
||||
if (cnrConfig.exerciseId().is_set() && cnrConfig.exerciseId().get() != m_exerciseId)
|
||||
return false;
|
||||
if (cnrConfig.exerciseId().is_set() && cnrConfig.exerciseId().get() != m_exerciseId)
|
||||
return false;
|
||||
|
||||
return LtsColumnFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
return LtsColumnFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+30
-47
@@ -1,77 +1,60 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <Proxies/CombatNetRadio/Helper/cnr_frequency_planning_helper.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <Proxies/CombatNetRadio/Helper/cnr_frequency_planning_helper.h>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class CombatNetRadioDialogModel final
|
||||
: public LtsWidgets::LtsAbstractTableModel<CnrConfig>
|
||||
class CombatNetRadioDialogModel final : public LtsWidgets::LtsAbstractTableModel<CnrConfig>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
CHANNEL,
|
||||
RADIO_CIRCUIT,
|
||||
CALL_SIGN,
|
||||
PARTY,
|
||||
UNIT,
|
||||
GLOBAL
|
||||
};
|
||||
public:
|
||||
enum Columns { CHANNEL, RADIO_CIRCUIT, CALL_SIGN, PARTY, UNIT, GLOBAL };
|
||||
|
||||
explicit CombatNetRadioDialogModel(int32_t exerciseId, QObject *parent = nullptr);
|
||||
explicit CombatNetRadioDialogModel(int32_t exerciseId, QObject* parent = nullptr);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &avmDtc, const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc);
|
||||
bool onlyGlobals();
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
bool init(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc);
|
||||
bool onlyGlobals();
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
int32_t m_exerciseId;
|
||||
QMap<int32_t, CnrChannel> m_cnrChannels;
|
||||
QMap<int32_t, ParticipantManagement::Party> m_parties;
|
||||
QMap<int32_t, ParticipantManagement::Participant> m_units;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
int32_t m_exerciseId;
|
||||
QMap<int32_t, CnrChannel> m_cnrChannels;
|
||||
QMap<int32_t, ParticipantManagement::Party> m_parties;
|
||||
QMap<int32_t, ParticipantManagement::Participant> m_units;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class CombatNetRadioDialogFilter : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
public:
|
||||
explicit CombatNetRadioDialogFilter(int32_t exerciseId, CombatNetRadioDialogModel *sourceModel);
|
||||
public:
|
||||
explicit CombatNetRadioDialogFilter(int32_t exerciseId, CombatNetRadioDialogModel* sourceModel);
|
||||
|
||||
QByteArray modelToJson() const;
|
||||
QByteArray modelToJson() const;
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
|
||||
|
||||
private:
|
||||
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::setSourceModel;
|
||||
private:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::setSourceModel;
|
||||
|
||||
int32_t m_exerciseId;
|
||||
CombatNetRadioDialogModel *m_sourceModel;
|
||||
int32_t m_exerciseId;
|
||||
CombatNetRadioDialogModel* m_sourceModel;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
Q_DECLARE_METATYPE(AudioVideoManagement::CnrConfig)
|
||||
Q_DECLARE_METATYPE(AudioVideoManagement::FrequencyPlanningData)
|
||||
Executable → Regular
+425
-443
File diff suppressed because it is too large.
Load diff
Executable → Regular
+68
-82
@@ -1,19 +1,17 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <boost/optional.hpp>
|
||||
#include <memory>
|
||||
|
||||
@@ -25,7 +23,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -34,90 +32,78 @@ class EditCombatNetRadioDialog;
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class EditCombatNetRadioDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::ModifyCnrConfigReplyHandler
|
||||
class EditCombatNetRadioDialog : public LtsWidgets::LtsDialog, protected Interface::Ftc::ModifyCnrConfigReplyHandler
|
||||
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EditCombatNetRadioDialog(int32_t exerciseId, LtsSession::LtsSession* session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc, QWidget* parent);
|
||||
|
||||
explicit EditCombatNetRadioDialog(int32_t exerciseId,
|
||||
LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc,
|
||||
QWidget *parent);
|
||||
explicit EditCombatNetRadioDialog(const CnrConfig& cnrConfig, int32_t exerciseId, LtsSession::LtsSession* session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc, QWidget* parent);
|
||||
|
||||
|
||||
~EditCombatNetRadioDialog();
|
||||
|
||||
explicit EditCombatNetRadioDialog(const CnrConfig &cnrConfig,
|
||||
int32_t exerciseId,
|
||||
LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc,
|
||||
QWidget *parent);
|
||||
void retranslate() override;
|
||||
|
||||
~EditCombatNetRadioDialog();
|
||||
void onModifyCnrConfigReply(const Core::FunctionReplyObject& replyObject) override final
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void retranslate() override;
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool apply() override;
|
||||
|
||||
void onModifyCnrConfigReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
private:
|
||||
EditCombatNetRadioDialog(const boost::optional<int32_t>& id, int32_t exerciseId, LtsSession::LtsSession* session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc, ExerciseManagement::Interface::Dtc* exmDtc,
|
||||
QWidget* parent);
|
||||
|
||||
protected:
|
||||
void init(LtsSession::LtsSession* session);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool apply() override;
|
||||
void initCbChannelsForCreate();
|
||||
void initCbChannels(int channelId);
|
||||
void updateFreeChannelsAndTakenNames();
|
||||
void updateCbChannels(QVector<int>&& freeChannels, QMap<int, QString>&& channelsToDisable);
|
||||
QVector<int> exercisesToConsider() const;
|
||||
QVector<int> exercisesToIgnore() const;
|
||||
bool isNameValid(const QString& name) const;
|
||||
|
||||
private:
|
||||
EditCombatNetRadioDialog(const boost::optional<int32_t> &id,
|
||||
int32_t exerciseId,
|
||||
LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc,
|
||||
QWidget *parent);
|
||||
QByteArray cnrConfigRequestToJson();
|
||||
ModifyCnrConfigRequest createRequest();
|
||||
ModifyCnrConfigRequest jsonToModifyCnrConfig(const QByteArray& content);
|
||||
void setUiValues(const CnrConfig& cnrConfig);
|
||||
void setUiValuesForGlobal();
|
||||
|
||||
void init(LtsSession::LtsSession *session);
|
||||
private Q_SLOTS:
|
||||
void onPartyIndexChanged(int index);
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
void onChannelChanged(int index);
|
||||
|
||||
void initCbChannelsForCreate();
|
||||
void initCbChannels(int channelId);
|
||||
void updateFreeChannelsAndTakenNames();
|
||||
void updateCbChannels(QVector<int> &&freeChannels, QMap<int, QString> &&channelsToDisable);
|
||||
QVector<int> exercisesToConsider() const;
|
||||
QVector<int> exercisesToIgnore() const;
|
||||
bool isNameValid(const QString &name) const;
|
||||
|
||||
QByteArray cnrConfigRequestToJson();
|
||||
ModifyCnrConfigRequest createRequest();
|
||||
ModifyCnrConfigRequest jsonToModifyCnrConfig(const QByteArray &content);
|
||||
void setUiValues(const CnrConfig &cnrConfig);
|
||||
void setUiValuesForGlobal();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onPartyIndexChanged(int index);
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
void onChannelChanged(int index);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::EditCombatNetRadioDialog> m_ui;
|
||||
boost::optional<int32_t> m_id;
|
||||
int32_t m_exerciseId;
|
||||
boost::optional<int32_t> m_channelId;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
ExerciseManagement::Interface::Dtc *m_exmDtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
QMap<int32_t, ParticipantManagement::Participant> m_units;
|
||||
QVector<QString> m_takenNames;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
bool m_isGlobal;
|
||||
};
|
||||
}
|
||||
private:
|
||||
std::unique_ptr<Ui::EditCombatNetRadioDialog> m_ui;
|
||||
boost::optional<int32_t> m_id;
|
||||
int32_t m_exerciseId;
|
||||
boost::optional<int32_t> m_channelId;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
ExerciseManagement::Interface::Dtc* m_exmDtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
QMap<int32_t, ParticipantManagement::Participant> m_units;
|
||||
QVector<QString> m_takenNames;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
bool m_isGlobal;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+21
-25
@@ -1,11 +1,10 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -23,7 +22,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
@@ -31,36 +30,33 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class LoadCombatNetRadioDialogModel;
|
||||
|
||||
class LoadCombatNetRadioDialog
|
||||
: public LtsWidgets::LtsFramelessDialog
|
||||
class LoadCombatNetRadioDialog : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoadCombatNetRadioDialog(const QByteArray &data,
|
||||
LtsSession::LtsSession *session,
|
||||
QWidget *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoadCombatNetRadioDialog(const QByteArray& data, LtsSession::LtsSession* session,
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
~LoadCombatNetRadioDialog();
|
||||
~LoadCombatNetRadioDialog();
|
||||
|
||||
QVector<Core::RemoveElementRequest> removeRequests() const;
|
||||
QVector<ModifyCnrConfigRequest> modifyRequests() const;
|
||||
QVector<Core::RemoveElementRequest> removeRequests() const;
|
||||
QVector<ModifyCnrConfigRequest> modifyRequests() const;
|
||||
|
||||
bool isApplied() const;
|
||||
bool isApplied() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOk();
|
||||
private Q_SLOTS:
|
||||
void onOk();
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::unique_ptr<Ui::LoadCombatNetRadioDialog> m_ui;
|
||||
LoadCombatNetRadioDialogModel *m_model;
|
||||
bool m_isApplied = false;
|
||||
};
|
||||
}
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::unique_ptr<Ui::LoadCombatNetRadioDialog> m_ui;
|
||||
LoadCombatNetRadioDialogModel* m_model;
|
||||
bool m_isApplied = false;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+287
-302
@@ -1,427 +1,412 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_load_combat_net_radio_dialog_model.h"
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <Core/core.hpp>
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include "avm_cnr_json_helper.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <Core/core.hpp>
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
LoadCombatNetRadioDialogModel::LoadCombatNetRadioDialogModel(const QByteArray &data,
|
||||
LtsSession::LtsSession *session,
|
||||
QObject *parent)
|
||||
: LtsAbstractTableModel<CnrConfig>(
|
||||
LoadCombatNetRadioDialogModel::LoadCombatNetRadioDialogModel(const QByteArray& data, LtsSession::LtsSession* session,
|
||||
QObject* parent)
|
||||
: LtsAbstractTableModel<CnrConfig>(
|
||||
{tr("Include"), tr("Channel"), tr("Radio Circuit"), tr("Code Word"), tr("Conflict(s)")}, parent),
|
||||
m_exerciseId(session == nullptr ? 0 : session->exerciseId())
|
||||
{
|
||||
tr("Include"),
|
||||
tr("Channel"),
|
||||
tr("Radio Circuit"),
|
||||
tr("Code Word"),
|
||||
tr("Conflict(s)")
|
||||
}, parent)
|
||||
, m_exerciseId(session == nullptr ? 0 : session->exerciseId())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Own exercise id: " << m_exerciseId;
|
||||
DEBUG_LOG(m_logger) << "Own exercise id: " << m_exerciseId;
|
||||
|
||||
if (session != nullptr)
|
||||
{
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> avmDtc;
|
||||
|
||||
if (!session->getDtc<AudioVideoManagement::DataInterface>(avmDtc)
|
||||
|| !avmDtc->enableCnrChannel()
|
||||
|| !avmDtc->enableCnrConfig())
|
||||
ERROR_LOG(m_logger) << "Could not get AVM data";
|
||||
else
|
||||
if (session != nullptr)
|
||||
{
|
||||
m_cnrChannels = avmDtc->cnrChannels();
|
||||
m_cnrConfigs = avmDtc->cnrConfigs();
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> avmDtc;
|
||||
|
||||
if (!session->getDtc<AudioVideoManagement::DataInterface>(avmDtc) || !avmDtc->enableCnrChannel() ||
|
||||
!avmDtc->enableCnrConfig())
|
||||
ERROR_LOG(m_logger) << "Could not get AVM data";
|
||||
else
|
||||
{
|
||||
m_cnrChannels = avmDtc->cnrChannels();
|
||||
m_cnrConfigs = avmDtc->cnrConfigs();
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "cnrconfigs: " << m_cnrConfigs.size();
|
||||
DEBUG_LOG(m_logger) << "ownExerciseId: " << m_exerciseId;
|
||||
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> exmDtc;
|
||||
|
||||
if (!session->getDtc<ExerciseManagement::DataInterface>(exmDtc) || !exmDtc->enableExercise())
|
||||
ERROR_LOG(m_logger) << "Could not get EXM data";
|
||||
else
|
||||
m_exercises = exmDtc->exercises();
|
||||
|
||||
DEBUG_LOG(m_logger) << "exercises: " << m_exercises.size();
|
||||
}
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Got invalid session.";
|
||||
|
||||
m_vecData = jsonToCnrConfigVector(data);
|
||||
|
||||
m_includeStates.reserve(m_vecData.size());
|
||||
m_conflicts.reserve(m_vecData.size());
|
||||
|
||||
for (int32_t idxCounter = 0; idxCounter < m_vecData.size(); ++idxCounter)
|
||||
{
|
||||
Conflicts conflicts = getConflicts(idxCounter, m_vecData.at(idxCounter));
|
||||
|
||||
m_conflicts.append(conflicts);
|
||||
m_includeStates.append(conflicts == NO_CONFLICT ? Qt::Checked : Qt::Unchecked);
|
||||
|
||||
if (conflicts & CHANNEL_TAKEN_IN_GLOBAL || conflicts & RADIO_CIRCUIT_TAKEN_IN_GLOBAL)
|
||||
m_disabledRows.append(idxCounter);
|
||||
}
|
||||
}
|
||||
|
||||
Qt::ItemFlags LoadCombatNetRadioDialogModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
if (indexIsValid(index) && m_disabledRows.contains(index.row()))
|
||||
return Qt::NoItemFlags;
|
||||
|
||||
if (index.column() > 0)
|
||||
return LtsAbstractTableModel::flags(index);
|
||||
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | LtsAbstractTableModel::flags(index);
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
if (indexIsValid(index) && role == Qt::CheckStateRole && index.column() == 0 && value.canConvert<Qt::CheckState>())
|
||||
{
|
||||
m_includeStates[index.row()] = value.value<Qt::CheckState>();
|
||||
|
||||
emit dataChanged(index, index, {role});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "cnrconfigs: " << m_cnrConfigs.size();
|
||||
DEBUG_LOG(m_logger) << "ownExerciseId: " << m_exerciseId;
|
||||
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> exmDtc;
|
||||
|
||||
if (!session->getDtc<ExerciseManagement::DataInterface>(exmDtc)
|
||||
|| !exmDtc->enableExercise())
|
||||
ERROR_LOG(m_logger) << "Could not get EXM data";
|
||||
else
|
||||
m_exercises = exmDtc->exercises();
|
||||
|
||||
DEBUG_LOG(m_logger) << "exercises: " << m_exercises.size();
|
||||
}
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Got invalid session.";
|
||||
|
||||
m_vecData = jsonToCnrConfigVector(data);
|
||||
|
||||
m_includeStates.reserve(m_vecData.size());
|
||||
m_conflicts.reserve(m_vecData.size());
|
||||
|
||||
for (int32_t idxCounter = 0; idxCounter < m_vecData.size(); ++idxCounter)
|
||||
{
|
||||
Conflicts conflicts = getConflicts(idxCounter, m_vecData.at(idxCounter));
|
||||
|
||||
m_conflicts.append(conflicts);
|
||||
m_includeStates.append(conflicts == NO_CONFLICT ? Qt::Checked : Qt::Unchecked);
|
||||
|
||||
if (conflicts & CHANNEL_TAKEN_IN_GLOBAL || conflicts & RADIO_CIRCUIT_TAKEN_IN_GLOBAL)
|
||||
m_disabledRows.append(idxCounter);
|
||||
}
|
||||
return QAbstractTableModel::setData(index, value, role);
|
||||
}
|
||||
|
||||
Qt::ItemFlags LoadCombatNetRadioDialogModel::flags(const QModelIndex &index) const
|
||||
QVariant LoadCombatNetRadioDialogModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (indexIsValid(index) && m_disabledRows.contains(index.row()))
|
||||
return Qt::NoItemFlags;
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
if (index.column() > 0)
|
||||
return LtsAbstractTableModel::flags(index);
|
||||
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | LtsAbstractTableModel::flags(index);
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (indexIsValid(index)
|
||||
&& role == Qt::CheckStateRole
|
||||
&& index.column() == 0
|
||||
&& value.canConvert<Qt::CheckState>())
|
||||
{
|
||||
m_includeStates[index.row()] = value.value<Qt::CheckState>();
|
||||
|
||||
emit dataChanged(index, index, {role});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return QAbstractTableModel::setData(index, value, role);
|
||||
}
|
||||
|
||||
QVariant LoadCombatNetRadioDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
const CnrConfig &config = m_vecData.at(index.row());
|
||||
switch (index.column())
|
||||
switch (role)
|
||||
{
|
||||
case CHANNEL:
|
||||
return QString::fromStdString(m_cnrChannels.value(config.cnrChannelId()).name());
|
||||
case RADIO_CIRCUIT:
|
||||
return QString::fromStdString(config.radioCircuit());
|
||||
case CALL_SIGN:
|
||||
return QString::fromStdString(config.callSign());
|
||||
case CONFLICTS:
|
||||
return conflictsText(m_conflicts.at(index.row()));
|
||||
default:
|
||||
return QVariant();
|
||||
case Qt::DisplayRole: {
|
||||
const CnrConfig& config = m_vecData.at(index.row());
|
||||
switch (index.column())
|
||||
{
|
||||
case CHANNEL:
|
||||
return QString::fromStdString(m_cnrChannels.value(config.cnrChannelId()).name());
|
||||
case RADIO_CIRCUIT:
|
||||
return QString::fromStdString(config.radioCircuit());
|
||||
case CALL_SIGN:
|
||||
return QString::fromStdString(config.callSign());
|
||||
case CONFLICTS:
|
||||
return conflictsText(m_conflicts.at(index.row()));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
case Qt::CheckStateRole:
|
||||
if (index.column() != 0)
|
||||
return QVariant();
|
||||
return m_includeStates.at(index.row());
|
||||
case Qt::BackgroundRole:
|
||||
return getConflictsRowColor(m_conflicts.at(index.row()));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
case Qt::CheckStateRole:
|
||||
if (index.column() != 0)
|
||||
return QVariant();
|
||||
return m_includeStates.at(index.row());
|
||||
case Qt::BackgroundRole:
|
||||
return getConflictsRowColor(m_conflicts.at(index.row()));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::allChecked() const
|
||||
{
|
||||
for (int32_t row = 0; row < m_includeStates.size(); ++row)
|
||||
{
|
||||
if (m_disabledRows.contains(row))
|
||||
continue;
|
||||
for (int32_t row = 0; row < m_includeStates.size(); ++row)
|
||||
{
|
||||
if (m_disabledRows.contains(row))
|
||||
continue;
|
||||
|
||||
if (m_includeStates.at(row) == Qt::Unchecked)
|
||||
return false;
|
||||
}
|
||||
if (m_includeStates.at(row) == Qt::Unchecked)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void LoadCombatNetRadioDialogModel::setCheckState(bool isChecked)
|
||||
{
|
||||
const QVariant data = QVariant(isChecked ? Qt::Checked : Qt::Unchecked);
|
||||
const int role = Qt::CheckStateRole;
|
||||
const QVariant data = QVariant(isChecked ? Qt::Checked : Qt::Unchecked);
|
||||
const int role = Qt::CheckStateRole;
|
||||
|
||||
for (int32_t row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
if (m_disabledRows.contains(row))
|
||||
continue;
|
||||
for (int32_t row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
if (m_disabledRows.contains(row))
|
||||
continue;
|
||||
|
||||
setData(createIndex(row, 0), data, role);
|
||||
}
|
||||
setData(createIndex(row, 0), data, role);
|
||||
}
|
||||
}
|
||||
|
||||
LoadCombatNetRadioDialogModel::Conflicts LoadCombatNetRadioDialogModel::getConflicts(int32_t row, const CnrConfig &config)
|
||||
LoadCombatNetRadioDialogModel::Conflicts LoadCombatNetRadioDialogModel::getConflicts(int32_t row,
|
||||
const CnrConfig& config)
|
||||
{
|
||||
Conflicts conflicts = NO_CONFLICT;
|
||||
Conflicts conflicts = NO_CONFLICT;
|
||||
|
||||
for (auto it = m_cnrConfigs.constBegin(); it != m_cnrConfigs.constEnd(); ++it)
|
||||
{
|
||||
if (!(conflicts & RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG) && isRadioCircuitTakenInOwnConfig(config, it.value()))
|
||||
for (auto it = m_cnrConfigs.constBegin(); it != m_cnrConfigs.constEnd(); ++it)
|
||||
{
|
||||
conflicts |= RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
if (!(conflicts & RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG) && isRadioCircuitTakenInOwnConfig(config, it.value()))
|
||||
{
|
||||
conflicts |= RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE) &&
|
||||
isRadioCircuitTakenInAnotherExercise(config, it.value()))
|
||||
{
|
||||
conflicts |= RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_ACTIVE_EXERCISE) && isChannelTakenInActiveExercise(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_ACTIVE_EXERCISE;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_LINKED_EXERCISE) && isChannelTakenInLinkedExercise(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_LINKED_EXERCISE;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_OWN_CONFIG) && isChannelTakenInOwnConfig(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_OWN_CONFIG;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_GLOBAL) && isChannelTakenInGlobal(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_GLOBAL;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & RADIO_CIRCUIT_TAKEN_IN_GLOBAL) && isRadioCircuitTakenInGlobal(config, it.value()))
|
||||
{
|
||||
conflicts |= RADIO_CIRCUIT_TAKEN_IN_GLOBAL;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
}
|
||||
|
||||
if (!(conflicts & RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE) && isRadioCircuitTakenInAnotherExercise(config, it.value()))
|
||||
{
|
||||
conflicts |= RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_ACTIVE_EXERCISE) && isChannelTakenInActiveExercise(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_ACTIVE_EXERCISE;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_LINKED_EXERCISE) && isChannelTakenInLinkedExercise(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_LINKED_EXERCISE;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_OWN_CONFIG) && isChannelTakenInOwnConfig(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_OWN_CONFIG;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_GLOBAL) && isChannelTakenInGlobal(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_GLOBAL;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & RADIO_CIRCUIT_TAKEN_IN_GLOBAL) && isRadioCircuitTakenInGlobal(config, it.value()))
|
||||
{
|
||||
conflicts |= RADIO_CIRCUIT_TAKEN_IN_GLOBAL;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
}
|
||||
|
||||
return conflicts;
|
||||
return conflicts;
|
||||
}
|
||||
|
||||
QString LoadCombatNetRadioDialogModel::conflictsText(Conflicts conflicts) const
|
||||
{
|
||||
QStringList conflictTexts;
|
||||
QStringList conflictTexts;
|
||||
|
||||
if (conflicts & RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG)
|
||||
conflictTexts.append(tr("Radio Circuit is already taken in own config."));
|
||||
if (conflicts & RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG)
|
||||
conflictTexts.append(tr("Radio Circuit is already taken in own config."));
|
||||
|
||||
if (conflicts & RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE)
|
||||
conflictTexts.append(tr("Radio Circuit is already taken in another exercise."));
|
||||
if (conflicts & RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE)
|
||||
conflictTexts.append(tr("Radio Circuit is already taken in another exercise."));
|
||||
|
||||
if (conflicts & CHANNEL_TAKEN_IN_ACTIVE_EXERCISE)
|
||||
conflictTexts.append(tr("Channel already taken in active exercise."));
|
||||
if (conflicts & CHANNEL_TAKEN_IN_ACTIVE_EXERCISE)
|
||||
conflictTexts.append(tr("Channel already taken in active exercise."));
|
||||
|
||||
if (conflicts & CHANNEL_TAKEN_IN_LINKED_EXERCISE)
|
||||
conflictTexts.append(tr("Channel already taken in linked exercise."));
|
||||
if (conflicts & CHANNEL_TAKEN_IN_LINKED_EXERCISE)
|
||||
conflictTexts.append(tr("Channel already taken in linked exercise."));
|
||||
|
||||
if (conflicts & CHANNEL_TAKEN_IN_OWN_CONFIG)
|
||||
conflictTexts.append(tr("Channel is already taken in own Cnr Config."));
|
||||
if (conflicts & CHANNEL_TAKEN_IN_OWN_CONFIG)
|
||||
conflictTexts.append(tr("Channel is already taken in own Cnr Config."));
|
||||
|
||||
if (conflicts & CHANNEL_TAKEN_IN_GLOBAL)
|
||||
conflictTexts.append(tr("Channel already taken in global Cnr Config."));
|
||||
if (conflicts & CHANNEL_TAKEN_IN_GLOBAL)
|
||||
conflictTexts.append(tr("Channel already taken in global Cnr Config."));
|
||||
|
||||
if (conflicts & RADIO_CIRCUIT_TAKEN_IN_GLOBAL)
|
||||
conflictTexts.append(tr("Radio Circuit already taken in global Cnr Config."));
|
||||
if (conflicts & RADIO_CIRCUIT_TAKEN_IN_GLOBAL)
|
||||
conflictTexts.append(tr("Radio Circuit already taken in global Cnr Config."));
|
||||
|
||||
return conflictTexts.isEmpty() ? QLatin1String("-") : conflictTexts.join(QLatin1Char('\n'));
|
||||
return conflictTexts.isEmpty() ? QLatin1String("-") : conflictTexts.join(QLatin1Char('\n'));
|
||||
}
|
||||
|
||||
void LoadCombatNetRadioDialogModel::addConflictedCnr(int32_t row, int32_t cnrConfigId)
|
||||
{
|
||||
m_conflictedCnrIds[row].append(cnrConfigId);
|
||||
m_conflictedCnrIds[row].append(cnrConfigId);
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isActiveExercise(int32_t exerciseId) const
|
||||
{
|
||||
if (exerciseId == 0)
|
||||
return true;
|
||||
if (exerciseId == 0)
|
||||
return true;
|
||||
|
||||
using namespace ExerciseManagement;
|
||||
using namespace ExerciseManagement;
|
||||
|
||||
ExerciseState exerciseState = m_exercises.value(exerciseId).state();
|
||||
ExerciseState exerciseState = m_exercises.value(exerciseId).state();
|
||||
|
||||
return exerciseState == ExerciseState::Started || exerciseState == ExerciseState::Paused;
|
||||
return exerciseState == ExerciseState::Started || exerciseState == ExerciseState::Paused;
|
||||
}
|
||||
|
||||
QColor LoadCombatNetRadioDialogModel::getConflictsRowColor(Conflicts conflicts) const
|
||||
{
|
||||
if (conflicts >= CHANNEL_TAKEN_IN_GLOBAL)
|
||||
return QColor(Qt::red).lighter();
|
||||
if (conflicts >= CHANNEL_TAKEN_IN_GLOBAL)
|
||||
return QColor(Qt::red).lighter();
|
||||
|
||||
if (conflicts > NO_CONFLICT)
|
||||
return QColor(Qt::yellow).lighter();
|
||||
if (conflicts > NO_CONFLICT)
|
||||
return QColor(Qt::yellow).lighter();
|
||||
|
||||
return QColor(Qt::green).lighter();
|
||||
return QColor(Qt::green).lighter();
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isRadioCircuitTakenInOwnConfig(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const
|
||||
bool LoadCombatNetRadioDialogModel::isRadioCircuitTakenInOwnConfig(const CnrConfig& loadConfig,
|
||||
const CnrConfig& existingConfig) const
|
||||
{
|
||||
if (m_exerciseId == 0)
|
||||
return !existingConfig.exerciseId().is_set() && existingConfig.radioCircuit() == loadConfig.radioCircuit();
|
||||
if (m_exerciseId == 0)
|
||||
return !existingConfig.exerciseId().is_set() && existingConfig.radioCircuit() == loadConfig.radioCircuit();
|
||||
|
||||
if (!existingConfig.exerciseId().is_set()
|
||||
|| existingConfig.exerciseId().get() != m_exerciseId
|
||||
|| existingConfig.radioCircuit() != loadConfig.radioCircuit())
|
||||
return false;
|
||||
if (!existingConfig.exerciseId().is_set() || existingConfig.exerciseId().get() != m_exerciseId ||
|
||||
existingConfig.radioCircuit() != loadConfig.radioCircuit())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isRadioCircuitTakenInAnotherExercise(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const
|
||||
bool LoadCombatNetRadioDialogModel::isRadioCircuitTakenInAnotherExercise(const CnrConfig& loadConfig,
|
||||
const CnrConfig& existingConfig) const
|
||||
{
|
||||
if (!isActiveExercise(m_exerciseId)
|
||||
|| !existingConfig.exerciseId().is_set()
|
||||
|| !isActiveExercise(existingConfig.exerciseId().get())
|
||||
|| existingConfig.exerciseId().get() == m_exerciseId
|
||||
|| existingConfig.radioCircuit() != loadConfig.radioCircuit())
|
||||
return false;
|
||||
if (!isActiveExercise(m_exerciseId) || !existingConfig.exerciseId().is_set() ||
|
||||
!isActiveExercise(existingConfig.exerciseId().get()) || existingConfig.exerciseId().get() == m_exerciseId ||
|
||||
existingConfig.radioCircuit() != loadConfig.radioCircuit())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInActiveExercise(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInActiveExercise(const CnrConfig& loadConfig,
|
||||
const CnrConfig& existingConfig) const
|
||||
{
|
||||
int32_t exerciseId = existingConfig.exerciseId().is_set() ? existingConfig.exerciseId().get() : 0;
|
||||
int32_t exerciseId = existingConfig.exerciseId().is_set() ? existingConfig.exerciseId().get() : 0;
|
||||
|
||||
if (!isActiveExercise(m_exerciseId)
|
||||
|| exerciseId == 0
|
||||
|| exerciseId == m_exerciseId
|
||||
|| !isActiveExercise(exerciseId)
|
||||
|| existingConfig.cnrChannelId() != loadConfig.cnrChannelId()
|
||||
|| !isActiveExercise(exerciseId))
|
||||
return false;
|
||||
if (!isActiveExercise(m_exerciseId) || exerciseId == 0 || exerciseId == m_exerciseId ||
|
||||
!isActiveExercise(exerciseId) || existingConfig.cnrChannelId() != loadConfig.cnrChannelId() ||
|
||||
!isActiveExercise(exerciseId))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInLinkedExercise(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInLinkedExercise(const CnrConfig& loadConfig,
|
||||
const CnrConfig& existingConfig) const
|
||||
{
|
||||
if (m_exerciseId == 0 || m_exercises.value(m_exerciseId).linkedExerciseId() == 0)
|
||||
return false;
|
||||
if (m_exerciseId == 0 || m_exercises.value(m_exerciseId).linkedExerciseId() == 0)
|
||||
return false;
|
||||
|
||||
int32_t linkedExerciseId = m_exercises.value(m_exerciseId).linkedExerciseId();
|
||||
int32_t linkedExerciseId = m_exercises.value(m_exerciseId).linkedExerciseId();
|
||||
|
||||
int32_t exerciseId = existingConfig.exerciseId().is_set() ? existingConfig.exerciseId().get() : 0;
|
||||
int32_t exerciseId = existingConfig.exerciseId().is_set() ? existingConfig.exerciseId().get() : 0;
|
||||
|
||||
if (exerciseId != linkedExerciseId || existingConfig.cnrChannelId() != loadConfig.cnrChannelId())
|
||||
return false;
|
||||
if (exerciseId != linkedExerciseId || existingConfig.cnrChannelId() != loadConfig.cnrChannelId())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInOwnConfig(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInOwnConfig(const CnrConfig& loadConfig,
|
||||
const CnrConfig& existingConfig) const
|
||||
{
|
||||
int32_t exerciseId = existingConfig.exerciseId().is_set() ? existingConfig.exerciseId().get() : 0;
|
||||
int32_t exerciseId = existingConfig.exerciseId().is_set() ? existingConfig.exerciseId().get() : 0;
|
||||
|
||||
return existingConfig.cnrChannelId() == loadConfig.cnrChannelId() && exerciseId == m_exerciseId;
|
||||
return existingConfig.cnrChannelId() == loadConfig.cnrChannelId() && exerciseId == m_exerciseId;
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInGlobal(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInGlobal(const CnrConfig& loadConfig,
|
||||
const CnrConfig& existingConfig) const
|
||||
{
|
||||
if (!isActiveExercise(m_exerciseId)
|
||||
|| m_exerciseId == 0
|
||||
|| existingConfig.exerciseId().is_set()
|
||||
|| existingConfig.cnrChannelId() != loadConfig.cnrChannelId())
|
||||
return false;
|
||||
if (!isActiveExercise(m_exerciseId) || m_exerciseId == 0 || existingConfig.exerciseId().is_set() ||
|
||||
existingConfig.cnrChannelId() != loadConfig.cnrChannelId())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isRadioCircuitTakenInGlobal(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const
|
||||
bool LoadCombatNetRadioDialogModel::isRadioCircuitTakenInGlobal(const CnrConfig& loadConfig,
|
||||
const CnrConfig& existingConfig) const
|
||||
{
|
||||
if (!isActiveExercise(m_exerciseId)
|
||||
|| m_exerciseId == 0
|
||||
|| existingConfig.exerciseId().is_set()
|
||||
|| existingConfig.radioCircuit() != loadConfig.radioCircuit())
|
||||
return false;
|
||||
if (!isActiveExercise(m_exerciseId) || m_exerciseId == 0 || existingConfig.exerciseId().is_set() ||
|
||||
existingConfig.radioCircuit() != loadConfig.radioCircuit())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
QVector<Core::RemoveElementRequest> LoadCombatNetRadioDialogModel::removeRequests() const
|
||||
{
|
||||
QVector<Core::RemoveElementRequest> removeRequestsVec;
|
||||
QVector<Core::RemoveElementRequest> removeRequestsVec;
|
||||
|
||||
for (int32_t idxCounter = 0; idxCounter < m_includeStates.size(); ++idxCounter)
|
||||
{
|
||||
if (m_includeStates.at(idxCounter) == Qt::Checked && m_conflicts.at(idxCounter) != NO_CONFLICT)
|
||||
for (int32_t idxCounter = 0; idxCounter < m_includeStates.size(); ++idxCounter)
|
||||
{
|
||||
if (!m_conflictedCnrIds.contains(idxCounter))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Tried to get remove request for row " << idxCounter << " but it is not present.";
|
||||
continue;
|
||||
}
|
||||
if (m_includeStates.at(idxCounter) == Qt::Checked && m_conflicts.at(idxCounter) != NO_CONFLICT)
|
||||
{
|
||||
if (!m_conflictedCnrIds.contains(idxCounter))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Tried to get remove request for row " << idxCounter
|
||||
<< " but it is not present.";
|
||||
continue;
|
||||
}
|
||||
|
||||
const QVector<int32_t> cnrConfigIds = m_conflictedCnrIds.value(idxCounter);
|
||||
const QVector<int32_t> cnrConfigIds = m_conflictedCnrIds.value(idxCounter);
|
||||
|
||||
for (int32_t cnrConfigId : cnrConfigIds)
|
||||
{
|
||||
Core::RemoveElementRequest removeRequest(cnrConfigId);
|
||||
for (int32_t cnrConfigId : cnrConfigIds)
|
||||
{
|
||||
Core::RemoveElementRequest removeRequest(cnrConfigId);
|
||||
|
||||
if (!removeRequestsVec.contains(removeRequest))
|
||||
removeRequestsVec.append(removeRequest);
|
||||
}
|
||||
if (!removeRequestsVec.contains(removeRequest))
|
||||
removeRequestsVec.append(removeRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return removeRequestsVec;
|
||||
return removeRequestsVec;
|
||||
}
|
||||
|
||||
QVector<ModifyCnrConfigRequest> LoadCombatNetRadioDialogModel::modifyRequests() const
|
||||
{
|
||||
const dds::core::optional<int32_t> exerciseId = m_exerciseId == 0 ? dds::core::optional<int32_t>() : dds::core::optional<int32_t>(m_exerciseId);
|
||||
const int32_t partyId = m_exerciseId == 0 ? 1 : 0;
|
||||
QVector<ModifyCnrConfigRequest> modifyRequestsVec;
|
||||
const dds::core::optional<int32_t> exerciseId =
|
||||
m_exerciseId == 0 ? dds::core::optional<int32_t>() : dds::core::optional<int32_t>(m_exerciseId);
|
||||
const int32_t partyId = m_exerciseId == 0 ? 1 : 0;
|
||||
QVector<ModifyCnrConfigRequest> modifyRequestsVec;
|
||||
|
||||
modifyRequestsVec.reserve(m_includeStates.size());
|
||||
modifyRequestsVec.reserve(m_includeStates.size());
|
||||
|
||||
for (int32_t row = 0; row < m_includeStates.size(); ++row)
|
||||
{
|
||||
if (m_includeStates.at(row) != Qt::Checked)
|
||||
continue;
|
||||
for (int32_t row = 0; row < m_includeStates.size(); ++row)
|
||||
{
|
||||
if (m_includeStates.at(row) != Qt::Checked)
|
||||
continue;
|
||||
|
||||
const CnrConfig &cnrConfig = m_vecData.at(row);
|
||||
const CnrConfig& cnrConfig = m_vecData.at(row);
|
||||
|
||||
modifyRequestsVec.append({0,
|
||||
cnrConfig.cnrChannelId(),
|
||||
exerciseId,
|
||||
cnrConfig.radioCircuit(),
|
||||
cnrConfig.recording(),
|
||||
{},
|
||||
partyId,
|
||||
cnrConfig.callSign()});
|
||||
}
|
||||
modifyRequestsVec.append({0,
|
||||
cnrConfig.cnrChannelId(),
|
||||
exerciseId,
|
||||
cnrConfig.radioCircuit(),
|
||||
cnrConfig.recording(),
|
||||
{},
|
||||
partyId,
|
||||
cnrConfig.callSign()});
|
||||
}
|
||||
|
||||
return modifyRequestsVec;
|
||||
return modifyRequestsVec;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+54
-68
@@ -1,14 +1,13 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Proxies/CombatNetRadio/Helper/cnr_frequency_planning_helper.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <Proxies/CombatNetRadio/Helper/cnr_frequency_planning_helper.h>
|
||||
|
||||
namespace Core
|
||||
{
|
||||
@@ -21,7 +20,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
@@ -31,83 +30,70 @@ class LtsSession;
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class LoadCombatNetRadioDialogModel final
|
||||
: public LtsWidgets::LtsAbstractTableModel<CnrConfig>
|
||||
class LoadCombatNetRadioDialogModel final : public LtsWidgets::LtsAbstractTableModel<CnrConfig>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
INCLUDE,
|
||||
CHANNEL,
|
||||
RADIO_CIRCUIT,
|
||||
CALL_SIGN,
|
||||
CONFLICTS
|
||||
};
|
||||
public:
|
||||
enum Columns { INCLUDE, CHANNEL, RADIO_CIRCUIT, CALL_SIGN, CONFLICTS };
|
||||
|
||||
enum Conflict
|
||||
{
|
||||
NO_CONFLICT = 0,
|
||||
RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG = 0b00000001,
|
||||
RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE = 0b00000010,
|
||||
CHANNEL_TAKEN_IN_ACTIVE_EXERCISE = 0b00000100,
|
||||
CHANNEL_TAKEN_IN_LINKED_EXERCISE = 0b00001000,
|
||||
CHANNEL_TAKEN_IN_OWN_CONFIG = 0b00010000,
|
||||
enum Conflict {
|
||||
NO_CONFLICT = 0,
|
||||
RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG = 0b00000001,
|
||||
RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE = 0b00000010,
|
||||
CHANNEL_TAKEN_IN_ACTIVE_EXERCISE = 0b00000100,
|
||||
CHANNEL_TAKEN_IN_LINKED_EXERCISE = 0b00001000,
|
||||
CHANNEL_TAKEN_IN_OWN_CONFIG = 0b00010000,
|
||||
|
||||
|
||||
CHANNEL_TAKEN_IN_GLOBAL = 0b00100000,
|
||||
RADIO_CIRCUIT_TAKEN_IN_GLOBAL = 0b01000000,
|
||||
};
|
||||
Q_DECLARE_FLAGS(Conflicts, Conflict)
|
||||
CHANNEL_TAKEN_IN_GLOBAL = 0b00100000,
|
||||
RADIO_CIRCUIT_TAKEN_IN_GLOBAL = 0b01000000,
|
||||
};
|
||||
Q_DECLARE_FLAGS(Conflicts, Conflict)
|
||||
|
||||
explicit LoadCombatNetRadioDialogModel(const QByteArray &data,
|
||||
LtsSession::LtsSession *session,
|
||||
QObject *parent = nullptr);
|
||||
explicit LoadCombatNetRadioDialogModel(const QByteArray& data, LtsSession::LtsSession* session,
|
||||
QObject* parent = nullptr);
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
|
||||
bool allChecked() const;
|
||||
bool allChecked() const;
|
||||
|
||||
QVector<Core::RemoveElementRequest> removeRequests() const;
|
||||
QVector<AudioVideoManagement::ModifyCnrConfigRequest> modifyRequests() const;
|
||||
QVector<Core::RemoveElementRequest> removeRequests() const;
|
||||
QVector<AudioVideoManagement::ModifyCnrConfigRequest> modifyRequests() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setCheckState(bool isChecked);
|
||||
public Q_SLOTS:
|
||||
void setCheckState(bool isChecked);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
LoadCombatNetRadioDialogModel::Conflicts getConflicts(int32_t row, const CnrConfig& config);
|
||||
QString conflictsText(Conflicts conflicts) const;
|
||||
|
||||
bool isRadioCircuitTakenInOwnConfig(const CnrConfig& loadConfig, const CnrConfig& existingConfig) const;
|
||||
bool isRadioCircuitTakenInAnotherExercise(const CnrConfig& loadConfig, const CnrConfig& existingConfig) const;
|
||||
bool isChannelTakenInActiveExercise(const CnrConfig& loadConfig, const CnrConfig& existingConfig) const;
|
||||
bool isChannelTakenInLinkedExercise(const CnrConfig& loadConfig, const CnrConfig& existingConfig) const;
|
||||
bool isChannelTakenInOwnConfig(const CnrConfig& loadConfig, const CnrConfig& existingConfig) const;
|
||||
bool isChannelTakenInGlobal(const CnrConfig& loadConfig, const CnrConfig& existingConfig) const;
|
||||
bool isRadioCircuitTakenInGlobal(const CnrConfig& loadConfig, const CnrConfig& existingConfig) const;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
LoadCombatNetRadioDialogModel::Conflicts getConflicts(int32_t row, const CnrConfig &config);
|
||||
QString conflictsText(Conflicts conflicts) const;
|
||||
void addConflictedCnr(int32_t row, int32_t cnrConfigId);
|
||||
|
||||
bool isRadioCircuitTakenInOwnConfig(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const;
|
||||
bool isRadioCircuitTakenInAnotherExercise(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const;
|
||||
bool isChannelTakenInActiveExercise(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const;
|
||||
bool isChannelTakenInLinkedExercise(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const;
|
||||
bool isChannelTakenInOwnConfig(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const;
|
||||
bool isChannelTakenInGlobal(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const;
|
||||
bool isRadioCircuitTakenInGlobal(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const;
|
||||
bool isActiveExercise(int32_t exerciseId) const;
|
||||
|
||||
void addConflictedCnr(int32_t row, int32_t cnrConfigId);
|
||||
QColor getConflictsRowColor(Conflicts conflicts) const;
|
||||
|
||||
bool isActiveExercise(int32_t exerciseId) const;
|
||||
|
||||
QColor getConflictsRowColor(Conflicts conflicts) const;
|
||||
|
||||
private:
|
||||
int32_t m_exerciseId;
|
||||
QMap<int32_t, CnrChannel> m_cnrChannels;
|
||||
QMap<int32_t, CnrConfig> m_cnrConfigs;
|
||||
QMap<int32_t, ExerciseManagement::Exercise> m_exercises;
|
||||
QMap<int32_t, QVector<int32_t> > m_conflictedCnrIds;
|
||||
QVector<Qt::CheckState> m_includeStates;
|
||||
QVector<int32_t> m_disabledRows;
|
||||
QVector<Conflicts> m_conflicts;
|
||||
private:
|
||||
int32_t m_exerciseId;
|
||||
QMap<int32_t, CnrChannel> m_cnrChannels;
|
||||
QMap<int32_t, CnrConfig> m_cnrConfigs;
|
||||
QMap<int32_t, ExerciseManagement::Exercise> m_exercises;
|
||||
QMap<int32_t, QVector<int32_t>> m_conflictedCnrIds;
|
||||
QVector<Qt::CheckState> m_includeStates;
|
||||
QVector<int32_t> m_disabledRows;
|
||||
QVector<Conflicts> m_conflicts;
|
||||
};
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+251
-291
@@ -1,422 +1,382 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_edit_frequency_planning_dialog.h"
|
||||
#include <utility>
|
||||
#include "ui_avm_edit_frequency_planning_dialog.h"
|
||||
|
||||
#include "avm_edit_frequency_planning_frequency_data_model.h"
|
||||
#include "avm_load_frequency_planning_dialog.h"
|
||||
#include "ui_avm_edit_frequency_planning_dialog.h"
|
||||
|
||||
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <LtsDataView/lts_data_view.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <LtsDataView/lts_data_view.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include "avm_load_frequency_planning_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <utility>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool isActive(ExerciseManagement::ExerciseState state)
|
||||
{
|
||||
return (state == ExerciseManagement::ExerciseState::Started ||
|
||||
state == ExerciseManagement::ExerciseState::Paused);
|
||||
return (state == ExerciseManagement::ExerciseState::Started || state == ExerciseManagement::ExerciseState::Paused);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
EditFrequencyPlanningDialog::EditFrequencyPlanningDialog(LtsSession::LtsSession *session,
|
||||
const QString &menuGroup,
|
||||
const QString &freqPlanningDialogIdentifier,
|
||||
const FrequencyPlanning &planning,
|
||||
const bool copy,
|
||||
const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc,
|
||||
QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_session(session)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_freqPlanningDialogIdentifier(freqPlanningDialogIdentifier)
|
||||
, m_ui(new Ui::EditFrequencyPlanningDialog)
|
||||
, m_planning(planning)
|
||||
, m_avmDtc(avmDtc)
|
||||
, m_avmFtc(avmFtc)
|
||||
, m_ppmDtc(ppmDtc)
|
||||
, m_ismDtc(ismDtc)
|
||||
, m_exmDtc(exmDtc)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_frequencyDataModel(new EditFrequencyPlanningFrequencyDataModel(planning, m_session->exerciseId(), avmDtc, ismDtc, ppmDtc, this))
|
||||
, m_frequencyPlanningId(copy ? 0 : planning.id())
|
||||
, m_exerciseId(session->exerciseId())
|
||||
, m_isEdit(EditFrequencyPlanningSetResourceDialog::DialogMode::Assign)
|
||||
, m_activeFrequencyPlanningStatus(0)
|
||||
EditFrequencyPlanningDialog::EditFrequencyPlanningDialog(
|
||||
LtsSession::LtsSession* session, const QString& menuGroup, const QString& freqPlanningDialogIdentifier,
|
||||
const FrequencyPlanning& planning, const bool copy, const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc, const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc, ExerciseManagement::Interface::Dtc* exmDtc,
|
||||
QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_session(session),
|
||||
m_menuGroup(menuGroup), m_freqPlanningDialogIdentifier(freqPlanningDialogIdentifier),
|
||||
m_ui(new Ui::EditFrequencyPlanningDialog), m_planning(planning), m_avmDtc(avmDtc), m_avmFtc(avmFtc),
|
||||
m_ppmDtc(ppmDtc), m_ismDtc(ismDtc), m_exmDtc(exmDtc), m_requestHelper(new LtsUtils::RequestHelper(this)),
|
||||
m_frequencyDataModel(
|
||||
new EditFrequencyPlanningFrequencyDataModel(planning, m_session->exerciseId(), avmDtc, ismDtc, ppmDtc, this)),
|
||||
m_frequencyPlanningId(copy ? 0 : planning.id()), m_exerciseId(session->exerciseId()),
|
||||
m_isEdit(EditFrequencyPlanningSetResourceDialog::DialogMode::Assign), m_activeFrequencyPlanningStatus(0)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->leName->setText(QString::fromStdString(m_planning.name()));
|
||||
m_ui->lbDate->setText(DTG::toStringMSec(m_planning.date()));
|
||||
m_ui->leName->setText(QString::fromStdString(m_planning.name()));
|
||||
m_ui->lbDate->setText(DTG::toStringMSec(m_planning.date()));
|
||||
|
||||
|
||||
m_uiRequirements->addRequirement( { m_ui->label, [this]() { return !m_ui->leName->text().isEmpty(); } });
|
||||
m_uiRequirements->addRequirement({m_ui->label, [this]() { return !m_ui->leName->text().isEmpty(); }});
|
||||
|
||||
FPFDelegate *treeDelegate = new FPFDelegate(m_frequencyDataModel);
|
||||
m_ui->dvFrequencyData->treeView()->setItemDelegateForColumn(EditFrequencyPlanningFrequencyDataModel::Columns::PROPERTIES, treeDelegate);
|
||||
FPFDelegate* treeDelegate = new FPFDelegate(m_frequencyDataModel);
|
||||
m_ui->dvFrequencyData->treeView()->setItemDelegateForColumn(
|
||||
EditFrequencyPlanningFrequencyDataModel::Columns::PROPERTIES, treeDelegate);
|
||||
|
||||
m_ui->dvFrequencyData->setModel(m_frequencyDataModel);
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
m_ui->dvFrequencyData->setModel(m_frequencyDataModel);
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::RADIO_CIRCUIT_ID);
|
||||
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::RADIO_CIRCUIT_ID);
|
||||
|
||||
#endif
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::AKW_BUNDLE);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::AKW_RADIO_CIRCUIT);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::FSB_BUNDLE);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::COMSEC);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::DEVICE);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::PILOTTON);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::AKW_BUNDLE);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::AKW_RADIO_CIRCUIT);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::FSB_BUNDLE);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::COMSEC);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::DEVICE);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::PILOTTON);
|
||||
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &EditFrequencyPlanningDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &EditFrequencyPlanningDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &EditFrequencyPlanningDialog::onPrint);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &EditFrequencyPlanningDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &EditFrequencyPlanningDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &EditFrequencyPlanningDialog::onPrint);
|
||||
|
||||
connect(m_ui->dvFrequencyData, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &EditFrequencyPlanningDialog::enableSelectedUnassignButton);
|
||||
connect(m_ui->dvFrequencyData, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&EditFrequencyPlanningDialog::enableSelectedUnassignButton);
|
||||
|
||||
connect(m_ui->dvFrequencyData, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &EditFrequencyPlanningDialog::onAddClicked);
|
||||
connect(m_ui->dvFrequencyData, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&EditFrequencyPlanningDialog::onAddClicked);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
if (m_frequencyPlanningId == 0)
|
||||
slotChangesMade();
|
||||
if (m_frequencyPlanningId == 0)
|
||||
slotChangesMade();
|
||||
|
||||
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Assign"));
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Remove, tr("Unassign"));
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Assign"));
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Remove, tr("Unassign"));
|
||||
|
||||
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&EditFrequencyPlanningDialog::onImportButtonClicked,
|
||||
&EditFrequencyPlanningDialog::onExportButtonClicked);
|
||||
m_buttonBox->connectLibraryButton(this, &EditFrequencyPlanningDialog::onImportButtonClicked,
|
||||
&EditFrequencyPlanningDialog::onExportButtonClicked);
|
||||
|
||||
if (!session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
if (!session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Frequency_Planning"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Frequency_Planning"));
|
||||
}
|
||||
|
||||
EditFrequencyPlanningDialog::~EditFrequencyPlanningDialog()
|
||||
|
||||
{
|
||||
emit aboutToCloseMe(m_frequencyPlanningId);
|
||||
emit aboutToCloseMe(m_frequencyPlanningId);
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::retranslate()
|
||||
{
|
||||
translate(m_ui.get(), m_avmDtc->frequencyPlanning(m_frequencyPlanningId), tr("Frequency Planning"));
|
||||
translate(m_ui.get(), m_avmDtc->frequencyPlanning(m_frequencyPlanningId), tr("Frequency Planning"));
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onRemoveFrequencyPlanningReply(const Core::FunctionReplyObject &reply)
|
||||
void EditFrequencyPlanningDialog::onRemoveFrequencyPlanningReply(const Core::FunctionReplyObject& reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG(m_logger) << reply.str();
|
||||
m_requestHelper->requestReply(reply);
|
||||
if (reply.error())
|
||||
ERROR_LOG(m_logger) << reply.str();
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onModifyFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject)
|
||||
void EditFrequencyPlanningDialog::onModifyFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
if (!replyObject.error())
|
||||
m_frequencyDataModel->setFrequencePlanningId(replyObject.id());
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
if (!replyObject.error())
|
||||
m_frequencyDataModel->setFrequencePlanningId(replyObject.id());
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
|
||||
bool EditFrequencyPlanningDialog::apply()
|
||||
{
|
||||
if (!m_frequencyDataModel->checkResourceAssignments())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Multiple assignments with the same resource are not possible. Please correct the selected entries."));
|
||||
return false;
|
||||
}
|
||||
ModifyFrequencyPlanningRequest request = m_frequencyDataModel->modifyFrequencyPlanningRequest();
|
||||
if (!m_frequencyDataModel->checkResourceAssignments())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(
|
||||
this,
|
||||
tr("Multiple assignments with the same resource are not possible. Please correct the selected entries."));
|
||||
return false;
|
||||
}
|
||||
ModifyFrequencyPlanningRequest request = m_frequencyDataModel->modifyFrequencyPlanningRequest();
|
||||
|
||||
request.date(m_session->partitionTime());
|
||||
m_ui->lbDate->setText(DTG::toStringMSec(request.date()));
|
||||
m_planning.date() = request.date();
|
||||
request.id(m_frequencyPlanningId);
|
||||
request.name(m_ui->leName->text().toStdString());
|
||||
request.date(m_session->partitionTime());
|
||||
m_ui->lbDate->setText(DTG::toStringMSec(request.date()));
|
||||
m_planning.date() = request.date();
|
||||
request.id(m_frequencyPlanningId);
|
||||
request.name(m_ui->leName->text().toStdString());
|
||||
|
||||
return m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_avmFtc->modifyFrequencyPlanningRequest(request, this);
|
||||
});
|
||||
return m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_avmFtc->modifyFrequencyPlanningRequest(request, this); });
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onAddClicked()
|
||||
void EditFrequencyPlanningDialog::onAddClicked()
|
||||
{
|
||||
|
||||
|
||||
QModelIndex idx = m_ui->dvFrequencyData->currentIndex();
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
QModelIndex idx = m_ui->dvFrequencyData->currentIndex();
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
CnrConfig cnrConfigRow = m_frequencyDataModel->itemData(idx).cnrConfig;
|
||||
int cnrConfigId = cnrConfigRow.id();
|
||||
if (cnrConfigId <= 0)
|
||||
return;
|
||||
CnrConfig cnrConfigRow = m_frequencyDataModel->itemData(idx).cnrConfig;
|
||||
int cnrConfigId = cnrConfigRow.id();
|
||||
if (cnrConfigId <= 0)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "---RessourceDialog aufrufen...."
|
||||
<< " cnrConfigId: " << cnrConfigId
|
||||
<< " radioCircuit: " << cnrConfigRow.radioCircuit()
|
||||
<< " FrequencySetId: " << m_frequencyDataModel->getFrequencySetId();
|
||||
DEBUG_LOG(m_logger) << "---RessourceDialog aufrufen...."
|
||||
<< " cnrConfigId: " << cnrConfigId << " radioCircuit: " << cnrConfigRow.radioCircuit()
|
||||
<< " FrequencySetId: " << m_frequencyDataModel->getFrequencySetId();
|
||||
|
||||
FrequencyPlanningData fpd = m_frequencyDataModel->getfrequencyPlanningData(cnrConfigId);
|
||||
if (!fpd.cnrConfigId())
|
||||
{
|
||||
fpd.cnrConfigId(cnrConfigId);
|
||||
}
|
||||
|
||||
|
||||
EditFrequencyPlanningResourceDialog *frequencyPlanningResourceDialog
|
||||
= new EditFrequencyPlanningResourceDialog(m_frequencyDataModel->getFrequencySetId(),
|
||||
m_isEdit,
|
||||
this );
|
||||
FrequencyPlanningData fpd = m_frequencyDataModel->getfrequencyPlanningData(cnrConfigId);
|
||||
if (!fpd.cnrConfigId())
|
||||
{
|
||||
fpd.cnrConfigId(cnrConfigId);
|
||||
}
|
||||
|
||||
frequencyPlanningResourceDialog->init(m_session, fpd, m_frequencyDataModel->getAllocatedFrequencyPlanningSetIds());
|
||||
|
||||
connect(this, &QObject::destroyed,
|
||||
frequencyPlanningResourceDialog, &QObject::deleteLater);
|
||||
EditFrequencyPlanningResourceDialog* frequencyPlanningResourceDialog =
|
||||
new EditFrequencyPlanningResourceDialog(m_frequencyDataModel->getFrequencySetId(), m_isEdit, this);
|
||||
|
||||
addDialog(frequencyPlanningResourceDialog, m_menuGroup, QLatin1String("avmFrequencyPlanning") + QString::number(cnrConfigId), LtsWidgets::LayoutArea::eDialogTab);
|
||||
frequencyPlanningResourceDialog->init(m_session, fpd, m_frequencyDataModel->getAllocatedFrequencyPlanningSetIds());
|
||||
|
||||
connect(frequencyPlanningResourceDialog, &EditFrequencyPlanningResourceDialog::signalAssignRadioCircuit,
|
||||
this, &EditFrequencyPlanningDialog::onAssignRadioCircuit);
|
||||
connect(this, &QObject::destroyed, frequencyPlanningResourceDialog, &QObject::deleteLater);
|
||||
|
||||
addDialog(frequencyPlanningResourceDialog, m_menuGroup,
|
||||
QLatin1String("avmFrequencyPlanning") + QString::number(cnrConfigId), LtsWidgets::LayoutArea::eDialogTab);
|
||||
|
||||
connect(frequencyPlanningResourceDialog, &EditFrequencyPlanningResourceDialog::signalAssignRadioCircuit, this,
|
||||
&EditFrequencyPlanningDialog::onAssignRadioCircuit);
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onRemoveClicked()
|
||||
void EditFrequencyPlanningDialog::onRemoveClicked()
|
||||
{
|
||||
QModelIndex idx = m_ui->dvFrequencyData->currentIndex();
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
QModelIndex idx = m_ui->dvFrequencyData->currentIndex();
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
CnrConfig cnrConfigRow = m_frequencyDataModel->itemData(idx).cnrConfig;
|
||||
int cnrConfigId = cnrConfigRow.id();
|
||||
if (cnrConfigId <= 0)
|
||||
return;
|
||||
unassignRadioCircuit(cnrConfigId);
|
||||
CnrConfig cnrConfigRow = m_frequencyDataModel->itemData(idx).cnrConfig;
|
||||
int cnrConfigId = cnrConfigRow.id();
|
||||
if (cnrConfigId <= 0)
|
||||
return;
|
||||
unassignRadioCircuit(cnrConfigId);
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::enableSelectedUnassignButton()
|
||||
{
|
||||
QModelIndex idx = m_ui->dvFrequencyData->currentIndex();
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
QModelIndex idx = m_ui->dvFrequencyData->currentIndex();
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
auto itemData = m_frequencyDataModel->itemData(idx);
|
||||
CnrConfig cnrConfigRow = itemData.cnrConfig;
|
||||
int cnrConfigId = cnrConfigRow.id();
|
||||
if (cnrConfigId <= 0)
|
||||
return;
|
||||
auto itemData = m_frequencyDataModel->itemData(idx);
|
||||
CnrConfig cnrConfigRow = itemData.cnrConfig;
|
||||
int cnrConfigId = cnrConfigRow.id();
|
||||
if (cnrConfigId <= 0)
|
||||
return;
|
||||
|
||||
|
||||
FrequencyPlanningData fpd = m_frequencyDataModel->getfrequencyPlanningData(cnrConfigId);
|
||||
FrequencyPlanningData fpd = m_frequencyDataModel->getfrequencyPlanningData(cnrConfigId);
|
||||
|
||||
QVector<RadioCircuit*> circuits = AudioVideoManagement::fromJson(fpd.properties());
|
||||
QVector<RadioCircuit*> circuits = AudioVideoManagement::fromJson(fpd.properties());
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, true);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, true);
|
||||
|
||||
if( (!cnrConfigRow.exerciseId().is_set()
|
||||
&& m_planning.exerciseId().is_set())
|
||||
||
|
||||
itemData.readOnly
|
||||
)
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Show"));
|
||||
m_isEdit = EditFrequencyPlanningSetResourceDialog::DialogMode::Show;
|
||||
if (circuits.size() == 0)
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, false);
|
||||
}
|
||||
else if (circuits.size() > 0)
|
||||
{
|
||||
m_isEdit = EditFrequencyPlanningSetResourceDialog::DialogMode::Edit;
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Edit"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isEdit = EditFrequencyPlanningSetResourceDialog::DialogMode::Assign;
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Assign"));
|
||||
}
|
||||
if ((!cnrConfigRow.exerciseId().is_set() && m_planning.exerciseId().is_set()) || itemData.readOnly)
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Show"));
|
||||
m_isEdit = EditFrequencyPlanningSetResourceDialog::DialogMode::Show;
|
||||
if (circuits.size() == 0)
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, false);
|
||||
}
|
||||
else if (circuits.size() > 0)
|
||||
{
|
||||
m_isEdit = EditFrequencyPlanningSetResourceDialog::DialogMode::Edit;
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Edit"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isEdit = EditFrequencyPlanningSetResourceDialog::DialogMode::Assign;
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Assign"));
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "---enableAssignUnassignButtons()...."
|
||||
<< " cnrConfigId: " << cnrConfigId
|
||||
<< " radioCircuitId: " << cnrConfigRow.radioCircuit();
|
||||
DEBUG_LOG(m_logger) << "---enableAssignUnassignButtons()...."
|
||||
<< " cnrConfigId: " << cnrConfigId << " radioCircuitId: " << cnrConfigRow.radioCircuit();
|
||||
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, !itemData.readOnly && m_isEdit == EditFrequencyPlanningSetResourceDialog::DialogMode::Edit);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove,
|
||||
!itemData.readOnly &&
|
||||
m_isEdit == EditFrequencyPlanningSetResourceDialog::DialogMode::Edit);
|
||||
|
||||
qDeleteAll(circuits);
|
||||
qDeleteAll(circuits);
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onAssignRadioCircuit(const FrequencyPlanningData &fpd)
|
||||
void EditFrequencyPlanningDialog::onAssignRadioCircuit(const FrequencyPlanningData& fpd)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "---onAssignRadioCircuit()...."
|
||||
<< "CnrConfigId: " << fpd.cnrConfigId();
|
||||
<< "CnrConfigId: " << fpd.cnrConfigId();
|
||||
|
||||
m_frequencyDataModel->setFrequencyPlanningData(fpd);
|
||||
|
||||
if (!m_frequencyDataModel->checkResourceAssignments())
|
||||
{
|
||||
|
||||
focusDialog(m_menuGroup, m_freqPlanningDialogIdentifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Multiple assignments with the same resource are not possible. Please correct the selected entries."));
|
||||
return;
|
||||
}
|
||||
enableSelectedUnassignButton();
|
||||
slotChangesMade();
|
||||
m_ui->dvFrequencyData->repaint();
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
m_frequencyDataModel->setFrequencyPlanningData(fpd);
|
||||
|
||||
if (!m_frequencyDataModel->checkResourceAssignments())
|
||||
{
|
||||
|
||||
focusDialog(m_menuGroup, m_freqPlanningDialogIdentifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
LtsWidgets::LtsMessageDialog::showMessage(
|
||||
this,
|
||||
tr("Multiple assignments with the same resource are not possible. Please correct the selected entries."));
|
||||
return;
|
||||
}
|
||||
enableSelectedUnassignButton();
|
||||
slotChangesMade();
|
||||
m_ui->dvFrequencyData->repaint();
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->dvFrequencyData->treeView() );
|
||||
LtsPrinting::printView(m_session, this, m_ui->dvFrequencyData->treeView());
|
||||
}
|
||||
|
||||
int32_t EditFrequencyPlanningDialog::currentFrequencySetId() const
|
||||
{
|
||||
QModelIndex currentFrequencySetDataIndex = m_ui->dvFrequencyData->currentIndex();
|
||||
QModelIndex currentFrequencySetDataIndex = m_ui->dvFrequencyData->currentIndex();
|
||||
|
||||
if (!currentFrequencySetDataIndex.isValid())
|
||||
return -1;
|
||||
if (!currentFrequencySetDataIndex.isValid())
|
||||
return -1;
|
||||
|
||||
return m_frequencyDataModel->data(currentFrequencySetDataIndex, Qt::UserRole).toInt();
|
||||
return m_frequencyDataModel->data(currentFrequencySetDataIndex, Qt::UserRole).toInt();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QVector<int> EditFrequencyPlanningDialog::otherActiveExercises() const
|
||||
{
|
||||
const auto allExercises_ = m_exmDtc->exercises();
|
||||
const auto allExercises_ = m_exmDtc->exercises();
|
||||
|
||||
Q_ASSERT(::isActive(allExercises_[m_exerciseId].state()));
|
||||
Q_ASSERT(::isActive(allExercises_[m_exerciseId].state()));
|
||||
|
||||
auto allExercises = allExercises_.values();
|
||||
auto newEnd = std::remove_if(allExercises.begin(), allExercises.end(),
|
||||
[](const ExerciseManagement::Exercise& ex) { return ex.isDeleted(); });
|
||||
allExercises.erase(newEnd, allExercises.end());
|
||||
|
||||
auto allExercises = allExercises_.values();
|
||||
auto newEnd = std::remove_if(allExercises.begin(), allExercises.end(), [] (const ExerciseManagement::Exercise &ex) { return ex.isDeleted(); });
|
||||
allExercises.erase(newEnd, allExercises.end());
|
||||
QVector<int> toBeConsidered;
|
||||
for (const auto& exercise : std::as_const(allExercises))
|
||||
{
|
||||
if (exercise.id() == m_exerciseId)
|
||||
continue;
|
||||
|
||||
QVector<int> toBeConsidered;
|
||||
for (const auto &exercise : std::as_const(allExercises))
|
||||
{
|
||||
if (exercise.id() == m_exerciseId)
|
||||
continue;
|
||||
|
||||
if (::isActive(exercise.state()))
|
||||
toBeConsidered.append(exercise.id());
|
||||
}
|
||||
return toBeConsidered;
|
||||
if (::isActive(exercise.state()))
|
||||
toBeConsidered.append(exercise.id());
|
||||
}
|
||||
return toBeConsidered;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QVector<int> EditFrequencyPlanningDialog::otherActivePlans() const
|
||||
{
|
||||
QVector<int> result;
|
||||
QVector<int> exercises = otherActiveExercises();
|
||||
QVector<int> result;
|
||||
QVector<int> exercises = otherActiveExercises();
|
||||
|
||||
const auto activePlans = m_avmDtc->activeFrequencyPlannings();
|
||||
for (const auto &activePlan : activePlans)
|
||||
{
|
||||
if (exercises.contains(activePlan.exerciseId()))
|
||||
result.append(activePlan.frequencyPlanningId());
|
||||
}
|
||||
return result;
|
||||
const auto activePlans = m_avmDtc->activeFrequencyPlannings();
|
||||
for (const auto& activePlan : activePlans)
|
||||
{
|
||||
if (exercises.contains(activePlan.exerciseId()))
|
||||
result.append(activePlan.frequencyPlanningId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::unassignRadioCircuit(int32_t cnrConfigId)
|
||||
{
|
||||
m_frequencyDataModel->unassignRadioCircuit(cnrConfigId);
|
||||
enableSelectedUnassignButton();
|
||||
slotChangesMade();
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
m_frequencyDataModel->unassignRadioCircuit(cnrConfigId);
|
||||
enableSelectedUnassignButton();
|
||||
slotChangesMade();
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = m_frequencyDataModel->uiToJson();
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
QByteArray byteArray = m_frequencyDataModel->uiToJson();
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
DEBUG_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(), FileManagement::toString(FileManagement::XmlType::AVMEditFrequencyPlanning));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMEditFrequencyPlanning)))
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(),
|
||||
FileManagement::toString(FileManagement::XmlType::AVMEditFrequencyPlanning));
|
||||
if (fileId > 0)
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("Invalid xml file content"),
|
||||
windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes,
|
||||
texts);
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMEditFrequencyPlanning)))
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Invalid xml file content"), windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal, LtsWidgets::Button::Yes, texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadFrequencyPlanningDialog loadingDialog(content, m_frequencyDataModel->toFrequencyPlanning(), m_avmDtc,
|
||||
m_ismDtc);
|
||||
loadingDialog.exec();
|
||||
|
||||
if (loadingDialog.isApplied())
|
||||
{
|
||||
const QVector<int> unassignments = loadingDialog.unassignments();
|
||||
|
||||
for (int idToUnassign : unassignments)
|
||||
m_frequencyDataModel->unassignRadioCircuit(idToUnassign);
|
||||
|
||||
const QVector<FrequencyPlanningData> planningData = loadingDialog.newPlanningData();
|
||||
|
||||
for (const FrequencyPlanningData& currentData : planningData)
|
||||
m_frequencyDataModel->setFrequencyPlanningData(currentData);
|
||||
|
||||
slotChangesMade();
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadFrequencyPlanningDialog loadingDialog(content, m_frequencyDataModel->toFrequencyPlanning(), m_avmDtc, m_ismDtc) ;
|
||||
loadingDialog.exec();
|
||||
|
||||
if (loadingDialog.isApplied())
|
||||
{
|
||||
const QVector<int> unassignments = loadingDialog.unassignments();
|
||||
|
||||
for (int idToUnassign : unassignments)
|
||||
m_frequencyDataModel->unassignRadioCircuit(idToUnassign);
|
||||
|
||||
const QVector<FrequencyPlanningData> planningData = loadingDialog.newPlanningData();
|
||||
|
||||
for (const FrequencyPlanningData ¤tData : planningData)
|
||||
m_frequencyDataModel->setFrequencyPlanningData(currentData);
|
||||
|
||||
slotChangesMade();
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+742
-806
File diff suppressed because it is too large.
Load diff
Executable → Regular
+69
-74
@@ -1,99 +1,94 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_edit_frequency_planning_resource_data_model.h"
|
||||
#include <Proxies/CombatNetRadio/Helper/cnr_frequency_planning_helper.h>
|
||||
|
||||
#include <AudioVideoManagement/avm_translation.h>
|
||||
#include <Proxies/CombatNetRadio/Helper/cnr_frequency_planning_helper.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
EditFrequencyPlanningResourceDataModel::EditFrequencyPlanningResourceDataModel(const QSet<int> &assignedFrequencySetDataIds,
|
||||
const FrequencyBand frequencyBand,
|
||||
QObject *parent)
|
||||
: LtsAbstractTableModel<FrequencySetDataWithId>(
|
||||
{
|
||||
tr("FSD id"),
|
||||
tr("Function"),
|
||||
tr("Device"),
|
||||
tr("Frequency"),
|
||||
tr("AKW Bundle"),
|
||||
tr("FSB Bundle"),
|
||||
tr("AKW Radio Circuit"),
|
||||
tr("COMSEC"),
|
||||
}, parent)
|
||||
, m_assignedFrequencySetDataIds(assignedFrequencySetDataIds)
|
||||
, m_frequencyBand(frequencyBand)
|
||||
EditFrequencyPlanningResourceDataModel::EditFrequencyPlanningResourceDataModel(
|
||||
const QSet<int>& assignedFrequencySetDataIds, const FrequencyBand frequencyBand, QObject* parent)
|
||||
: LtsAbstractTableModel<FrequencySetDataWithId>(
|
||||
{
|
||||
tr("FSD id"),
|
||||
tr("Function"),
|
||||
tr("Device"),
|
||||
tr("Frequency"),
|
||||
tr("AKW Bundle"),
|
||||
tr("FSB Bundle"),
|
||||
tr("AKW Radio Circuit"),
|
||||
tr("COMSEC"),
|
||||
},
|
||||
parent),
|
||||
m_assignedFrequencySetDataIds(assignedFrequencySetDataIds), m_frequencyBand(frequencyBand)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant EditFrequencyPlanningResourceDataModel::data(const QModelIndex &index, int role) const
|
||||
QVariant EditFrequencyPlanningResourceDataModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if ((role != Qt::DisplayRole && role != Qt::UserRole) || !indexIsValid(index))
|
||||
return QVariant();
|
||||
if ((role != Qt::DisplayRole && role != Qt::UserRole) || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const FrequencySetDataWithId &setData = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
QLocale locale(QLocale::German);
|
||||
switch (index.column())
|
||||
const FrequencySetDataWithId& setData = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
case FREQ_SET_DATA_ID:
|
||||
return setData.id();
|
||||
case FUNCTION:
|
||||
return QString::fromStdString(setData.function());
|
||||
case DEVICE:
|
||||
return toString(setData.frequencyBand());
|
||||
case FREQUENCY:
|
||||
return tr("%1 MHz").arg(locale.toString(setData.frequency() / 1000., 'f', 3));
|
||||
case AKW_BUNDLE:
|
||||
if (setData.akwBundle().is_set())
|
||||
return setData.akwBundle().get();
|
||||
return QStringLiteral("-");
|
||||
case FSB_BUNDLE:
|
||||
if (setData.fsbBundle().is_set())
|
||||
return setData.fsbBundle().get();
|
||||
return QStringLiteral("-");
|
||||
case AKW_RADIO_CIRCUIT:
|
||||
if (setData.akwRadioCircuit())
|
||||
return setData.akwRadioCircuit().get();
|
||||
return QStringLiteral("-");
|
||||
case COMSEC:
|
||||
if (setData.comsec().is_set())
|
||||
return setData.comsec().get();
|
||||
return QStringLiteral("-");
|
||||
QLocale locale(QLocale::German);
|
||||
switch (index.column())
|
||||
{
|
||||
case FREQ_SET_DATA_ID:
|
||||
return setData.id();
|
||||
case FUNCTION:
|
||||
return QString::fromStdString(setData.function());
|
||||
case DEVICE:
|
||||
return toString(setData.frequencyBand());
|
||||
case FREQUENCY:
|
||||
return tr("%1 MHz").arg(locale.toString(setData.frequency() / 1000., 'f', 3));
|
||||
case AKW_BUNDLE:
|
||||
if (setData.akwBundle().is_set())
|
||||
return setData.akwBundle().get();
|
||||
return QStringLiteral("-");
|
||||
case FSB_BUNDLE:
|
||||
if (setData.fsbBundle().is_set())
|
||||
return setData.fsbBundle().get();
|
||||
return QStringLiteral("-");
|
||||
case AKW_RADIO_CIRCUIT:
|
||||
if (setData.akwRadioCircuit())
|
||||
return setData.akwRadioCircuit().get();
|
||||
return QStringLiteral("-");
|
||||
case COMSEC:
|
||||
if (setData.comsec().is_set())
|
||||
return setData.comsec().get();
|
||||
return QStringLiteral("-");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
return setData.id();
|
||||
else if (role == Qt::UserRole)
|
||||
return setData.id();
|
||||
|
||||
return QVariant();
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool EditFrequencyPlanningResourceDataModel::isFiltered(const AudioVideoManagement::FrequencySetDataWithId &data, DataModification modType) const
|
||||
bool EditFrequencyPlanningResourceDataModel::isFiltered(const AudioVideoManagement::FrequencySetDataWithId& data,
|
||||
DataModification modType) const
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (m_frequencyBand != FrequencyBand_def::REL &&
|
||||
data.frequencyBand() != m_frequencyBand)
|
||||
return true;
|
||||
if (m_frequencyBand != FrequencyBand_def::REL && data.frequencyBand() != m_frequencyBand)
|
||||
return true;
|
||||
|
||||
|
||||
if(m_frequencyBand == FrequencyBand_def::REL &&
|
||||
data.frequencyBand() != FrequencyBand_def::VHF)
|
||||
return true;
|
||||
if (m_frequencyBand == FrequencyBand_def::REL && data.frequencyBand() != FrequencyBand_def::VHF)
|
||||
return true;
|
||||
|
||||
Q_UNUSED(modType);
|
||||
|
||||
if (m_assignedFrequencySetDataIds.contains(data.id()))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "---m_assignments.size(): " << m_assignedFrequencySetDataIds.size()
|
||||
<< " frequencySetDataId: " << data.id() << " ist bereits enthalten";
|
||||
return true;
|
||||
}
|
||||
Q_UNUSED(modType);
|
||||
|
||||
return false;
|
||||
if (m_assignedFrequencySetDataIds.contains(data.id()))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "---m_assignments.size(): " << m_assignedFrequencySetDataIds.size()
|
||||
<< " frequencySetDataId: " << data.id() << " ist bereits enthalten";
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+344
-364
@@ -1,491 +1,471 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_frequency_planning_dialog.h"
|
||||
#include "ui_avm_frequency_planning_dialog.h"
|
||||
#include "avm_frequency_planning_dialog_model.h"
|
||||
|
||||
#include "avm_edit_frequency_planning_dialog.h"
|
||||
#include "avm_frequency_planning_dialog_model.h"
|
||||
#include "avm_init_frequency_planning_dialog.h"
|
||||
#include "ui_avm_frequency_planning_dialog.h"
|
||||
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <AudioVideoManagement/avm_translation.h>
|
||||
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <QMessageBox>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
FrequencyPlanningDialog::FrequencyPlanningDialog(LtsSession::LtsSession *session, const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ui(new Ui::FrequencyPlanningDialog)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_copy(false)
|
||||
, m_session(session)
|
||||
, m_model(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_activePlanning( { -1, -1 })
|
||||
, m_avmDtc(nullptr)
|
||||
, m_avmFtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_ismDtc(nullptr)
|
||||
, m_flmGui(nullptr)
|
||||
, m_activeFrequencyPlanningStatus(0)
|
||||
FrequencyPlanningDialog::FrequencyPlanningDialog(LtsSession::LtsSession* session, const QString& menuGroup,
|
||||
QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_ui(new Ui::FrequencyPlanningDialog),
|
||||
m_menuGroup(menuGroup), m_copy(false), m_session(session), m_model(nullptr),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this)), m_activePlanning({-1, -1}), m_avmDtc(nullptr),
|
||||
m_avmFtc(nullptr), m_ppmDtc(nullptr), m_ismDtc(nullptr), m_flmGui(nullptr), m_activeFrequencyPlanningStatus(0)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
DEBUG_LOG(m_logger) << "---FrequencyPlanningDialog() ";
|
||||
m_ui->dataView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_ui->dataView->treeView()->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &FrequencyPlanningDialog::onPrint);
|
||||
DEBUG_LOG(m_logger) << "---FrequencyPlanningDialog() ";
|
||||
m_ui->dataView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_ui->dataView->treeView()->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Frequency_Planning"));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &FrequencyPlanningDialog::onPrint);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Frequency_Planning"));
|
||||
}
|
||||
|
||||
FrequencyPlanningDialog::~FrequencyPlanningDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Frequency Planning"));
|
||||
translate(m_ui, tr("Frequency Planning"));
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::unsetActiveFrequencyPlanning()
|
||||
{
|
||||
m_ui->lbActiveFrequencyPlanning->setText(tr("No Frequency Planning set"));
|
||||
m_activePlanning = { -1, -1 };
|
||||
m_model->unsetActivePlanning();
|
||||
onSelectionChanged();
|
||||
m_ui->lbActiveFrequencyPlanning->setText(tr("No Frequency Planning set"));
|
||||
m_activePlanning = {-1, -1};
|
||||
m_model->unsetActivePlanning();
|
||||
onSelectionChanged();
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::setActiveFrequencyPlanning(const ActiveFrequencyPlanning &activePlanning)
|
||||
void FrequencyPlanningDialog::setActiveFrequencyPlanning(const ActiveFrequencyPlanning& activePlanning)
|
||||
{
|
||||
m_ui->lbActiveFrequencyPlanning->setText(QString::fromStdString(m_avmDtc->frequencyPlanning(activePlanning.frequencyPlanningId()).name()));
|
||||
m_activePlanning = activePlanning;
|
||||
m_model->setActivePlanning(m_activePlanning.frequencyPlanningId());
|
||||
onSelectionChanged();
|
||||
m_ui->lbActiveFrequencyPlanning->setText(
|
||||
QString::fromStdString(m_avmDtc->frequencyPlanning(activePlanning.frequencyPlanningId()).name()));
|
||||
m_activePlanning = activePlanning;
|
||||
m_model->setActivePlanning(m_activePlanning.frequencyPlanningId());
|
||||
onSelectionChanged();
|
||||
}
|
||||
|
||||
bool FrequencyPlanningDialog::init(const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc)
|
||||
bool FrequencyPlanningDialog::init(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc)
|
||||
{
|
||||
if (!(ppmDtc->enableParty() &&
|
||||
ppmDtc->enableParticipant() &&
|
||||
ppmDtc->enableType() &&
|
||||
avmDtc->enableCnrConfig() &&
|
||||
avmDtc->enableFrequencyPlanning() &&
|
||||
avmDtc->enableFrequencySet() &&
|
||||
avmDtc->enableActiveFrequencyPlanning() &&
|
||||
ismDtc->enableMainStructureElement()))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable topics";
|
||||
return false;
|
||||
}
|
||||
if (!(ppmDtc->enableParty() && ppmDtc->enableParticipant() && ppmDtc->enableType() && avmDtc->enableCnrConfig() &&
|
||||
avmDtc->enableFrequencyPlanning() && avmDtc->enableFrequencySet() &&
|
||||
avmDtc->enableActiveFrequencyPlanning() && ismDtc->enableMainStructureElement()))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable topics";
|
||||
return false;
|
||||
}
|
||||
|
||||
delete m_model;
|
||||
m_model = new FrequencyPlanningDialogModel(m_session->exerciseId(), this);
|
||||
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_ismDtc = ismDtc;
|
||||
m_exmDtc = exmDtc;
|
||||
|
||||
if (!m_model->init(avmDtc))
|
||||
{
|
||||
delete m_model;
|
||||
m_model = nullptr;
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
m_model = new FrequencyPlanningDialogModel(m_session->exerciseId(), this);
|
||||
|
||||
m_proxyModel = new FrequencyPlanningDialogProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->dataView->setModel(m_proxyModel);
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_ismDtc = ismDtc;
|
||||
m_exmDtc = exmDtc;
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &FrequencyPlanningDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &FrequencyPlanningDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &FrequencyPlanningDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this, &FrequencyPlanningDialog::onActivateDeactivatePlanningClicked);
|
||||
if (!m_model->init(avmDtc))
|
||||
{
|
||||
delete m_model;
|
||||
m_model = nullptr;
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &FrequencyPlanningDialog::onSelectionChanged);
|
||||
m_proxyModel = new FrequencyPlanningDialogProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->dataView->setModel(m_proxyModel);
|
||||
|
||||
unsetActiveFrequencyPlanning();
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &FrequencyPlanningDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &FrequencyPlanningDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &FrequencyPlanningDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this,
|
||||
&FrequencyPlanningDialog::onActivateDeactivatePlanningClicked);
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&FrequencyPlanningDialog::onSelectionChanged);
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &FrequencyPlanningDialog::onEditClicked);
|
||||
connect(m_avmDtc.get(), &Interface::Dtc::activeFrequencyPlanningChanged,
|
||||
this, &FrequencyPlanningDialog::onActiveFrequencyPlanningChanged);
|
||||
unsetActiveFrequencyPlanning();
|
||||
|
||||
m_ui->dataView->hideColumn(FrequencyPlanningDialogModel::Columns::SET);
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&FrequencyPlanningDialog::onEditClicked);
|
||||
connect(m_avmDtc.get(), &Interface::Dtc::activeFrequencyPlanningChanged, this,
|
||||
&FrequencyPlanningDialog::onActiveFrequencyPlanningChanged);
|
||||
|
||||
m_avmDtc->activeFrequencyPlannings([this](const ActiveFrequencyPlanning & data)
|
||||
{
|
||||
onActiveFrequencyPlanningChanged(data, DataModification::eAdded);
|
||||
});
|
||||
onSelectionChanged();
|
||||
m_ui->dataView->hideColumn(FrequencyPlanningDialogModel::Columns::SET);
|
||||
|
||||
setStatus(tr("No active Radio Controller connected."), {}, time(0) * 1000, TransmissionReason::TR_Unknown, Qt::red);
|
||||
for(auto &elem : m_avmDtc->frequencyPlanningStatuss())
|
||||
{
|
||||
if (!elem.isActive())
|
||||
continue;
|
||||
m_activeFrequencyPlanningStatus = elem.id();
|
||||
onFrequencyPlanningStatusChanged(elem, DataModification::eAdded);
|
||||
}
|
||||
connect(m_avmDtc.get(), &Interface::Dtc::frequencyPlanningStatusChanged, this, &FrequencyPlanningDialog::onFrequencyPlanningStatusChanged);
|
||||
m_avmDtc->activeFrequencyPlannings([this](const ActiveFrequencyPlanning& data) {
|
||||
onActiveFrequencyPlanningChanged(data, DataModification::eAdded);
|
||||
});
|
||||
onSelectionChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onFrequencyPlanningStatusChanged(const AudioVideoManagement::FrequencyPlanningStatus &data, DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
if (data.id() != m_activeFrequencyPlanningStatus)
|
||||
return;
|
||||
}
|
||||
else if (modType == DataModification::eRemoved)
|
||||
{
|
||||
if (data.id() != m_activeFrequencyPlanningStatus)
|
||||
return;
|
||||
|
||||
m_activeFrequencyPlanningStatus = 0;
|
||||
setStatus(tr("No active Radio Controller connected."), {}, time(0) * 1000, TransmissionReason::TR_Unknown, Qt::red);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!data.isActive())
|
||||
return;
|
||||
m_activeFrequencyPlanningStatus = data.id();
|
||||
}
|
||||
for (auto& elem : m_avmDtc->frequencyPlanningStatuss())
|
||||
{
|
||||
if (!elem.isActive())
|
||||
continue;
|
||||
m_activeFrequencyPlanningStatus = elem.id();
|
||||
onFrequencyPlanningStatusChanged(elem, DataModification::eAdded);
|
||||
}
|
||||
connect(m_avmDtc.get(), &Interface::Dtc::frequencyPlanningStatusChanged, this,
|
||||
&FrequencyPlanningDialog::onFrequencyPlanningStatusChanged);
|
||||
|
||||
|
||||
|
||||
if (data.activated().is_set())
|
||||
{
|
||||
setStatus(tr("Activated"), QString::fromStdString(data.requester()), data.activated().get(), data.reason(), Qt::green);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.received().is_set())
|
||||
{
|
||||
setStatus(tr("In Progress"), QString::fromStdString(data.requester()), data.received().get(), data.reason(), Qt::yellow);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.sent().is_set())
|
||||
{
|
||||
setStatus(tr("Sent"), QString::fromStdString(data.requester()), data.sent().get(), TransmissionReason::TR_Unknown, Qt::yellow);
|
||||
return;
|
||||
}
|
||||
setStatus(tr("Connection established, status unknown."), {}, time(0) * 1000, TransmissionReason::TR_Unknown, Qt::yellow);
|
||||
return true;
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::setStatus(const QString &statusText, const QString &requester, qint64 timeStampMsecs, TransmissionReason reason, Qt::GlobalColor color)
|
||||
void FrequencyPlanningDialog::onFrequencyPlanningStatusChanged(
|
||||
const AudioVideoManagement::FrequencyPlanningStatus& data, DataModification modType)
|
||||
{
|
||||
m_ui->lblStatus->setText(statusText);
|
||||
m_ui->lblStatusTime->setText(DTG::toStringMSec(timeStampMsecs));
|
||||
m_ui->lblStatus->setToolTip(toString(reason));
|
||||
m_ui->lblStatusTime->setToolTip(requester);
|
||||
setBackgroundColor(m_ui->lblStatus, color, color != Qt::black);
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
if (data.id() != m_activeFrequencyPlanningStatus)
|
||||
return;
|
||||
}
|
||||
else if (modType == DataModification::eRemoved)
|
||||
{
|
||||
if (data.id() != m_activeFrequencyPlanningStatus)
|
||||
return;
|
||||
|
||||
m_activeFrequencyPlanningStatus = 0;
|
||||
setStatus(tr("No active Radio Controller connected."), {}, time(0) * 1000, TransmissionReason::TR_Unknown,
|
||||
Qt::red);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!data.isActive())
|
||||
return;
|
||||
m_activeFrequencyPlanningStatus = data.id();
|
||||
}
|
||||
|
||||
if (data.activated().is_set())
|
||||
{
|
||||
setStatus(tr("Activated"), QString::fromStdString(data.requester()), data.activated().get(), data.reason(),
|
||||
Qt::green);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.received().is_set())
|
||||
{
|
||||
setStatus(tr("In Progress"), QString::fromStdString(data.requester()), data.received().get(), data.reason(),
|
||||
Qt::yellow);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.sent().is_set())
|
||||
{
|
||||
setStatus(tr("Sent"), QString::fromStdString(data.requester()), data.sent().get(),
|
||||
TransmissionReason::TR_Unknown, Qt::yellow);
|
||||
return;
|
||||
}
|
||||
setStatus(tr("Connection established, status unknown."), {}, time(0) * 1000, TransmissionReason::TR_Unknown,
|
||||
Qt::yellow);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::setStatus(const QString& statusText, const QString& requester, qint64 timeStampMsecs,
|
||||
TransmissionReason reason, Qt::GlobalColor color)
|
||||
{
|
||||
m_ui->lblStatus->setText(statusText);
|
||||
m_ui->lblStatusTime->setText(DTG::toStringMSec(timeStampMsecs));
|
||||
m_ui->lblStatus->setToolTip(toString(reason));
|
||||
m_ui->lblStatusTime->setToolTip(requester);
|
||||
setBackgroundColor(m_ui->lblStatus, color, color != Qt::black);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::setBackgroundColor(QWidget *w, Qt::GlobalColor color, bool bSetColor)
|
||||
void FrequencyPlanningDialog::setBackgroundColor(QWidget* w, Qt::GlobalColor color, bool bSetColor)
|
||||
{
|
||||
if (!w)
|
||||
return;
|
||||
if (!w)
|
||||
return;
|
||||
|
||||
if (bSetColor)
|
||||
{
|
||||
QPalette pal = QApplication::palette(w);
|
||||
pal.setColor(QPalette::Window, color);
|
||||
w->setPalette(pal);
|
||||
w->setAutoFillBackground(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
w->setPalette(QApplication::palette(w));
|
||||
w->setAutoFillBackground(false);
|
||||
}
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onModifyFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onRemoveFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onRemoveActiveFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onModifyActiveFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onAddClicked()
|
||||
{
|
||||
const QModelIndexList selectedRows = m_ui->dataView->selectedRows();
|
||||
Q_ASSERT(selectedRows.empty() || selectedRows.size() == 1);
|
||||
QMap<int32_t, FrequencySet> frequencySets = m_avmDtc->frequencySets();
|
||||
if (selectedRows.empty())
|
||||
{
|
||||
if(frequencySets.size() == 1)
|
||||
if (bSetColor)
|
||||
{
|
||||
FrequencyPlanning planning;
|
||||
|
||||
planning.id(0);
|
||||
if(m_session->exerciseId() != 0)
|
||||
planning.exerciseId(m_session->exerciseId());
|
||||
planning.frequencySetId(frequencySets.first().id());
|
||||
planning.date(m_session->partitionTime());
|
||||
showEditDialog(planning);
|
||||
QPalette pal = QApplication::palette(w);
|
||||
pal.setColor(QPalette::Window, color);
|
||||
w->setPalette(pal);
|
||||
w->setAutoFillBackground(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
InitFrequencyPlanningDialog *initDialog = new InitFrequencyPlanningDialog(m_session, m_avmDtc, this);
|
||||
|
||||
connect(initDialog, &InitFrequencyPlanningDialog::newInitFrequencyPlanning,
|
||||
this, &FrequencyPlanningDialog::showEditDialog);
|
||||
w->setPalette(QApplication::palette(w));
|
||||
w->setAutoFillBackground(false);
|
||||
}
|
||||
}
|
||||
|
||||
m_copy = false;
|
||||
addDialog(initDialog, m_menuGroup, QStringLiteral("NewFrequencyPlanning"));
|
||||
void FrequencyPlanningDialog::onModifyFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onRemoveFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onRemoveActiveFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onModifyActiveFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onAddClicked()
|
||||
{
|
||||
const QModelIndexList selectedRows = m_ui->dataView->selectedRows();
|
||||
Q_ASSERT(selectedRows.empty() || selectedRows.size() == 1);
|
||||
QMap<int32_t, FrequencySet> frequencySets = m_avmDtc->frequencySets();
|
||||
if (selectedRows.empty())
|
||||
{
|
||||
if (frequencySets.size() == 1)
|
||||
{
|
||||
FrequencyPlanning planning;
|
||||
|
||||
planning.id(0);
|
||||
if (m_session->exerciseId() != 0)
|
||||
planning.exerciseId(m_session->exerciseId());
|
||||
planning.frequencySetId(frequencySets.first().id());
|
||||
planning.date(m_session->partitionTime());
|
||||
showEditDialog(planning);
|
||||
}
|
||||
else
|
||||
{
|
||||
InitFrequencyPlanningDialog* initDialog = new InitFrequencyPlanningDialog(m_session, m_avmDtc, this);
|
||||
|
||||
connect(initDialog, &InitFrequencyPlanningDialog::newInitFrequencyPlanning, this,
|
||||
&FrequencyPlanningDialog::showEditDialog);
|
||||
|
||||
m_copy = false;
|
||||
addDialog(initDialog, m_menuGroup, QStringLiteral("NewFrequencyPlanning"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_copy = true;
|
||||
qint64 dateOfCreation = m_session->partitionTime();
|
||||
FrequencyPlanning planning = m_model->data(selectedRows.constFirst(), Qt::UserRole).value<FrequencyPlanning>();
|
||||
planning.date(dateOfCreation);
|
||||
showEditDialog(planning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_copy = true;
|
||||
qint64 dateOfCreation = m_session->partitionTime();
|
||||
FrequencyPlanning planning = m_model->data(selectedRows.constFirst(), Qt::UserRole).value<FrequencyPlanning>();
|
||||
planning.date(dateOfCreation);
|
||||
showEditDialog(planning);
|
||||
}
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onEditClicked()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
const FrequencyPlanning &fp = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>();
|
||||
DEBUG_LOG(m_logger) << "---onEditClicked() FrequencyPlanningId: " << fp.id() << " FrequencySetDataId: " << fp.frequencySetId();
|
||||
const FrequencyPlanning& fp = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>();
|
||||
DEBUG_LOG(m_logger) << "---onEditClicked() FrequencyPlanningId: " << fp.id()
|
||||
<< " FrequencySetDataId: " << fp.frequencySetId();
|
||||
|
||||
m_copy = false;
|
||||
showEditDialog(m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>());
|
||||
m_copy = false;
|
||||
showEditDialog(m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>());
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onRemoveClicked()
|
||||
{
|
||||
const QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
const QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
int planningId = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>().id();
|
||||
|
||||
if (m_editDlgMap.contains(planningId))
|
||||
{
|
||||
m_editDlgMap.value(planningId)->deleteLater();
|
||||
m_editDlgMap.remove(planningId);
|
||||
}
|
||||
int planningId = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>().id();
|
||||
|
||||
Core::RemoveElementRequest req;
|
||||
if (m_editDlgMap.contains(planningId))
|
||||
{
|
||||
m_editDlgMap.value(planningId)->deleteLater();
|
||||
m_editDlgMap.remove(planningId);
|
||||
}
|
||||
|
||||
req.id(planningId);
|
||||
Core::RemoveElementRequest req;
|
||||
|
||||
m_requestHelper->startSingleRequest([this, req]()
|
||||
{
|
||||
return m_avmFtc->removeFrequencyPlanningRequest(req, this);
|
||||
});
|
||||
req.id(planningId);
|
||||
|
||||
m_requestHelper->startSingleRequest([this, req]() { return m_avmFtc->removeFrequencyPlanningRequest(req, this); });
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onSelectionChanged()
|
||||
{
|
||||
const QModelIndexList selectedRows = m_ui->dataView->selectedRows();
|
||||
bool hasSelection = !selectedRows.empty();
|
||||
bool selectedIsActive = false;
|
||||
if (hasSelection)
|
||||
{
|
||||
const QModelIndex currentIndex = selectedRows.constFirst();
|
||||
selectedIsActive = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>().id() == m_activePlanning.frequencyPlanningId();
|
||||
}
|
||||
const QModelIndexList selectedRows = m_ui->dataView->selectedRows();
|
||||
bool hasSelection = !selectedRows.empty();
|
||||
bool selectedIsActive = false;
|
||||
if (hasSelection)
|
||||
{
|
||||
const QModelIndex currentIndex = selectedRows.constFirst();
|
||||
selectedIsActive = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>().id() ==
|
||||
m_activePlanning.frequencyPlanningId();
|
||||
}
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, hasSelection);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, hasSelection && !selectedIsActive);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, hasSelection && m_session->exerciseId() && m_session->exerciseState() == LtsWidgets::ExcState::eStarted);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, hasSelection);
|
||||
|
||||
if (selectedIsActive)
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Deactivate"));
|
||||
else
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Activate"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, hasSelection && !selectedIsActive);
|
||||
|
||||
bool disableGlobalPlanning = m_session->exerciseId() == 0 && m_proxyModel->rowCount() !=0;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, !disableGlobalPlanning);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save,
|
||||
hasSelection && m_session->exerciseId() &&
|
||||
m_session->exerciseState() == LtsWidgets::ExcState::eStarted);
|
||||
|
||||
if (selectedIsActive)
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Deactivate"));
|
||||
else
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Activate"));
|
||||
|
||||
bool disableGlobalPlanning = m_session->exerciseId() == 0 && m_proxyModel->rowCount() != 0;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, !disableGlobalPlanning);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onActivateDeactivatePlanningClicked()
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Frequency Planning"), tr("Are you sure you want to switch the active frequency planning?"),
|
||||
QMessageBox::StandardButtons(QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No))
|
||||
== QMessageBox::StandardButton::No)
|
||||
return;
|
||||
{
|
||||
if (QMessageBox::question(
|
||||
this, tr("Frequency Planning"), tr("Are you sure you want to switch the active frequency planning?"),
|
||||
QMessageBox::StandardButtons(QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No)) ==
|
||||
QMessageBox::StandardButton::No)
|
||||
return;
|
||||
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
int32_t planningId = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>().id();
|
||||
int32_t planningId = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>().id();
|
||||
|
||||
bool isActive = planningId == m_activePlanning.frequencyPlanningId();
|
||||
if (!isActive)
|
||||
{
|
||||
ModifyActiveFrequencyPlanningRequest request(m_session->exerciseId(), planningId);
|
||||
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
bool isActive = planningId == m_activePlanning.frequencyPlanningId();
|
||||
if (!isActive)
|
||||
{
|
||||
return m_avmFtc->modifyActiveFrequencyPlanningRequest(request, this);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveActiveFrequencyPlanningRequest request(m_session->exerciseId());
|
||||
ModifyActiveFrequencyPlanningRequest request(m_session->exerciseId(), planningId);
|
||||
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_avmFtc->modifyActiveFrequencyPlanningRequest(request, this); });
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_avmFtc->removeActiveFrequencyPlanningRequest(request, this);
|
||||
});
|
||||
}
|
||||
RemoveActiveFrequencyPlanningRequest request(m_session->exerciseId());
|
||||
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_avmFtc->removeActiveFrequencyPlanningRequest(request, this); });
|
||||
}
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::showEditDialog(const FrequencyPlanning &planning)
|
||||
void FrequencyPlanningDialog::showEditDialog(const FrequencyPlanning& planning)
|
||||
{
|
||||
QString widgetIdentifier(QStringLiteral("FrequencyPlanning%1").arg(QString::number(planning.id())));
|
||||
if (m_copy)
|
||||
widgetIdentifier.append(QStringLiteral("Copy"));
|
||||
QString widgetIdentifier(QStringLiteral("FrequencyPlanning%1").arg(QString::number(planning.id())));
|
||||
if (m_copy)
|
||||
widgetIdentifier.append(QStringLiteral("Copy"));
|
||||
|
||||
if (baseLayoutWidget()->focusTab(menuGroup(), widgetIdentifier, LtsWidgets::LayoutArea::eDialogTab))
|
||||
return;
|
||||
EditFrequencyPlanningDialog *dlg = new EditFrequencyPlanningDialog(m_session, m_menuGroup, widgetIdentifier, planning, m_copy, m_avmDtc, m_avmFtc, m_ppmDtc, m_ismDtc, m_exmDtc, this);
|
||||
connect(dlg, &EditFrequencyPlanningDialog::aboutToCloseMe, this , [this](int planningId)
|
||||
{
|
||||
if (planningId <= 0 || !m_editDlgMap.contains(planningId))
|
||||
return;
|
||||
m_editDlgMap.remove(planningId);
|
||||
});
|
||||
if (baseLayoutWidget()->focusTab(menuGroup(), widgetIdentifier, LtsWidgets::LayoutArea::eDialogTab))
|
||||
return;
|
||||
EditFrequencyPlanningDialog* dlg =
|
||||
new EditFrequencyPlanningDialog(m_session, m_menuGroup, widgetIdentifier, planning, m_copy, m_avmDtc, m_avmFtc,
|
||||
m_ppmDtc, m_ismDtc, m_exmDtc, this);
|
||||
connect(dlg, &EditFrequencyPlanningDialog::aboutToCloseMe, this, [this](int planningId) {
|
||||
if (planningId <= 0 || !m_editDlgMap.contains(planningId))
|
||||
return;
|
||||
m_editDlgMap.remove(planningId);
|
||||
});
|
||||
|
||||
addDialog(dlg, m_menuGroup, widgetIdentifier);
|
||||
|
||||
addDialog(dlg, m_menuGroup, widgetIdentifier);
|
||||
|
||||
if (!m_copy)
|
||||
{
|
||||
m_editDlgMap.insert(planning.id(), dlg);
|
||||
}
|
||||
if (!m_copy)
|
||||
{
|
||||
m_editDlgMap.insert(planning.id(), dlg);
|
||||
}
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onActiveFrequencyPlanningChanged(const ActiveFrequencyPlanning &data, DataModification modType)
|
||||
void FrequencyPlanningDialog::onActiveFrequencyPlanningChanged(const ActiveFrequencyPlanning& data,
|
||||
DataModification modType)
|
||||
{
|
||||
if (data.exerciseId() != m_session->exerciseId())
|
||||
return;
|
||||
if (data.exerciseId() != m_session->exerciseId())
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
unsetActiveFrequencyPlanning();
|
||||
else
|
||||
setActiveFrequencyPlanning(data);
|
||||
if (modType == DataModification::eRemoved)
|
||||
unsetActiveFrequencyPlanning();
|
||||
else
|
||||
setActiveFrequencyPlanning(data);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView() );
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView());
|
||||
}
|
||||
|
||||
|
||||
void FrequencyPlanningDialog::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = m_model->modelToJson();
|
||||
QByteArray byteArray = m_model->modelToJson();
|
||||
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
if (m_model->rowCount() > 0)
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("Only available if the list is empty."),
|
||||
windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes,
|
||||
texts);
|
||||
return;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
if (m_model->rowCount() > 0)
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Only available if the list is empty."), windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal, LtsWidgets::Button::Yes, texts);
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(), FileManagement::toString(FileManagement::XmlType::AVMFrequencyPlanning));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMFrequencyPlanning)))
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(),
|
||||
FileManagement::toString(FileManagement::XmlType::AVMFrequencyPlanning));
|
||||
if (fileId > 0)
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("Invalid xml file content"),
|
||||
windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes,
|
||||
texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QVector<ModifyFrequencyPlanningRequest> requests = m_model->jsonToFrequencyPlanningVector(content);
|
||||
for (const auto &request : requests)
|
||||
{
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMFrequencyPlanning)))
|
||||
{
|
||||
return m_avmFtc->modifyFrequencyPlanningRequest(request, this);
|
||||
});
|
||||
}
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Invalid xml file content"), windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal, LtsWidgets::Button::Yes, texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QVector<ModifyFrequencyPlanningRequest> requests = m_model->jsonToFrequencyPlanningVector(content);
|
||||
for (const auto& request : requests)
|
||||
{
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_avmFtc->modifyFrequencyPlanningRequest(request, this); });
|
||||
}
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+67
-70
@@ -1,14 +1,12 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
@@ -27,7 +25,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
@@ -35,7 +33,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace InfrastructureManagement
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
@@ -43,7 +41,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
@@ -60,71 +58,70 @@ class FrequencyPlanningDialogModel;
|
||||
class FrequencyPlanningDialogProxyModel;
|
||||
class EditFrequencyPlanningDialog;
|
||||
|
||||
class FrequencyPlanningDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::ModifyFrequencyPlanningReplyHandler
|
||||
, protected Interface::Ftc::RemoveFrequencyPlanningReplyHandler
|
||||
, protected Interface::Ftc::ModifyActiveFrequencyPlanningReplyHandler
|
||||
, protected Interface::Ftc::RemoveActiveFrequencyPlanningReplyHandler
|
||||
class FrequencyPlanningDialog : public LtsWidgets::LtsDialog,
|
||||
protected Interface::Ftc::ModifyFrequencyPlanningReplyHandler,
|
||||
protected Interface::Ftc::RemoveFrequencyPlanningReplyHandler,
|
||||
protected Interface::Ftc::ModifyActiveFrequencyPlanningReplyHandler,
|
||||
protected Interface::Ftc::RemoveActiveFrequencyPlanningReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FrequencyPlanningDialog(LtsSession::LtsSession *session, const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~FrequencyPlanningDialog();
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FrequencyPlanningDialog(LtsSession::LtsSession* session, const QString& menuGroup,
|
||||
QWidget* parent = nullptr);
|
||||
~FrequencyPlanningDialog();
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc);
|
||||
bool init(const std::shared_ptr<Interface::Dtc>& avmDtc, const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc);
|
||||
|
||||
void onModifyFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onRemoveFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onRemoveActiveFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onModifyActiveFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onModifyFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
void onRemoveFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
void onRemoveActiveFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
void onModifyActiveFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onActivateDeactivatePlanningClicked();
|
||||
void showEditDialog(const FrequencyPlanning &planning);
|
||||
void onActiveFrequencyPlanningChanged(const ActiveFrequencyPlanning &data, DataModification modType);
|
||||
void onFrequencyPlanningStatusChanged(const FrequencyPlanningStatus &data, DataModification modType);
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
signals:
|
||||
void aboutToCloseMe(int);
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onActivateDeactivatePlanningClicked();
|
||||
void showEditDialog(const FrequencyPlanning& planning);
|
||||
void onActiveFrequencyPlanningChanged(const ActiveFrequencyPlanning& data, DataModification modType);
|
||||
void onFrequencyPlanningStatusChanged(const FrequencyPlanningStatus& data, DataModification modType);
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
signals:
|
||||
void aboutToCloseMe(int);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void unsetActiveFrequencyPlanning();
|
||||
void setActiveFrequencyPlanning(const ActiveFrequencyPlanning& activePlanning);
|
||||
void setButtonSetActivePlanningEnabled();
|
||||
static void setBackgroundColor(QWidget* w, Qt::GlobalColor color, bool bSetColor);
|
||||
void setStatus(const QString& statusText, const QString& requester, qint64 timeStampMsecs,
|
||||
TransmissionReason reason = TransmissionReason_def::TR_Unknown, Qt::GlobalColor color = Qt::black);
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void unsetActiveFrequencyPlanning();
|
||||
void setActiveFrequencyPlanning(const ActiveFrequencyPlanning &activePlanning);
|
||||
void setButtonSetActivePlanningEnabled();
|
||||
static void setBackgroundColor(QWidget *w, Qt::GlobalColor color, bool bSetColor);
|
||||
void setStatus(const QString &statusText, const QString &requester, qint64 timeStampMsecs, TransmissionReason reason = TransmissionReason_def::TR_Unknown, Qt::GlobalColor color = Qt::black);
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private:
|
||||
Ui::FrequencyPlanningDialog *m_ui;
|
||||
QString m_menuGroup;
|
||||
bool m_copy;
|
||||
LtsSession::LtsSession *m_session;
|
||||
FrequencyPlanningDialogModel *m_model;
|
||||
FrequencyPlanningDialogProxyModel *m_proxyModel;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
ActiveFrequencyPlanning m_activePlanning;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
ExerciseManagement::Interface::Dtc *m_exmDtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
QMap<int, EditFrequencyPlanningDialog*> m_editDlgMap;
|
||||
int m_activeFrequencyPlanningStatus;
|
||||
};
|
||||
}
|
||||
private:
|
||||
Ui::FrequencyPlanningDialog* m_ui;
|
||||
QString m_menuGroup;
|
||||
bool m_copy;
|
||||
LtsSession::LtsSession* m_session;
|
||||
FrequencyPlanningDialogModel* m_model;
|
||||
FrequencyPlanningDialogProxyModel* m_proxyModel;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
ActiveFrequencyPlanning m_activePlanning;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
ExerciseManagement::Interface::Dtc* m_exmDtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
QMap<int, EditFrequencyPlanningDialog*> m_editDlgMap;
|
||||
int m_activeFrequencyPlanningStatus;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+131
-145
@@ -1,197 +1,183 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_frequency_planning_dialog_model.h"
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
FrequencyPlanningDialogModel::FrequencyPlanningDialogModel(int32_t exerciseId, QObject *parent)
|
||||
: LtsAbstractTableModel<FrequencyPlanning>(
|
||||
FrequencyPlanningDialogModel::FrequencyPlanningDialogModel(int32_t exerciseId, QObject* parent)
|
||||
: LtsAbstractTableModel<FrequencyPlanning>({tr("Name"), tr("Date"), tr("Set"), tr("Active")}, parent),
|
||||
m_exerciseId(exerciseId)
|
||||
{
|
||||
tr("Name"),
|
||||
tr("Date"),
|
||||
tr("Set"),
|
||||
tr("Active")
|
||||
}, parent)
|
||||
, m_exerciseId(exerciseId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "---FrequencyPlanningDialogModel() ";
|
||||
DEBUG_LOG(m_logger) << "---FrequencyPlanningDialogModel() ";
|
||||
}
|
||||
|
||||
QVariant FrequencyPlanningDialogModel::data(const QModelIndex &index, int role) const
|
||||
QVariant FrequencyPlanningDialogModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if ((role != Qt::DisplayRole && role != Qt::UserRole) || !indexIsValid(index))
|
||||
if ((role != Qt::DisplayRole && role != Qt::UserRole) || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const FrequencyPlanning& planning = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case NAME:
|
||||
return QString::fromStdString(planning.name());
|
||||
case DATE:
|
||||
return QDateTime::fromMSecsSinceEpoch(planning.date());
|
||||
case SET: {
|
||||
const FrequencySet frequencySet = m_avmDtc->frequencySet(planning.frequencySetId());
|
||||
return QString::fromStdString(frequencySet.name());
|
||||
}
|
||||
case ACTIVE:
|
||||
return planning.id() == m_activePlanningId ? tr("Active") : QStringLiteral("-");
|
||||
}
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
return QVariant::fromValue(planning);
|
||||
|
||||
return QVariant();
|
||||
|
||||
const FrequencyPlanning &planning = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case NAME:
|
||||
return QString::fromStdString(planning.name());
|
||||
case DATE:
|
||||
return QDateTime::fromMSecsSinceEpoch(planning.date());
|
||||
case SET:
|
||||
{
|
||||
const FrequencySet frequencySet = m_avmDtc->frequencySet(planning.frequencySetId());
|
||||
return QString::fromStdString(frequencySet.name());
|
||||
}
|
||||
case ACTIVE:
|
||||
return planning.id() == m_activePlanningId ? tr("Active") : QStringLiteral("-");
|
||||
}
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
return QVariant::fromValue(planning);
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool FrequencyPlanningDialogModel::init(const std::shared_ptr<Interface::Dtc> &avmDtc)
|
||||
bool FrequencyPlanningDialogModel::init(const std::shared_ptr<Interface::Dtc>& avmDtc)
|
||||
{
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmDtc = avmDtc;
|
||||
|
||||
m_frequencySets = m_avmDtc->frequencySets();
|
||||
m_frequencySets = m_avmDtc->frequencySets();
|
||||
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::frequencyPlanningChanged,
|
||||
this, &FrequencyPlanningDialogModel::onFrequencyPlanningChanged);
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::frequencyPlanningChanged, this,
|
||||
&FrequencyPlanningDialogModel::onFrequencyPlanningChanged);
|
||||
|
||||
m_avmDtc->frequencyPlannings([this](const FrequencyPlanning & p)
|
||||
{
|
||||
if (p.exerciseId().is_set() && p.exerciseId().get() == m_exerciseId)
|
||||
insertRow(p);
|
||||
});
|
||||
m_avmDtc->frequencyPlannings([this](const FrequencyPlanning& p) {
|
||||
if (p.exerciseId().is_set() && p.exerciseId().get() == m_exerciseId)
|
||||
insertRow(p);
|
||||
});
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
FrequencySet FrequencyPlanningDialogModel::frequencySetByIndex(const QModelIndex &index) const
|
||||
FrequencySet FrequencyPlanningDialogModel::frequencySetByIndex(const QModelIndex& index) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return FrequencySet();
|
||||
if (!indexIsValid(index))
|
||||
return FrequencySet();
|
||||
|
||||
return m_frequencySets.value(m_vecData.at(index.row()).frequencySetId());
|
||||
return m_frequencySets.value(m_vecData.at(index.row()).frequencySetId());
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialogModel::onFrequencyPlanningChanged(const FrequencyPlanning &data, DataModification modType)
|
||||
void FrequencyPlanningDialogModel::onFrequencyPlanningChanged(const FrequencyPlanning& data, DataModification modType)
|
||||
{
|
||||
INFO_LOG(m_logger) << "onFrequencyPlanningChanged "
|
||||
<< " data.exerciseId()" << data.exerciseId()
|
||||
<< " m_exerciseId=" << m_exerciseId;
|
||||
if ((data.exerciseId().is_set() && data.exerciseId().get() != m_exerciseId)
|
||||
|| (!data.exerciseId().is_set() && m_exerciseId != 0))
|
||||
return;
|
||||
INFO_LOG(m_logger) << "onFrequencyPlanningChanged "
|
||||
<< " data.exerciseId()" << data.exerciseId() << " m_exerciseId=" << m_exerciseId;
|
||||
if ((data.exerciseId().is_set() && data.exerciseId().get() != m_exerciseId) ||
|
||||
(!data.exerciseId().is_set() && m_exerciseId != 0))
|
||||
return;
|
||||
|
||||
onDataChanged(data, modType);
|
||||
onDataChanged(data, modType);
|
||||
}
|
||||
|
||||
QByteArray FrequencyPlanningDialogModel::modelToJson()
|
||||
{
|
||||
QJsonObject obj;
|
||||
QJsonArray arr;
|
||||
QJsonArray arrData;
|
||||
QJsonObject obj;
|
||||
QJsonArray arr;
|
||||
QJsonArray arrData;
|
||||
|
||||
for (int row = 0; row < rowCount(); row++)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "row =" << ": " << row;
|
||||
QJsonObject inner;
|
||||
const FrequencyPlanning &planning = m_vecData.at(row);
|
||||
|
||||
inner[QStringLiteral("id")] = planning.id();
|
||||
inner[QStringLiteral("name")] = QString::fromStdString(planning.name());
|
||||
inner[QStringLiteral("dateOfCreation")] = planning.date();
|
||||
if(planning.exerciseId().is_set())
|
||||
for (int row = 0; row < rowCount(); row++)
|
||||
{
|
||||
inner[QStringLiteral("exerciseId")] = planning.exerciseId().get();
|
||||
DEBUG_LOG(m_logger) << "row =" << ": " << row;
|
||||
QJsonObject inner;
|
||||
const FrequencyPlanning& planning = m_vecData.at(row);
|
||||
|
||||
inner[QStringLiteral("id")] = planning.id();
|
||||
inner[QStringLiteral("name")] = QString::fromStdString(planning.name());
|
||||
inner[QStringLiteral("dateOfCreation")] = planning.date();
|
||||
if (planning.exerciseId().is_set())
|
||||
{
|
||||
inner[QStringLiteral("exerciseId")] = planning.exerciseId().get();
|
||||
}
|
||||
inner[QStringLiteral("frequencySetId")] = planning.frequencySetId();
|
||||
|
||||
arrData = {};
|
||||
for (const FrequencyPlanningData& planningData : planning.data())
|
||||
{
|
||||
QJsonObject innerData;
|
||||
innerData[QStringLiteral("cnrConfigId")] = planningData.cnrConfigId();
|
||||
innerData[QStringLiteral("properties")] = QString::fromStdString(planningData.properties());
|
||||
arrData += innerData;
|
||||
}
|
||||
inner[QStringLiteral("data")] = arrData;
|
||||
arr += inner;
|
||||
}
|
||||
inner[QStringLiteral("frequencySetId")] = planning.frequencySetId();
|
||||
|
||||
arrData = {};
|
||||
for (const FrequencyPlanningData &planningData : planning.data())
|
||||
{
|
||||
QJsonObject innerData;
|
||||
innerData[QStringLiteral("cnrConfigId")] = planningData.cnrConfigId();
|
||||
innerData[QStringLiteral("properties")] = QString::fromStdString(planningData.properties());
|
||||
arrData += innerData;
|
||||
}
|
||||
inner[QStringLiteral("data")] = arrData;
|
||||
arr += inner;
|
||||
}
|
||||
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AVMFrequencyPlanning);
|
||||
obj[QStringLiteral("FrequencyPlanning")] = arr;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AVMFrequencyPlanning);
|
||||
obj[QStringLiteral("FrequencyPlanning")] = arr;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
QVector<ModifyFrequencyPlanningRequest> FrequencyPlanningDialogModel::jsonToFrequencyPlanningVector(const QByteArray &content)
|
||||
QVector<ModifyFrequencyPlanningRequest>
|
||||
FrequencyPlanningDialogModel::jsonToFrequencyPlanningVector(const QByteArray& content)
|
||||
{
|
||||
QVector<ModifyFrequencyPlanningRequest> result;
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject toplevelObj(doc.object());
|
||||
const QJsonArray arr(toplevelObj.value(QStringLiteral("FrequencyPlanning")).toArray());
|
||||
for (const auto &ele : arr)
|
||||
{
|
||||
const QJsonObject obj(ele.toObject());
|
||||
ModifyFrequencyPlanningRequest frequencyPlanning;
|
||||
frequencyPlanning.date(obj[QStringLiteral("dateOfCreation")].toDouble());
|
||||
frequencyPlanning.exerciseId(m_exerciseId);
|
||||
frequencyPlanning.frequencySetId(obj[QStringLiteral("frequencySetId")].toInt());
|
||||
frequencyPlanning.id(0);
|
||||
frequencyPlanning.name(obj[QStringLiteral("name")].toString().toStdString());
|
||||
|
||||
|
||||
const QJsonArray arrData = (obj.value(QStringLiteral("data")).toArray());
|
||||
frequencyPlanning.data().reserve(arrData.size());
|
||||
for (const auto &eleData : arrData)
|
||||
QVector<ModifyFrequencyPlanningRequest> result;
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject toplevelObj(doc.object());
|
||||
const QJsonArray arr(toplevelObj.value(QStringLiteral("FrequencyPlanning")).toArray());
|
||||
for (const auto& ele : arr)
|
||||
{
|
||||
const QJsonObject objData(eleData.toObject());
|
||||
FrequencyPlanningData frequencyPlanningData;
|
||||
frequencyPlanningData.cnrConfigId(objData[QStringLiteral("cnrConfigId")].toInt());
|
||||
frequencyPlanningData.properties(objData[QStringLiteral("properties")].toString().toStdString());
|
||||
frequencyPlanning.data().push_back(frequencyPlanningData);
|
||||
const QJsonObject obj(ele.toObject());
|
||||
ModifyFrequencyPlanningRequest frequencyPlanning;
|
||||
frequencyPlanning.date(obj[QStringLiteral("dateOfCreation")].toDouble());
|
||||
frequencyPlanning.exerciseId(m_exerciseId);
|
||||
frequencyPlanning.frequencySetId(obj[QStringLiteral("frequencySetId")].toInt());
|
||||
frequencyPlanning.id(0);
|
||||
frequencyPlanning.name(obj[QStringLiteral("name")].toString().toStdString());
|
||||
|
||||
const QJsonArray arrData = (obj.value(QStringLiteral("data")).toArray());
|
||||
frequencyPlanning.data().reserve(arrData.size());
|
||||
for (const auto& eleData : arrData)
|
||||
{
|
||||
const QJsonObject objData(eleData.toObject());
|
||||
FrequencyPlanningData frequencyPlanningData;
|
||||
frequencyPlanningData.cnrConfigId(objData[QStringLiteral("cnrConfigId")].toInt());
|
||||
frequencyPlanningData.properties(objData[QStringLiteral("properties")].toString().toStdString());
|
||||
frequencyPlanning.data().push_back(frequencyPlanningData);
|
||||
}
|
||||
|
||||
result.push_back(std::move(frequencyPlanning));
|
||||
}
|
||||
|
||||
|
||||
result.push_back(std::move(frequencyPlanning));
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialogProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
void FrequencyPlanningDialogProxyModel::setSourceModel(QAbstractItemModel* sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<FrequencyPlanningDialogModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
m_sourceModel = qobject_cast<FrequencyPlanningDialogModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool FrequencyPlanningDialogProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
bool FrequencyPlanningDialogProxyModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const
|
||||
{
|
||||
if (!m_sourceModel ||
|
||||
source_left.column() != source_right.column() ||
|
||||
!source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
if (!m_sourceModel || source_left.column() != source_right.column() || !source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
const auto& dataLeft = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
case FrequencyPlanningDialogModel::DATE:
|
||||
return dataLeft.date() < dataRight.date();
|
||||
case FrequencyPlanningDialogModel::NAME:
|
||||
case FrequencyPlanningDialogModel::SET:
|
||||
case FrequencyPlanningDialogModel::ACTIVE:
|
||||
case FrequencyPlanningDialogModel::COUNT:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
case FrequencyPlanningDialogModel::DATE:
|
||||
return dataLeft.date() < dataRight.date();
|
||||
case FrequencyPlanningDialogModel::NAME:
|
||||
case FrequencyPlanningDialogModel::SET:
|
||||
case FrequencyPlanningDialogModel::ACTIVE:
|
||||
case FrequencyPlanningDialogModel::COUNT:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+41
-43
@@ -1,73 +1,71 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <boost/optional.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class FrequencyPlanningDialogModel final
|
||||
: public LtsWidgets::LtsAbstractTableModel<FrequencyPlanning>
|
||||
class FrequencyPlanningDialogModel final : public LtsWidgets::LtsAbstractTableModel<FrequencyPlanning>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
NAME,
|
||||
DATE,
|
||||
SET,
|
||||
ACTIVE,
|
||||
COUNT
|
||||
};
|
||||
public:
|
||||
enum Columns { NAME, DATE, SET, ACTIVE, COUNT };
|
||||
|
||||
explicit FrequencyPlanningDialogModel(int32_t exerciseId, QObject *parent = nullptr);
|
||||
explicit FrequencyPlanningDialogModel(int32_t exerciseId, QObject* parent = nullptr);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
QVariant data(const QModelIndex& index, int role) const override final;
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &avmDtc);
|
||||
bool init(const std::shared_ptr<Interface::Dtc>& avmDtc);
|
||||
|
||||
void setActivePlanning(int activePlanningId) { m_activePlanningId = activePlanningId; }
|
||||
void unsetActivePlanning() { m_activePlanningId.reset(); }
|
||||
void setActivePlanning(int activePlanningId)
|
||||
{
|
||||
m_activePlanningId = activePlanningId;
|
||||
}
|
||||
|
||||
FrequencySet frequencySetByIndex(const QModelIndex &index) const;
|
||||
QByteArray modelToJson();
|
||||
QVector<ModifyFrequencyPlanningRequest> jsonToFrequencyPlanningVector(const QByteArray &content);
|
||||
void unsetActivePlanning()
|
||||
{
|
||||
m_activePlanningId.reset();
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFrequencyPlanningChanged(const FrequencyPlanning &data, DataModification modType);
|
||||
FrequencySet frequencySetByIndex(const QModelIndex& index) const;
|
||||
QByteArray modelToJson();
|
||||
QVector<ModifyFrequencyPlanningRequest> jsonToFrequencyPlanningVector(const QByteArray& content);
|
||||
|
||||
private:
|
||||
private Q_SLOTS:
|
||||
void onFrequencyPlanningChanged(const FrequencyPlanning& data, DataModification modType);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
int32_t m_exerciseId;
|
||||
boost::optional<int> m_activePlanningId;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
int32_t m_exerciseId;
|
||||
boost::optional<int> m_activePlanningId;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
|
||||
QMap<int32_t, FrequencySet> m_frequencySets;
|
||||
QMap<int32_t, FrequencySet> m_frequencySets;
|
||||
|
||||
friend class FrequencyPlanningDialogProxyModel;
|
||||
};
|
||||
friend class FrequencyPlanningDialogProxyModel;
|
||||
};
|
||||
|
||||
class FrequencyPlanningDialogProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
private:
|
||||
FrequencyPlanningDialogModel *m_sourceModel = nullptr;
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel* sourceModel) override;
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override;
|
||||
|
||||
private:
|
||||
FrequencyPlanningDialogModel* m_sourceModel = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Q_DECLARE_METATYPE(AudioVideoManagement::FrequencyPlanning)
|
||||
Executable → Regular
+158
-165
@@ -1,238 +1,231 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_frequency_planning_widget.h"
|
||||
#include <LtsWidgets/lts_spinbox.h>
|
||||
#include "ui_avm_frequency_planning_widget.h"
|
||||
|
||||
#include "avm_edit_frequency_planning_set_resource_dialog.h"
|
||||
#include "avm_radio_specifica_hf_widget.h"
|
||||
#include "avm_radio_specifica_vhf_widget.h"
|
||||
#include "avm_radio_specifica_uhf_widget.h"
|
||||
#include "avm_radio_specifica_vhf_widget.h"
|
||||
#include "ui_avm_frequency_planning_widget.h"
|
||||
|
||||
#include <AudioVideoManagement/avm_translation.h>
|
||||
#include <InfrastructureManagement/Gui/IsmComboBox/ism_combobox_gui_plugin.h>
|
||||
|
||||
#include <LtsWidgets/lts_spinbox.h>
|
||||
#include <QJsonArray>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
FrequencyPlanningWidget::FrequencyPlanningWidget(const std::shared_ptr<Interface::Dtc> &avmDtc, QSet<int> &allocatedDataSets, QWidget *parent) : QWidget(parent)
|
||||
, m_ui(new Ui::FrequencyPlanningWidget)
|
||||
, m_assignedFrequencySetDataIds(allocatedDataSets)
|
||||
, m_avmDtc(avmDtc),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
m_ui->setupUi(this);
|
||||
FrequencyPlanningWidget::FrequencyPlanningWidget(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
QSet<int>& allocatedDataSets, QWidget* parent)
|
||||
: QWidget(parent), m_ui(new Ui::FrequencyPlanningWidget), m_assignedFrequencySetDataIds(allocatedDataSets),
|
||||
m_avmDtc(avmDtc), m_logger(NGL::NGLLoggerBootstrap::getLogger())
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->cbFrequencyBand->addItem(toString(FrequencyBand_def::VHF), FrequencyBand_def::VHF);
|
||||
m_ui->cbFrequencyBand->addItem(toString(FrequencyBand_def::HF), FrequencyBand_def::HF);
|
||||
m_ui->cbFrequencyBand->addItem(toString(FrequencyBand_def::UHF), FrequencyBand_def::UHF);
|
||||
m_ui->cbFrequencyBand->addItem(toString(FrequencyBand_def::VHF), FrequencyBand_def::VHF);
|
||||
m_ui->cbFrequencyBand->addItem(toString(FrequencyBand_def::HF), FrequencyBand_def::HF);
|
||||
m_ui->cbFrequencyBand->addItem(toString(FrequencyBand_def::UHF), FrequencyBand_def::UHF);
|
||||
|
||||
connect(m_ui->leName, &QLineEdit::textChanged,
|
||||
this, &FrequencyPlanningWidget::onNameChanged);
|
||||
connect(m_ui->cbFrequencyBand, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this, &FrequencyPlanningWidget::onFrequencyBandChanged);
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::cnrConfigChanged,
|
||||
this, &FrequencyPlanningWidget::onCnrConfigChanged);
|
||||
connect(m_ui->leName, &QLineEdit::textChanged, this, &FrequencyPlanningWidget::onNameChanged);
|
||||
connect(m_ui->cbFrequencyBand, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
||||
&FrequencyPlanningWidget::onFrequencyBandChanged);
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::cnrConfigChanged, this,
|
||||
&FrequencyPlanningWidget::onCnrConfigChanged);
|
||||
}
|
||||
|
||||
bool FrequencyPlanningWidget::init(LtsSession::LtsSession *session, RadioCircuit *data, const CnrConfig &cnrConfigId, int frequencySetId, FrequencyBand ft)
|
||||
bool FrequencyPlanningWidget::init(LtsSession::LtsSession* session, RadioCircuit* data, const CnrConfig& cnrConfigId,
|
||||
int frequencySetId, FrequencyBand ft)
|
||||
{
|
||||
m_frequencySetId = frequencySetId;
|
||||
m_cnrConfigId = cnrConfigId.id();
|
||||
m_hasParty = cnrConfigId.partyId() != 0;
|
||||
m_frequencySetId = frequencySetId;
|
||||
m_cnrConfigId = cnrConfigId.id();
|
||||
m_hasParty = cnrConfigId.partyId() != 0;
|
||||
|
||||
if (!session->getForeignGuiInterface<InfrastructureManagement::ForeignGuiComboboxInterface>(m_ismCbxIfc))
|
||||
return false;
|
||||
|
||||
m_ui->cbFrequencyBand->setCurrentIndex(m_ui->cbFrequencyBand->findData(ft.underlying()));
|
||||
m_ui->cbFrequencyBand->setVisible(false);
|
||||
m_ui->lbxFrequencyBand->setVisible(false);
|
||||
|
||||
switch (ft.underlying())
|
||||
{
|
||||
|
||||
case FrequencyBand_def::HF:
|
||||
{
|
||||
createHFWidget(data);
|
||||
break;
|
||||
}
|
||||
case FrequencyBand_def::UHF:
|
||||
{
|
||||
createUHFWidget(data);
|
||||
break;
|
||||
}
|
||||
case FrequencyBand_def::VHF:
|
||||
{
|
||||
createVHFWidget(data);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ft = data ? data->freqBand : FrequencyBand::VHF;
|
||||
m_isRelay = true;
|
||||
if (!session->getForeignGuiInterface<InfrastructureManagement::ForeignGuiComboboxInterface>(m_ismCbxIfc))
|
||||
return false;
|
||||
|
||||
m_ui->cbFrequencyBand->setCurrentIndex(m_ui->cbFrequencyBand->findData(ft.underlying()));
|
||||
m_ui->cbFrequencyBand->setVisible(true);
|
||||
m_ui->lbxFrequencyBand->setVisible(true);
|
||||
m_ui->cbFrequencyBand->setVisible(false);
|
||||
m_ui->lbxFrequencyBand->setVisible(false);
|
||||
|
||||
switch (ft.underlying())
|
||||
{
|
||||
case FrequencyBand_def::HF:
|
||||
createHFWidget(data);
|
||||
break;
|
||||
case FrequencyBand_def::UHF:
|
||||
createUHFWidget(data);
|
||||
break;
|
||||
case FrequencyBand_def::VHF:
|
||||
createVHFWidget(data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
|
||||
case FrequencyBand_def::HF: {
|
||||
createHFWidget(data);
|
||||
break;
|
||||
}
|
||||
case FrequencyBand_def::UHF: {
|
||||
createUHFWidget(data);
|
||||
break;
|
||||
}
|
||||
case FrequencyBand_def::VHF: {
|
||||
createVHFWidget(data);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ft = data ? data->freqBand : FrequencyBand::VHF;
|
||||
m_isRelay = true;
|
||||
|
||||
m_ui->cbFrequencyBand->setCurrentIndex(m_ui->cbFrequencyBand->findData(ft.underlying()));
|
||||
m_ui->cbFrequencyBand->setVisible(true);
|
||||
m_ui->lbxFrequencyBand->setVisible(true);
|
||||
switch (ft.underlying())
|
||||
{
|
||||
case FrequencyBand_def::HF:
|
||||
createHFWidget(data);
|
||||
break;
|
||||
case FrequencyBand_def::UHF:
|
||||
createUHFWidget(data);
|
||||
break;
|
||||
case FrequencyBand_def::VHF:
|
||||
createVHFWidget(data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_ismCbxIfc->fillRadioStationsComboBox(m_ui->cbRadioStation, ft.underlying());
|
||||
if (m_hasParty && !m_isRelay)
|
||||
m_ui->cbRadioStation->addItem(tr("Automatic"), 0);
|
||||
if (!data)
|
||||
m_ui->leName->clear();
|
||||
else
|
||||
{
|
||||
m_ui->leName->setText(data->name);
|
||||
m_ui->cbRadioStation->setCurrentIndex(m_ui->cbRadioStation->findData(data->radioStationId));
|
||||
}
|
||||
m_ismCbxIfc->fillRadioStationsComboBox(m_ui->cbRadioStation, ft.underlying());
|
||||
if (m_hasParty && !m_isRelay)
|
||||
m_ui->cbRadioStation->addItem(tr("Automatic"), 0);
|
||||
if (!data)
|
||||
m_ui->leName->clear();
|
||||
else
|
||||
{
|
||||
m_ui->leName->setText(data->name);
|
||||
m_ui->cbRadioStation->setCurrentIndex(m_ui->cbRadioStation->findData(data->radioStationId));
|
||||
}
|
||||
|
||||
adjustSize();
|
||||
return true;
|
||||
adjustSize();
|
||||
return true;
|
||||
}
|
||||
|
||||
void FrequencyPlanningWidget::setNameDisabled(bool disable)
|
||||
{
|
||||
m_ui->leName->setDisabled(disable);
|
||||
m_ui->leName->setDisabled(disable);
|
||||
}
|
||||
|
||||
void FrequencyPlanningWidget::setName(const QString &name)
|
||||
void FrequencyPlanningWidget::setName(const QString& name)
|
||||
{
|
||||
m_ui->leName->setText(name);
|
||||
m_ui->leName->setText(name);
|
||||
}
|
||||
|
||||
|
||||
void FrequencyPlanningWidget::setRelaisRestrictions(bool restrict)
|
||||
{
|
||||
if (restrict)
|
||||
{
|
||||
m_ui->cbFrequencyBand->setCurrentIndex(m_ui->cbFrequencyBand->findData(FrequencyBand_def::VHF));
|
||||
m_ui->cbFrequencyBand->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->cbFrequencyBand->setEnabled(true);
|
||||
}
|
||||
|
||||
if (restrict)
|
||||
{
|
||||
m_ui->cbFrequencyBand->setCurrentIndex(m_ui->cbFrequencyBand->findData(FrequencyBand_def::VHF));
|
||||
m_ui->cbFrequencyBand->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->cbFrequencyBand->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
QJsonObject FrequencyPlanningWidget::toJson() const
|
||||
{
|
||||
return frequencyPlanningJson(m_radioSpecificaWidget->toJson(),
|
||||
m_ui->leName->text(),
|
||||
static_cast<FrequencyBand::inner_enum>(m_ui->cbFrequencyBand->currentData().toInt()),
|
||||
m_ui->cbRadioStation->currentData().toInt());
|
||||
return frequencyPlanningJson(m_radioSpecificaWidget->toJson(), m_ui->leName->text(),
|
||||
static_cast<FrequencyBand::inner_enum>(m_ui->cbFrequencyBand->currentData().toInt()),
|
||||
m_ui->cbRadioStation->currentData().toInt());
|
||||
}
|
||||
|
||||
QVector<QPair<QLabel *, const std::function<bool ()> > > FrequencyPlanningWidget::requirements() const
|
||||
QVector<QPair<QLabel*, const std::function<bool()>>> FrequencyPlanningWidget::requirements() const
|
||||
{
|
||||
return m_radioSpecificaWidget->requirements();
|
||||
return m_radioSpecificaWidget->requirements();
|
||||
}
|
||||
|
||||
FrequencyPlanningWidget::~FrequencyPlanningWidget()
|
||||
{
|
||||
if(m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
delete m_ui;
|
||||
if (m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void FrequencyPlanningWidget::onFrequencyBandChanged()
|
||||
{
|
||||
switch (m_ui->cbFrequencyBand->currentData().toInt())
|
||||
{
|
||||
case FrequencyBand_def::HF:
|
||||
createHFWidget();
|
||||
break;
|
||||
case FrequencyBand_def::UHF:
|
||||
createUHFWidget();
|
||||
break;
|
||||
case FrequencyBand_def::VHF:
|
||||
createVHFWidget();
|
||||
break;
|
||||
}
|
||||
switch (m_ui->cbFrequencyBand->currentData().toInt())
|
||||
{
|
||||
case FrequencyBand_def::HF:
|
||||
createHFWidget();
|
||||
break;
|
||||
case FrequencyBand_def::UHF:
|
||||
createUHFWidget();
|
||||
break;
|
||||
case FrequencyBand_def::VHF:
|
||||
createVHFWidget();
|
||||
break;
|
||||
}
|
||||
|
||||
m_ui->cbRadioStation->clear();
|
||||
m_ismCbxIfc->fillRadioStationsComboBox(m_ui->cbRadioStation, m_ui->cbFrequencyBand->currentData().toInt());
|
||||
if(m_hasParty && !m_isRelay)
|
||||
m_ui->cbRadioStation->addItem(tr("Automatic"), 0);
|
||||
m_ui->cbRadioStation->clear();
|
||||
m_ismCbxIfc->fillRadioStationsComboBox(m_ui->cbRadioStation, m_ui->cbFrequencyBand->currentData().toInt());
|
||||
if (m_hasParty && !m_isRelay)
|
||||
m_ui->cbRadioStation->addItem(tr("Automatic"), 0);
|
||||
|
||||
if(m_radioSpecificaWidget)
|
||||
m_ui->gridLayout->addWidget(m_radioSpecificaWidget,5,0,1,2);
|
||||
adjustSize();
|
||||
if (m_radioSpecificaWidget)
|
||||
m_ui->gridLayout->addWidget(m_radioSpecificaWidget, 5, 0, 1, 2);
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void FrequencyPlanningWidget::createHFWidget(RadioCircuit* circuit)
|
||||
{
|
||||
if(m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
m_radioSpecificaWidget = new RadioSpecificaHfWidget(m_ui->radioSpecificaWidget);
|
||||
if(!circuit)
|
||||
return;
|
||||
RadioCircuitHF *dataHf = dynamic_cast<RadioCircuitHF*>(circuit);
|
||||
m_radioSpecificaWidget->setValues(dataHf);
|
||||
if (m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
m_radioSpecificaWidget = new RadioSpecificaHfWidget(m_ui->radioSpecificaWidget);
|
||||
if (!circuit)
|
||||
return;
|
||||
RadioCircuitHF* dataHf = dynamic_cast<RadioCircuitHF*>(circuit);
|
||||
m_radioSpecificaWidget->setValues(dataHf);
|
||||
}
|
||||
|
||||
void FrequencyPlanningWidget::createUHFWidget(RadioCircuit* circuit)
|
||||
{
|
||||
if(m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
m_radioSpecificaWidget = new RadioSpecificaUhfWidget(m_ui->radioSpecificaWidget);
|
||||
if(!circuit)
|
||||
return;
|
||||
RadioCircuitUHF* dataUhf = dynamic_cast<RadioCircuitUHF*>(circuit);
|
||||
m_radioSpecificaWidget->setValues(dataUhf);
|
||||
if (m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
m_radioSpecificaWidget = new RadioSpecificaUhfWidget(m_ui->radioSpecificaWidget);
|
||||
if (!circuit)
|
||||
return;
|
||||
RadioCircuitUHF* dataUhf = dynamic_cast<RadioCircuitUHF*>(circuit);
|
||||
m_radioSpecificaWidget->setValues(dataUhf);
|
||||
}
|
||||
|
||||
void FrequencyPlanningWidget::createVHFWidget(RadioCircuit* circuit)
|
||||
{
|
||||
if(m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
auto *widget = new RadioSpecificaVhfWidget(m_assignedFrequencySetDataIds, m_ui->radioSpecificaWidget);
|
||||
widget->init(m_frequencySetId, m_avmDtc, m_cnrConfigId);
|
||||
m_radioSpecificaWidget = widget;
|
||||
if (m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
auto* widget = new RadioSpecificaVhfWidget(m_assignedFrequencySetDataIds, m_ui->radioSpecificaWidget);
|
||||
widget->init(m_frequencySetId, m_avmDtc, m_cnrConfigId);
|
||||
m_radioSpecificaWidget = widget;
|
||||
|
||||
if(!circuit)
|
||||
return;
|
||||
RadioCircuitVHF* dataVhf = dynamic_cast<RadioCircuitVHF*>(circuit);
|
||||
m_radioSpecificaWidget->setValues(dataVhf);
|
||||
if (!circuit)
|
||||
return;
|
||||
RadioCircuitVHF* dataVhf = dynamic_cast<RadioCircuitVHF*>(circuit);
|
||||
m_radioSpecificaWidget->setValues(dataVhf);
|
||||
}
|
||||
|
||||
void FrequencyPlanningWidget::onCnrConfigChanged(const AudioVideoManagement::CnrConfig &config, DataModification modType)
|
||||
void FrequencyPlanningWidget::onCnrConfigChanged(const AudioVideoManagement::CnrConfig& config,
|
||||
DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
if (m_cnrConfigId == config.id())
|
||||
{
|
||||
m_ui->leName->setText(QString::fromStdString(config.radioCircuit()));
|
||||
}
|
||||
Q_UNUSED(modType);
|
||||
if (m_cnrConfigId == config.id())
|
||||
{
|
||||
m_ui->leName->setText(QString::fromStdString(config.radioCircuit()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+32
-36
@@ -1,70 +1,66 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_init_frequency_planning_dialog.h"
|
||||
|
||||
#include "ui_avm_init_frequency_planning_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
InitFrequencyPlanningDialog::InitFrequencyPlanningDialog(LtsSession::LtsSession *session, const std::shared_ptr<Interface::Dtc> &avmDtc, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkCancel)
|
||||
, m_ui(new Ui::InitFrequencyPlanningDialog)
|
||||
, m_dateOfCreation(session->partitionTime())
|
||||
, m_session(session)
|
||||
InitFrequencyPlanningDialog::InitFrequencyPlanningDialog(LtsSession::LtsSession* session,
|
||||
const std::shared_ptr<Interface::Dtc>& avmDtc, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkCancel), m_ui(new Ui::InitFrequencyPlanningDialog),
|
||||
m_dateOfCreation(session->partitionTime()), m_session(session)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "---InitFrequencyPlanningDialog() ";
|
||||
m_ui->setupUi(this);
|
||||
DEBUG_LOG(m_logger) << "---InitFrequencyPlanningDialog() ";
|
||||
m_ui->setupUi(this);
|
||||
|
||||
QMap<int32_t, FrequencySet> frequencySets = avmDtc->frequencySets();
|
||||
QMap<int32_t, FrequencySet> frequencySets = avmDtc->frequencySets();
|
||||
|
||||
for (auto it = frequencySets.constBegin(); it != frequencySets.constEnd(); ++it)
|
||||
m_ui->cbFrequencySets->addItem(QString::fromStdString(it.value().name()), QVariant::fromValue(it.key()));
|
||||
for (auto it = frequencySets.constBegin(); it != frequencySets.constEnd(); ++it)
|
||||
m_ui->cbFrequencySets->addItem(QString::fromStdString(it.value().name()), QVariant::fromValue(it.key()));
|
||||
|
||||
m_ui->tbTime->setText(DTG::toStringMSec(m_dateOfCreation));
|
||||
|
||||
connect(m_ui->tbTime, &QToolButton::clicked, this, [this]()
|
||||
{
|
||||
m_dateOfCreation = m_session->partitionTime();
|
||||
m_ui->tbTime->setText(DTG::toStringMSec(m_dateOfCreation));
|
||||
});
|
||||
|
||||
m_uiRequirements->addRequirement( { m_ui->lblName, [this]() { return !m_ui->leName->text().isEmpty(); } });
|
||||
m_uiRequirements->addRequirement( { m_ui->lblFrequencySets, [this]() { return !m_ui->cbFrequencySets->currentText().isEmpty(); } });
|
||||
connect(m_ui->tbTime, &QToolButton::clicked, this, [this]() {
|
||||
m_dateOfCreation = m_session->partitionTime();
|
||||
m_ui->tbTime->setText(DTG::toStringMSec(m_dateOfCreation));
|
||||
});
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Frequency_Planning"));
|
||||
m_uiRequirements->addRequirement({m_ui->lblName, [this]() { return !m_ui->leName->text().isEmpty(); }});
|
||||
m_uiRequirements->addRequirement(
|
||||
{m_ui->lblFrequencySets, [this]() { return !m_ui->cbFrequencySets->currentText().isEmpty(); }});
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Frequency_Planning"));
|
||||
}
|
||||
|
||||
|
||||
InitFrequencyPlanningDialog::~InitFrequencyPlanningDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void InitFrequencyPlanningDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("New Frequency Planning"));
|
||||
translate(m_ui, tr("New Frequency Planning"));
|
||||
}
|
||||
|
||||
|
||||
bool InitFrequencyPlanningDialog::apply()
|
||||
{
|
||||
FrequencyPlanning planning;
|
||||
FrequencyPlanning planning;
|
||||
|
||||
planning.id(0);
|
||||
if(m_session->exerciseId() != 0)
|
||||
planning.exerciseId(m_session->exerciseId());
|
||||
planning.frequencySetId(m_ui->cbFrequencySets->currentData().toInt());
|
||||
planning.name(m_ui->leName->text().toStdString());
|
||||
planning.date(m_dateOfCreation);
|
||||
planning.id(0);
|
||||
if (m_session->exerciseId() != 0)
|
||||
planning.exerciseId(m_session->exerciseId());
|
||||
planning.frequencySetId(m_ui->cbFrequencySets->currentData().toInt());
|
||||
planning.name(m_ui->leName->text().toStdString());
|
||||
planning.date(m_dateOfCreation);
|
||||
|
||||
emit newInitFrequencyPlanning(planning);
|
||||
emit newInitFrequencyPlanning(planning);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+18
-20
@@ -1,12 +1,10 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
class QCheckBox;
|
||||
|
||||
@@ -24,23 +22,23 @@ namespace AudioVideoManagement
|
||||
{
|
||||
class InitFrequencyPlanningDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InitFrequencyPlanningDialog(LtsSession::LtsSession *session, const std::shared_ptr<Interface::Dtc> &avmDtc, QWidget *parent);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InitFrequencyPlanningDialog(LtsSession::LtsSession* session, const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
QWidget* parent);
|
||||
|
||||
~InitFrequencyPlanningDialog();
|
||||
~InitFrequencyPlanningDialog();
|
||||
|
||||
signals:
|
||||
void newInitFrequencyPlanning(const FrequencyPlanning &);
|
||||
signals:
|
||||
void newInitFrequencyPlanning(const FrequencyPlanning&);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
|
||||
Ui::InitFrequencyPlanningDialog *m_ui;
|
||||
qint64 m_dateOfCreation;
|
||||
LtsSession::LtsSession *m_session;
|
||||
};
|
||||
}
|
||||
Ui::InitFrequencyPlanningDialog* m_ui;
|
||||
qint64 m_dateOfCreation;
|
||||
LtsSession::LtsSession* m_session;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+23
-27
@@ -1,11 +1,10 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -23,7 +22,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace InfrastructureManagement
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
@@ -31,38 +30,35 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class LoadFrequencyPlanningDialogModel;
|
||||
|
||||
class LoadFrequencyPlanningDialog
|
||||
: public LtsWidgets::LtsFramelessDialog
|
||||
class LoadFrequencyPlanningDialog : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoadFrequencyPlanningDialog(const QByteArray &data,
|
||||
const FrequencyPlanning &initPlan,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
QWidget *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoadFrequencyPlanningDialog(const QByteArray& data, const FrequencyPlanning& initPlan,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
~LoadFrequencyPlanningDialog();
|
||||
~LoadFrequencyPlanningDialog();
|
||||
|
||||
QVector<int32_t> unassignments() const;
|
||||
QVector<FrequencyPlanningData> newPlanningData() const;
|
||||
QVector<int32_t> unassignments() const;
|
||||
QVector<FrequencyPlanningData> newPlanningData() const;
|
||||
|
||||
bool isApplied() const;
|
||||
bool isApplied() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOk();
|
||||
private Q_SLOTS:
|
||||
void onOk();
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::unique_ptr<Ui::LoadFrequencyPlanningDialog> m_ui;
|
||||
LoadFrequencyPlanningDialogModel *m_model;
|
||||
bool m_isApplied = false;
|
||||
};
|
||||
}
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::unique_ptr<Ui::LoadFrequencyPlanningDialog> m_ui;
|
||||
LoadFrequencyPlanningDialogModel* m_model;
|
||||
bool m_isApplied = false;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+695
-756
File diff suppressed because it is too large.
Load diff
Executable → Regular
+175
-206
@@ -1,329 +1,298 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_eloka_dialog.h"
|
||||
#include <utility>
|
||||
|
||||
#include "ui_avm_eloka_dialog.h"
|
||||
|
||||
#include <avm_eloka_edit_dialog.h>
|
||||
#include <AudioVideoManagement/ava_session.h>
|
||||
#include <AudioVideoManagement/ava_control.h>
|
||||
#include <AudioVideoManagement/av_helper.h>
|
||||
#include <AudioVideoManagement/ava_control.h>
|
||||
#include <AudioVideoManagement/ava_session.h>
|
||||
#include <AudioVideoManagement/stream_name_mapping.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <QTreeView>
|
||||
#include <avm_eloka_edit_dialog.h>
|
||||
#include <utility>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
ElokaDialog::ElokaDialog(LtsSession::LtsSession *session, AvaSession *avaSession, Interface::Dtc *avmDtc, StreamNameMapping *streamNameMapping,
|
||||
const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ui(new Ui::ElokaDialog)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_elokaModel(new ElokaModel(session, this))
|
||||
, m_session(session)
|
||||
, m_avaSession(avaSession)
|
||||
, m_elokaListCollector(m_avaSession->control()->comm(), [this] (QVector<AvaEloka> &&eloka) { onQueryElokaResponse(std::move(eloka)); })
|
||||
, m_streamNameMapping(streamNameMapping)
|
||||
, m_avmDtc(avmDtc)
|
||||
, m_avaSessionEstablished(false)
|
||||
, m_usedCnr()
|
||||
, m_usedTvc()
|
||||
, m_usedAnnouncement()
|
||||
ElokaDialog::ElokaDialog(LtsSession::LtsSession* session, AvaSession* avaSession, Interface::Dtc* avmDtc,
|
||||
StreamNameMapping* streamNameMapping, const QString& menuGroup, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_ui(new Ui::ElokaDialog),
|
||||
m_menuGroup(menuGroup), m_elokaModel(new ElokaModel(session, this)), m_session(session), m_avaSession(avaSession),
|
||||
m_elokaListCollector(m_avaSession->control()->comm(),
|
||||
[this](QVector<AvaEloka>&& eloka) { onQueryElokaResponse(std::move(eloka)); }),
|
||||
m_streamNameMapping(streamNameMapping), m_avmDtc(avmDtc), m_avaSessionEstablished(false), m_usedCnr(),
|
||||
m_usedTvc(), m_usedAnnouncement()
|
||||
{
|
||||
Q_ASSERT(session);
|
||||
Q_ASSERT(avaSession);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
Q_ASSERT(avmDtc);
|
||||
Q_ASSERT(session);
|
||||
Q_ASSERT(avaSession);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
Q_ASSERT(avmDtc);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_avaSession, &AvaSession::sessionEstablished,
|
||||
this, &ElokaDialog::onAvaSessionEstablished);
|
||||
connect(m_avaSession, &AvaSession::disconnected,
|
||||
this, &ElokaDialog::onAvaSessionDisconnected);
|
||||
connect(m_avaSession, &AvaSession::sessionEstablished, this, &ElokaDialog::onAvaSessionEstablished);
|
||||
connect(m_avaSession, &AvaSession::disconnected, this, &ElokaDialog::onAvaSessionDisconnected);
|
||||
|
||||
m_elokaListCollector.start();
|
||||
m_elokaListCollector.start();
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add,
|
||||
this, &ElokaDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit,
|
||||
this, &ElokaDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove,
|
||||
this, &ElokaDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print,
|
||||
this, &ElokaDialog::onPrint);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &ElokaDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ElokaDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &ElokaDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ElokaDialog::onPrint);
|
||||
|
||||
m_ui->tvEloka->setModel(m_elokaModel);
|
||||
m_ui->tvEloka->setModel(m_elokaModel);
|
||||
|
||||
connect(m_ui->tvEloka, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &ElokaDialog::onSelectionChanged);
|
||||
onSelectionChanged();
|
||||
connect(m_ui->tvEloka, &LtsDataView::LtsDataView::signalSelectionChanged, this, &ElokaDialog::onSelectionChanged);
|
||||
onSelectionChanged();
|
||||
|
||||
connect(m_ui->tvEloka, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &ElokaDialog::onEditClicked);
|
||||
connect(m_ui->tvEloka, &LtsDataView::LtsDataView::signalDoubleClicked, this, &ElokaDialog::onEditClicked);
|
||||
|
||||
setAvaSessionStatus(m_avaSession->isEstablished());
|
||||
setAvaSessionStatus(m_avaSession->isEstablished());
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Electronic_Warfare_Measures"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Electronic_Warfare_Measures"));
|
||||
}
|
||||
|
||||
ElokaDialog::~ElokaDialog()
|
||||
{
|
||||
delete m_elokaModel;
|
||||
delete m_ui;
|
||||
m_avaSession->control()->queryEloka(AvaQueryElokaMode::Stop);
|
||||
delete m_elokaModel;
|
||||
delete m_ui;
|
||||
m_avaSession->control()->queryEloka(AvaQueryElokaMode::Stop);
|
||||
}
|
||||
|
||||
void ElokaDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Eloka"));
|
||||
translate(m_ui, tr("Eloka"));
|
||||
}
|
||||
|
||||
void ElokaDialog::onAvaSessionEstablished()
|
||||
{
|
||||
setAvaSessionStatus(true);
|
||||
setAvaSessionStatus(true);
|
||||
}
|
||||
|
||||
void ElokaDialog::onAvaSessionDisconnected()
|
||||
{
|
||||
m_elokaListCollector.reset();
|
||||
m_elokaListCollector.start();
|
||||
setAvaSessionStatus(false);
|
||||
m_elokaListCollector.reset();
|
||||
m_elokaListCollector.start();
|
||||
setAvaSessionStatus(false);
|
||||
}
|
||||
|
||||
void ElokaDialog::setAvaSessionStatus(bool established)
|
||||
{
|
||||
m_avaSessionEstablished = established;
|
||||
m_avaSessionEstablished = established;
|
||||
|
||||
|
||||
if (established)
|
||||
m_avaSession->control()->queryEloka(AvaQueryElokaMode::Push);
|
||||
if (established)
|
||||
m_avaSession->control()->queryEloka(AvaQueryElokaMode::Push);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, established);
|
||||
m_ui->lblAvaSessionStatus->setVisible(!established);
|
||||
onSelectionChanged();
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, established);
|
||||
m_ui->lblAvaSessionStatus->setVisible(!established);
|
||||
onSelectionChanged();
|
||||
}
|
||||
|
||||
void ElokaDialog::onAddClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "**** onAddClicked() ";
|
||||
DEBUG_LOG(m_logger) << "**** onAddClicked() ";
|
||||
|
||||
ElokaEditDialog *dialog = new ElokaEditDialog(m_session, m_avaSession, m_avmDtc, m_streamNameMapping,
|
||||
ElokaData(), this);
|
||||
ElokaEditDialog* dialog =
|
||||
new ElokaEditDialog(m_session, m_avaSession, m_avmDtc, m_streamNameMapping, ElokaData(), this);
|
||||
|
||||
connect(dialog, &ElokaEditDialog::signalNewEloka, this,
|
||||
[this](const ElokaData & data)
|
||||
{
|
||||
m_elokaModel->insertRow(data);
|
||||
});
|
||||
connect(dialog, &ElokaEditDialog::signalNewEloka, this,
|
||||
[this](const ElokaData& data) { m_elokaModel->insertRow(data); });
|
||||
|
||||
getUsedRadioCircuits();
|
||||
dialog->init(m_usedCnr, m_usedTvc, m_usedAnnouncement);
|
||||
getUsedRadioCircuits();
|
||||
dialog->init(m_usedCnr, m_usedTvc, m_usedAnnouncement);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("AddEloka"));
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("AddEloka"));
|
||||
}
|
||||
|
||||
void ElokaDialog::onEditClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "**** onEditClicked() ";
|
||||
DEBUG_LOG(m_logger) << "**** onEditClicked() ";
|
||||
|
||||
const QModelIndex idx = m_ui->tvEloka->currentIndex();
|
||||
const QModelIndex idx = m_ui->tvEloka->currentIndex();
|
||||
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
|
||||
const ElokaData data = m_elokaModel->getRowData(idx.row());
|
||||
const ElokaData data = m_elokaModel->getRowData(idx.row());
|
||||
|
||||
ElokaEditDialog *dialog = new ElokaEditDialog(m_session, m_avaSession, m_avmDtc, m_streamNameMapping,
|
||||
data, this);
|
||||
ElokaEditDialog* dialog = new ElokaEditDialog(m_session, m_avaSession, m_avmDtc, m_streamNameMapping, data, this);
|
||||
|
||||
connect(dialog, &ElokaEditDialog::signalNewEloka, this,
|
||||
[ = ](const ElokaData & data)
|
||||
{
|
||||
m_elokaModel->setRowData(idx.row(), data);
|
||||
});
|
||||
connect(dialog, &ElokaEditDialog::signalNewEloka, this,
|
||||
[=](const ElokaData& data) { m_elokaModel->setRowData(idx.row(), data); });
|
||||
|
||||
getUsedRadioCircuits();
|
||||
dialog->init(m_usedCnr, m_usedTvc, m_usedAnnouncement);
|
||||
getUsedRadioCircuits();
|
||||
dialog->init(m_usedCnr, m_usedTvc, m_usedAnnouncement);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditEloka"));
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditEloka"));
|
||||
}
|
||||
|
||||
void ElokaDialog::onRemoveClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "**** onRemoveClicked() ";
|
||||
DEBUG_LOG(m_logger) << "**** onRemoveClicked() ";
|
||||
|
||||
const QModelIndex idx = m_ui->tvEloka->currentIndex();
|
||||
const QModelIndex idx = m_ui->tvEloka->currentIndex();
|
||||
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
m_avaSession->control()->releaseEloka(m_elokaModel->getRowData(idx.row()).internalName);
|
||||
m_elokaModel->removeRow(idx.row());
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
m_avaSession->control()->releaseEloka(m_elokaModel->getRowData(idx.row()).internalName);
|
||||
m_elokaModel->removeRow(idx.row());
|
||||
}
|
||||
|
||||
void ElokaDialog::onSelectionChanged()
|
||||
{
|
||||
QModelIndexList selectedRows = m_ui->tvEloka->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
QModelIndexList selectedRows = m_ui->tvEloka->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit,
|
||||
cntSelectedRows == 1 && m_avaSessionEstablished);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove,
|
||||
cntSelectedRows > 0 && m_avaSessionEstablished);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add,
|
||||
!(m_elokaModel->rowCount() >= 20));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1 && m_avaSessionEstablished);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, cntSelectedRows > 0 && m_avaSessionEstablished);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, !(m_elokaModel->rowCount() >= 20));
|
||||
}
|
||||
|
||||
void ElokaDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->tvEloka->treeView() );
|
||||
LtsPrinting::printView(m_session, this, m_ui->tvEloka->treeView());
|
||||
}
|
||||
|
||||
void ElokaDialog::onQueryElokaResponse(const QVector<AvaEloka> &&eloka)
|
||||
void ElokaDialog::onQueryElokaResponse(const QVector<AvaEloka>&& eloka)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onQueryElokaResponse";
|
||||
DEBUG_LOG(m_logger) << "onQueryElokaResponse";
|
||||
|
||||
m_elokaListCollector.start();
|
||||
m_elokaModel->clear();
|
||||
m_elokaListCollector.start();
|
||||
m_elokaModel->clear();
|
||||
|
||||
if (eloka.isEmpty())
|
||||
return;
|
||||
if (eloka.isEmpty())
|
||||
return;
|
||||
|
||||
const auto cnrTvcProfiles = m_avmDtc->cnrTvcProfiles();
|
||||
QMultiMap<qint32, ElokaCircuitType> userProfile;
|
||||
int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
int exerciseId = m_session->exerciseId();
|
||||
const auto cnrTvcProfiles = m_avmDtc->cnrTvcProfiles();
|
||||
QMultiMap<qint32, ElokaCircuitType> userProfile;
|
||||
int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
int exerciseId = m_session->exerciseId();
|
||||
|
||||
for (const auto &cnrTvcProfile : cnrTvcProfiles)
|
||||
{
|
||||
if (cnrTvcProfile.exerciseId() == exerciseId &&
|
||||
cnrTvcProfile.operatorId() == operatorId)
|
||||
for (const auto& cnrTvcProfile : cnrTvcProfiles)
|
||||
{
|
||||
for (const auto &cnrTvcProfileData : cnrTvcProfile.data())
|
||||
{
|
||||
if (cnrTvcProfileData.radioSystemId() == RadioSystem::inner_enum::Cnr)
|
||||
userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Cnr);
|
||||
else
|
||||
userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Tvc);
|
||||
}
|
||||
if (cnrTvcProfile.exerciseId() == exerciseId && cnrTvcProfile.operatorId() == operatorId)
|
||||
{
|
||||
for (const auto& cnrTvcProfileData : cnrTvcProfile.data())
|
||||
{
|
||||
if (cnrTvcProfileData.radioSystemId() == RadioSystem::inner_enum::Cnr)
|
||||
userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Cnr);
|
||||
else
|
||||
userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Tvc);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ElokaData data;
|
||||
for (const auto &elokaData : eloka)
|
||||
{
|
||||
data.internalName = elokaData.stream;
|
||||
data.displayName = elokaData.stream;
|
||||
data.action = elokaData.signal;
|
||||
data.mode = AvaElokaMode::EndlessLoop;
|
||||
data.startTime = toMSecSinceEpoch(elokaData.time);
|
||||
ElokaData data;
|
||||
for (const auto& elokaData : eloka)
|
||||
{
|
||||
data.internalName = elokaData.stream;
|
||||
data.displayName = elokaData.stream;
|
||||
data.action = elokaData.signal;
|
||||
data.mode = AvaElokaMode::EndlessLoop;
|
||||
data.startTime = toMSecSinceEpoch(elokaData.time);
|
||||
|
||||
if (isCnr(data, userProfile) ||
|
||||
isTvc(data, userProfile) ||
|
||||
isAnnouncement(data))
|
||||
m_elokaModel->insertRow(data);
|
||||
}
|
||||
if (isCnr(data, userProfile) || isTvc(data, userProfile) || isAnnouncement(data))
|
||||
m_elokaModel->insertRow(data);
|
||||
}
|
||||
}
|
||||
|
||||
void ElokaDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->tvEloka->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->tvEloka->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool ElokaDialog::isCnr(ElokaData& data, const QMultiMap<qint32, ElokaCircuitType>& userProfile)
|
||||
{
|
||||
const QMap<qint32, CnrConfig> cnrs = m_avmDtc->cnrConfigs();
|
||||
const QMap<qint32, CnrConfig> cnrs = m_avmDtc->cnrConfigs();
|
||||
|
||||
for (const auto &cnr : cnrs)
|
||||
{
|
||||
if ((QString::fromStdString(cnr.radioCircuit()) == data.internalName) &&
|
||||
(userProfile.contains(cnr.id(), ElokaCircuitType::Cnr)))
|
||||
for (const auto& cnr : cnrs)
|
||||
{
|
||||
data.circuitType = ElokaCircuitType::Cnr;
|
||||
data.party = cnr.partyId();
|
||||
data.id = cnr.id();
|
||||
return true;
|
||||
if ((QString::fromStdString(cnr.radioCircuit()) == data.internalName) &&
|
||||
(userProfile.contains(cnr.id(), ElokaCircuitType::Cnr)))
|
||||
{
|
||||
data.circuitType = ElokaCircuitType::Cnr;
|
||||
data.party = cnr.partyId();
|
||||
data.id = cnr.id();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ElokaDialog::isTvc(ElokaData& data, const QMultiMap<qint32, ElokaCircuitType>& userProfile)
|
||||
{
|
||||
const QMap<qint32, TvcConfig> tvcs = m_avmDtc->tvcConfigs();
|
||||
const QMap<qint32, TvcConfig> tvcs = m_avmDtc->tvcConfigs();
|
||||
|
||||
for (const auto &tvc : tvcs)
|
||||
{
|
||||
if (tvc.exerciseId() != m_session->exerciseId())
|
||||
continue;
|
||||
if ((QString::fromStdString(tvc.radioCircuit()) == data.internalName) &&
|
||||
(userProfile.contains(tvc.id(), ElokaCircuitType::Tvc)))
|
||||
for (const auto& tvc : tvcs)
|
||||
{
|
||||
data.circuitType = ElokaCircuitType::Tvc;
|
||||
data.party = 0;
|
||||
data.id = tvc.id();
|
||||
return true;
|
||||
if (tvc.exerciseId() != m_session->exerciseId())
|
||||
continue;
|
||||
if ((QString::fromStdString(tvc.radioCircuit()) == data.internalName) &&
|
||||
(userProfile.contains(tvc.id(), ElokaCircuitType::Tvc)))
|
||||
{
|
||||
data.circuitType = ElokaCircuitType::Tvc;
|
||||
data.party = 0;
|
||||
data.id = tvc.id();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ElokaDialog::isAnnouncement(ElokaData& data)
|
||||
{
|
||||
QMap<qint32, Stream> announcements;
|
||||
QMap<qint32, Stream> streams = m_avmDtc->streams();
|
||||
for (const Stream &stream : std::as_const(streams))
|
||||
{
|
||||
if ((stream.type() == StreamType_def::AudioOut) ||
|
||||
(stream.type() == StreamType_def::AudioInOut))
|
||||
announcements.insert(stream.id(), stream);
|
||||
}
|
||||
|
||||
for (const auto &announcement : announcements)
|
||||
{
|
||||
if (QString::fromStdString(announcement.name()) == data.internalName)
|
||||
QMap<qint32, Stream> announcements;
|
||||
QMap<qint32, Stream> streams = m_avmDtc->streams();
|
||||
for (const Stream& stream : std::as_const(streams))
|
||||
{
|
||||
data.circuitType = ElokaCircuitType::Announcement;
|
||||
data.party = -1;
|
||||
data.id = announcement.id();
|
||||
data.exerciseId = m_session->exerciseId();
|
||||
data.displayName = m_streamNameMapping->displayName(data.internalName);
|
||||
return true;
|
||||
if ((stream.type() == StreamType_def::AudioOut) || (stream.type() == StreamType_def::AudioInOut))
|
||||
announcements.insert(stream.id(), stream);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
for (const auto& announcement : announcements)
|
||||
{
|
||||
if (QString::fromStdString(announcement.name()) == data.internalName)
|
||||
{
|
||||
data.circuitType = ElokaCircuitType::Announcement;
|
||||
data.party = -1;
|
||||
data.id = announcement.id();
|
||||
data.exerciseId = m_session->exerciseId();
|
||||
data.displayName = m_streamNameMapping->displayName(data.internalName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ElokaDialog::getUsedRadioCircuits()
|
||||
{
|
||||
m_usedAnnouncement.clear();
|
||||
m_usedCnr.clear();
|
||||
m_usedTvc.clear();
|
||||
m_usedAnnouncement.clear();
|
||||
m_usedCnr.clear();
|
||||
m_usedTvc.clear();
|
||||
|
||||
for (int i=0; i < m_elokaModel->rowCount(); ++i)
|
||||
{
|
||||
ElokaData elokaData = m_elokaModel->getRowData(i);
|
||||
switch (elokaData.circuitType)
|
||||
for (int i = 0; i < m_elokaModel->rowCount(); ++i)
|
||||
{
|
||||
case ElokaCircuitType::Cnr:
|
||||
m_usedCnr.push_back(elokaData.id);
|
||||
break;
|
||||
case ElokaCircuitType::Tvc:
|
||||
m_usedTvc.push_back(elokaData.id);
|
||||
break;
|
||||
case ElokaCircuitType::Announcement:
|
||||
m_usedAnnouncement.push_back(elokaData.id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
ElokaData elokaData = m_elokaModel->getRowData(i);
|
||||
switch (elokaData.circuitType)
|
||||
{
|
||||
case ElokaCircuitType::Cnr:
|
||||
m_usedCnr.push_back(elokaData.id);
|
||||
break;
|
||||
case ElokaCircuitType::Tvc:
|
||||
m_usedTvc.push_back(elokaData.id);
|
||||
break;
|
||||
case ElokaCircuitType::Announcement:
|
||||
m_usedAnnouncement.push_back(elokaData.id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+348
-393
@@ -1,264 +1,233 @@
|
||||
|
||||
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <utility>
|
||||
|
||||
#include "avm_eloka_edit_dialog.h"
|
||||
#include "ui_avm_eloka_edit_dialog.h"
|
||||
#include <AudioVideoManagement/ava_session.h>
|
||||
#include <AudioVideoManagement/ava_control.h>
|
||||
#include <AudioVideoManagement/stream_name_mapping.h>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include "ui_avm_eloka_edit_dialog.h"
|
||||
|
||||
#include <AudioVideoManagement/ava_control.h>
|
||||
#include <AudioVideoManagement/ava_session.h>
|
||||
#include <AudioVideoManagement/stream_name_mapping.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <boost/optional.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
||||
|
||||
struct ComboBoxUserData
|
||||
{
|
||||
QString internalName;
|
||||
AudioVideoManagement::ElokaCircuitType circuitType;
|
||||
int id;
|
||||
QString internalName;
|
||||
AudioVideoManagement::ElokaCircuitType circuitType;
|
||||
int id;
|
||||
};
|
||||
|
||||
|
||||
ComboBoxUserData userDataAt(QComboBox *cb, int index)
|
||||
ComboBoxUserData userDataAt(QComboBox* cb, int index)
|
||||
{
|
||||
Q_ASSERT(cb);
|
||||
Q_ASSERT(index >= 0 && index < cb->count());
|
||||
QVariant userData = cb->itemData(index);
|
||||
Q_ASSERT(userData.canConvert<ComboBoxUserData>());
|
||||
return userData.value<ComboBoxUserData>();
|
||||
Q_ASSERT(cb);
|
||||
Q_ASSERT(index >= 0 && index < cb->count());
|
||||
QVariant userData = cb->itemData(index);
|
||||
Q_ASSERT(userData.canConvert<ComboBoxUserData>());
|
||||
return userData.value<ComboBoxUserData>();
|
||||
}
|
||||
|
||||
ComboBoxUserData currentUserData(QComboBox* cb)
|
||||
{
|
||||
Q_ASSERT(cb);
|
||||
return userDataAt(cb, cb->currentIndex());
|
||||
Q_ASSERT(cb);
|
||||
return userDataAt(cb, cb->currentIndex());
|
||||
}
|
||||
|
||||
|
||||
|
||||
boost::optional<int> currentId(QComboBox *comboBox, AudioVideoManagement::ElokaCircuitType circuitType)
|
||||
boost::optional<int> currentId(QComboBox* comboBox, AudioVideoManagement::ElokaCircuitType circuitType)
|
||||
{
|
||||
Q_ASSERT(comboBox);
|
||||
Q_ASSERT(comboBox);
|
||||
|
||||
int selectedIndex = comboBox->currentIndex();
|
||||
if (selectedIndex == -1)
|
||||
return boost::none;
|
||||
int selectedIndex = comboBox->currentIndex();
|
||||
if (selectedIndex == -1)
|
||||
return boost::none;
|
||||
|
||||
QVariant userData_ = comboBox->itemData(selectedIndex);
|
||||
Q_ASSERT(userData_.canConvert<ComboBoxUserData>());
|
||||
ComboBoxUserData userData = userData_.value<ComboBoxUserData>();
|
||||
if (userData.circuitType != circuitType)
|
||||
return boost::none;
|
||||
|
||||
return userData.id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void selectItemWithId(QComboBox *comboBox, boost::optional<int> id)
|
||||
{
|
||||
Q_ASSERT(comboBox);
|
||||
|
||||
if (comboBox->count() == 0)
|
||||
return;
|
||||
|
||||
if (!id.is_initialized())
|
||||
{
|
||||
comboBox->setCurrentIndex(0);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < comboBox->count(); ++i)
|
||||
{
|
||||
QVariant userData_ = comboBox->itemData(i);
|
||||
QVariant userData_ = comboBox->itemData(selectedIndex);
|
||||
Q_ASSERT(userData_.canConvert<ComboBoxUserData>());
|
||||
ComboBoxUserData userData = userData_.value<ComboBoxUserData>();
|
||||
if (userData.id == *id)
|
||||
{
|
||||
comboBox->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ComboBoxUserData userData = userData_.value<ComboBoxUserData>();
|
||||
if (userData.circuitType != circuitType)
|
||||
return boost::none;
|
||||
|
||||
comboBox->setCurrentIndex(0);
|
||||
return userData.id;
|
||||
}
|
||||
|
||||
}
|
||||
void selectItemWithId(QComboBox* comboBox, boost::optional<int> id)
|
||||
{
|
||||
Q_ASSERT(comboBox);
|
||||
|
||||
if (comboBox->count() == 0)
|
||||
return;
|
||||
|
||||
if (!id.is_initialized())
|
||||
{
|
||||
comboBox->setCurrentIndex(0);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < comboBox->count(); ++i)
|
||||
{
|
||||
QVariant userData_ = comboBox->itemData(i);
|
||||
Q_ASSERT(userData_.canConvert<ComboBoxUserData>());
|
||||
ComboBoxUserData userData = userData_.value<ComboBoxUserData>();
|
||||
if (userData.id == *id)
|
||||
{
|
||||
comboBox->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
comboBox->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(ComboBoxUserData)
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
ElokaEditDialog::ElokaEditDialog(LtsSession::LtsSession *session, AvaSession *avaSession, Interface::Dtc *avmDtc, StreamNameMapping *streamNameMapping,
|
||||
const ElokaData &data, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::ElokaEditDialog)
|
||||
, m_session(session)
|
||||
, m_streamNameMapping(streamNameMapping)
|
||||
, m_avaCtrl(avaSession->control())
|
||||
, m_avmDtc(avmDtc)
|
||||
, m_elokaData(data)
|
||||
, m_cnrConfigMap()
|
||||
, m_tvcConfigMap()
|
||||
, m_announcementMap()
|
||||
, m_userProfile()
|
||||
ElokaEditDialog::ElokaEditDialog(LtsSession::LtsSession* session, AvaSession* avaSession, Interface::Dtc* avmDtc,
|
||||
StreamNameMapping* streamNameMapping, const ElokaData& data, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_ui(new Ui::ElokaEditDialog),
|
||||
m_session(session), m_streamNameMapping(streamNameMapping), m_avaCtrl(avaSession->control()), m_avmDtc(avmDtc),
|
||||
m_elokaData(data), m_cnrConfigMap(), m_tvcConfigMap(), m_announcementMap(), m_userProfile()
|
||||
{
|
||||
Q_ASSERT(session);
|
||||
Q_ASSERT(avaSession);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
Q_ASSERT(avmDtc);
|
||||
Q_ASSERT(session);
|
||||
Q_ASSERT(avaSession);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
Q_ASSERT(avmDtc);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_uiRequirements->addRequirement( { m_ui->lbAction, [this]() { return !m_ui->cmbAction->currentText().isEmpty(); } });
|
||||
m_uiRequirements->addRequirement( { m_ui->lbCircuit, [this]() { return !m_ui->cmbCircuit->currentText().isEmpty(); } });
|
||||
m_uiRequirements->addRequirement({m_ui->lbAction, [this]() { return !m_ui->cmbAction->currentText().isEmpty(); }});
|
||||
m_uiRequirements->addRequirement(
|
||||
{m_ui->lbCircuit, [this]() { return !m_ui->cmbCircuit->currentText().isEmpty(); }});
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Electronic_Warfare_Measures"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Electronic_Warfare_Measures"));
|
||||
}
|
||||
|
||||
ElokaEditDialog::~ElokaEditDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ElokaEditDialog::retranslate()
|
||||
{
|
||||
bool isNew = true;
|
||||
if (!m_elokaData.internalName.isEmpty())
|
||||
isNew = false;
|
||||
bool isNew = true;
|
||||
if (!m_elokaData.internalName.isEmpty())
|
||||
isNew = false;
|
||||
|
||||
translate(m_ui, QString(), isNew, tr("Eloka"));
|
||||
translate(m_ui, QString(), isNew, tr("Eloka"));
|
||||
}
|
||||
|
||||
bool ElokaEditDialog::init(const std::vector<qint32> &usedCnr,
|
||||
const std::vector<qint32> &usedTvc,
|
||||
const std::vector<qint32> &usedAnnouncement)
|
||||
bool ElokaEditDialog::init(const std::vector<qint32>& usedCnr, const std::vector<qint32>& usedTvc,
|
||||
const std::vector<qint32>& usedAnnouncement)
|
||||
{
|
||||
setUnchangeable(true);
|
||||
setUnchangeable(true);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->rbTvc->hide();
|
||||
m_ui->rbTvc->hide();
|
||||
#endif
|
||||
|
||||
getUserProfile();
|
||||
|
||||
|
||||
getActiveCnrs();
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
for (int used : usedCnr)
|
||||
m_cnrConfigMap.remove(used);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cnrConfigMap.remove(m_elokaData.id);
|
||||
}
|
||||
getUserProfile();
|
||||
|
||||
|
||||
m_tvcConfigMap = m_avmDtc->tvcConfigs();
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
for (int used : usedTvc)
|
||||
m_tvcConfigMap.remove(used);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tvcConfigMap.remove(m_elokaData.id);
|
||||
}
|
||||
getActiveCnrs();
|
||||
|
||||
|
||||
const QMap<qint32, Stream> streams = m_avmDtc->streams();
|
||||
for (const Stream &stream : streams)
|
||||
{
|
||||
if ((stream.type() == StreamType_def::AudioOut) ||
|
||||
(stream.type() == StreamType_def::AudioInOut))
|
||||
m_announcementMap.insert(stream.id(), stream);
|
||||
}
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
for (int used : usedAnnouncement)
|
||||
m_announcementMap.remove(used);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_announcementMap.remove(m_elokaData.id);
|
||||
}
|
||||
|
||||
connect(m_avmDtc,
|
||||
&AudioVideoManagement::Interface::Dtc::cnrConfigChanged,
|
||||
this, &ElokaEditDialog::onCnrConfigChanged);
|
||||
connect(m_avmDtc,
|
||||
&AudioVideoManagement::Interface::Dtc::tvcConfigChanged,
|
||||
this, &ElokaEditDialog::onTvcConfigChanged);
|
||||
connect(m_avmDtc,
|
||||
&AudioVideoManagement::Interface::Dtc::cnrTvcProfileChanged,
|
||||
this, &ElokaEditDialog::onCnrTvcProfileChanged);
|
||||
connect(m_avmDtc,
|
||||
&AudioVideoManagement::Interface::Dtc::streamChanged,
|
||||
this, &ElokaEditDialog::onStreamChanged);
|
||||
|
||||
connect(m_ui->cmbCircuit,
|
||||
QOverload<int>::of(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ElokaEditDialog::onCmbCircuitChanged);
|
||||
connect(m_ui->rbCnr, &QRadioButton::toggled,
|
||||
this, &ElokaEditDialog::onCbCnrToggled);
|
||||
connect(m_ui->rbAnnouncement, &QRadioButton::toggled,
|
||||
this, &ElokaEditDialog::onCbAnnouncementToggled);
|
||||
connect(m_ui->rbTvc, &QRadioButton::toggled,
|
||||
this, &ElokaEditDialog::onCbTvcToggled);
|
||||
connect(m_avaCtrl, &AvaControl::getElokaListResponse,
|
||||
this, &ElokaEditDialog::onGetElokaListResponse);
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
|
||||
checkedRadioButtons(true, false, false);
|
||||
enabledRadioButtons(true, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_elokaData.circuitType == ElokaCircuitType::Cnr)
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
checkedRadioButtons(true, false, false);
|
||||
enabledRadioButtons(true, false, false);
|
||||
for (int used : usedCnr)
|
||||
m_cnrConfigMap.remove(used);
|
||||
}
|
||||
if (m_elokaData.circuitType == ElokaCircuitType::Tvc)
|
||||
else
|
||||
{
|
||||
checkedRadioButtons(false, true, false);
|
||||
enabledRadioButtons(false, true, false);
|
||||
m_cnrConfigMap.remove(m_elokaData.id);
|
||||
}
|
||||
if (m_elokaData.circuitType == ElokaCircuitType::Announcement)
|
||||
|
||||
m_tvcConfigMap = m_avmDtc->tvcConfigs();
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
checkedRadioButtons(false, false, true);
|
||||
enabledRadioButtons(false, false, true);
|
||||
for (int used : usedTvc)
|
||||
m_tvcConfigMap.remove(used);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tvcConfigMap.remove(m_elokaData.id);
|
||||
}
|
||||
if (m_elokaData.mode == AvaElokaMode::EndlessLoop)
|
||||
m_ui->chbEndlessPlayback->setChecked(true);
|
||||
|
||||
setCurrentCircuit(m_elokaData);
|
||||
m_ui->cmbAction->setCurrentText(m_elokaData.action);
|
||||
}
|
||||
const QMap<qint32, Stream> streams = m_avmDtc->streams();
|
||||
for (const Stream& stream : streams)
|
||||
{
|
||||
if ((stream.type() == StreamType_def::AudioOut) || (stream.type() == StreamType_def::AudioInOut))
|
||||
m_announcementMap.insert(stream.id(), stream);
|
||||
}
|
||||
|
||||
setUnchangeable(false);
|
||||
return true;
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
for (int used : usedAnnouncement)
|
||||
m_announcementMap.remove(used);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_announcementMap.remove(m_elokaData.id);
|
||||
}
|
||||
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::cnrConfigChanged, this,
|
||||
&ElokaEditDialog::onCnrConfigChanged);
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::tvcConfigChanged, this,
|
||||
&ElokaEditDialog::onTvcConfigChanged);
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::cnrTvcProfileChanged, this,
|
||||
&ElokaEditDialog::onCnrTvcProfileChanged);
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::streamChanged, this, &ElokaEditDialog::onStreamChanged);
|
||||
|
||||
connect(m_ui->cmbCircuit, QOverload<int>::of(&LtsWidgets::LtsComboBox::currentIndexChanged), this,
|
||||
&ElokaEditDialog::onCmbCircuitChanged);
|
||||
connect(m_ui->rbCnr, &QRadioButton::toggled, this, &ElokaEditDialog::onCbCnrToggled);
|
||||
connect(m_ui->rbAnnouncement, &QRadioButton::toggled, this, &ElokaEditDialog::onCbAnnouncementToggled);
|
||||
connect(m_ui->rbTvc, &QRadioButton::toggled, this, &ElokaEditDialog::onCbTvcToggled);
|
||||
connect(m_avaCtrl, &AvaControl::getElokaListResponse, this, &ElokaEditDialog::onGetElokaListResponse);
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
|
||||
checkedRadioButtons(true, false, false);
|
||||
enabledRadioButtons(true, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_elokaData.circuitType == ElokaCircuitType::Cnr)
|
||||
{
|
||||
checkedRadioButtons(true, false, false);
|
||||
enabledRadioButtons(true, false, false);
|
||||
}
|
||||
if (m_elokaData.circuitType == ElokaCircuitType::Tvc)
|
||||
{
|
||||
checkedRadioButtons(false, true, false);
|
||||
enabledRadioButtons(false, true, false);
|
||||
}
|
||||
if (m_elokaData.circuitType == ElokaCircuitType::Announcement)
|
||||
{
|
||||
checkedRadioButtons(false, false, true);
|
||||
enabledRadioButtons(false, false, true);
|
||||
}
|
||||
if (m_elokaData.mode == AvaElokaMode::EndlessLoop)
|
||||
m_ui->chbEndlessPlayback->setChecked(true);
|
||||
|
||||
setCurrentCircuit(m_elokaData);
|
||||
m_ui->cmbAction->setCurrentText(m_elokaData.action);
|
||||
}
|
||||
|
||||
setUnchangeable(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ElokaEditDialog::checkedRadioButtons(bool cnr, bool tvc, bool announcement)
|
||||
{
|
||||
m_ui->rbCnr->setChecked(cnr);
|
||||
m_ui->rbTvc->setChecked(tvc);
|
||||
m_ui->rbAnnouncement->setChecked(announcement);
|
||||
m_ui->rbCnr->setChecked(cnr);
|
||||
m_ui->rbTvc->setChecked(tvc);
|
||||
m_ui->rbAnnouncement->setChecked(announcement);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::enabledRadioButtons(bool cnr, bool tvc, bool announcement)
|
||||
@@ -270,288 +239,274 @@ void ElokaEditDialog::enabledRadioButtons(bool cnr, bool tvc, bool announcement)
|
||||
|
||||
void ElokaEditDialog::onCmbCircuitChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(index);
|
||||
|
||||
m_ui->cmbAction->clear();
|
||||
m_ui->cmbAction->clear();
|
||||
|
||||
if (m_ui->cmbCircuit->currentText().isEmpty())
|
||||
return;
|
||||
if (m_ui->cmbCircuit->currentText().isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
ComboBoxUserData userData = currentUserData(m_ui->cmbCircuit);
|
||||
m_avaCtrl->getElokaList(userData.internalName);
|
||||
ComboBoxUserData userData = currentUserData(m_ui->cmbCircuit);
|
||||
m_avaCtrl->getElokaList(userData.internalName);
|
||||
}
|
||||
|
||||
bool ElokaEditDialog::apply()
|
||||
{
|
||||
ComboBoxUserData userData = currentUserData(m_ui->cmbCircuit);
|
||||
ComboBoxUserData userData = currentUserData(m_ui->cmbCircuit);
|
||||
|
||||
ElokaData data;
|
||||
data.id = userData.id;
|
||||
data.internalName = userData.internalName;
|
||||
data.displayName = m_ui->cmbCircuit->currentText();
|
||||
data.party = -1;
|
||||
data.exerciseId = m_session->exerciseId();
|
||||
data.circuitType = userData.circuitType;
|
||||
data.action = m_ui->cmbAction->currentText();
|
||||
data.mode = m_ui->chbEndlessPlayback->isChecked() ? AvaElokaMode::EndlessLoop : AvaElokaMode::Once;
|
||||
data.startTime = m_session->partitionTime();
|
||||
ElokaData data;
|
||||
data.id = userData.id;
|
||||
data.internalName = userData.internalName;
|
||||
data.displayName = m_ui->cmbCircuit->currentText();
|
||||
data.party = -1;
|
||||
data.exerciseId = m_session->exerciseId();
|
||||
data.circuitType = userData.circuitType;
|
||||
data.action = m_ui->cmbAction->currentText();
|
||||
data.mode = m_ui->chbEndlessPlayback->isChecked() ? AvaElokaMode::EndlessLoop : AvaElokaMode::Once;
|
||||
data.startTime = m_session->partitionTime();
|
||||
|
||||
if (userData.circuitType == ElokaCircuitType::Cnr)
|
||||
data.party = m_cnrConfigMap.value(userData.id).partyId();
|
||||
if (userData.circuitType == ElokaCircuitType::Cnr)
|
||||
data.party = m_cnrConfigMap.value(userData.id).partyId();
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
m_avaCtrl->chooseEloka(data.internalName, data.action, data.mode);
|
||||
else if (m_elokaData.action != data.action)
|
||||
{
|
||||
m_avaCtrl->releaseEloka(m_elokaData.internalName);
|
||||
m_avaCtrl->chooseEloka(data.internalName, data.action, data.mode);
|
||||
}
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
m_avaCtrl->chooseEloka(data.internalName, data.action, data.mode);
|
||||
else if (m_elokaData.action != data.action)
|
||||
{
|
||||
m_avaCtrl->releaseEloka(m_elokaData.internalName);
|
||||
m_avaCtrl->chooseEloka(data.internalName, data.action, data.mode);
|
||||
}
|
||||
|
||||
m_elokaData = data;
|
||||
emit signalNewEloka(data);
|
||||
return true;
|
||||
m_elokaData = data;
|
||||
emit signalNewEloka(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onCbCnrToggled(bool checked)
|
||||
{
|
||||
if (!checked)
|
||||
return;
|
||||
if (!checked)
|
||||
return;
|
||||
|
||||
fillComboBoxCircuit(ElokaCircuitType::Cnr);
|
||||
fillComboBoxCircuit(ElokaCircuitType::Cnr);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onCbAnnouncementToggled(bool checked)
|
||||
{
|
||||
if (!checked)
|
||||
return;
|
||||
if (!checked)
|
||||
return;
|
||||
|
||||
fillComboBoxCircuit(ElokaCircuitType::Announcement);
|
||||
fillComboBoxCircuit(ElokaCircuitType::Announcement);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onCbTvcToggled(bool checked)
|
||||
{
|
||||
if (!checked)
|
||||
return;
|
||||
if (!checked)
|
||||
return;
|
||||
|
||||
fillComboBoxCircuit(ElokaCircuitType::Tvc);
|
||||
fillComboBoxCircuit(ElokaCircuitType::Tvc);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::getActiveCnrs()
|
||||
{
|
||||
const QMap<qint32, CnrConfig> cnrs = m_avmDtc->cnrConfigs();
|
||||
for (const CnrConfig &cnr : cnrs)
|
||||
{
|
||||
if (cnr.isActive() == true)
|
||||
m_cnrConfigMap.insert(cnr.id(), cnr);
|
||||
}
|
||||
const QMap<qint32, CnrConfig> cnrs = m_avmDtc->cnrConfigs();
|
||||
for (const CnrConfig& cnr : cnrs)
|
||||
{
|
||||
if (cnr.isActive() == true)
|
||||
m_cnrConfigMap.insert(cnr.id(), cnr);
|
||||
}
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onCnrConfigChanged(const CnrConfig &data,
|
||||
DataModification modType)
|
||||
void ElokaEditDialog::onCnrConfigChanged(const CnrConfig& data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onCnrConfigChanged";
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
m_cnrConfigMap.insert(data.id(), data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
m_cnrConfigMap.remove(data.id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "onCnrConfigChanged";
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified: {
|
||||
m_cnrConfigMap.insert(data.id(), data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved: {
|
||||
m_cnrConfigMap.remove(data.id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ui->rbCnr->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Cnr);
|
||||
if (m_ui->rbCnr->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Cnr);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onTvcConfigChanged(const TvcConfig &data,
|
||||
DataModification modType)
|
||||
void ElokaEditDialog::onTvcConfigChanged(const TvcConfig& data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onTvcConfigChanged";
|
||||
DEBUG_LOG(m_logger) << "onTvcConfigChanged";
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
m_tvcConfigMap.insert(data.id(), data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
m_tvcConfigMap.remove(data.id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified: {
|
||||
m_tvcConfigMap.insert(data.id(), data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved: {
|
||||
m_tvcConfigMap.remove(data.id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ui->rbTvc->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Tvc);
|
||||
if (m_ui->rbTvc->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Tvc);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onStreamChanged(const Stream &data,
|
||||
DataModification modType)
|
||||
void ElokaEditDialog::onStreamChanged(const Stream& data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onStreamChanged";
|
||||
DEBUG_LOG(m_logger) << "onStreamChanged";
|
||||
|
||||
if ((data.type() != StreamType_def::AudioOut) &&
|
||||
(data.type() != StreamType_def::AudioInOut))
|
||||
return;
|
||||
if ((data.type() != StreamType_def::AudioOut) && (data.type() != StreamType_def::AudioInOut))
|
||||
return;
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
m_announcementMap.insert(data.id(), data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
m_announcementMap.remove(data.id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified: {
|
||||
m_announcementMap.insert(data.id(), data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved: {
|
||||
m_announcementMap.remove(data.id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ui->rbAnnouncement->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Announcement);
|
||||
if (m_ui->rbAnnouncement->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Announcement);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onCnrTvcProfileChanged(const CnrTvcProfile &data,
|
||||
DataModification modType)
|
||||
void ElokaEditDialog::onCnrTvcProfileChanged(const CnrTvcProfile& data, DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
DEBUG_LOG(m_logger) << "onCnrTvcProfileChanged";
|
||||
Q_UNUSED(modType);
|
||||
DEBUG_LOG(m_logger) << "onCnrTvcProfileChanged";
|
||||
|
||||
if (data.exerciseId() != m_session->exerciseId() ||
|
||||
data.operatorId() != LtsSessionData::LtsSessionData::getInstance()->getOperatorId())
|
||||
return;
|
||||
if (data.exerciseId() != m_session->exerciseId() ||
|
||||
data.operatorId() != LtsSessionData::LtsSessionData::getInstance()->getOperatorId())
|
||||
return;
|
||||
|
||||
getUserProfile();
|
||||
getUserProfile();
|
||||
|
||||
if (m_ui->rbCnr->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Cnr);
|
||||
else if (m_ui->rbTvc->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Tvc);
|
||||
if (m_ui->rbCnr->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Cnr);
|
||||
else if (m_ui->rbTvc->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Tvc);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::getUserProfile()
|
||||
{
|
||||
m_userProfile.clear();
|
||||
m_userProfile.clear();
|
||||
|
||||
const QMap<qint32, AudioVideoManagement::CnrTvcProfile> cnrTvcProfiles = m_avmDtc->cnrTvcProfiles();
|
||||
int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
int exerciseId = m_session->exerciseId();
|
||||
const QMap<qint32, AudioVideoManagement::CnrTvcProfile> cnrTvcProfiles = m_avmDtc->cnrTvcProfiles();
|
||||
int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
int exerciseId = m_session->exerciseId();
|
||||
|
||||
for (const auto &cnrTvcProfile : cnrTvcProfiles)
|
||||
{
|
||||
if (cnrTvcProfile.exerciseId() == exerciseId &&
|
||||
cnrTvcProfile.operatorId() == operatorId)
|
||||
for (const auto& cnrTvcProfile : cnrTvcProfiles)
|
||||
{
|
||||
for (const auto &cnrTvcProfileData : cnrTvcProfile.data())
|
||||
if (cnrTvcProfileData.radioSystemId() == RadioSystem::inner_enum::Cnr)
|
||||
m_userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Cnr);
|
||||
else
|
||||
m_userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Tvc);
|
||||
if (cnrTvcProfile.exerciseId() == exerciseId && cnrTvcProfile.operatorId() == operatorId)
|
||||
{
|
||||
for (const auto& cnrTvcProfileData : cnrTvcProfile.data())
|
||||
if (cnrTvcProfileData.radioSystemId() == RadioSystem::inner_enum::Cnr)
|
||||
m_userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Cnr);
|
||||
else
|
||||
m_userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Tvc);
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ElokaEditDialog::fillComboBoxCircuit(ElokaCircuitType type)
|
||||
{
|
||||
boost::optional<int> selectedId = currentId(m_ui->cmbCircuit, type);
|
||||
m_ui->cmbCircuit->clear();
|
||||
boost::optional<int> selectedId = currentId(m_ui->cmbCircuit, type);
|
||||
m_ui->cmbCircuit->clear();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ElokaCircuitType::Cnr:
|
||||
{
|
||||
for (const CnrConfig &cnr : std::as_const(m_cnrConfigMap))
|
||||
switch (type)
|
||||
{
|
||||
if (!m_userProfile.contains(cnr.id(), ElokaCircuitType::Cnr))
|
||||
continue;
|
||||
case ElokaCircuitType::Cnr: {
|
||||
for (const CnrConfig& cnr : std::as_const(m_cnrConfigMap))
|
||||
{
|
||||
if (!m_userProfile.contains(cnr.id(), ElokaCircuitType::Cnr))
|
||||
continue;
|
||||
|
||||
QString internalName = QString::fromStdString(cnr.radioCircuit());
|
||||
QVariant userData = QVariant::fromValue(ComboBoxUserData{internalName, ElokaCircuitType::Cnr, cnr.id()});
|
||||
m_ui->cmbCircuit->addItem(internalName, userData);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElokaCircuitType::Tvc:
|
||||
{
|
||||
for (const TvcConfig &tvc : std::as_const(m_tvcConfigMap))
|
||||
{
|
||||
if (!m_userProfile.contains(tvc.id(), ElokaCircuitType::Tvc))
|
||||
continue;
|
||||
QString internalName = QString::fromStdString(cnr.radioCircuit());
|
||||
QVariant userData =
|
||||
QVariant::fromValue(ComboBoxUserData{internalName, ElokaCircuitType::Cnr, cnr.id()});
|
||||
m_ui->cmbCircuit->addItem(internalName, userData);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElokaCircuitType::Tvc: {
|
||||
for (const TvcConfig& tvc : std::as_const(m_tvcConfigMap))
|
||||
{
|
||||
if (!m_userProfile.contains(tvc.id(), ElokaCircuitType::Tvc))
|
||||
continue;
|
||||
|
||||
QString internalName = QString::fromStdString(tvc.radioCircuit());
|
||||
QVariant userData = QVariant::fromValue(ComboBoxUserData{internalName, ElokaCircuitType::Tvc, tvc.id()});
|
||||
m_ui->cmbCircuit->addItem(internalName, userData);
|
||||
QString internalName = QString::fromStdString(tvc.radioCircuit());
|
||||
QVariant userData =
|
||||
QVariant::fromValue(ComboBoxUserData{internalName, ElokaCircuitType::Tvc, tvc.id()});
|
||||
m_ui->cmbCircuit->addItem(internalName, userData);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElokaCircuitType::Announcement: {
|
||||
for (const Stream& stream : std::as_const(m_announcementMap))
|
||||
{
|
||||
QString internalName = QString::fromStdString(stream.name());
|
||||
QString displayName = m_streamNameMapping->displayName(internalName);
|
||||
QVariant userData =
|
||||
QVariant::fromValue(ComboBoxUserData{internalName, ElokaCircuitType::Announcement, stream.id()});
|
||||
m_ui->cmbCircuit->addItem(displayName, userData);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElokaCircuitType::Announcement:
|
||||
{
|
||||
for (const Stream &stream : std::as_const(m_announcementMap))
|
||||
{
|
||||
QString internalName = QString::fromStdString(stream.name());
|
||||
QString displayName = m_streamNameMapping->displayName(internalName);
|
||||
QVariant userData = QVariant::fromValue(ComboBoxUserData{internalName, ElokaCircuitType::Announcement, stream.id()});
|
||||
m_ui->cmbCircuit->addItem(displayName, userData);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_ui->cmbCircuit->model()->sort(0);
|
||||
selectItemWithId(m_ui->cmbCircuit, selectedId);
|
||||
m_ui->cmbCircuit->model()->sort(0);
|
||||
selectItemWithId(m_ui->cmbCircuit, selectedId);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::setCurrentCircuit(const ElokaData &data)
|
||||
void ElokaEditDialog::setCurrentCircuit(const ElokaData& data)
|
||||
{
|
||||
for (int i = 0; i < m_ui->cmbCircuit->count(); ++i)
|
||||
{
|
||||
ComboBoxUserData userData = userDataAt(m_ui->cmbCircuit, i);
|
||||
if (userData.circuitType != data.circuitType)
|
||||
continue;
|
||||
for (int i = 0; i < m_ui->cmbCircuit->count(); ++i)
|
||||
{
|
||||
ComboBoxUserData userData = userDataAt(m_ui->cmbCircuit, i);
|
||||
if (userData.circuitType != data.circuitType)
|
||||
continue;
|
||||
|
||||
if (userData.id != data.id)
|
||||
continue;
|
||||
if (userData.id != data.id)
|
||||
continue;
|
||||
|
||||
m_ui->cmbCircuit->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
m_ui->cmbCircuit->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT(false);
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onGetElokaListResponse(const QVector<QString> &actions)
|
||||
void ElokaEditDialog::onGetElokaListResponse(const QVector<QString>& actions)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onGetElokaListResponse";
|
||||
if (!m_elokaData.internalName.isEmpty())
|
||||
setUnchangeable(true);
|
||||
DEBUG_LOG(m_logger) << "onGetElokaListResponse";
|
||||
if (!m_elokaData.internalName.isEmpty())
|
||||
setUnchangeable(true);
|
||||
|
||||
m_ui->cmbAction->clear();
|
||||
m_ui->cmbAction->clear();
|
||||
|
||||
if (actions.isEmpty())
|
||||
return;
|
||||
if (actions.isEmpty())
|
||||
return;
|
||||
|
||||
for (const QString &action : actions)
|
||||
m_ui->cmbAction->addItem(action);
|
||||
for (const QString& action : actions)
|
||||
m_ui->cmbAction->addItem(action);
|
||||
|
||||
if(m_elokaData.action.isEmpty() == false)
|
||||
m_ui->cmbAction->setCurrentText(m_elokaData.action);
|
||||
if (m_elokaData.action.isEmpty() == false)
|
||||
m_ui->cmbAction->setCurrentText(m_elokaData.action);
|
||||
|
||||
if (!m_elokaData.internalName.isEmpty())
|
||||
setUnchangeable(false);
|
||||
if (!m_elokaData.internalName.isEmpty())
|
||||
setUnchangeable(false);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+108
-135
@@ -1,218 +1,191 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_mvs_dialog.h"
|
||||
#include "ui_avm_mvs_dialog.h"
|
||||
#include "avm_mvs_edit_dialog.h"
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include "avm_mvs_edit_dialog.h"
|
||||
#include "ui_avm_mvs_dialog.h"
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
MvsDialog::MvsDialog(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::MvsDialog)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_model(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_avmDtc(nullptr)
|
||||
, m_avmFtc(nullptr)
|
||||
MvsDialog::MvsDialog(const QString& menuGroup, LtsSession::LtsSession* session, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_session(session),
|
||||
m_ui(new Ui::MvsDialog), m_menuGroup(menuGroup), m_model(nullptr),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this)), m_avmDtc(nullptr), m_avmFtc(nullptr)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Configuration_Video_Teams"));
|
||||
m_ui->setupUi(this);
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Configuration_Video_Teams"));
|
||||
}
|
||||
|
||||
MvsDialog::~MvsDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void MvsDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Configure Mobile Video Teams"));
|
||||
translate(m_ui, tr("Configure Mobile Video Teams"));
|
||||
}
|
||||
|
||||
void MvsDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool MvsDialog::init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc, const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &avmFtc)
|
||||
bool MvsDialog::init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& avmFtc)
|
||||
{
|
||||
|
||||
delete m_model;
|
||||
m_model = new MvsModel(this);
|
||||
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
|
||||
if (!m_model->init(m_session->exerciseId(), avmDtc))
|
||||
{
|
||||
delete m_model;
|
||||
m_model = nullptr;
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
m_model = new MvsModel(this);
|
||||
|
||||
m_ui->dataView->setModel(m_model);
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &MvsDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &MvsDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &MvsDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &MvsDialog::onPrint);
|
||||
if (!m_model->init(m_session->exerciseId(), avmDtc))
|
||||
{
|
||||
delete m_model;
|
||||
m_model = nullptr;
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &MvsDialog::onSelectionChanged);
|
||||
m_ui->dataView->setModel(m_model);
|
||||
|
||||
onSelectionChanged();
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &MvsDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &MvsDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &MvsDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &MvsDialog::onPrint);
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &MvsDialog::onEditClicked);
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged, this, &MvsDialog::onSelectionChanged);
|
||||
|
||||
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&MvsDialog::onImportButtonClicked,
|
||||
&MvsDialog::onExportButtonClicked);
|
||||
onSelectionChanged();
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked, this, &MvsDialog::onEditClicked);
|
||||
|
||||
return true;
|
||||
m_buttonBox->connectLibraryButton(this, &MvsDialog::onImportButtonClicked, &MvsDialog::onExportButtonClicked);
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MvsDialog::onVideoTeamModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
void MvsDialog::onVideoTeamModifyReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
|
||||
void MvsDialog::onAddClicked()
|
||||
{
|
||||
EditVideoTeamDialog *dialog = new EditVideoTeamDialog(m_avmDtc, m_session->exerciseId(), this);
|
||||
EditVideoTeamDialog* dialog = new EditVideoTeamDialog(m_avmDtc, m_session->exerciseId(), this);
|
||||
|
||||
connect(dialog, &EditVideoTeamDialog::modifyRequest, this, [this](const AudioVideoManagement::VideoTeamModifyRequest & request)
|
||||
{
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_avmFtc->videoTeamModifyRequest(request, this);
|
||||
});
|
||||
});
|
||||
connect(dialog, &EditVideoTeamDialog::modifyRequest, this,
|
||||
[this](const AudioVideoManagement::VideoTeamModifyRequest& request) {
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_avmFtc->videoTeamModifyRequest(request, this); });
|
||||
});
|
||||
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("NewVideoTeam"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("NewVideoTeam"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void MvsDialog::onEditClicked()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
AudioVideoManagement::VideoTeam config = m_model->getRowData(currentIndex.row());
|
||||
EditVideoTeamDialog *dialog = new EditVideoTeamDialog(config.id(),
|
||||
m_avmDtc,
|
||||
m_session->exerciseId(),
|
||||
config,
|
||||
this);
|
||||
AudioVideoManagement::VideoTeam config = m_model->getRowData(currentIndex.row());
|
||||
EditVideoTeamDialog* dialog = new EditVideoTeamDialog(config.id(), m_avmDtc, m_session->exerciseId(), config, this);
|
||||
|
||||
connect(dialog, &EditVideoTeamDialog::modifyRequest, this, [this](const AudioVideoManagement::VideoTeamModifyRequest & request)
|
||||
{
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_avmFtc->videoTeamModifyRequest(request, this);
|
||||
});
|
||||
});
|
||||
connect(dialog, &EditVideoTeamDialog::modifyRequest, this,
|
||||
[this](const AudioVideoManagement::VideoTeamModifyRequest& request) {
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_avmFtc->videoTeamModifyRequest(request, this); });
|
||||
});
|
||||
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditVideoTeam%1").arg(config.id()), LtsWidgets::LayoutArea::eDialogTab);
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditVideoTeam%1").arg(config.id()),
|
||||
LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void MvsDialog::onRemoveClicked()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
AudioVideoManagement::VideoTeamModifyRequest request;
|
||||
const VideoTeam team = m_model->getRowData(currentIndex.row());
|
||||
request.id(team.id());
|
||||
request.name(team.name());
|
||||
request.ssrc(team.ssrc());
|
||||
request.streamName(team.streamName());
|
||||
request.vtPort(team.vtPort());
|
||||
request.exerciseId(0);
|
||||
AudioVideoManagement::VideoTeamModifyRequest request;
|
||||
const VideoTeam team = m_model->getRowData(currentIndex.row());
|
||||
request.id(team.id());
|
||||
request.name(team.name());
|
||||
request.ssrc(team.ssrc());
|
||||
request.streamName(team.streamName());
|
||||
request.vtPort(team.vtPort());
|
||||
request.exerciseId(0);
|
||||
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_avmFtc->videoTeamModifyRequest(request, this);
|
||||
});
|
||||
m_model->removeRow(currentIndex.row());
|
||||
m_requestHelper->startSingleRequest([this, request]() { return m_avmFtc->videoTeamModifyRequest(request, this); });
|
||||
m_model->removeRow(currentIndex.row());
|
||||
}
|
||||
|
||||
void MvsDialog::onSelectionChanged()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, currentIndex.isValid());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, currentIndex.isValid());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, currentIndex.isValid());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, currentIndex.isValid());
|
||||
}
|
||||
|
||||
void MvsDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView());
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MvsDialog::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = m_model->modelToJson();
|
||||
QByteArray byteArray = m_model->modelToJson();
|
||||
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
}
|
||||
|
||||
void MvsDialog::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(), FileManagement::toString(FileManagement::XmlType::AVMMvsDialog));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMMvsDialog)))
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(),
|
||||
FileManagement::toString(FileManagement::XmlType::AVMMvsDialog));
|
||||
if (fileId > 0)
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("Invalid xml file content"),
|
||||
windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes,
|
||||
texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QVector<VideoTeamModifyRequest> requests = m_model->jsonToVideoTeamVector(content);
|
||||
for (const auto &request : requests)
|
||||
{
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMMvsDialog)))
|
||||
{
|
||||
return m_avmFtc->videoTeamModifyRequest(request, this);
|
||||
});
|
||||
}
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Invalid xml file content"), windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal, LtsWidgets::Button::Yes, texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QVector<VideoTeamModifyRequest> requests = m_model->jsonToVideoTeamVector(content);
|
||||
for (const auto& request : requests)
|
||||
{
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_avmFtc->videoTeamModifyRequest(request, this); });
|
||||
}
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+38
-42
@@ -1,16 +1,13 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
|
||||
#include "avm_mvs_model.h"
|
||||
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
@@ -34,7 +31,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
@@ -42,48 +39,47 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class MvsDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected AudioVideoManagement::Interface::Ftc::VideoTeamModifyReplyHandler
|
||||
class MvsDialog : public LtsWidgets::LtsDialog,
|
||||
protected AudioVideoManagement::Interface::Ftc::VideoTeamModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MvsDialog(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~MvsDialog();
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MvsDialog(const QString& menuGroup, LtsSession::LtsSession* session, QWidget* parent = nullptr);
|
||||
~MvsDialog();
|
||||
|
||||
bool init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc, const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &avmFtc);
|
||||
bool init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& avmFtc);
|
||||
|
||||
void onVideoTeamModifyReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onVideoTeamModifyReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
private:
|
||||
LtsSession::LtsSession* m_session;
|
||||
Ui::MvsDialog* m_ui;
|
||||
QString m_menuGroup;
|
||||
MvsModel* m_model;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession *m_session;
|
||||
Ui::MvsDialog *m_ui;
|
||||
QString m_menuGroup;
|
||||
MvsModel *m_model;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_avmFtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
};
|
||||
}
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_avmFtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+33
-44
@@ -1,13 +1,11 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
class QCheckBox;
|
||||
|
||||
@@ -16,55 +14,46 @@ namespace Ui
|
||||
class EditVideoTeamDialog;
|
||||
}
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class EditVideoTeamDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
class EditVideoTeamDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EditVideoTeamDialog(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc,
|
||||
int32_t exerciseId,
|
||||
QWidget *parent = nullptr);
|
||||
explicit EditVideoTeamDialog(int32_t id,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc,
|
||||
int32_t exerciseId,
|
||||
const VideoTeam &team,
|
||||
QWidget *parent);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EditVideoTeamDialog(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc,
|
||||
int32_t exerciseId, QWidget* parent = nullptr);
|
||||
explicit EditVideoTeamDialog(int32_t id, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc,
|
||||
int32_t exerciseId, const VideoTeam& team, QWidget* parent);
|
||||
|
||||
~EditVideoTeamDialog();
|
||||
~EditVideoTeamDialog();
|
||||
|
||||
void retranslate() override;
|
||||
void retranslate() override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void modifyRequest(const AudioVideoManagement::VideoTeamModifyRequest &request);
|
||||
Q_SIGNALS:
|
||||
void modifyRequest(const AudioVideoManagement::VideoTeamModifyRequest& request);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool apply() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool apply() override;
|
||||
private:
|
||||
EditVideoTeamDialog(int32_t id, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc,
|
||||
int32_t exerciseId, QWidget* parent);
|
||||
|
||||
private:
|
||||
EditVideoTeamDialog(int32_t id,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc,
|
||||
int32_t exerciseId,
|
||||
QWidget *parent);
|
||||
void init();
|
||||
|
||||
void init();
|
||||
private Q_SLOTS:
|
||||
void onCheckTakenTeams();
|
||||
void onCurrentTeamChanged();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onCheckTakenTeams();
|
||||
void onCurrentTeamChanged();
|
||||
private:
|
||||
Ui::EditVideoTeamDialog* m_ui;
|
||||
|
||||
private:
|
||||
Ui::EditVideoTeamDialog *m_ui;
|
||||
|
||||
int32_t m_exerciseId;
|
||||
int32_t m_id;
|
||||
VideoTeam m_videoTeam;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
QMap<QString, int32_t> m_takenTeams;
|
||||
QMap<QString, int32_t> m_teamsToIndex;
|
||||
};
|
||||
}
|
||||
int32_t m_exerciseId;
|
||||
int32_t m_id;
|
||||
VideoTeam m_videoTeam;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
QMap<QString, int32_t> m_takenTeams;
|
||||
QMap<QString, int32_t> m_teamsToIndex;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+98
-106
@@ -1,138 +1,130 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_mvs_dialog.h"
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
MvsModel::MvsModel(QObject *parent)
|
||||
: LtsAbstractTableModel<AudioVideoManagement::VideoTeam>(
|
||||
MvsModel::MvsModel(QObject* parent)
|
||||
: LtsAbstractTableModel<AudioVideoManagement::VideoTeam>({tr("Video Team Name"), tr("Stream Name")}, parent),
|
||||
m_exerciseId(-1)
|
||||
{
|
||||
tr("Video Team Name"),
|
||||
tr("Stream Name")
|
||||
}, parent)
|
||||
, m_exerciseId(-1)
|
||||
{}
|
||||
|
||||
QVariant MvsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const AudioVideoManagement::VideoTeam &config = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case CHANNEL:
|
||||
return QString::fromStdString(m_videoTeams.value(config.id()).name());
|
||||
case STREAM_NAME:
|
||||
return QString::fromStdString(config.streamName());
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool MvsModel::init(int32_t exerciseId, const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc)
|
||||
QVariant MvsModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
m_avmDtc = avmDtc;
|
||||
m_exerciseId = exerciseId;
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
m_videoTeams = avmDtc->videoTeams();
|
||||
const AudioVideoManagement::VideoTeam& config = m_vecData.at(index.row());
|
||||
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::videoTeamChanged,
|
||||
this, [this](const AudioVideoManagement::VideoTeam & data, DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
switch (index.column())
|
||||
{
|
||||
case CHANNEL:
|
||||
return QString::fromStdString(m_videoTeams.value(config.id()).name());
|
||||
case STREAM_NAME:
|
||||
return QString::fromStdString(config.streamName());
|
||||
}
|
||||
|
||||
if (data.exerciseId() == m_exerciseId)
|
||||
onDataChanged(data, DataModification::eAdded);
|
||||
else
|
||||
onDataChanged(data, DataModification::eRemoved);
|
||||
}
|
||||
);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVector<AudioVideoManagement::VideoTeam> configs;
|
||||
const QMap<int, AudioVideoManagement::VideoTeam> configMap = m_avmDtc->videoTeams();
|
||||
for (auto it = configMap.begin(); it != configMap.end(); ++it)
|
||||
{
|
||||
if (it.value().exerciseId() == m_exerciseId)
|
||||
configs.append(it.value());
|
||||
}
|
||||
setData(configs);
|
||||
bool MvsModel::init(int32_t exerciseId, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc)
|
||||
{
|
||||
m_avmDtc = avmDtc;
|
||||
m_exerciseId = exerciseId;
|
||||
|
||||
return true;
|
||||
m_videoTeams = avmDtc->videoTeams();
|
||||
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::videoTeamChanged, this,
|
||||
[this](const AudioVideoManagement::VideoTeam& data, DataModification modType) {
|
||||
Q_UNUSED(modType);
|
||||
|
||||
if (data.exerciseId() == m_exerciseId)
|
||||
onDataChanged(data, DataModification::eAdded);
|
||||
else
|
||||
onDataChanged(data, DataModification::eRemoved);
|
||||
});
|
||||
|
||||
QVector<AudioVideoManagement::VideoTeam> configs;
|
||||
const QMap<int, AudioVideoManagement::VideoTeam> configMap = m_avmDtc->videoTeams();
|
||||
for (auto it = configMap.begin(); it != configMap.end(); ++it)
|
||||
{
|
||||
if (it.value().exerciseId() == m_exerciseId)
|
||||
configs.append(it.value());
|
||||
}
|
||||
setData(configs);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray MvsModel::modelToJson()
|
||||
{
|
||||
QJsonObject obj;
|
||||
QJsonArray arr;
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AVMMvsDialog);
|
||||
QJsonObject obj;
|
||||
QJsonArray arr;
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AVMMvsDialog);
|
||||
|
||||
for (int row = 0; row < rowCount(); row++)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "row =" << ": " << row;
|
||||
QJsonObject inner;
|
||||
const VideoTeam &config = m_vecData.at(row);
|
||||
inner[QStringLiteral("id")] = config.id();
|
||||
inner[QStringLiteral("exerciseId")] = config.exerciseId();
|
||||
inner[QStringLiteral("name")] = QString::fromStdString(config.name());
|
||||
inner[QStringLiteral("streamName")] = QString::fromStdString(config.streamName());
|
||||
arr += inner;
|
||||
}
|
||||
for (int row = 0; row < rowCount(); row++)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "row =" << ": " << row;
|
||||
QJsonObject inner;
|
||||
const VideoTeam& config = m_vecData.at(row);
|
||||
inner[QStringLiteral("id")] = config.id();
|
||||
inner[QStringLiteral("exerciseId")] = config.exerciseId();
|
||||
inner[QStringLiteral("name")] = QString::fromStdString(config.name());
|
||||
inner[QStringLiteral("streamName")] = QString::fromStdString(config.streamName());
|
||||
arr += inner;
|
||||
}
|
||||
|
||||
obj[QStringLiteral("videoTeams")] = arr;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
obj[QStringLiteral("videoTeams")] = arr;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
QVector<VideoTeamModifyRequest> MvsModel::jsonToVideoTeamVector(const QByteArray &content)
|
||||
{
|
||||
|
||||
QVector<VideoTeamModifyRequest> result;
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject obj(doc.object());
|
||||
const QJsonArray arr(obj.value(QStringLiteral("videoTeams")).toArray());
|
||||
for (const auto &ele : arr)
|
||||
{
|
||||
const QJsonObject obj(ele.toObject());
|
||||
int id = obj[QStringLiteral("id")].toInt();
|
||||
if (id <= 0)
|
||||
return QVector<VideoTeamModifyRequest>();
|
||||
|
||||
const VideoTeam team = m_avmDtc->videoTeam(id);
|
||||
if (!m_avmDtc->isFreeVideoTeam(m_exerciseId, id))
|
||||
continue;
|
||||
|
||||
VideoTeamModifyRequest config;
|
||||
config.id(id);
|
||||
config.name(team.name());
|
||||
config.ssrc(team.ssrc());
|
||||
config.vtPort(team.vtPort());
|
||||
config.exerciseId(m_exerciseId);
|
||||
config.streamName(obj[QStringLiteral("streamName")].toString().toStdString());
|
||||
|
||||
INFO_LOG(m_logger) << "insertRow: " << config.name()
|
||||
<< " VideoTeamId=" << config.id();
|
||||
result.append(std::move(config));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool MvsModel::isFiltered(const VideoTeam &data, DataModification modType) const
|
||||
QVector<VideoTeamModifyRequest> MvsModel::jsonToVideoTeamVector(const QByteArray& content)
|
||||
{
|
||||
|
||||
Q_UNUSED(modType)
|
||||
if (data.exerciseId() != m_exerciseId)
|
||||
return true;
|
||||
return false;
|
||||
QVector<VideoTeamModifyRequest> result;
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject obj(doc.object());
|
||||
const QJsonArray arr(obj.value(QStringLiteral("videoTeams")).toArray());
|
||||
for (const auto& ele : arr)
|
||||
{
|
||||
const QJsonObject obj(ele.toObject());
|
||||
int id = obj[QStringLiteral("id")].toInt();
|
||||
if (id <= 0)
|
||||
return QVector<VideoTeamModifyRequest>();
|
||||
|
||||
const VideoTeam team = m_avmDtc->videoTeam(id);
|
||||
if (!m_avmDtc->isFreeVideoTeam(m_exerciseId, id))
|
||||
continue;
|
||||
|
||||
VideoTeamModifyRequest config;
|
||||
config.id(id);
|
||||
config.name(team.name());
|
||||
config.ssrc(team.ssrc());
|
||||
config.vtPort(team.vtPort());
|
||||
config.exerciseId(m_exerciseId);
|
||||
config.streamName(obj[QStringLiteral("streamName")].toString().toStdString());
|
||||
|
||||
INFO_LOG(m_logger) << "insertRow: " << config.name() << " VideoTeamId=" << config.id();
|
||||
result.append(std::move(config));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
bool MvsModel::isFiltered(const VideoTeam& data, DataModification modType) const
|
||||
{
|
||||
|
||||
Q_UNUSED(modType)
|
||||
if (data.exerciseId() != m_exerciseId)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+20
-28
@@ -1,46 +1,38 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <memory>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class MvsModel final
|
||||
: public LtsWidgets::LtsAbstractTableModel<AudioVideoManagement::VideoTeam>
|
||||
class MvsModel final : public LtsWidgets::LtsAbstractTableModel<AudioVideoManagement::VideoTeam>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
CHANNEL,
|
||||
STREAM_NAME,
|
||||
COUNT
|
||||
};
|
||||
public:
|
||||
enum Columns { CHANNEL, STREAM_NAME, COUNT };
|
||||
|
||||
explicit MvsModel(QObject *parent = nullptr);
|
||||
explicit MvsModel(QObject* parent = nullptr);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
QVariant data(const QModelIndex& index, int role) const override final;
|
||||
|
||||
bool init(int32_t exerciseId, const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc);
|
||||
QByteArray modelToJson();
|
||||
QVector<VideoTeamModifyRequest> jsonToVideoTeamVector(const QByteArray &content);
|
||||
bool isFiltered(const VideoTeam &data, DataModification modType) const override;
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
int32_t m_exerciseId;
|
||||
bool init(int32_t exerciseId, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc);
|
||||
QByteArray modelToJson();
|
||||
QVector<VideoTeamModifyRequest> jsonToVideoTeamVector(const QByteArray& content);
|
||||
bool isFiltered(const VideoTeam& data, DataModification modType) const override;
|
||||
|
||||
QMap<int32_t, AudioVideoManagement::VideoTeam> m_videoTeams;
|
||||
};
|
||||
}
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
int32_t m_exerciseId;
|
||||
|
||||
QMap<int32_t, AudioVideoManagement::VideoTeam> m_videoTeams;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
Q_DECLARE_METATYPE(AudioVideoManagement::VideoTeam)
|
||||
Executable → Regular
+173
-201
@@ -1,265 +1,237 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_mvs_video_team_dialog.h"
|
||||
#include "ui_avm_mvs_video_team_dialog.h"
|
||||
|
||||
#include "receiverelement.h"
|
||||
#include "ui_avm_mvs_video_team_dialog.h"
|
||||
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AudioVideoManagement/avm_mvs_video_team_gui_plugin_interface.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <QButtonGroup>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
MvsVideoTeamDialog::MvsVideoTeamDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::MvsVideoTeamDialog)
|
||||
, m_session(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_flmGui(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
MvsVideoTeamDialog::MvsVideoTeamDialog(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_ui(new Ui::MvsVideoTeamDialog),
|
||||
m_session(nullptr), m_dtc(nullptr), m_ftc(nullptr), m_flmGui(nullptr),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Mobile_Video_System"));
|
||||
|
||||
}
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Mobile_Video_System"));
|
||||
}
|
||||
|
||||
MvsVideoTeamDialog::~MvsVideoTeamDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void MvsVideoTeamDialog::retranslate()
|
||||
{
|
||||
QString text = tr("Mobile Video System");
|
||||
translate(m_ui, text);
|
||||
QString text = tr("Mobile Video System");
|
||||
translate(m_ui, text);
|
||||
}
|
||||
|
||||
void MvsVideoTeamDialog::enaDisa(bool enable)
|
||||
{
|
||||
Q_UNUSED(enable);
|
||||
|
||||
if (!m_flmGui)
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Export, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Import, false);
|
||||
}
|
||||
Q_UNUSED(enable);
|
||||
|
||||
if (!m_flmGui)
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Export, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Import, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool MvsVideoTeamDialog::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &ftc)
|
||||
bool MvsVideoTeamDialog::init(LtsSession::LtsSession* session,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& ftc)
|
||||
{
|
||||
m_session = session;
|
||||
m_session = session;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
|
||||
session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui);
|
||||
session->getDtc<InfrastructureManagement::DataInterface>(m_ismDtc);
|
||||
session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui);
|
||||
session->getDtc<InfrastructureManagement::DataInterface>(m_ismDtc);
|
||||
|
||||
m_receiverMap = m_dtc->videoReceivers();
|
||||
m_receiverMap = m_dtc->videoReceivers();
|
||||
|
||||
int row = 1;
|
||||
int column = 2;
|
||||
|
||||
|
||||
int row = 1;
|
||||
int column = 2;
|
||||
QMap<std::string, VideoTeam> teamMap;
|
||||
auto cbVt = [this, &row, &teamMap](const AudioVideoManagement::VideoTeam& vt) {
|
||||
if (vt.exerciseId() != m_session->exerciseId())
|
||||
return;
|
||||
|
||||
QMap<std::string , VideoTeam> teamMap;
|
||||
auto cbVt = [this, &row, &teamMap](const AudioVideoManagement::VideoTeam & vt)
|
||||
{
|
||||
if (vt.exerciseId() != m_session->exerciseId())
|
||||
return;
|
||||
|
||||
|
||||
m_teamToRow.insert(vt.programId() == 3 ? 2 : 1, vt.programId() == 3 ? 2 : 1);
|
||||
teamMap.insert(vt.name(), vt);
|
||||
};
|
||||
m_dtc->videoTeams(cbVt);
|
||||
m_teamToRow.insert(vt.programId() == 3 ? 2 : 1, vt.programId() == 3 ? 2 : 1);
|
||||
teamMap.insert(vt.name(), vt);
|
||||
};
|
||||
m_dtc->videoTeams(cbVt);
|
||||
|
||||
const QMap<int, AudioVideoManagement::VideoReceiver> vts = m_dtc->videoReceivers();
|
||||
QSet<int> teamId;
|
||||
for (auto rec : vts)
|
||||
{
|
||||
if (teamMap.value(rec.streamName()).id() > 0)
|
||||
teamId.insert(rec.teamId());
|
||||
}
|
||||
for (auto team: teamId)
|
||||
{
|
||||
QLabel *lbl = new QLabel(QStringLiteral("MLVS")+QString::number(team), this);
|
||||
m_ui->glMvs->addWidget(lbl, team == 1 ? 1 : 2, 0);
|
||||
}
|
||||
|
||||
auto cbMs = [this, &column](const InfrastructureManagement::MainStructureElement & mse)
|
||||
{
|
||||
if (mse.structureElementTypeId() == InfrastructureManagement::StructureElementType::RadioStation && !mse.isDeleted() && mse.id() > 0)
|
||||
const QMap<int, AudioVideoManagement::VideoReceiver> vts = m_dtc->videoReceivers();
|
||||
QSet<int> teamId;
|
||||
for (auto rec : vts)
|
||||
{
|
||||
m_stationToColumn.insert(mse.id(), column);
|
||||
QLabel *lblStation = new QLabel(QString::fromStdString(mse.name()), this);
|
||||
lblStation->setProperty("RadioStation", true);
|
||||
lblStation->setProperty("column", column);
|
||||
lblStation->setProperty("name", QString::fromStdString(mse.name()));
|
||||
m_ui->glMvs->addWidget(lblStation, 0, column++);
|
||||
lblStation->hide();
|
||||
if (teamMap.value(rec.streamName()).id() > 0)
|
||||
teamId.insert(rec.teamId());
|
||||
}
|
||||
};
|
||||
m_ismDtc->mainStructureElements(cbMs);
|
||||
|
||||
auto cbRec = [this, teamMap](const AudioVideoManagement::VideoReceiver & rec)
|
||||
{
|
||||
if (m_teamToRow.value(rec.teamId()) <= 0)
|
||||
return;
|
||||
if (!teamMap.contains(rec.streamName()))
|
||||
return;
|
||||
m_receiverMap.insert(rec.id(), rec);
|
||||
if (m_stationToColumn.value(rec.mainStructureElementId()) > 0 && m_teamToRow.value(rec.teamId()) > 0)
|
||||
for (auto team : teamId)
|
||||
{
|
||||
ReceiverElement *btn = createReceiverElement(rec);
|
||||
|
||||
int row = m_teamToRow.value(rec.teamId());
|
||||
int column = m_stationToColumn.value(rec.mainStructureElementId());
|
||||
if (!m_videoTeamButtonGroup.contains(row))
|
||||
{
|
||||
QRadioButton *none = new QRadioButton(tr("None"), this);
|
||||
none->setChecked(true);
|
||||
QLabel* lbl = new QLabel(QStringLiteral("MLVS") + QString::number(team), this);
|
||||
m_ui->glMvs->addWidget(lbl, team == 1 ? 1 : 2, 0);
|
||||
}
|
||||
|
||||
m_ui->glMvs->addWidget(none, row, 1);
|
||||
m_videoTeamButtonGroup.insert(row, new QButtonGroup(this));
|
||||
m_videoTeamButtonGroup[row]->addButton(none, 0);
|
||||
}
|
||||
m_videoTeamButtonGroup[row]->addButton(btn->radioButton(), rec.mainStructureElementId());
|
||||
m_videoTeamButtonGroup[row]->setProperty("teamId", rec.teamId());
|
||||
m_receiverIds.insert(QPair<int, int>(rec.mainStructureElementId(), rec.teamId()), rec.id());
|
||||
bool isActive = rec.isActive();
|
||||
btn->setButtonChecked(isActive);
|
||||
btn->radioButton()->setChecked(isActive);
|
||||
m_ui->glMvs->addWidget(btn, row, column);
|
||||
|
||||
for (int i = 0; i < m_ui->glMvs->count(); i++)
|
||||
{
|
||||
QWidget* widget = m_ui->glMvs->itemAt(i)->widget();
|
||||
if ( widget->property("RadioStation").toBool() && widget->property("column").toInt() == column)
|
||||
auto cbMs = [this, &column](const InfrastructureManagement::MainStructureElement& mse) {
|
||||
if (mse.structureElementTypeId() == InfrastructureManagement::StructureElementType::RadioStation &&
|
||||
!mse.isDeleted() && mse.id() > 0)
|
||||
{
|
||||
widget->show();
|
||||
m_stationToColumn.insert(mse.id(), column);
|
||||
QLabel* lblStation = new QLabel(QString::fromStdString(mse.name()), this);
|
||||
lblStation->setProperty("RadioStation", true);
|
||||
lblStation->setProperty("column", column);
|
||||
lblStation->setProperty("name", QString::fromStdString(mse.name()));
|
||||
m_ui->glMvs->addWidget(lblStation, 0, column++);
|
||||
lblStation->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
m_dtc->videoReceivers(cbRec);
|
||||
enaDisa(true);
|
||||
};
|
||||
m_ismDtc->mainStructureElements(cbMs);
|
||||
|
||||
auto cbRec = [this, teamMap](const AudioVideoManagement::VideoReceiver& rec) {
|
||||
if (m_teamToRow.value(rec.teamId()) <= 0)
|
||||
return;
|
||||
if (!teamMap.contains(rec.streamName()))
|
||||
return;
|
||||
m_receiverMap.insert(rec.id(), rec);
|
||||
if (m_stationToColumn.value(rec.mainStructureElementId()) > 0 && m_teamToRow.value(rec.teamId()) > 0)
|
||||
{
|
||||
ReceiverElement* btn = createReceiverElement(rec);
|
||||
|
||||
connect(m_dtc.get(), &AudioVideoManagement::Interface::Dtc::videoReceiverChanged, this, &MvsVideoTeamDialog::updateReceiverButton);
|
||||
int row = m_teamToRow.value(rec.teamId());
|
||||
int column = m_stationToColumn.value(rec.mainStructureElementId());
|
||||
if (!m_videoTeamButtonGroup.contains(row))
|
||||
{
|
||||
QRadioButton* none = new QRadioButton(tr("None"), this);
|
||||
none->setChecked(true);
|
||||
|
||||
return true;
|
||||
m_ui->glMvs->addWidget(none, row, 1);
|
||||
m_videoTeamButtonGroup.insert(row, new QButtonGroup(this));
|
||||
m_videoTeamButtonGroup[row]->addButton(none, 0);
|
||||
}
|
||||
m_videoTeamButtonGroup[row]->addButton(btn->radioButton(), rec.mainStructureElementId());
|
||||
m_videoTeamButtonGroup[row]->setProperty("teamId", rec.teamId());
|
||||
m_receiverIds.insert(QPair<int, int>(rec.mainStructureElementId(), rec.teamId()), rec.id());
|
||||
bool isActive = rec.isActive();
|
||||
btn->setButtonChecked(isActive);
|
||||
btn->radioButton()->setChecked(isActive);
|
||||
m_ui->glMvs->addWidget(btn, row, column);
|
||||
|
||||
for (int i = 0; i < m_ui->glMvs->count(); i++)
|
||||
{
|
||||
QWidget* widget = m_ui->glMvs->itemAt(i)->widget();
|
||||
if (widget->property("RadioStation").toBool() && widget->property("column").toInt() == column)
|
||||
{
|
||||
widget->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
m_dtc->videoReceivers(cbRec);
|
||||
enaDisa(true);
|
||||
|
||||
connect(m_dtc.get(), &AudioVideoManagement::Interface::Dtc::videoReceiverChanged, this,
|
||||
&MvsVideoTeamDialog::updateReceiverButton);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MvsVideoTeamDialog::setData()
|
||||
{
|
||||
|
||||
}
|
||||
void MvsVideoTeamDialog::setData() {}
|
||||
|
||||
bool MvsVideoTeamDialog::apply()
|
||||
{
|
||||
VideoReceiverModifyActiveRequest req;
|
||||
DEBUG_LOG(m_logger) << "apply m_videoTeamButtonGroup.size=" << m_videoTeamButtonGroup.size();
|
||||
QMap<int, QButtonGroup *> ::const_iterator itBg;
|
||||
for (itBg = m_videoTeamButtonGroup.constBegin(); itBg != m_videoTeamButtonGroup.constEnd(); ++itBg)
|
||||
{
|
||||
int teamId = itBg.value()->property("teamId").toInt();
|
||||
int mainStructureElementId = itBg.value()->checkedId();
|
||||
int oldActiveId = m_dtc->getActiveVideoReceiver(teamId);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Team id = " << teamId;
|
||||
DEBUG_LOG(m_logger) << "Main structure element id = " << mainStructureElementId;
|
||||
DEBUG_LOG(m_logger) << "Old active video receiver = " << oldActiveId;
|
||||
|
||||
if (itBg.value()->checkedId() == 0)
|
||||
VideoReceiverModifyActiveRequest req;
|
||||
DEBUG_LOG(m_logger) << "apply m_videoTeamButtonGroup.size=" << m_videoTeamButtonGroup.size();
|
||||
QMap<int, QButtonGroup*>::const_iterator itBg;
|
||||
for (itBg = m_videoTeamButtonGroup.constBegin(); itBg != m_videoTeamButtonGroup.constEnd(); ++itBg)
|
||||
{
|
||||
req.isActive(false);
|
||||
req.id(0);
|
||||
QMapIterator<qint32, AudioVideoManagement::VideoReceiver> i(m_receiverMap);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if ((i.value().isActive())
|
||||
&& i.value().teamId() == teamId)
|
||||
req.id(i.value().id());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
req.isActive(true);
|
||||
req.id(m_receiverIds.value(QPair<int, int>(mainStructureElementId, teamId)));
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "itBg.key=" << itBg.key()
|
||||
<< " mainStructureElementId=" << mainStructureElementId
|
||||
<< " teamId=" << teamId
|
||||
<< " id=" << req.id()
|
||||
<< " isActive=" << req.isActive();
|
||||
int teamId = itBg.value()->property("teamId").toInt();
|
||||
int mainStructureElementId = itBg.value()->checkedId();
|
||||
int oldActiveId = m_dtc->getActiveVideoReceiver(teamId);
|
||||
|
||||
|
||||
if ((m_receiverMap.value(req.id()).isActive() != req.isActive())
|
||||
&& req.id() > 0)
|
||||
{
|
||||
|
||||
if (oldActiveId > 0)
|
||||
{
|
||||
VideoReceiverModifyActiveRequest reqInactive;
|
||||
reqInactive.id(oldActiveId);
|
||||
reqInactive.isActive(false);
|
||||
m_requestHelper->addRequest([this, reqInactive]()
|
||||
DEBUG_LOG(m_logger) << "Team id = " << teamId;
|
||||
DEBUG_LOG(m_logger) << "Main structure element id = " << mainStructureElementId;
|
||||
DEBUG_LOG(m_logger) << "Old active video receiver = " << oldActiveId;
|
||||
|
||||
if (itBg.value()->checkedId() == 0)
|
||||
{
|
||||
return m_ftc->videoReceiverModifyActiveRequest(reqInactive, this);
|
||||
});
|
||||
}
|
||||
m_requestHelper->addRequest([this, req]()
|
||||
{
|
||||
return m_ftc->videoReceiverModifyActiveRequest(req, this);
|
||||
});
|
||||
req.isActive(false);
|
||||
req.id(0);
|
||||
QMapIterator<qint32, AudioVideoManagement::VideoReceiver> i(m_receiverMap);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if ((i.value().isActive()) && i.value().teamId() == teamId)
|
||||
req.id(i.value().id());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
req.isActive(true);
|
||||
req.id(m_receiverIds.value(QPair<int, int>(mainStructureElementId, teamId)));
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "itBg.key=" << itBg.key() << " mainStructureElementId=" << mainStructureElementId
|
||||
<< " teamId=" << teamId << " id=" << req.id() << " isActive=" << req.isActive();
|
||||
|
||||
if ((m_receiverMap.value(req.id()).isActive() != req.isActive()) && req.id() > 0)
|
||||
{
|
||||
|
||||
if (oldActiveId > 0)
|
||||
{
|
||||
VideoReceiverModifyActiveRequest reqInactive;
|
||||
reqInactive.id(oldActiveId);
|
||||
reqInactive.isActive(false);
|
||||
m_requestHelper->addRequest(
|
||||
[this, reqInactive]() { return m_ftc->videoReceiverModifyActiveRequest(reqInactive, this); });
|
||||
}
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->videoReceiverModifyActiveRequest(req, this); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
ReceiverElement *MvsVideoTeamDialog::createReceiverElement(const VideoReceiver &rec)
|
||||
ReceiverElement* MvsVideoTeamDialog::createReceiverElement(const VideoReceiver& rec)
|
||||
{
|
||||
ReceiverElement *re = new ReceiverElement(this);
|
||||
re->init(rec);
|
||||
if (rec.isActive())
|
||||
m_oldActiveTeamToRec.insert(rec.teamId(), rec.id());
|
||||
m_elementList.insert(rec.teamId(), re);
|
||||
return re;
|
||||
ReceiverElement* re = new ReceiverElement(this);
|
||||
re->init(rec);
|
||||
if (rec.isActive())
|
||||
m_oldActiveTeamToRec.insert(rec.teamId(), rec.id());
|
||||
m_elementList.insert(rec.teamId(), re);
|
||||
return re;
|
||||
}
|
||||
|
||||
void MvsVideoTeamDialog::updateReceiverButton(const AudioVideoManagement::VideoReceiver &rec, DataModification modType)
|
||||
void MvsVideoTeamDialog::updateReceiverButton(const AudioVideoManagement::VideoReceiver& rec, DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
m_receiverMap.insert(rec.id(), rec);
|
||||
for (auto it = m_elementList.lowerBound(rec.teamId()) ; it != m_elementList.end(); ++it)
|
||||
{
|
||||
if (it.key() != rec.teamId())
|
||||
break;
|
||||
auto *receiverElement = it.value();
|
||||
if (receiverElement->property("recId").toInt() != rec.id())
|
||||
continue;
|
||||
Q_UNUSED(modType);
|
||||
m_receiverMap.insert(rec.id(), rec);
|
||||
for (auto it = m_elementList.lowerBound(rec.teamId()); it != m_elementList.end(); ++it)
|
||||
{
|
||||
if (it.key() != rec.teamId())
|
||||
break;
|
||||
auto* receiverElement = it.value();
|
||||
if (receiverElement->property("recId").toInt() != rec.id())
|
||||
continue;
|
||||
|
||||
receiverElement->setButtonChecked(rec.isActive());
|
||||
receiverElement->setSnr(rec.snr());
|
||||
receiverElement->setDbm(rec.dbm());
|
||||
receiverElement->setStreamName(QString::fromStdString(rec.streamName()));
|
||||
receiverElement->setFrequency(rec.frequency());
|
||||
receiverElement->setIsLocked(rec.isLocked());
|
||||
}
|
||||
receiverElement->setButtonChecked(rec.isActive());
|
||||
receiverElement->setSnr(rec.snr());
|
||||
receiverElement->setDbm(rec.dbm());
|
||||
receiverElement->setStreamName(QString::fromStdString(rec.streamName()));
|
||||
receiverElement->setFrequency(rec.frequency());
|
||||
receiverElement->setIsLocked(rec.isLocked());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+45
-53
@@ -1,21 +1,15 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
#include <Services/AudioVideoManagement/logger.h>
|
||||
|
||||
#include <Services/AudioVideoManagement/avm_ftc.h>
|
||||
#include <Services/AudioVideoManagement/avm_dtc.h>
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
|
||||
#include <Services/AudioVideoManagement/avm_dtc.h>
|
||||
#include <Services/AudioVideoManagement/avm_ftc.h>
|
||||
#include <Services/AudioVideoManagement/logger.h>
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
@@ -28,66 +22,64 @@ class MvsVideoTeamDialog;
|
||||
}
|
||||
|
||||
class ReceiverElement;
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class MvsVideoTeamDialog : public LtsWidgets::LtsDialog,
|
||||
private AudioVideoManagement::Interface::Ftc::VideoReceiverModifyActiveReplyHandler
|
||||
private AudioVideoManagement::Interface::Ftc::VideoReceiverModifyActiveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MvsVideoTeamDialog(QWidget *parent = nullptr);
|
||||
~MvsVideoTeamDialog();
|
||||
public:
|
||||
explicit MvsVideoTeamDialog(QWidget* parent = nullptr);
|
||||
~MvsVideoTeamDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &ftc);
|
||||
bool init(LtsSession::LtsSession* session, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& ftc);
|
||||
|
||||
void onVideoReceiverModifyActiveReply(const Core::FunctionReplyObject &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
void onVideoReceiverModifyActiveReply(const Core::FunctionReplyObject& reply) override final
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
ReceiverElement* createReceiverElement(const VideoReceiver& rec);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
ReceiverElement *createReceiverElement(const VideoReceiver &rec);
|
||||
private slots:
|
||||
bool apply() override;
|
||||
void updateReceiverButton(const AudioVideoManagement::VideoReceiver& rec, DataModification modType);
|
||||
|
||||
private slots:
|
||||
bool apply() override;
|
||||
void updateReceiverButton(const AudioVideoManagement::VideoReceiver &rec, DataModification modType);
|
||||
private:
|
||||
void retranslate() override;
|
||||
void enaDisa(bool enable);
|
||||
void setData();
|
||||
|
||||
private:
|
||||
Ui::MvsVideoTeamDialog* m_ui;
|
||||
LtsSession::LtsSession* m_session;
|
||||
QString m_menuGroup;
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void enaDisa(bool enable);
|
||||
void setData();
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_ftc;
|
||||
|
||||
private:
|
||||
Ui::MvsVideoTeamDialog *m_ui;
|
||||
LtsSession::LtsSession *m_session;
|
||||
QString m_menuGroup;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_ftc;
|
||||
AudioVideoManagement::VideoReceiver m_data;
|
||||
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
|
||||
AudioVideoManagement::VideoReceiver m_data;
|
||||
QMap<qint32, AudioVideoManagement::VideoReceiver> m_receiverMap;
|
||||
QMap<int, QButtonGroup*> m_videoTeamButtonGroup;
|
||||
QMap<int, int> m_stationToColumn;
|
||||
QMap<int, int> m_teamToRow;
|
||||
QMultiMap<int, ReceiverElement*> m_elementList;
|
||||
QMap<int, int> m_oldActiveTeamToRec;
|
||||
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
QHash<QPair<int, int>, int> m_receiverIds;
|
||||
|
||||
QMap<qint32, AudioVideoManagement::VideoReceiver> m_receiverMap;
|
||||
QMap<int, QButtonGroup *> m_videoTeamButtonGroup;
|
||||
QMap<int, int> m_stationToColumn;
|
||||
QMap<int, int> m_teamToRow;
|
||||
QMultiMap<int, ReceiverElement *> m_elementList;
|
||||
QMap<int, int> m_oldActiveTeamToRec;
|
||||
|
||||
|
||||
|
||||
|
||||
QHash<QPair<int, int>, int> m_receiverIds;
|
||||
|
||||
QVector <int> mainStructureElementIds;
|
||||
QVector<int> mainStructureElementIds;
|
||||
};
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+52
-65
@@ -1,16 +1,13 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/avm.hpp>
|
||||
|
||||
#include <QVector>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
class QCheckBox;
|
||||
|
||||
@@ -25,7 +22,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
@@ -33,80 +30,70 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class EditTrainingVoiceCommunicationDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::ModifyTvcConfigReplyHandler
|
||||
class EditTrainingVoiceCommunicationDialog : public LtsWidgets::LtsDialog,
|
||||
protected Interface::Ftc::ModifyTvcConfigReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EditTrainingVoiceCommunicationDialog(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc, int32_t exerciseId,
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
explicit EditTrainingVoiceCommunicationDialog(const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc,
|
||||
int32_t exerciseId,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
explicit EditTrainingVoiceCommunicationDialog(const TvcConfig& config,
|
||||
const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc, int32_t exerciseId,
|
||||
QWidget* parent);
|
||||
|
||||
explicit EditTrainingVoiceCommunicationDialog(const TvcConfig &config,
|
||||
const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc,
|
||||
int32_t exerciseId,
|
||||
QWidget *parent);
|
||||
~EditTrainingVoiceCommunicationDialog();
|
||||
|
||||
~EditTrainingVoiceCommunicationDialog();
|
||||
void retranslate() override;
|
||||
|
||||
void retranslate() override;
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool apply() override;
|
||||
void onModifyTvcConfigReply(const Core::FunctionReplyObject& reply) override;
|
||||
|
||||
protected:
|
||||
private:
|
||||
EditTrainingVoiceCommunicationDialog(int32_t id, const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc, int32_t exerciseId,
|
||||
QWidget* parent);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool apply() override;
|
||||
void onModifyTvcConfigReply(const Core::FunctionReplyObject &reply) override;
|
||||
void init();
|
||||
void checkToDisableChkRecording();
|
||||
|
||||
private:
|
||||
EditTrainingVoiceCommunicationDialog(int32_t id,
|
||||
const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc,
|
||||
int32_t exerciseId,
|
||||
QWidget *parent);
|
||||
private slots:
|
||||
void updateFreeChannelsAndTakenNames();
|
||||
|
||||
void init();
|
||||
void checkToDisableChkRecording();
|
||||
private:
|
||||
void updateCbChannels(QVector<int>&& freeChannels);
|
||||
QVector<int> exercisesToConsider() const;
|
||||
QVector<int> exercisesToIgnore() const;
|
||||
|
||||
private slots:
|
||||
void updateFreeChannelsAndTakenNames();
|
||||
void initCbChannelsForCreate();
|
||||
void initCbChannelsForEdit(int channelId);
|
||||
|
||||
private:
|
||||
void updateCbChannels(QVector<int> &&freeChannels);
|
||||
QVector<int> exercisesToConsider() const;
|
||||
QVector<int> exercisesToIgnore() const;
|
||||
bool isNameValid(const QString& name) const;
|
||||
|
||||
void initCbChannelsForCreate();
|
||||
void initCbChannelsForEdit(int channelId);
|
||||
|
||||
bool isNameValid(const QString &name) const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::EditTrainingVoiceCommunicationDialog> m_ui;
|
||||
int32_t m_id;
|
||||
int32_t m_exerciseId;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
ExerciseManagement::Interface::Dtc *m_exmDtc;
|
||||
QVector<QString> m_takenNames;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
};
|
||||
}
|
||||
private:
|
||||
std::unique_ptr<Ui::EditTrainingVoiceCommunicationDialog> m_ui;
|
||||
int32_t m_id;
|
||||
int32_t m_exerciseId;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
ExerciseManagement::Interface::Dtc* m_exmDtc;
|
||||
QVector<QString> m_takenNames;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+111
-122
@@ -1,209 +1,198 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_training_voice_communication_dialog.h"
|
||||
#include "ui_avm_training_voice_communication_dialog.h"
|
||||
#include "avm_training_voice_communication_dialog_model.h"
|
||||
#include "avm_edit_training_voice_communication_dialog.h"
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include "avm_edit_training_voice_communication_dialog.h"
|
||||
#include "avm_training_voice_communication_dialog_model.h"
|
||||
#include "ui_avm_training_voice_communication_dialog.h"
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
TrainingVoiceCommunicationDialog::TrainingVoiceCommunicationDialog(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::TrainingVoiceCommunicationDialog)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_avmDtc(nullptr)
|
||||
, m_avmFtc(nullptr)
|
||||
TrainingVoiceCommunicationDialog::TrainingVoiceCommunicationDialog(const QString& menuGroup,
|
||||
LtsSession::LtsSession* session, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_session(session),
|
||||
m_ui(new Ui::TrainingVoiceCommunicationDialog), m_menuGroup(menuGroup),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this)), m_avmDtc(nullptr), m_avmFtc(nullptr)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Training_Voice_Communication"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Training_Voice_Communication"));
|
||||
}
|
||||
|
||||
TrainingVoiceCommunicationDialog::~TrainingVoiceCommunicationDialog() = default;
|
||||
|
||||
void TrainingVoiceCommunicationDialog::retranslate()
|
||||
{
|
||||
translate(m_ui.get(), tr("Training Voice Communication"));
|
||||
translate(m_ui.get(), tr("Training Voice Communication"));
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool TrainingVoiceCommunicationDialog::init(const std::shared_ptr<Interface::Dtc> &avmDtc, const std::shared_ptr<Interface::Ftc> &avmFtc, ExerciseManagement::Interface::Dtc *exmDtc)
|
||||
bool TrainingVoiceCommunicationDialog::init(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc)
|
||||
{
|
||||
Q_ASSERT(exmDtc);
|
||||
Q_ASSERT(exmDtc);
|
||||
|
||||
if (!(avmDtc->enableTvcChannel() &&
|
||||
avmDtc->enableTvcConfig() &&
|
||||
avmFtc->enableModifyTvcConfig() &&
|
||||
avmFtc->enableRemoveTvcConfig()))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable topics";
|
||||
return false;
|
||||
}
|
||||
if (!(avmDtc->enableTvcChannel() && avmDtc->enableTvcConfig() && avmFtc->enableModifyTvcConfig() &&
|
||||
avmFtc->enableRemoveTvcConfig()))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable topics";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_model.reset(new TrainingVoiceCommunicationDialogModel(this));
|
||||
m_filter.reset(new TrainingVoiceCommunicationDialogFilter(m_session->exerciseId(), m_model.get()));
|
||||
m_model.reset(new TrainingVoiceCommunicationDialogModel(this));
|
||||
m_filter.reset(new TrainingVoiceCommunicationDialogFilter(m_session->exerciseId(), m_model.get()));
|
||||
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
m_exmDtc = exmDtc;
|
||||
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
m_exmDtc = exmDtc;
|
||||
if (!m_model->init(m_session->exerciseId(), avmDtc))
|
||||
{
|
||||
m_filter.reset();
|
||||
m_model.reset();
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_model->init(m_session->exerciseId(), avmDtc))
|
||||
{
|
||||
m_filter.reset();
|
||||
m_model.reset();
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
m_ui->dataView->setModel(m_filter.get());
|
||||
|
||||
m_ui->dataView->setModel(m_filter.get());
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &TrainingVoiceCommunicationDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &TrainingVoiceCommunicationDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this,
|
||||
&TrainingVoiceCommunicationDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &TrainingVoiceCommunicationDialog::onPrint);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &TrainingVoiceCommunicationDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &TrainingVoiceCommunicationDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &TrainingVoiceCommunicationDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &TrainingVoiceCommunicationDialog::onPrint);
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&TrainingVoiceCommunicationDialog::onSelectionChanged);
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &TrainingVoiceCommunicationDialog::onSelectionChanged);
|
||||
onSelectionChanged();
|
||||
|
||||
onSelectionChanged();
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&TrainingVoiceCommunicationDialog::onEditClicked);
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &TrainingVoiceCommunicationDialog::onEditClicked);
|
||||
m_buttonBox->connectLibraryButton(this, &TrainingVoiceCommunicationDialog::onImportButtonClicked,
|
||||
&TrainingVoiceCommunicationDialog::onExportButtonClicked);
|
||||
|
||||
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&TrainingVoiceCommunicationDialog::onImportButtonClicked,
|
||||
&TrainingVoiceCommunicationDialog::onExportButtonClicked);
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->dataView->hideColumn(TrainingVoiceCommunicationDialogModel::RECORDING);
|
||||
m_ui->dataView->hideColumn(TrainingVoiceCommunicationDialogModel::RECORDING);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onModifyTvcConfigReply(const Core::FunctionReplyObject &replyObject)
|
||||
void TrainingVoiceCommunicationDialog::onModifyTvcConfigReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onRemoveTvcConfigReply(const Core::FunctionReplyObject &replyObject)
|
||||
void TrainingVoiceCommunicationDialog::onRemoveTvcConfigReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onAddClicked()
|
||||
{
|
||||
EditTrainingVoiceCommunicationDialog *dialog = new EditTrainingVoiceCommunicationDialog(m_avmDtc, m_avmFtc, m_exmDtc, m_session->exerciseId(), this);
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("NewTVCConfig"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
EditTrainingVoiceCommunicationDialog* dialog =
|
||||
new EditTrainingVoiceCommunicationDialog(m_avmDtc, m_avmFtc, m_exmDtc, m_session->exerciseId(), this);
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("NewTVCConfig"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onEditClicked()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
TvcConfig config = m_model->getRowData(currentIndex.row());
|
||||
TvcConfig config = m_model->getRowData(currentIndex.row());
|
||||
|
||||
EditTrainingVoiceCommunicationDialog *dialog = new EditTrainingVoiceCommunicationDialog(config, m_avmDtc, m_avmFtc, m_exmDtc, m_session->exerciseId(), this);
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditTVCConfig%1").arg(config.id()), LtsWidgets::LayoutArea::eDialogTab);
|
||||
EditTrainingVoiceCommunicationDialog* dialog =
|
||||
new EditTrainingVoiceCommunicationDialog(config, m_avmDtc, m_avmFtc, m_exmDtc, m_session->exerciseId(), this);
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditTVCConfig%1").arg(config.id()),
|
||||
LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onRemoveClicked()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
Core::RemoveElementRequest request(m_model->getRowData(currentIndex.row()).id());
|
||||
Core::RemoveElementRequest request(m_model->getRowData(currentIndex.row()).id());
|
||||
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_avmFtc->removeTvcConfigRequest(request, this);
|
||||
});
|
||||
m_requestHelper->startSingleRequest([this, request]() { return m_avmFtc->removeTvcConfigRequest(request, this); });
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onSelectionChanged()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, currentIndex.isValid());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, currentIndex.isValid());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, currentIndex.isValid());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, currentIndex.isValid());
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView());
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = m_filter->modelToJson();
|
||||
QByteArray byteArray = m_filter->modelToJson();
|
||||
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(), FileManagement::toString(FileManagement::XmlType::AVMTrainingVoiceCommunication));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMTrainingVoiceCommunication)))
|
||||
QByteArray content;
|
||||
int fileId =
|
||||
m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(),
|
||||
FileManagement::toString(FileManagement::XmlType::AVMTrainingVoiceCommunication));
|
||||
if (fileId > 0)
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("Invalid xml file content"),
|
||||
windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes,
|
||||
texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QVector<ModifyTvcConfigRequest> requests = m_model->jsonToTvcConfigVector(content);
|
||||
for (const auto &request : requests)
|
||||
{
|
||||
m_requestHelper->addRequest([this, request]()
|
||||
if (!m_flmGui->isXmlType(content,
|
||||
FileManagement::toString(FileManagement::XmlType::AVMTrainingVoiceCommunication)))
|
||||
{
|
||||
return m_avmFtc->modifyTvcConfigRequest(request, this);
|
||||
});
|
||||
}
|
||||
(void) m_requestHelper->startRequests();
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Invalid xml file content"), windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal, LtsWidgets::Button::Yes, texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QVector<ModifyTvcConfigRequest> requests = m_model->jsonToTvcConfigVector(content);
|
||||
for (const auto& request : requests)
|
||||
{
|
||||
m_requestHelper->addRequest(
|
||||
[this, request]() { return m_avmFtc->modifyTvcConfigRequest(request, this); });
|
||||
}
|
||||
(void)m_requestHelper->startRequests();
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+41
-44
@@ -1,14 +1,11 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
@@ -32,7 +29,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
@@ -40,53 +37,53 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class TrainingVoiceCommunicationDialogModel;
|
||||
class TrainingVoiceCommunicationDialogFilter;
|
||||
|
||||
class TrainingVoiceCommunicationDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::ModifyTvcConfigReplyHandler
|
||||
, protected Interface::Ftc::RemoveTvcConfigReplyHandler
|
||||
class TrainingVoiceCommunicationDialog : public LtsWidgets::LtsDialog,
|
||||
protected Interface::Ftc::ModifyTvcConfigReplyHandler,
|
||||
protected Interface::Ftc::RemoveTvcConfigReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TrainingVoiceCommunicationDialog(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~TrainingVoiceCommunicationDialog();
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TrainingVoiceCommunicationDialog(const QString& menuGroup, LtsSession::LtsSession* session,
|
||||
QWidget* parent = nullptr);
|
||||
~TrainingVoiceCommunicationDialog();
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &avmDtc, const std::shared_ptr<Interface::Ftc> &avmFtc, ExerciseManagement::Interface::Dtc *exmDtc);
|
||||
bool init(const std::shared_ptr<Interface::Dtc>& avmDtc, const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc);
|
||||
|
||||
void onModifyTvcConfigReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onRemoveTvcConfigReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onModifyTvcConfigReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
void onRemoveTvcConfigReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::unique_ptr<TrainingVoiceCommunicationDialogModel> m_model;
|
||||
std::unique_ptr<TrainingVoiceCommunicationDialogFilter> m_filter;
|
||||
std::unique_ptr<Ui::TrainingVoiceCommunicationDialog> m_ui;
|
||||
QString m_menuGroup;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
ExerciseManagement::Interface::Dtc *m_exmDtc{nullptr};
|
||||
};
|
||||
}
|
||||
private:
|
||||
LtsSession::LtsSession* m_session;
|
||||
std::unique_ptr<TrainingVoiceCommunicationDialogModel> m_model;
|
||||
std::unique_ptr<TrainingVoiceCommunicationDialogFilter> m_filter;
|
||||
std::unique_ptr<Ui::TrainingVoiceCommunicationDialog> m_ui;
|
||||
QString m_menuGroup;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
ExerciseManagement::Interface::Dtc* m_exmDtc{nullptr};
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Loaded 100 of 848 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user