-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalarmdetails.cpp
80 lines (72 loc) · 2.22 KB
/
alarmdetails.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 "alarmdetails.h"
#include "ui_alarmdetails.h"
#include "alarmwizard.h"
#include "../../controlpanel/alarmdaemon.h"
AlarmDetails::AlarmDetails(QWidget *parent, Alarm *alarm) :
QWidget(parent),
_ui(new Ui::AlarmDetails),
_alarm(alarm)
{
_ui->setupUi(this);
if ( alarm == NULL )
{
this->close();
delete this;
}
_ui->detailBrowser->clear();
_ui->detailBrowser->append(alarm->getName());
_ui->detailBrowser->append("Time: " + alarm->getTime());
QString rep = "";
Weekdays days = alarm->getDays();
bool weekend = false, weekdays = false;
if ( days.monday && days.tuesday && days.wednesday && days.thursday && days.friday )
weekdays = true;
if ( days.saturday && days.sunday )
weekend = true;
if ( weekdays && weekend )
rep += "Everyday, ";
else if ( weekdays )
rep += "Weekdays, ";
else if ( weekend )
rep += "Weekend, ";
else
{
if ( days.monday )
rep += "Monday, ";
if ( days.tuesday )
rep += "Tuesday, ";
if ( days.wednesday )
rep += "Wednesday, ";
if ( days.thursday )
rep += "Thursday, ";
if ( days.friday )
rep += "Friday, ";
if ( days.saturday )
rep += "Saturday, ";
if ( days.sunday )
rep += "Sunday, ";
}
rep.chop(2);
_ui->detailBrowser->append("Repetitions: " + rep);
_ui->detailBrowser->append("Ringtone: " + alarm->getSource() );
_ui->detailBrowser->append("Snoozetime: " + QString::number(alarm->getSnoozeTime()) );
connect( _ui->editButton, SIGNAL(clicked()), this, SLOT(editAlarm()));
connect( _ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteAlarm()));
}
AlarmDetails::~AlarmDetails()
{
delete _ui;
}
void AlarmDetails::editAlarm()
{
AlarmWizard *wizard = new AlarmWizard(NULL, _alarm);
connect( wizard, SIGNAL(accepted()), this, SLOT(deleteLater()) );
connect( wizard, SIGNAL(rejected()), this, SLOT(deleteLater()) );
wizard->showFullScreen();
}
void AlarmDetails::deleteAlarm()
{
AlarmDaemon::getInstance().removeAlarm(_alarm);
this->close();
delete this;
}