-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLapInformationProxyModel.cpp
More file actions
56 lines (46 loc) · 1.53 KB
/
LapInformationProxyModel.cpp
File metadata and controls
56 lines (46 loc) · 1.53 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
#include "LapInformationProxyModel.hpp"
LapInformationProxyModel::LapInformationProxyModel(QObject *parent) :
QIdentityProxyModel(parent)
{
}
LapInformationProxyModel::~LapInformationProxyModel(void)
{
}
QVariant LapInformationProxyModel::data(const QModelIndex &proxyIndex, int role) const
{
if (role == Qt::DisplayRole && proxyIndex.column() == 0)
{
int depth = 0;
QModelIndex parent = proxyIndex.parent();
for (depth = 0; parent.isValid(); depth++)
parent = parent.parent();
int num;
switch (depth) {
case 0:
num = this->sourceModel()->data(proxyIndex).toInt();
return QString("Course " + QString::number(num));
break;
case 1:
num = this->sourceModel()->data(proxyIndex).toInt();
return QString("Tour " + QString::number(num));
break;
default:;
}
}
else if (role == Qt::BackgroundColorRole && proxyIndex.row() % 2 != 0)
{
return QColor(220, 220, 220);
}
return QIdentityProxyModel::data(proxyIndex, role);
/*
if (role != Qt::BackgroundColorRole || proxyIndex.row() % 2 == 0)
return QIdentityProxyModel::data(proxyIndex, role);
return QColor(220, 220, 220);
*/
}
QVariant LapInformationProxyModel::headerData(int section,
Qt::Orientation orientation,
int role) const
{
return QIdentityProxyModel::headerData(section, orientation, role);
}