/** * @RDE_HEADER@ * Helper class to provide symbol rendering in QAbstractItemModels * $Id$ * $HeadURL$ * $Author$ * Created by Christian Ehrlicher, SLSE, 2017-11-01 */ #pragma once #include #include #include #include #include class QAbstractItemModel; class QModelIndex; class QVariant; namespace NGL { class INGLLogger; } namespace AdvancedSymbology { class SymbolResult; class ForeignDataInterface; enum class Role; class TableModelSymbolRendererBase { protected: explicit TableModelSymbolRendererBase(int iconColumn); virtual ~TableModelSymbolRendererBase() = default; void init(const std::shared_ptr &asb, QObject *super); void setDefaultRoleAndColor(const Role &role, const QColor &partyColor); QColor defaultColor() const { return m_partyColor; } Role defaultRole() const { return m_partyRole; } QVariant decorationData(const QModelIndex &idx, int id) const; QIcon decorationIcon(const QModelIndex &idx, int id) const; bool tryRenderSymbol(const QString &symbol, int id); bool tryRenderSymbol(const QString &symbol, int id, const QColor &color, Role role); void removeRenderedSymbol(int id); private: void symbolRendered(AdvancedSymbology::SymbolResult *sr); virtual NGL::INGLLogger &logger() const = 0; virtual QAbstractItemModel *model() = 0; virtual QModelIndex indexForId(int id, int column) = 0; private: std::shared_ptr m_asb; struct SymbolResultData { QSharedPointer result; QVector ids; }; QHash m_symbolResultMapping; Role m_partyRole; QColor m_partyColor; const int m_iconColumn; // participantId QHash m_symbols; QObject *m_super; // class which derives us, needed for proper con }; } // namespace AdvancedSymbology