119 lines
3.7 KiB
C++
Executable File
119 lines
3.7 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* TargetParticipantModel
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Norbert Thoden, NLE, 2020-06-29
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "tgt_participant_handler.h"
|
|
#include <TargetManagement/tgt_dtc.h>
|
|
#include <TargetManagement/logger.h>
|
|
|
|
#include <LtsWidgets/lts_abstract_table_model.h>
|
|
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
|
#include <LtsSession/lts_session.h>
|
|
|
|
namespace TargetManagement
|
|
{
|
|
|
|
// Forward:
|
|
class ParticipantHandler;
|
|
|
|
// --------------------------------------------------------
|
|
// TargetParticipantModel
|
|
// --------------------------------------------------------
|
|
class TargetParticipantModel final : public LtsWidgets::LtsAbstractTableModel<TargetManagement::ShootbackTarget>
|
|
{
|
|
Q_OBJECT
|
|
using BaseClass = LtsWidgets::LtsAbstractTableModel<TargetManagement::ShootbackTarget>;
|
|
|
|
public:
|
|
enum Columns
|
|
{
|
|
Id,
|
|
|
|
// linked participant:
|
|
ShootbackTargetName,
|
|
TargetPartipantId,
|
|
TargetPartipantEquipmentNumber,
|
|
TargetPartipantEquipmentType,
|
|
Participant,
|
|
|
|
// main/base config
|
|
Position,
|
|
ActivateLaserDesignation,
|
|
ActivateLights,
|
|
ActivatePopupAutomatic,
|
|
HitsToKill,
|
|
PermanentInstalledTarget,
|
|
VisibleParticipants,
|
|
};
|
|
|
|
explicit TargetParticipantModel(QObject *parent = nullptr);
|
|
|
|
bool initModel(const std::shared_ptr<Interface::Dtc> &tgtDtc,
|
|
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
|
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> &ppmGuiCbxIfc,
|
|
LtsSession::LtsSession *session);
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
|
|
QVariant data(const QModelIndex &, int) const override;
|
|
|
|
const QHash <int, QString> &getParticipantHierarchies() const { return m_participantHandler->getParticipantHierarchies(); }
|
|
const QHash <int, QPixmap> &getParticipantDecorations() const { return m_participantHandler->getParticipantDecorations(); }
|
|
QSet<int> getAssociatedParticipantIds() const;
|
|
|
|
const QVector<ShootbackTarget> &getData() const { return m_vecData; }
|
|
|
|
Q_SIGNALS:
|
|
void signalParticipantNamesChanged();
|
|
|
|
private Q_SLOTS:
|
|
void onShootbackTargetChanged(const TargetManagement::ShootbackTarget &data,
|
|
const DataModification modType);
|
|
void updateColumnFilter();
|
|
|
|
private:
|
|
friend class TargetParticipantProxyModel;
|
|
std::shared_ptr<TargetManagement::Interface::Dtc> m_tgt_dtc;
|
|
ParticipantHandler *m_participantHandler{nullptr};
|
|
LtsSession::LtsSession *m_session{nullptr};
|
|
|
|
QIcon m_yes{QLatin1String("icon:yes.svg")};
|
|
QIcon m_no{QLatin1String("icon:no.svg")};
|
|
|
|
// column filter
|
|
QSet<int> m_usedActiveLaserDesignations;
|
|
QSet<int> m_usedActivateLights;
|
|
QSet<int> m_usedActivatePopupAutomatic;
|
|
QSet<int> m_usedHitsToKill;
|
|
QSet<int> m_usedPermanetTargetInstalled;
|
|
|
|
LOGGER_T m_logger;
|
|
};
|
|
|
|
// --------------------------------------------------------
|
|
// TargetParticipantProxyModel
|
|
// --------------------------------------------------------
|
|
class TargetParticipantProxyModel : public LtsWidgets::LtsColumnFilterProxyModel
|
|
{
|
|
Q_OBJECT
|
|
using BaseClass = LtsWidgets::LtsColumnFilterProxyModel;
|
|
|
|
public:
|
|
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
|
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
|
|
|
protected:
|
|
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
|
|
|
protected:
|
|
TargetParticipantModel *m_sourceModel{nullptr};
|
|
};
|
|
|
|
} //namespace TargetManagement
|