The PolylinesModel is a Qt model which represents Polylines.
Definition at line 25 of file ColorTableModel.h.
#include <ColorTableModel.h>
|
| ColorTableModel (const std::map< std::string, DataHolderLib::Color * > &colorLookupTable, QObject *parent=nullptr) |
|
| ~ColorTableModel () override |
|
int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
|
QVariant | data (const QModelIndex &index, int role) const override |
|
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
|
QVariant | headerData (int section, Qt::Orientation orientation, int role) const override |
|
◆ ColorTableModel()
ColorTableModel::ColorTableModel |
( |
const std::map< std::string, DataHolderLib::Color * > & | colorLookupTable, |
|
|
QObject * | parent = nullptr ) |
|
explicit |
Definition at line 17 of file ColorTableModel.cpp.
20{
21 Q_UNUSED(parent)
22
24}
bool buildTable(const std::map< std::string, DataHolderLib::Color * > &colorLookupTable)
References buildTable().
◆ ~ColorTableModel()
ColorTableModel::~ColorTableModel |
( |
| ) |
|
|
overridedefault |
◆ buildTable()
bool ColorTableModel::buildTable |
( |
const std::map< std::string, DataHolderLib::Color * > & | colorLookupTable | ) |
|
|
private |
Definition at line 91 of file ColorTableModel.cpp.
93{
94 int count = 0;
95 beginInsertRows(QModelIndex(), 0, colorLookupTable.size() - 1);
96
97 for (const auto& row : colorLookupTable)
98 {
99 QColor color((*row.second)[0], (*row.second)[1], (*row.second)[2]);
100 QString
name(QString::fromStdString(row.first));
101
102
103
104
105
106
107
108
109
110
111
112 QPair<QString, QColor> pair(name, color);
114 }
115
116 endInsertRows();
117 return true;
118}
QList< QPair< QString, QColor > > _listOfPairs
References _listOfPairs.
Referenced by ColorTableModel().
◆ columnCount()
int ColorTableModel::columnCount |
( |
const QModelIndex & | parent = QModelIndex() | ) |
const |
|
override |
◆ data()
QVariant ColorTableModel::data |
( |
const QModelIndex & | index, |
|
|
int | role ) const |
|
override |
Definition at line 62 of file ColorTableModel.cpp.
63{
64 if (!index.isValid())
65 {
66 return QVariant();
67 }
68
69 if (index.row() >=
_listOfPairs.size() || index.row() < 0)
70 {
71 return QVariant();
72 }
73
74 if (role == Qt::DisplayRole)
75 {
76 QPair<QString, QColor> pair =
_listOfPairs.at(index.row());
77
78 switch (index.column())
79 {
80 case 0:
81 return pair.first;
82 case 1:
83 return pair.second;
84 default:
85 return QVariant();
86 }
87 }
88 return QVariant();
89}
References _listOfPairs.
◆ headerData()
QVariant ColorTableModel::headerData |
( |
int | section, |
|
|
Qt::Orientation | orientation, |
|
|
int | role ) const |
|
override |
Definition at line 36 of file ColorTableModel.cpp.
38{
39 if (role != Qt::DisplayRole)
40 {
41 return QVariant();
42 }
43
44 if (orientation == Qt::Horizontal)
45 {
46 switch (section)
47 {
48 case 0:
49 return "Name";
50 case 1:
51 return "Colour";
52 default:
53 return QVariant();
54 }
55 }
56 else
57 {
58 return QString("Row %1").arg(section);
59 }
60}
◆ rowCount()
int ColorTableModel::rowCount |
( |
const QModelIndex & | parent = QModelIndex() | ) |
const |
|
inlineoverride |
◆ _listOfPairs
QList< QPair<QString, QColor> > ColorTableModel::_listOfPairs |
|
private |
The documentation for this class was generated from the following files: