The PolylinesModel is a Qt model which represents Polylines.
Definition at line 14 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 6 of file ColorTableModel.cpp.
9{
10 Q_UNUSED(parent)
11
13}
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 80 of file ColorTableModel.cpp.
82{
83 int count = 0;
84 beginInsertRows(QModelIndex(), 0, colorLookupTable.size() - 1);
85
86 for (const auto& row : colorLookupTable)
87 {
88 QColor color((*row.second)[0], (*row.second)[1], (*row.second)[2]);
89 QString
name(QString::fromStdString(row.first));
90
91
92
93
94
95
96
97
98
99
100
101 QPair<QString, QColor> pair(name, color);
103 }
104
105 endInsertRows();
106 return true;
107}
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 51 of file ColorTableModel.cpp.
52{
53 if (!index.isValid())
54 {
55 return QVariant();
56 }
57
58 if (index.row() >=
_listOfPairs.size() || index.row() < 0)
59 {
60 return QVariant();
61 }
62
63 if (role == Qt::DisplayRole)
64 {
65 QPair<QString, QColor> pair =
_listOfPairs.at(index.row());
66
67 switch (index.column())
68 {
69 case 0:
70 return pair.first;
71 case 1:
72 return pair.second;
73 default:
74 return QVariant();
75 }
76 }
77 return QVariant();
78}
References _listOfPairs.
◆ headerData()
| QVariant ColorTableModel::headerData |
( |
int | section, |
|
|
Qt::Orientation | orientation, |
|
|
int | role ) const |
|
override |
Definition at line 25 of file ColorTableModel.cpp.
27{
28 if (role != Qt::DisplayRole)
29 {
30 return QVariant();
31 }
32
33 if (orientation == Qt::Horizontal)
34 {
35 switch (section)
36 {
37 case 0:
38 return "Name";
39 case 1:
40 return "Colour";
41 default:
42 return QVariant();
43 }
44 }
45 else
46 {
47 return QString("Row %1").arg(section);
48 }
49}
◆ 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: