Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Helper class to provide symbol rendering in QAbstractItemModels
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2017-11-01
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <QColor>
|
||||
#include <QHash>
|
||||
#include <QIcon>
|
||||
#include <QSharedPointer>
|
||||
|
||||
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<AdvancedSymbology::ForeignDataInterface> &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<AdvancedSymbology::ForeignDataInterface> m_asb;
|
||||
struct SymbolResultData
|
||||
{
|
||||
QSharedPointer<AdvancedSymbology::SymbolResult> result;
|
||||
QVector<int> ids;
|
||||
};
|
||||
QHash<AdvancedSymbology::SymbolResult *, SymbolResultData> m_symbolResultMapping;
|
||||
Role m_partyRole;
|
||||
QColor m_partyColor;
|
||||
const int m_iconColumn;
|
||||
// participantId
|
||||
QHash<int, QIcon> m_symbols;
|
||||
QObject *m_super; // class which derives us, needed for proper con
|
||||
};
|
||||
|
||||
|
||||
} // namespace AdvancedSymbology
|
||||
Reference in new issue
Block a user