-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbcelltablemodel.cpp
More file actions
62 lines (49 loc) · 1.34 KB
/
Copy pathbcelltablemodel.cpp
File metadata and controls
62 lines (49 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "bcelltablemodel.h"
BCellTableModel::BCellTableModel(QObject *parent) : QAbstractTableModel(parent)
{
}
BCellTableModel::BCellTableModel(QList<QPair<QVariant, QVariant> > cells0, QObject *parent) : QAbstractTableModel(parent)
{
cells = cells0;
}
int BCellTableModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return 144;
}
int BCellTableModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return 2;
}
QVariant BCellTableModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (index.row() >= cells.size() || index.row() < 0)
return QVariant();
if (role == Qt::DisplayRole) {
QPair<QVariant, QVariant> pair = cells.at(index.row());
if (index.column() == 0)
return pair.first;
else if (index.column() == 1)
return pair.second;
}
return QVariant();
}
QVariant BCellTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role != Qt::DisplayRole)
return QVariant();
if (orientation == Qt::Horizontal) {
switch (section) {
case 0:
return tr("Voltage");
case 1:
return tr("Temperature");
default:
return QVariant();
}
}
return QVariant();
}