-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventbox.cpp
62 lines (55 loc) · 2.12 KB
/
eventbox.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
#include "eventbox.h"
#include "ui_eventbox.h"
EventBox::EventBox(QString name, QString contributeurs, QTime m_debut, int m_signe, QTime m_fin, QString lieu, QString description) : debut(m_debut), signe(m_signe), fin(m_fin), began(false), finish(false), ui(new Ui::EventBox){
ui->setupUi(this);
ui->name->setTitle(name);
ui->contribs->setText(contributeurs);
ui->lieu->setText(lieu);
this->setToolTip(description);
if(signe == -1 && TimeCalcs::toMs(debut) > TimeCalcs::toMs(fin)){
ui->time->setText("-"+debut.toString());
ui->fin->setText("-" + TimeCalcs::addition(debut, fin, 1, -1).toString());
}
else if(signe == -1 && TimeCalcs::toMs(debut) == TimeCalcs::toMs(fin)){
ui->time->setText("-"+debut.toString());
ui->fin->setText(TimeCalcs::addition(debut, fin, 1, -1).toString());
}
else{
ui->time->setText(debut.toString());
ui->fin->setText(TimeCalcs::addition(fin, debut, 1, signe).toString());
}
ui->progression->setValue(0);
ui->progression->hide();
}
EventBox::~EventBox(){
delete ui;
}
void EventBox::setTime(QTime m_time){
time = m_time;
ui->time->setText(TimeCalcs::addition(debut, time, signe).toString());
ui->fin->setText(TimeCalcs::addition(TimeCalcs::addition(debut, time, signe), fin).toString());
reload();
}
void EventBox::reload(){
if(TimeCalcs::toMs(QTime::currentTime()) > TimeCalcs::toMs(TimeCalcs::addition(debut, time, signe))){
if(!began){
began = true;
emit begin();
ui->progression->show();
}
int avance = TimeCalcs::toMs(QTime::currentTime()) - TimeCalcs::toMs(TimeCalcs::addition(debut, time, signe));
if(avance > TimeCalcs::toMs(fin)){
ui->progression->setValue(100);
if(!finish){
finish=true;
emit finished();
}
}
else
ui->progression->setValue((avance*100)/TimeCalcs::toMs(fin));
}
}
void EventBox::mousePressEvent(QMouseEvent *a){
if(finish)
hide();
}