-
Notifications
You must be signed in to change notification settings - Fork 0
/
addeventdialog.cpp
71 lines (65 loc) · 2.08 KB
/
addeventdialog.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
#include "addeventdialog.h"
#include "ui_addeventdialog.h"
addeventDialog::addeventDialog(QWidget *parent, bool p) :
QDialog(parent),
ui(new Ui::addeventDialog)
{
ui->setupUi(this);
setWindowIcon(QIcon("icon.png"));
QStringList List;
List << "08:05 - 09:40" //maybe read from file?
<< "09:50 - 11:25"
<< "11:45 - 13:20"
<< "13:30 - 15:05"
<< "15:15 - 16:50"
<< "17:00 - 18:35"
<< "18:45 - 20:20";
//TODO ADD IT IN DB ^
ui->listWidget->addItems(List);
m_addDialog = p;
if(p)
{
this->setWindowTitle(QString::fromLocal8Bit("Добавить событие"));
ui->timeEdit->setTime(QTime::currentTime());
ui->dateEdit->setDate(QDate::currentDate());
}
else
this->setWindowTitle(QString::fromLocal8Bit("Редактировать событие"));
connect(ui->listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(changeTime(QListWidgetItem*)));
}
addeventDialog::~addeventDialog()
{
delete ui;
}
void addeventDialog::on_buttonBox_accepted()
{
QString cabinet = ui->cabinetEdit->text();
QString date = ui->dateEdit->date().toString("dd.MM.yyyy");
QString time = ui->timeEdit->time().toString("hh:mm:ss");
QString inf = ui->notesEdit->document()->toPlainText();
if(m_addDialog)
emit addEventSignal(cabinet, date, time, inf);
else
emit editEventSignal(m_id, cabinet, date, time, inf);
}
void addeventDialog::setElements(quint8 id, QString cabinet, QString date, QString time, QString inf)
{
m_id = id;
ui->cabinetEdit->setText(cabinet);
ui->dateEdit->setDate(QDate::fromString(date, "dd.MM.yyyy"));
ui->timeEdit->setTime(QTime::fromString(time, "hh:mm:ss"));
ui->notesEdit->setText(inf);
}
void addeventDialog::changeTime(QListWidgetItem *item)
{
ui->timeEdit->setTime(QTime::fromString(item->text().left(5), "hh:mm"));
}
void addeventDialog::show()
{
if(m_addDialog)
{
ui->timeEdit->setTime(QTime::currentTime());
ui->dateEdit->setDate(QDate::currentDate());
}
QDialog::show();
}