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
+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
|
||||
Reference in new issue
Block a user