-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathracetablewidget.cpp
More file actions
76 lines (58 loc) · 3.05 KB
/
racetablewidget.cpp
File metadata and controls
76 lines (58 loc) · 3.05 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* OpenRaceLapTimer - Copyright 2015 by airbirds.de, a project of polyvision UG (haftungsbeschränkt)
*
* Author: Alexander B. Bierbrauer
*
* This file is part of OpenRaceLapTimer.
*
* OpenRaceLapTimer is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* OpenRaceLapTimer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with Foobar. If not, see http://www.gnu.org/licenses/.
**/
#include "racetablewidget.h"
#include <QVBoxLayout>
#include <QTableWidget>
#include "rltdatabase.h"
#include "modelrace.h"
#include <QDebug>
#include <QPushButton>
RaceTableWidget::RaceTableWidget(QWidget *parent) : QWidget(parent)
{
m_pLayout= new QVBoxLayout(this);
m_pTableRaces = new QTableWidget(this);
m_pLayout->addWidget(m_pTableRaces);
m_pTableRaces->setColumnCount(5);
//this->ui->tableWidget->setRowCount(CurrentRace::instance()->getPilotsList()->size());
m_pTableRaces->setHorizontalHeaderItem(0,new QTableWidgetItem("name"));
m_pTableRaces->setHorizontalHeaderItem(1,new QTableWidgetItem("created at"));
m_pTableRaces->setHorizontalHeaderItem(2,new QTableWidgetItem("num pilots"));
m_pTableRaces->setHorizontalHeaderItem(3,new QTableWidgetItem("fastest lap"));
m_pTableRaces->setHorizontalHeaderItem(4,new QTableWidgetItem("fastest pilot"));
m_pButtonStartRace = new QPushButton();
m_pButtonStartRace->setText("start a new race");
this->m_pLayout->addWidget(m_pButtonStartRace);
this->updateTable();
connect(m_pButtonStartRace,SIGNAL(clicked(bool)),this,SLOT(startButtonClicked(bool)));
// pilot name
}
void RaceTableWidget::updateTable(){
QList<ModelRace*> list = RLTDatabase::instance()->getRaces();
m_pTableRaces->clearContents();
m_pTableRaces->setRowCount(list.size());
for(int i = 0; i < list.size(); i++){
ModelRace *model = list.at(i);
QTableWidgetItem *itemPilotName = new QTableWidgetItem(model->getName());
m_pTableRaces->setItem(i,0,itemPilotName);
QTableWidgetItem *itemCreatedAt = new QTableWidgetItem(model->getCreatedAt().toString());
m_pTableRaces->setItem(i,1,itemCreatedAt);
QTableWidgetItem *itemNumPilots = new QTableWidgetItem(QString("%1").arg(model->getNumPilots()));
m_pTableRaces->setItem(i,2,itemNumPilots);
QTableWidgetItem *itemFastestLapTime = new QTableWidgetItem(model->getFormatedFastedLapTime());
m_pTableRaces->setItem(i,3,itemFastestLapTime);
QTableWidgetItem *itemFastestLapTimePilot = new QTableWidgetItem(model->getFastestPilotName());
m_pTableRaces->setItem(i,4,itemFastestLapTimePilot);
}
}
void RaceTableWidget::startButtonClicked(bool){
emit signalStartRace();
}