-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimulationInfoTableModel.cpp
More file actions
40 lines (34 loc) · 985 Bytes
/
SimulationInfoTableModel.cpp
File metadata and controls
40 lines (34 loc) · 985 Bytes
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
#include "SimulationInfoTableModel.h"
SimulationInfoTableModel::SimulationInfoTableModel(QObject* parent)
: QAbstractTableModel(parent)
{
}
int SimulationInfoTableModel::rowCount(const QModelIndex&) const
{
return displayData.size();
}
int SimulationInfoTableModel::columnCount(const QModelIndex&) const
{
return 2;
}
QVariant SimulationInfoTableModel::data(const QModelIndex& index, int role) const
{
switch (role) {
case Qt::ItemDataRole::ToolTipRole:
return displayData.at(index.row()).description;
case Qt::ItemDataRole::DisplayRole:
if (index.column() == NAME_COLUMN) {
return displayData.at(index.row()).name;
} else if (index.column() == VALUE_COLUMN) {
return displayData.at(index.row()).value;
}
break;
}
return {};
}
void SimulationInfoTableModel::UpdateAll(QVector<TableRow>&& newData)
{
beginResetModel();
displayData = std::move(newData);
endResetModel();
}