95 lines
3.3 KiB
C++
Executable File
95 lines
3.3 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* HMI Plugin for ParticipantManagement - Participant Pool Model
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Patric Karwat, SLSE, 2016-10-05
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <ParticipantManagement/logger.h>
|
|
#include <Services/ParticipantManagement/ppm_dtc.h>
|
|
|
|
#include <LtsWidgets/lts_abstract_table_model.h>
|
|
#include <Plugins/AdvancedSymbology/Helper/table_model_symbol_renderer.h>
|
|
|
|
namespace LtsSession
|
|
{
|
|
class LtsSessionDataDds;
|
|
}
|
|
|
|
namespace ParticipantManagement
|
|
{
|
|
//----------------------------------------------------------------------------
|
|
class ParticipantPoolModel final : public LtsWidgets::LtsAbstractTableModel<ParticipantManagement::ParticipantData>
|
|
, public AdvancedSymbology::TableModelSymbolRenderer<ParticipantPoolModel>
|
|
{
|
|
Q_OBJECT
|
|
friend class AdvancedSymbology::TableModelSymbolRenderer<ParticipantPoolModel>;
|
|
public:
|
|
enum Columns
|
|
{
|
|
ColRemove,
|
|
ColDesignatorIdentifier,
|
|
ColTypeClass,
|
|
ColType,
|
|
ColParticipantId
|
|
};
|
|
|
|
ParticipantPoolModel(QObject *parent,
|
|
LtsSession::LtsSessionDataDds *session,
|
|
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtc,
|
|
bool asSupportService);
|
|
|
|
bool onReinitModel();
|
|
|
|
bool canRemoveRow(int row) const;
|
|
bool removeRow(int row) override;
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
int columnCount(const QModelIndex &parent) const override;
|
|
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
|
bool dropMimeData(const QMimeData *data,
|
|
Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
|
Qt::DropActions supportedDropActions() const override { return Qt::MoveAction | Qt::CopyAction; }
|
|
Qt::DropActions supportedDragActions() const override { return Qt::MoveAction; }
|
|
|
|
QStringList mimeTypes() const override;
|
|
QVector<ParticipantManagement::ParticipantData> getPoolData() const;
|
|
bool addNewTemplateToPool(int id, const QString &designator, const QString &tactIdentifier);
|
|
|
|
public Q_SLOTS:
|
|
void onParticipantDataChanged(const Participant &data, DataModification modType);
|
|
void onParticipantOrganisationChanged(const ParticipantOrganisation &data, DataModification modType);
|
|
|
|
|
|
Q_SIGNALS:
|
|
void startUnitNamer(int);
|
|
void modifyParticipantData(const QVector<ParticipantData> &participantData, const QString &originatorMimeType);
|
|
|
|
private:
|
|
bool moveFromPartyToPool(int rootParticipantId, const QString &mimeType);
|
|
QVector<Participant> getSuperiorParticipants(int participantId);
|
|
bool convertFromParticipantTemplateToParticipantData(const ParticipantManagement::TemplateParticipant &inputParticipant, ParticipantManagement::ParticipantData &outPutData);
|
|
bool isValidTypeClass(int typeId) const;
|
|
void insertRow(const Participant &participant);
|
|
void tryRemoveParticipantFromModel(int participantId);
|
|
|
|
int poolPartyId() const { return m_asSupportService ? 1 : 0; }
|
|
|
|
private:
|
|
bool m_asSupportService;
|
|
QVector<ParticipantData> m_fullPoolData;
|
|
QVector<ParticipantData> m_dataToDelete;
|
|
QHash<int, ParticipantOrganisation> m_participantOrganization;
|
|
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtc;
|
|
|
|
NGL::INGLLogger &m_logger;
|
|
|
|
};
|
|
|
|
} //namespace ParticipantManagement
|
|
|