Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+820
@@ -0,0 +1,820 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for ParticipantManagement - ParticipantConfigDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-06-13
|
||||
*/
|
||||
|
||||
#include "participant_config_dialog.h"
|
||||
#include "ui_participant_config_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <ProjectDataManagement/pdm_to_string.h>
|
||||
#include <AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/Gui/Common/participant_vulnerability_types.h>
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
int ParticipantConfigDialog::s_preselectedParty = -1;
|
||||
|
||||
ParticipantConfigDialog::ParticipantConfigDialog(int ddsId, DialogType type, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_dialogType(type)
|
||||
, m_ddsId(ddsId)
|
||||
, m_typeClass(TypeClass::Human)
|
||||
, m_model(nullptr)
|
||||
, m_maxChars(80)
|
||||
, m_eqId(0)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_pdmGuiIfc(nullptr)
|
||||
, m_ppmCbxIfc(nullptr)
|
||||
, m_stateChanged(false)
|
||||
, m_modeChanged(false)
|
||||
, m_windowTitle(tr("Set Participant Status"))
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::ParticipantConfigDialog)
|
||||
, m_isTarget(false)
|
||||
, m_logger(getLogger("ParticipantConfigDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
connect(m_ui->cbStatus, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onStateAreaChanged);
|
||||
connect(m_ui->cbResetGearCharge, &QCheckBox::toggled, this, &ParticipantConfigDialog::onStateAreaChanged);
|
||||
connect(m_ui->cbResetManipulation, &QCheckBox::toggled, this, &ParticipantConfigDialog::onStateAreaChanged);
|
||||
connect(m_ui->cbResetMedSupplies, &QCheckBox::toggled, this, &ParticipantConfigDialog::onStateAreaChanged);
|
||||
connect(m_ui->teMail, &QPlainTextEdit::textChanged, this, &ParticipantConfigDialog::onTextChanged);
|
||||
connect(m_ui->cbLanguage, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
connect(m_ui->cbCheating, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
connect(m_ui->cbPersonalProtection, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
connect(m_ui->cbProtectionLevel, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
connect(m_ui->cbGrenadeSearchMode, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
connect(m_ui->cbInternationalMode, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
connect(m_ui->cbABCProtectionMode, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
|
||||
connect(m_ui->cbVest, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
|
||||
connect(m_ui->cbHelmet, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
connect(m_ui->slDecontamination, &QSlider::valueChanged, this, [this](int value)
|
||||
{
|
||||
changeLabelText(m_ui->lbDecontamination, value);
|
||||
});
|
||||
connect(m_ui->slMaintenance, &QSlider::valueChanged, this, [this](int value)
|
||||
{
|
||||
changeLabelText(m_ui->lbMaintenance, value);
|
||||
});
|
||||
connect(m_ui->slMedical, &QSlider::valueChanged, this, [this](int value)
|
||||
{
|
||||
changeLabelText(m_ui->lbMedical, value);
|
||||
});
|
||||
connect(m_ui->tvParticipants, &QTreeView::clicked, this, [this]() { retranslate(); });
|
||||
|
||||
setUnchangeable(true);
|
||||
connect(this, &ParticipantConfigDialog::signalChangesReset, this, [this]()
|
||||
{
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(true);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setEnabled(true);
|
||||
|
||||
});
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(true);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setEnabled(true);
|
||||
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ParticipantConfigDialog::slotPartyChanged);
|
||||
connect(m_ui->cbAll, &QCheckBox::toggled, this, &ParticipantConfigDialog::slotPartyChanged);
|
||||
|
||||
// maybe Add Icon?
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->setText(tr("Send and Close"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setText(tr("Send"));
|
||||
m_ui->lblCharsLeft->setText(tr("Characters left: %1").arg(m_maxChars));
|
||||
QFontMetricsF fm(m_ui->lblCharsLeft->font());
|
||||
m_ui->lblCharsLeft->setFixedWidth(fm.width(m_ui->lblCharsLeft->text()));
|
||||
|
||||
const bool bEnableProtectionLevel = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantStatus"),
|
||||
QStringLiteral("ProtectionLevel"));
|
||||
m_ui->lbProtectionLevel->setVisible(bEnableProtectionLevel);
|
||||
m_ui->cbProtectionLevel->setVisible(bEnableProtectionLevel);
|
||||
|
||||
const bool bEnablePersonalProtection = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantStatus"),
|
||||
QStringLiteral("PersonalProtection"));
|
||||
m_ui->cbPersonalProtection->setVisible(bEnablePersonalProtection);
|
||||
m_ui->lbPersonalProtection->setVisible(bEnablePersonalProtection);
|
||||
|
||||
const bool bEnableCheatingCheck = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantStatus"),
|
||||
QStringLiteral("CheatingCheck"));
|
||||
m_ui->cbCheating->setVisible(bEnableCheatingCheck);
|
||||
m_ui->lbCheating->setVisible(bEnableCheatingCheck);
|
||||
|
||||
const bool bHgrSearchMode = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantStatus"),
|
||||
QStringLiteral("HgrSearchMode"));
|
||||
m_ui->lbGrenadeSearchMode->setVisible(bHgrSearchMode);
|
||||
m_ui->cbGrenadeSearchMode->setVisible(bHgrSearchMode);
|
||||
|
||||
const bool showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
|
||||
QStringLiteral("HasPvSan"));
|
||||
m_ui->cbVitality->setVisible(showPvSan);
|
||||
m_ui->lblVitality->setVisible(showPvSan);
|
||||
m_ui->cbResetMedSupplies->setVisible(showPvSan);
|
||||
if (m_dialogType == DialogType::Config)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Set_Participant_Status"));
|
||||
else if (m_dialogType == DialogType::ConfigMulti)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Set_Participant_Status_Multi"));
|
||||
else
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Send_Participant_Message"));
|
||||
|
||||
bool showABCProtectionMode = strcmp(PROJECTBUILD, "commaster") == 0 ? true : false;
|
||||
m_ui->cbABCProtectionMode->setVisible(showABCProtectionMode);
|
||||
m_ui->lbABCProtectionMode->setVisible(showABCProtectionMode);
|
||||
|
||||
}
|
||||
|
||||
ParticipantConfigDialog::~ParticipantConfigDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::retranslate()
|
||||
{
|
||||
QString id;
|
||||
if (m_eqId > 0)
|
||||
id = QString::number(m_eqId);
|
||||
else if (m_ui->tvParticipants && m_ui->tvParticipants->selectionModel())
|
||||
{
|
||||
QModelIndexList idxList = m_ui->tvParticipants->selectionModel()->selectedIndexes();
|
||||
if (!idxList.isEmpty())
|
||||
id = QString::number(m_model->data(idxList.first(), Qt::DisplayRole).toInt());
|
||||
}
|
||||
|
||||
QString title = m_windowTitle;
|
||||
if (!id.isEmpty())
|
||||
title += QStringLiteral(": ") + id;
|
||||
|
||||
translate(m_ui, title);
|
||||
fillCbx();
|
||||
fillVitalityCbx();
|
||||
fillCbxWithActualValue();
|
||||
}
|
||||
|
||||
bool ParticipantConfigDialog::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc)
|
||||
{
|
||||
bool setCurrentValues = false;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
|
||||
if (!m_dtc || !m_ftc)
|
||||
return false;
|
||||
m_dtc->enableParticipant();
|
||||
m_dtc->enableParticipantMode();
|
||||
m_dtc->enableDynamicParticipantData();
|
||||
m_dtc->waitForHistoricalDataDynamicParticipantData(1000);
|
||||
m_dtc->waitForHistoricalDataParticipantMode(1000);
|
||||
m_dtc->waitForHistoricalDataParticipant(1000);
|
||||
|
||||
|
||||
if (!session->getForeignGuiInterface<ProjectDataManagement::ForeignGuiInterface>(m_pdmGuiIfc))
|
||||
return false;
|
||||
|
||||
if (!session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmCbxIfc))
|
||||
return false;
|
||||
fillVitalityCbx();
|
||||
|
||||
switch (m_dialogType)
|
||||
{
|
||||
case Config:
|
||||
m_ui->gbParticipants->hide();
|
||||
setCurrentValues = true;
|
||||
Q_FALLTHROUGH();
|
||||
case ConfigMulti:
|
||||
m_ui->gbMessage->hide();
|
||||
break;
|
||||
case Message:
|
||||
m_ui->gbParticipants->hide();
|
||||
setCurrentValues = true;
|
||||
Q_FALLTHROUGH();
|
||||
case MessageMulti:
|
||||
m_ui->gbMode->hide();
|
||||
m_ui->gbRes->hide();
|
||||
m_ui->gbState->hide();
|
||||
m_windowTitle = tr("Send Message");
|
||||
m_uiRequirements->addRequirement({ m_ui->lblTextMailBold, [this]() { return (m_ui->teMail->toPlainText().size() > 0); }});
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_ddsId > 0)
|
||||
{
|
||||
const Participant participant = m_dtc->participant(m_ddsId);
|
||||
if (participant.equipmentNumber().is_set())
|
||||
m_eqId = participant.equipmentNumber().get();
|
||||
if (!m_eqId && (m_dialogType == Config || m_dialogType == Message))
|
||||
return false;
|
||||
m_typeClass = m_dtc->type(participant.typeId()).typeClass();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_eqId = 0;
|
||||
m_typeClass = TypeClass::Unknown;
|
||||
}
|
||||
m_stateChanged = false;
|
||||
|
||||
|
||||
if (m_typeClass != TypeClass::Human && m_ddsId > 0)
|
||||
{
|
||||
m_ui->cbHelmet->setHidden(true);
|
||||
m_ui->lbHelmet->setHidden(true);
|
||||
m_ui->cbVest->setHidden(true);
|
||||
m_ui->lbVest->setHidden(true);
|
||||
m_ui->cbPersonalProtection->setHidden(true);
|
||||
m_ui->lbPersonalProtection->setHidden(true);
|
||||
m_ui->cbProtectionLevel->setHidden(true);
|
||||
m_ui->lbProtectionLevel->setHidden(true);
|
||||
m_ui->cbGrenadeSearchMode->setHidden(true);
|
||||
m_ui->lbGrenadeSearchMode->setHidden(true);
|
||||
m_ui->lbInternationalMode->setHidden(true);
|
||||
m_ui->cbInternationalMode->setHidden(true);
|
||||
m_ui->lbABCProtectionMode->setHidden(true);
|
||||
m_ui->cbABCProtectionMode->setHidden(true);
|
||||
}else if (m_typeClass == TypeClass::Human && m_ddsId > 0)
|
||||
{
|
||||
m_maxChars = 16;
|
||||
m_ui->lblCharsLeft->setText(tr("Characters left: %1").arg(m_maxChars));
|
||||
QFontMetricsF fm(m_ui->lblCharsLeft->font());
|
||||
m_ui->lblCharsLeft->setFixedWidth(fm.width(m_ui->lblCharsLeft->text()));
|
||||
}
|
||||
|
||||
if (m_dialogType == MessageMulti)
|
||||
{
|
||||
m_maxChars = 16;
|
||||
m_ui->lblCharsLeft->setText(tr("Characters left: %1").arg(m_maxChars));
|
||||
QFontMetricsF fm(m_ui->lblCharsLeft->font());
|
||||
m_ui->lblCharsLeft->setFixedWidth(fm.width(m_ui->lblCharsLeft->text()));
|
||||
}
|
||||
|
||||
m_modeChanged = false;
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> asbIfc;
|
||||
session->getForeignDataInterface<AdvancedSymbology::DataInterface>(asbIfc);
|
||||
m_model = new ParticipantConfigModel(this, m_dtc, asbIfc);
|
||||
if (m_dialogType == DialogType::MessageMulti || m_dialogType == DialogType::ConfigMulti)
|
||||
{
|
||||
m_ui->tvParticipants->setModel(m_model);
|
||||
connect(m_ui->tvParticipants->selectionModel(), &QItemSelectionModel::selectionChanged, this, &ParticipantConfigDialog::onSelectionChanged);
|
||||
fillCbx();
|
||||
if (setCurrentValues == true)
|
||||
fillCbxWithActualValue();
|
||||
slotPartyChanged();
|
||||
for (int column = 0; column < m_model->columnCount(); column++)
|
||||
m_ui->tvParticipants->resizeColumnToContents(column);
|
||||
}
|
||||
|
||||
if (m_ddsId == 0)
|
||||
{
|
||||
auto cb = [this]()
|
||||
{
|
||||
if (m_ui->cbAll->isChecked())
|
||||
return true;
|
||||
return !m_ui->tvParticipants->selectionModel()->selectedRows().isEmpty();
|
||||
};
|
||||
m_uiRequirements->addRequirement({ m_ui->lbParty, cb });
|
||||
}
|
||||
// Target display:
|
||||
{
|
||||
const Participant participant = m_dtc->participant(m_ddsId);
|
||||
if (participant.equipmentNumber().is_set())
|
||||
{
|
||||
const Type type = m_dtc->type(participant.typeId());
|
||||
const EquipmentType eqType = m_dtc->equipmentType(type.equipmentTypeId());
|
||||
if (eqType.wmsTypeClass() == WmsTypeClass::TargetHuman ||
|
||||
eqType.wmsTypeClass() == WmsTypeClass::TargetVehicle)
|
||||
{
|
||||
NOTICE_LOG(m_logger) << "isTarget = true";
|
||||
m_ui->gbMode->setHidden(true);
|
||||
m_ui->gbRes->setHidden(true);
|
||||
m_isTarget = true;
|
||||
}
|
||||
}
|
||||
//UAS
|
||||
if (m_dtc->isTypeUas(participant.typeId()) && m_ddsId > 0)
|
||||
{
|
||||
m_ui->cbResetManipulation->hide();
|
||||
m_ui->cbResetGearCharge->hide();
|
||||
m_ui->gbRes->hide();
|
||||
m_ui->gbMode->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const bool showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
|
||||
QStringLiteral("HasPvSan"))
|
||||
&& m_typeClass == TypeClass::Human;
|
||||
m_ui->cbVitality->setVisible(showPvSan);
|
||||
m_ui->lblVitality->setVisible(showPvSan);
|
||||
m_ui->cbResetMedSupplies->setVisible(showPvSan && m_typeClass == TypeClass::Human);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//private
|
||||
|
||||
void ParticipantConfigDialog::slotPartyChanged()
|
||||
{
|
||||
if (m_ui->cbAll->isChecked())
|
||||
{
|
||||
m_ui->cbParty->setEnabled(false);
|
||||
m_ui->tvParticipants->setEnabled(false);
|
||||
m_model->resetModel();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->cbParty->setEnabled(true);
|
||||
m_ui->tvParticipants->setEnabled(true);
|
||||
int curPartyId = m_ui->cbParty->currentData().toInt();
|
||||
s_preselectedParty = curPartyId;
|
||||
m_model->onReinitModel(curPartyId);
|
||||
m_ui->tvParticipants->expandAll();
|
||||
}
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::onSelectionChanged()
|
||||
{
|
||||
const QModelIndexList currentlySelectedParticipants = m_ui->tvParticipants->selectionModel()->selectedIndexes();
|
||||
//bool isPureHuman = true;
|
||||
|
||||
for (const QModelIndex &index : currentlySelectedParticipants)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setChildrenSelected row =" << index.row() << " column=" << index.column();
|
||||
ParticipantManagement::ParticipantData data = m_model->getParticipantData(index);
|
||||
TypeClass tc = m_dtc->type(data.typeId()).typeClass();
|
||||
if (tc != TypeClass::Human && tc != TypeClass::Unit)
|
||||
{
|
||||
//isPureHuman = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_ui->cbHelmet->setEnabled(true);
|
||||
m_ui->cbVest->setEnabled(true);
|
||||
m_ui->cbPersonalProtection->setEnabled(true);
|
||||
m_ui->cbProtectionLevel->setEnabled(true);
|
||||
m_ui->cbGrenadeSearchMode->setEnabled(true);
|
||||
m_ui->cbInternationalMode->setEnabled(true);
|
||||
m_ui->cbABCProtectionMode->setEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::fillCbx()
|
||||
{
|
||||
// Party (required by setting all participants)
|
||||
if (!m_ddsId)
|
||||
m_ppmCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
const int idx = m_ui->cbParty->findData(s_preselectedParty);
|
||||
if (idx >= 0)
|
||||
m_ui->cbParty->setCurrentIndex(idx);
|
||||
|
||||
QSignalBlocker(m_ui->cbStatus);
|
||||
m_ui->cbStatus->clear();
|
||||
//Vulnerability
|
||||
m_ui->cbStatus->addItem(tr("No Change"), -1);
|
||||
if ( m_isTarget)
|
||||
{
|
||||
m_ui->cbStatus->addItem(tr("CombatReady"), ProjectDataManagement::VulnerabilityState::CombatReady);
|
||||
m_ui->cbStatus->addItem(tr("Catastrophic Kill / Killed"), ProjectDataManagement::VulnerabilityState::CatastrophicKill);
|
||||
}
|
||||
else
|
||||
insertVulnerabilityStates(m_ui->cbStatus, m_typeClass);
|
||||
|
||||
// Player language
|
||||
m_pdmGuiIfc->fillPlayerLanguageComboBox(m_ui->cbLanguage);
|
||||
|
||||
// Player operation mode
|
||||
m_pdmGuiIfc->fillPlayerOperationModeComboBox(m_ui->cbCheating);
|
||||
|
||||
// Player mode helmet
|
||||
m_pdmGuiIfc->fillPlayerModeHelmetComboBox(m_ui->cbHelmet);
|
||||
|
||||
// Player mode vest
|
||||
m_pdmGuiIfc->fillPlayerModeVestComboBox(m_ui->cbVest);
|
||||
|
||||
// Player personal Protection
|
||||
m_pdmGuiIfc->fillPlayerPersonalProtectionComboBox(m_ui->cbPersonalProtection);
|
||||
|
||||
// Player protection level
|
||||
m_pdmGuiIfc->fillPlayerProtectionLevelComboBox(m_ui->cbProtectionLevel);
|
||||
|
||||
// Player handgrenade search mode
|
||||
m_pdmGuiIfc->fillPlayerHandgrenadeSearchModeComboBox(m_ui->cbGrenadeSearchMode);
|
||||
|
||||
m_pdmGuiIfc->fillPlayerInternationalModeComboBox(m_ui->cbInternationalMode);
|
||||
|
||||
m_pdmGuiIfc->fillABCProtectionComboBox(m_ui->cbABCProtectionMode);
|
||||
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::fillVitalityCbx()
|
||||
{
|
||||
QSignalBlocker(m_ui->cbVitality);
|
||||
m_ui->cbVitality->disconnect();
|
||||
m_ui->cbVitality->clear();
|
||||
m_ui->cbVitality->addItem(tr("No Change"), 0);
|
||||
if (!m_dtc)
|
||||
return;
|
||||
|
||||
bool setEnabled = false;
|
||||
if (m_dialogType == Config && m_dtc->type(m_dtc->participant(m_ddsId).typeId()).typeClass() == TypeClass::Human)
|
||||
setEnabled = true;
|
||||
switch (m_ui->cbStatus->currentData().toInt())
|
||||
{
|
||||
case -1:
|
||||
{
|
||||
m_ui->cbVitality->setEnabled(false);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::VulnerabilityState::LightDamage:
|
||||
{
|
||||
for (int i = 90 ; i >= 70; i -= 10)
|
||||
m_ui->cbVitality->addItem(QString::number(i), i);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::VulnerabilityState::MediumDamage:
|
||||
{
|
||||
for (int i = 60 ; i >= 40; i -= 10)
|
||||
m_ui->cbVitality->addItem(QString::number(i), i);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::VulnerabilityState::HeavyDamage:
|
||||
{
|
||||
for (int i = 30 ; i >= 10; i -= 10)
|
||||
m_ui->cbVitality->addItem(QString::number(i), i);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::VulnerabilityState::CombatReady:
|
||||
{
|
||||
m_ui->cbVitality->removeItem(0);
|
||||
m_ui->cbVitality->addItem(QString::number(100), 100);
|
||||
setEnabled = false;
|
||||
//m_ui->cbVitality->setCurrentIndex(m_ui->cbVitality->findData(100));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
setEnabled = false;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
connect(m_ui->cbVitality, static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged), this, [this]
|
||||
{
|
||||
m_stateChanged = true;
|
||||
});
|
||||
m_ui->cbVitality->setEnabled(setEnabled);
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::setCbxForInitEnabled(bool enabled)
|
||||
{
|
||||
//fixup apache reset and reactivate
|
||||
#ifndef GUEZ_MODE
|
||||
if (enabled && m_ddsId > 0 )
|
||||
{
|
||||
const Participant participant = m_dtc->participant(m_ddsId);
|
||||
const TypeClass tc = m_dtc->type(participant.typeId()).typeClass();
|
||||
if (tc == TypeClass::Aircraft && m_ui->cbStatus->currentIndex() < 1)
|
||||
enabled = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_ui->cbResetGearCharge->setEnabled(enabled);
|
||||
m_ui->cbResetGearCharge->setCheckable(enabled);
|
||||
m_ui->cbResetManipulation->setEnabled(enabled);
|
||||
m_ui->cbResetManipulation->setCheckable(enabled);
|
||||
m_ui->cbResetMedSupplies->setCheckable(enabled);
|
||||
m_ui->cbResetMedSupplies->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::fillCbxWithActualValue()
|
||||
{
|
||||
if(m_eqId <= 0)
|
||||
return;
|
||||
int partId = m_dtc->participantIdByEquipmentNumber(m_eqId);
|
||||
|
||||
ParticipantManagement::ParticipantMode mode = m_dtc->participantMode(partId);
|
||||
m_ui->cbHelmet->setCurrentIndex(m_ui->cbHelmet->findData(mode.modeHelmet().underlying()));
|
||||
m_ui->cbLanguage->setCurrentIndex(m_ui->cbLanguage->findData(mode.language().underlying()));
|
||||
m_ui->cbPersonalProtection->setCurrentIndex(m_ui->cbPersonalProtection->findData(mode.modePersonalProtection().underlying()));
|
||||
m_ui->cbProtectionLevel->setCurrentIndex(m_ui->cbProtectionLevel->findData(mode.protectionLevel().underlying()));
|
||||
m_ui->cbGrenadeSearchMode->setCurrentIndex(m_ui->cbGrenadeSearchMode->findData(mode.handgrenadeSearchMode().underlying()));
|
||||
m_ui->cbInternationalMode->setCurrentIndex(m_ui->cbInternationalMode->findData(mode.internationalMode().underlying()));
|
||||
m_ui->cbABCProtectionMode->setCurrentIndex(m_ui->cbABCProtectionMode->findData(mode.abcProtectionMode().underlying()));
|
||||
m_ui->cbVest->setCurrentIndex(m_ui->cbVest->findData(mode.modeVest().underlying()));
|
||||
m_modeChanged = false;
|
||||
|
||||
m_ui->cbStatus->setCurrentIndex(0);
|
||||
m_ui->cbVitality->setCurrentIndex(0);
|
||||
|
||||
std::vector< ParticipantManagement::StateInformation> stateHistory = m_dtc->dynamicParticipantData(partId).stateHistory();
|
||||
if (stateHistory.size() > 0)
|
||||
{
|
||||
auto stateInfo = m_dtc->youngestStateInformation(stateHistory);
|
||||
|
||||
int statusIndex = m_ui->cbStatus->findData(stateInfo.vulnerabilityState().underlying());
|
||||
if(statusIndex != -1)
|
||||
m_ui->cbStatus->setCurrentIndex(statusIndex);
|
||||
|
||||
int vitalityIndex = m_ui->cbVitality->findData(stateInfo.vitality());
|
||||
if(vitalityIndex != -1)
|
||||
m_ui->cbVitality->setCurrentIndex(vitalityIndex);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Slots
|
||||
|
||||
void ParticipantConfigDialog::onStateAreaChanged()
|
||||
{
|
||||
m_stateChanged = false;
|
||||
|
||||
setCbxForInitEnabled(m_ui->cbStatus->currentIndex() < 2);
|
||||
|
||||
fillVitalityCbx();
|
||||
|
||||
if (m_ui->cbStatus->currentIndex() == 0 &&
|
||||
!m_ui->cbResetManipulation->isChecked() &&
|
||||
!m_ui->cbResetMedSupplies->isChecked() &&
|
||||
!m_ui->cbResetGearCharge->isChecked())
|
||||
return;
|
||||
m_stateChanged = true;
|
||||
}
|
||||
|
||||
bool ParticipantConfigDialog::apply()
|
||||
{
|
||||
bool bAll = m_ui->cbAll->isChecked();
|
||||
|
||||
|
||||
// Which participant should be updated
|
||||
const std::set<int> participantIdSet(bAll ? std::set<int>({0}) : getParticipantIds());
|
||||
|
||||
if (participantIdSet.empty())
|
||||
return false;
|
||||
|
||||
const std::vector<int> participantIds(participantIdSet.begin(), participantIdSet.end());
|
||||
|
||||
|
||||
switch (m_dialogType)
|
||||
{
|
||||
|
||||
case Config:
|
||||
case ConfigMulti:
|
||||
{
|
||||
if (!m_modeChanged && !m_stateChanged)
|
||||
return false;
|
||||
|
||||
if (m_stateChanged)
|
||||
{
|
||||
if (m_ui->cbStatus->currentData().toInt() > 100)
|
||||
{
|
||||
OcCommandRequest req;
|
||||
// InitParticipantRequest req;
|
||||
req.action(m_ui->cbStatus->currentData().toInt() - 100);
|
||||
req.participantIds(participantIds);
|
||||
|
||||
m_ftc->ocCommandRequest(req);
|
||||
}
|
||||
else
|
||||
{
|
||||
const ProjectDataManagement::VulnerabilityState state = static_cast<ProjectDataManagement::VulnerabilityState_def::type>(m_ui->cbStatus->currentData().toInt());
|
||||
if (m_ui->cbStatus->currentIndex() == 1 ||
|
||||
m_ui->cbResetGearCharge->isChecked() ||
|
||||
m_ui->cbResetMedSupplies->isChecked() ||
|
||||
m_ui->cbResetManipulation->isChecked()) // (1) Ready for action or button checked -> init
|
||||
{
|
||||
InitParticipantRequest req;
|
||||
req.workstationId(LtsSessionData::LtsSessionData::getInstance()->getWorkstationId());
|
||||
req.restockCharges(m_ui->cbResetGearCharge->isChecked());
|
||||
req.resetManipulation(m_ui->cbResetManipulation->isChecked());
|
||||
req.resetVulnerabilityState(state == ProjectDataManagement::VulnerabilityState::CombatReady);
|
||||
req.restockSanitationMaterial(m_ui->cbResetMedSupplies->isChecked());
|
||||
req.participantIds(participantIds);
|
||||
m_requestHelper->addRequest([req, this]()
|
||||
{
|
||||
return m_ftc->initParticipantRequest(req, this);
|
||||
});
|
||||
}
|
||||
else //set new State
|
||||
{
|
||||
// Invalid enum value -1
|
||||
if (m_ui->cbStatus->currentData().toInt() != -1 || m_ui->cbVitality->currentData().toInt() != 0)
|
||||
{
|
||||
ModifyStateRequest req;
|
||||
req.workstationId(LtsSessionData::LtsSessionData::getInstance()->getWorkstationId());
|
||||
req.vulnerabilityState(state == ProjectDataManagement::VulnerabilityState::NoChange ? ProjectDataManagement::VulnerabilityState::CombatReady : state);
|
||||
req.participantIds(participantIds);
|
||||
req.vitality(m_ui->cbVitality->currentData().toInt());
|
||||
if(req.vitality() > 0) //if we set the vitality directly send base kind for pvSan
|
||||
req.vulnerabilityKind(2048);
|
||||
m_requestHelper->addRequest([req, this]()
|
||||
{
|
||||
return m_ftc->modifyStateRequest(req, this);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_modeChanged)
|
||||
{
|
||||
ProjectDataManagement::LanguageConfiguration lang = static_cast<ProjectDataManagement::LanguageConfiguration_def::type>(m_ui->cbLanguage->currentData().toInt());
|
||||
ProjectDataManagement::OperationMode opMode = static_cast<ProjectDataManagement::OperationMode_def::type>(m_ui->cbCheating->currentData().toInt());
|
||||
ProjectDataManagement::WphMode helmet = static_cast<ProjectDataManagement::WphMode_def::type>(m_ui->cbHelmet->currentData().toInt());
|
||||
ProjectDataManagement::WphMode vest = static_cast<ProjectDataManagement::WphMode_def::type>(m_ui->cbVest->currentData().toInt());
|
||||
ProjectDataManagement::PersonalProtection personalProtection = static_cast<ProjectDataManagement::PersonalProtection_def::type>(m_ui->cbPersonalProtection->currentData().toInt());
|
||||
ProjectDataManagement::ProtectionLevel protectionLevel = static_cast<ProjectDataManagement::ProtectionLevel_def::type>(m_ui->cbProtectionLevel->currentData().toInt());
|
||||
ProjectDataManagement::HandgrenadeSearchMode grenadeSearch;
|
||||
if(!m_ui->cbGrenadeSearchMode->isHidden())
|
||||
{
|
||||
grenadeSearch = static_cast<ProjectDataManagement::HandgrenadeSearchMode_def::type>(m_ui->cbGrenadeSearchMode->currentData().toInt());
|
||||
}
|
||||
else
|
||||
{
|
||||
grenadeSearch = ProjectDataManagement::HandgrenadeSearchMode::NoChange;
|
||||
}
|
||||
|
||||
ProjectDataManagement::InternationalMode internationalMode = static_cast<ProjectDataManagement::InternationalMode_def::type>(m_ui->cbInternationalMode->currentData().toInt());
|
||||
ProjectDataManagement::ABCProtectionMode abcProtectionMode = static_cast<ProjectDataManagement::ABCProtectionMode_def::type>(m_ui->cbABCProtectionMode->currentData().toInt());
|
||||
|
||||
int reactDecontMinutes = m_ui->slDecontamination->value() * 10;
|
||||
int reactMaintenanceMinutes = m_ui->slMaintenance->value() * 10;
|
||||
int reactMedicMinutes = m_ui->slMedical->value() * 10;
|
||||
SetParticipantModeRequest req(lang,
|
||||
opMode,
|
||||
reactDecontMinutes,
|
||||
reactMaintenanceMinutes,
|
||||
reactMedicMinutes,
|
||||
vest,
|
||||
helmet,
|
||||
personalProtection,
|
||||
protectionLevel,
|
||||
grenadeSearch,
|
||||
internationalMode,
|
||||
abcProtectionMode,
|
||||
0);
|
||||
|
||||
for (int participantId : participantIds)
|
||||
{
|
||||
if(participantId != 0)
|
||||
{
|
||||
auto data = m_dtc->participant(participantId);
|
||||
TypeClass tc = m_dtc->type(data.typeId()).typeClass();
|
||||
if (tc != TypeClass::Human)
|
||||
continue;
|
||||
}
|
||||
req.participantId(participantId);
|
||||
m_requestHelper->addRequest([req, this]()
|
||||
{
|
||||
return m_ftc->setParticipantModeRequest(req, this);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case Message:
|
||||
case MessageMulti:
|
||||
{
|
||||
SendMessageRequest req;
|
||||
req.message(m_ui->teMail->toPlainText().toStdString());
|
||||
req.participantIds(participantIds);
|
||||
m_requestHelper->addRequest([req, this]()
|
||||
{
|
||||
return m_ftc->sendMessageRequest(req, this);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//now start Requests
|
||||
|
||||
bool ret = m_requestHelper->startRequests();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::onTextChanged()
|
||||
{
|
||||
QString plainText(m_ui->teMail->toPlainText());
|
||||
int currentUsedChars = plainText.toUtf8().size();
|
||||
bool bNeedSetNew = false;
|
||||
|
||||
while (currentUsedChars > m_maxChars)
|
||||
{
|
||||
plainText.chop(1);
|
||||
currentUsedChars = plainText.toUtf8().size();
|
||||
bNeedSetNew = true; // do not set text directly, results in recursion
|
||||
}
|
||||
|
||||
// if text longer than allowed
|
||||
if (bNeedSetNew)
|
||||
{
|
||||
m_ui->teMail->setPlainText(plainText);
|
||||
m_ui->teMail->moveCursor(QTextCursor::End);
|
||||
}
|
||||
int charsLeft = m_maxChars - currentUsedChars;
|
||||
if (charsLeft > 9)
|
||||
m_ui->lblCharsLeft->setText(tr("Characters left: %1").arg(QString::number(m_maxChars - currentUsedChars)));
|
||||
else
|
||||
m_ui->lblCharsLeft->setText(tr("Characters left: %1").arg(QString::number(m_maxChars - currentUsedChars)));
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::changeLabelText(QLabel *label, int value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 0:
|
||||
label->setText(tr("No Change"));
|
||||
break;
|
||||
case 255:
|
||||
label->setText(tr("No Resurrection"));
|
||||
break;
|
||||
default:
|
||||
label->setText(QStringLiteral("%1 min").arg(value * 10));
|
||||
break;
|
||||
}
|
||||
onModeChanged();
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::onModeChanged()
|
||||
{
|
||||
m_modeChanged = false;
|
||||
if (m_ui->cbLanguage->currentIndex() == 0 &&
|
||||
m_ui->cbCheating->currentIndex() == 0 &&
|
||||
m_ui->cbPersonalProtection->currentIndex() == 0 &&
|
||||
m_ui->cbHelmet->currentIndex() == 0 &&
|
||||
m_ui->cbProtectionLevel->currentIndex() == 0 &&
|
||||
m_ui->cbGrenadeSearchMode->currentIndex() == 0 &&
|
||||
m_ui->cbInternationalMode->currentIndex() == 0 &&
|
||||
m_ui->cbABCProtectionMode->currentIndex() == 0 &&
|
||||
m_ui->slDecontamination->value() == 0 &&
|
||||
m_ui->slMaintenance->value() == 0 &&
|
||||
m_ui->slMedical->value() == 0
|
||||
)
|
||||
return;
|
||||
|
||||
m_modeChanged = true;
|
||||
}
|
||||
|
||||
std::set<int> ParticipantConfigDialog::getParticipantIds() const
|
||||
{
|
||||
if (m_ddsId) // single
|
||||
return {m_ddsId};
|
||||
|
||||
const QItemSelectionModel *selectionModel = m_ui->tvParticipants->selectionModel();
|
||||
const QModelIndexList rows = selectionModel->selectedRows();
|
||||
|
||||
std::set<int> ret;
|
||||
for (const QModelIndex &row : rows)
|
||||
{
|
||||
const auto c = getParticipantIds(row);
|
||||
for(auto id : c)
|
||||
{
|
||||
ret.insert(id);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QVector<int> ParticipantConfigDialog::getParticipantIds(const QModelIndex &parent) const
|
||||
{
|
||||
QVector<int> ret;
|
||||
|
||||
const ParticipantManagement::ParticipantData dataParent(m_model->getParticipantData(parent));
|
||||
if (dataParent.equipmentNumber().is_set())
|
||||
ret.append(dataParent.id());
|
||||
|
||||
// if(dataParent.equipmentNumber().get() == m_eqId)
|
||||
// {
|
||||
// DEBUG_LOG(m_logger)<<" >>>>>> [SET PP STATUS] participantId: "<< dataParent.id()<<" for equipNumb: "<< dataParent.equipmentNumber();
|
||||
// }
|
||||
const int rowCount = m_model->rowCount(parent);
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
{
|
||||
const QModelIndex childIndex = m_model->index(row, 0, parent);
|
||||
ret += getParticipantIds(childIndex);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
Reference in new issue
Block a user