Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

@@ -0,0 +1,118 @@
/**
* @RDE_HEADER@
* HMI Plugin for ParticipantManagement - Party Overview Model
* $Id$
* $HeadURL$
* $Author$
* Created by Norbert Thoden, NLE, 2020-05-29
*/
#include "tgt_shootback_target_model.h"
#include <LtsCoordTrans/lts_coord_trans.h>
namespace TargetMa nagement
{
//---------------------------------
// ShootbackTargetModel
//---------------------------------
ShootbackTargetModel::ShootbackTargetModel(QObject *parent)
: BaseClass({tr("Id"),
tr("TargetId"),
tr("Name"),
tr("TargetParticipantId"),
tr("Position"),
tr("ActivateLaserDesignation"),
tr("ActivateLights"),
tr("ActivatePopupAutomatic"),
tr("HitsToKill"),
tr("PermanentInstalledTarget"),
tr("VisibleParticipants"),
tr("Is Used")},
parent)
, m_dtc(nullptr)
, m_logger(getLogger("ShootbackTargetModel"))
{}
bool ShootbackTargetModel::initModel(const std::shared_ptr<TargetManagement::Interface::Dtc> &dtc)
{
if (!dtc)
return false;
m_dtc = dtc;
connect(m_dtc.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged,
this, &ShootbackTargetModel::onDataChanged);
connect(m_dtc.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged, [](const TargetManagement::ShootbackTarget &data, DataModification modType) {
ShootbackTargetModel::onDataChanged(data, modType);
});
m_dtc->shootbackTargets([this](const TargetManagement::ShootbackTarget & shootbackTarget)
{
insertRow(shootbackTarget);
});
return true;
}
QString toStringLocal(const std::vector< int32_t > &ids)
{
QString ret;
for (auto id : ids)
ret.append(QString::number(id));
return ret;
}
QVariant ShootbackTargetModel::data(const QModelIndex &index, int role) const
{
if (!indexIsValid(index))
return QVariant();
const TargetManagement::ShootbackTarget &shootbackTarget = m_vecData.at(index.row());
// if (role == Qt::BackgroundRole)
// {
// switch(index.column())
// {
// case Color:
// return QColor::fromRgb(QRgb(shootbackTarget.color()));
// case FadedColor:
// return QColor::fromRgb(QRgb(shootbackTarget.fadingColor()));
// }
// }
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case Id:
return shootbackTarget.id();
case TargetDataId:
return shootbackTarget.targetDataId();
case Name:
return QString::fromStdString(shootbackTarget.name());
case TargetParticipantId:
return shootbackTarget.targetParticipantId();
case Position:
{
const Core::GeoPosition2D &pos = shootbackTarget.position();
return LtsCoordTrans::mgrsFromGeographic(pos.lon(), pos.lat());
}
case ActivateLaserDesignation:
return shootbackTarget.activateLaserDesignation() ? tr("Yes") : tr("No");
case ActivateLights:
return shootbackTarget.activateLights() ? tr("Yes") : tr("No");
case ActivatePopupAutomatic:
return shootbackTarget.activatePopupAutomatic() ? tr("Yes") : tr("No");
case HitsToKill:
return shootbackTarget.hitsToKill();
case PermanentInstalledTarget:
return shootbackTarget.permanentInstalledTarget() ? tr("Yes") : tr("No");
case VisibleParticipants:
return TargetManagement::toStringLocal(shootbackTarget.visibleParticipants());
case IsUsedBy:
return shootbackTarget.isUsed() ? tr("Yes") : tr("No");
}
}
return QVariant();
}
} // namespace TargetManagement
@@ -0,0 +1,61 @@
/**
* @RDE_HEADER@
* HMI Plugin for ParticipantManagement - Party Overview Model
* $Id$
* $HeadURL$
* $Author$
* Created by Norbert Thoden, NLE, 2020-05-29
*/
#pragma once
#include <Services/TargetManagement/tgt_dtc.h>
#include <LtsWidgets/lts_abstract_table_model.h>
#include <TargetManagement/logger.h>
namespace TargetManagement
{
// --------------------------------------------------------
// ShootbackTargetModel
// --------------------------------------------------------
class ShootbackTargetModel final : public LtsWidgets::LtsAbstractTableModel<TargetManagement::ShootbackTarget>
{
using BaseClass = LtsWidgets::LtsAbstractTableModel<TargetManagement::ShootbackTarget>;
Q_OBJECT
public:
enum Columns
{
Id,
TargetDataId,
Name,
// ExerciseId,
TargetParticipantId,
Position,
ActivateLaserDesignation,
ActivateLights,
ActivatePopupAutomatic,
HitsToKill,
PermanentInstalledTarget,
VisibleParticipants,
IsUsedBy
};
explicit ShootbackTargetModel(QObject *parent = nullptr);
bool initModel(const std::shared_ptr<TargetManagement::Interface::Dtc> &dtc);
QVariant data(const QModelIndex &, int) const override;
protected:
bool isFiltered(const ShootbackTarget &data, DataModification modType) const override
{
return BaseClass::isFiltered(data, modType);
}
private:
std::shared_ptr<TargetManagement::Interface::Dtc> m_dtc;
LOGGER_T m_logger;
};
} //namespace TargetManagement
@@ -0,0 +1,213 @@
/**
* @RDE_HEADER@
* HMI Plugin for ParticipantManagement - Party View
* $Id$
* $HeadURL$
* $Author$
* Created by Norbert Thoden, NLE, 2020-05-29
*/
#include "tgt_shootback_target_view.h"
#include "ui_tgt_shootback_target_view.h"
//#include "CustomView/ppm_party.h"
#include "tgt_shootback_target_edit.h"
#include <LtsPrinting/printing.h>
#include <QTreeView>
namespace TargetManagement
{
ShootbackTargetView::ShootbackTargetView(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent)
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
, m_menuGroup(menuGroup)
, m_requestHelper(new LtsUtils::RequestHelper(this))
, m_session(session)
, m_ui(new Ui::ShootbackTargetView)
, m_logger(getLogger("ShootbackTargetView"))
{
m_ui->setupUi(this);
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
this, &ShootbackTargetView::enaDisa);
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &ShootbackTargetView::onEditShootbackTarget);
connect(m_ui->widget, &LtsDataView::LtsDataView::signalEnterPressed, this, &ShootbackTargetView::onEditShootbackTarget);
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ShootbackTargetView::onEditShootbackTarget);
// m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &ShootbackTargetView::onAddParty);
// m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &ShootbackTargetView::onRemoveParty);
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ShootbackTargetView::onPrint);
// m_buttonBox->connectButton(LtsWidgets::DialogButton::Load, this, &ShootbackTargetView::onSyncParties);
m_buttonBox->setText(LtsWidgets::DialogButton::Load, tr("Synchronize Parties"));
setOnlineHelpFilename(QStringLiteral("Administrator-ShootbackTargets"));
}
ShootbackTargetView::~ShootbackTargetView()
{
delete m_ui;
}
void ShootbackTargetView::retranslate()
{
translate(m_ui, tr("ShootbackTargets"));
}
bool ShootbackTargetView::init(const std::shared_ptr<TargetManagement::Interface::Dtc> &dtc,
const std::shared_ptr<TargetManagement::Interface::Ftc> &ftc)
{
if (!dtc || !ftc)
return false;
m_dtc = dtc;
m_ftc = ftc;
m_model = new ShootbackTargetModel(this);
m_model->initModel(m_dtc);
m_ui->widget->setModel(m_model);
// m_ui->widget->setModel(m_model, [this]() { return new CustomViewParty(this); });
#ifndef LTS_DEBUG
m_ui->widget->hideColumn(ShootbackTargetModel::Id);
#endif
m_ui->widget->setSortingEnabled(false);
connect(m_model, &ShootbackTargetModel::rowsInserted, this, &ShootbackTargetView::enaDisa);
connect(m_model, &ShootbackTargetModel::rowsRemoved, this, &ShootbackTargetView::enaDisa);
enaDisa();
return true;
}
void ShootbackTargetView::enaDisa()
{
//const QModelIndex idx = m_ui->widget->currentIndex();
bool bAddVisible = false;
bool bEditEnabled = false;
bool bRemoveEnabled = false;
bool bRemoveVisible = false;
bool bLoadEnabled = true;
bool bLoadVisible = (m_session->exerciseId() > 0);
/*
* const int row = idx.row();
if (m_ui->widget->selectedRows().size() == 0 || row < 0)
{
bEditEnabled = false;
bRemoveEnabled = false;
}
else
{
const ParticipantManagement::Party party = m_model->getRowData(row);
bEditEnabled = party.id() > 0; // all but not pool
bRemoveEnabled = !party.isUsedBy();
}
if (m_session->exerciseId() > 0)
{
// no add parties in ex_N, they need to be added in ex_0 and synchronized. Last updated: 2018.04.12
bAddVisible = false;
// sync possible only in preparing exercise
const bool bInPreparation = (m_session->exerciseState() == LtsWidgets::ExerciseState::eCreated);
if (bInPreparation)
{
// sync possible only in preparing exercise
bLoadEnabled = true;
bLoadVisible = true;
bRemoveVisible = true;
}
else
{
// sync and delete not possible after starting exercise
bLoadEnabled = false;
bLoadVisible = false;
bRemoveVisible = false;
bRemoveEnabled = false;
}
}
*/
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Add, bAddVisible);
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bEditEnabled);
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, bRemoveEnabled);
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove, bRemoveVisible);
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, bLoadEnabled);
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, bLoadVisible);
}
void ShootbackTargetView::onEditShootbackTarget()
{
const QModelIndex idx = m_ui->widget->currentIndex();
int row = idx.row();
if (row < 0)
return;
const TargetManagement::ShootbackTarget &target = m_model->getRowData(row);
ShootbackTargetEdit *dialog = new ShootbackTargetEdit(this);
dialog->init(m_dtc, m_ftc, nullptr, target);
addDialog(dialog, m_menuGroup, QLatin1String("tgtShootbackTarget") + QString::number(target.id()), LtsWidgets::LayoutArea::eDialogTab);
}
void ShootbackTargetView::onAddParty()
{
// PartyEdit *dialog = new PartyEdit(this);
// dialog->init(-1 , m_dtc, m_ftc, m_ppmGuiCbxIfc);
// addDialog(dialog, m_menuGroup, QLatin1String("ppmAddParty"), LtsWidgets::LayoutArea::eDialogTab);
}
void ShootbackTargetView::onRemoveParty()
{
// const QModelIndex curIdx = m_ui->widget->currentIndex();
// if (!curIdx.isValid())
// return;
// const Party party = m_model->getRowData(curIdx.row());
// if (party.id() < 0)
// return;
// RemovePartyRequest req;
// req.partyId(party.id());
// m_requestHelper->startSingleRequest([req, this]()
// {
// return m_ftc->removePartyRequest(req, this);
// });
// enaDisa();
}
void ShootbackTargetView::onPrint()
{
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
}
void ShootbackTargetView::onSyncParties()
{
// LtsWidgets::Button button = LtsWidgets::LtsMessageDialog::showMessage(this,tr("Changes in this exercise will be lost. Do you wish to continue?"), tr("Warning"),
// LtsWidgets::Behaviour::Modal, LtsWidgets::Button::Yes | LtsWidgets::Button::No);
// if (button == LtsWidgets::Button::Yes)
// {
// m_requestHelper->startSingleRequest([this]()
// {
// SyncPartiesRequest req;
// req.exerciseId(m_session->exerciseId());
// DEBUG_LOG(m_logger) << "Sync parties for exercise " << req.exerciseId();
// return m_ftc->syncPartiesRequest(req, this);
// });
// }
// enaDisa();
}
} // namespace TargetManagement
@@ -0,0 +1,69 @@
/**
* @RDE_HEADER@
* HMI Plugin for ParticipantManagement - Party View
* $Id$
* $HeadURL$
* $Author$
* Created by Norbert Thoden, NLE, 2020-05-29
*/
#pragma once
#include "tgt_shootback_target_model.h"
#include <TargetManagement/logger.h>
#include <Services/TargetManagement/tgt_dtc.h>
#include <Services/TargetManagement/tgt_ftc.h>
//#include <Services/ExerciseManagement/exm_dtc.h>
#include <LtsWidgets/lts_dialog.h>
#include <LtsSession/lts_session.h>
#include <LtsUtilsGuiDds/request_helper.h>
namespace Ui
{
class ShootbackTargetView;
}
namespace TargetManagement
{
class ShootbackTargetView : public LtsWidgets::LtsDialog
// , protected ParticipantManagement::Interface::Ftc::ModifyPartyDataReplyHandler
// , protected ParticipantManagement::Interface::Ftc::RemovePartyReplyHandler
// , protected ParticipantManagement::Interface::Ftc::SyncPartiesReplyHandler
{
Q_OBJECT
public:
explicit ShootbackTargetView(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent = nullptr);
~ShootbackTargetView();
bool init(const std::shared_ptr<TargetManagement::Interface::Dtc> &dtc,
const std::shared_ptr<TargetManagement::Interface::Ftc> &ftc);
private:
void retranslate() override;
// void onModifyPartyDataReply(const Core::FunctionReplyObject &replyObject) override { m_requestHelper->requestReply(replyObject); }
// void onRemovePartyReply(const Core::FunctionReplyObject &replyObject) override { m_requestHelper->requestReply(replyObject); }
// void onSyncPartiesReply(const Core::FunctionReplyObject &replyObject) override { m_requestHelper->requestReply(replyObject); }
void enaDisa();
void onEditShootbackTarget();
void onAddParty();
void onRemoveParty();
void onPrint();
void onSyncParties();
private:
QString m_menuGroup;
ShootbackTargetModel *m_model{nullptr};
std::shared_ptr<TargetManagement::Interface::Dtc> m_dtc;
std::shared_ptr<TargetManagement::Interface::Ftc> m_ftc;
LtsUtils::RequestHelper *m_requestHelper{nullptr};
LtsSession::LtsSession *m_session{nullptr};
Ui::ShootbackTargetView *m_ui{nullptr};
LOGGER_T m_logger;
};
} // namespace ParticipantManagement
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ShootbackTargetView</class>
<widget class="QWidget" name="ShootbackTargetView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>455</width>
<height>341</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="LtsDataView::LtsDataView" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>250</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LtsDataView::LtsDataView</class>
<extends>QWidget</extends>
<header>LtsDataView/lts_data_view.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>