-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresultstablemodel.cpp
84 lines (75 loc) · 1.83 KB
/
resultstablemodel.cpp
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "resultstablemodel.h"
ResultsTableModel::ResultsTableModel(QObject *parent) :
QAbstractTableModel(parent)
{
}
QVariant ResultsTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role != Qt::DisplayRole)
return QVariant();
if (orientation == Qt::Horizontal)
{
switch (section)
{
case 0:
return "Number";
case 1:
return "AVG(t1)";
case 2:
return "AVG(t2)";
case 3:
return "AVG(t1 + t2)";
case 4:
return "MT";
case 5:
return "DT";
default:
return QVariant();
}
}
return QVariant();
}
int ResultsTableModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return x1.size();
}
int ResultsTableModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return 6;
}
QVariant ResultsTableModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (index.row() >= x1.size() || index.row() < 0)
return QVariant();
if (role == Qt::DisplayRole) {
switch(index.column())
{
case 0:
return QString("%1").arg(index.row());
case 1:
return x1[index.row()];
case 2:
return x2[index.row()];
case 3:
return x3[index.row()];
case 4:
return mt[index.row()];
case 5:
return dt[index.row()];
}
}
return QVariant();
}
void ResultsTableModel::setData(QVector<double> &new_x1, QVector<double> &new_x2, QVector<double> &new_x3, QVector<double> &new_mt, QVector<double> &new_dt)
{
x1 = new_x1;
x2 = new_x2;
x3 = new_x3;
mt = new_mt;
dt = new_dt;
emit layoutChanged();
}