Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+106
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ParticipantManagement - Participant Organisation Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/ParticipantManagement/Gui/Common/participant_icon_model_base.h>
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QSet>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
//----------------------------------------------------------------------------
|
||||
class ParticipantOrgaModel final : public ParticipantIconModelBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
ColDescription,
|
||||
ColParticipantId
|
||||
};
|
||||
|
||||
enum class PartyOrganisationType
|
||||
{
|
||||
Party,
|
||||
Attached,
|
||||
Detached,
|
||||
Cooperate
|
||||
};
|
||||
|
||||
ParticipantOrgaModel(PartyOrganisationType orgType,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface> &asbIfc,
|
||||
QObject *parent);
|
||||
|
||||
QVector<ParticipantData> participantData(int partyId) const;
|
||||
QVector<int> rootParticipantIds() const;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
int columnCount(const QModelIndex &parent) const override;
|
||||
// We can only move Units around but not copy them here
|
||||
Qt::DropActions supportedDropActions() const override { return Qt::MoveAction; }
|
||||
Qt::DropActions supportedDragActions() const override { return Qt::MoveAction; }
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QStringList mimeTypes()const override;
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||
|
||||
void onReinitModel(int partyId);
|
||||
// for ProxyModel
|
||||
bool isParticipantType(int source_row, const QModelIndex &source_parent) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onParticipantOrganisationChanged(const ParticipantOrganisation &data, DataModification modType);
|
||||
|
||||
Q_SIGNALS:
|
||||
void participantDataChanged(int addedParticipantId);
|
||||
|
||||
private:
|
||||
void insertChildrenOf(int parentId,
|
||||
NGLTreeItem *parent, const QModelIndex &parentIdx,
|
||||
const QHash<int, QSet<int>> &parentId2id,
|
||||
const QHash<int, ParticipantData> &tmap);
|
||||
|
||||
QVector<Participant> inferiorParticipants(int partId) const;
|
||||
QVector<ParticipantData> getChildrenOf(NGLTreeItem *parentItem, int parentId, int hierarchyNumber, int &highestModId) const;
|
||||
|
||||
static QString headerFromOrganisationType(PartyOrganisationType orgType);
|
||||
bool isRootParticipantRelevant(const Participant &participant, int partyId) const;
|
||||
NGLTreeItem *createItem(const QVariant &data, const QIcon &icon) const override;
|
||||
|
||||
private:
|
||||
int m_partyId;
|
||||
PartyOrganisationType m_orgType;
|
||||
QHash<int, ParticipantOrganisation> m_participantOrganization;
|
||||
};
|
||||
|
||||
class ParticipantOrgaProxyModel final : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using QSortFilterProxyModel::QSortFilterProxyModel;
|
||||
|
||||
void onReinitModel(int partyId);
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||
|
||||
ParticipantOrgaModel *m_sourceModel;
|
||||
};
|
||||
|
||||
|
||||
} //namespace ParticipantManagement
|
||||
|
||||
Reference in new issue
Block a user