-
Notifications
You must be signed in to change notification settings - Fork 36
/
customitems.cpp
50 lines (42 loc) · 1.2 KB
/
customitems.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
#include "customitems.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
void PlayerTimeTableItem::updateTime(float newTime)
{
this->time = newTime;
this->setTime();
}
void PlayerTimeTableItem::setTime()
{
QString res;
int days = qRound(this->time) / 60 / 60 / 24;
int hours = qRound(this->time) / 60 / 60 % 24;
int minutes = qRound(this->time) / 60 % 60;
int seconds = qRound(this->time) % 60;
if(days)
{
res.append(QString("%1%2").arg(QString::number(days), "d "));
}
if(hours)
{
res.append(QString("%1%2").arg(QString::number(hours), "h "));
}
if(minutes)
{
res.append(QString("%1%2").arg(QString::number(minutes), "m "));
}
res.append(QString("%1%2").arg(QString::number(seconds), "s"));
this->setText(res);
}
ServerTableIndexItem::ServerTableIndexItem(ServerInfo *info) : QTableWidgetItem()
{
this->serverInfo = info;
}
ServerTableIndexItem::ServerTableIndexItem(ServerInfo *info, QString text) : QTableWidgetItem(text)
{
this->serverInfo = info;
}
ServerTableIndexItem *MainWindow::GetServerTableIndexItem(size_t row)
{
return ((ServerTableIndexItem *)ui->browserTable->item(row, kBrowserColIndex));
}