18 const std::map<std::string, DataHolderLib::Color*>& colorLookupTable,
29 const QModelIndex& parent )
const
39 if (role != Qt::DisplayRole)
44 if (orientation == Qt::Horizontal)
58 return QString(
"Row %1").arg(section);
69 if (index.row() >=
_listOfPairs.size() || index.row() < 0)
74 if (role == Qt::DisplayRole)
76 QPair<QString, QColor> pair =
_listOfPairs.at(index.row());
78 switch (index.column())
92 const std::map<std::string, DataHolderLib::Color*>& colorLookupTable)
95 beginInsertRows(QModelIndex(), 0, colorLookupTable.size() - 1);
97 for (
const auto& row : colorLookupTable)
99 QColor color((*row.second)[0], (*row.second)[1], (*row.second)[2]);
100 QString name(QString::fromStdString(row.first));
112 QPair<QString, QColor> pair(name, color);
Definition of the ColorTableModel 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)
~ColorTableModel() override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
QList< QPair< QString, QColor > > _listOfPairs