Files
qt5-legatus-legacy/Lts/Plugins/ParticipantManagement/Gui/Common/participant_icon_model_base.h
T
2026-08-13 18:33:10 +02:00

85 lines
2.2 KiB
C++
Executable File

/**
* @RDE_HEADER@
* A small helper class to provide icon rendering capabilities for NGLTreeModels
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Ehrlicher, SLSE, 2017-10-26
*/
#pragma once
#include <Plugins/ParticipantManagement/Gui/Common/ppmcommon_export.h>
#include <ParticipantManagement/ppm_dtc.h>
#include <nglwidgets/ngltreemodel.h>
#include <QColor>
#include <QSharedPointer>
namespace LtsSession
{
class LtsSessionDataDds;
}
namespace AdvancedSymbology
{
class ForeignDataInterface;
class SymbolResult;
enum class Role;
}
namespace NGL
{
class INGLLogger;
}
namespace ParticipantManagement
{
class PPMCOMMON_EXPORT ParticipantIconModelBase : public NGLTreeModel
{
Q_OBJECT
protected:
ParticipantIconModelBase(const std::shared_ptr<Interface::Dtc> &ppmDtc,
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface> &asbIfc,
const QStringList &hdr,
NGLTreeItem *rootItem,
QObject *parent,
NGL::INGLLogger &logger);
// type handling
ParticipantManagement::TypeClass typeClassIdFromTypeId(int typeId) const;
QString typeClassStringFromTypeId(int typeId) const;
bool isUnitType(int typeId) const;
// symbol handling
void tryRenderSymbol(const QString &symbol, NGLTreeItem *item);
void symbolRendered(AdvancedSymbology::SymbolResult *symbolResult);
bool updateIcon(const QModelIndex &currentIndex, NGLTreeItem *itemToUpdate, const QIcon &icon);
protected:
void onTypeChanged(const ParticipantManagement::Type &data, DataModification modType);
protected:
// misc
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtc;
// type handling
QHash<qint32, ParticipantManagement::Type> m_types;
// symbol handling
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> m_asb;
struct SymbolResultData
{
QSharedPointer<AdvancedSymbology::SymbolResult> result;
QVector<NGLTreeItem *> treeItems;
};
QHash<AdvancedSymbology::SymbolResult *, SymbolResultData> m_symbolResultMapping;
AdvancedSymbology::Role m_partyRole;
QColor m_partyColor;
NGL::INGLLogger &m_logger;
};
} // namespace ParticipantManagement