OGS
ColorTableModel.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <QAbstractTableModel>
18#include <QColor>
19
21
25class ColorTableModel : public QAbstractTableModel
26{
27 Q_OBJECT
28
29public:
30 explicit ColorTableModel(
31 const std::map<std::string, DataHolderLib::Color*>& colorLookupTable,
32 QObject* parent = nullptr);
33 ~ColorTableModel() override;
34
35 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
36
37 QVariant data(const QModelIndex& index, int role) const override;
38
39 int rowCount(const QModelIndex& parent = QModelIndex()) const override
40 {
41 Q_UNUSED (parent);
42 return _listOfPairs.size();
43 }
44
45 QVariant headerData(int section, Qt::Orientation orientation,
46 int role /*= Qt::DisplayRole*/) const override;
47
48private:
49 bool buildTable( const std::map<std::string, DataHolderLib::Color*> &colorLookupTable );
50
51 QList< QPair<QString, QColor> > _listOfPairs;
52};
Definition of the Color class.
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
QVariant data(const QModelIndex &index, int role) const override
ColorTableModel(const std::map< std::string, DataHolderLib::Color * > &colorLookupTable, QObject *parent=nullptr)
bool buildTable(const std::map< std::string, DataHolderLib::Color * > &colorLookupTable)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
~ColorTableModel() override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
QList< QPair< QString, QColor > > _listOfPairs