-
Notifications
You must be signed in to change notification settings - Fork 0
/
round.cpp
80 lines (68 loc) · 1.71 KB
/
round.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
#include "round.h"
Round::Round(TournamentsItem *parent,int number):
TournamentsItem(parent,ItemType::Round),
number(number)
{
}
QVariant Round::data(int role) const
{
switch(static_cast<RoundRoles>(role)){
case RoundRoles::NumberRole:
return number;
case RoundRoles::DateRole:
return date;
case RoundRoles::DescriptionRole:
return description;
}
return QVariant();
}
TournamentsItem *Round::child(int position) const
{
return static_cast<TournamentsItem*>(matches.at(position));
}
int Round::childCount() const
{
return matches.size();
}
int Round::columnCount() const
{
}
bool Round::addChild(TournamentsItem *match)
{
if(match->tourType != TournamentsItem::ItemType::Match){return false;}
matches.append(static_cast<Match*>(match));
return true;
}
int Round::position(TournamentsItem *item)
{
if(item->tourType != TournamentsItem::ItemType::Match){return -1;}
return matches.indexOf(static_cast<Match *>(item));
}
int Round::position(int id)
{
for(int i=0;i<matches.size();++i){
if(matches.at(i)->id == id){
return i;
}
}
return -1;
}
bool Round::setData(int role, const QVariant &value)
{
switch (static_cast<RoundRoles>(role)) {
case RoundRoles::DateRole:
if(date == value.toString()){return false;}
date = value.toString();
return true;
case RoundRoles::DescriptionRole:
if(description == value.toString()){return false;}
description = value.toString();
return true;
case RoundRoles::NumberRole:
if(number == value.toInt()){return false;}
number = value.toInt();
return true;
default:
return false;
}
}