-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddform.cpp
64 lines (51 loc) · 1.49 KB
/
addform.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 "addform.h"
#include "ui_addform.h"
AddForm::AddForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::AddForm)
{
ui->setupUi(this);
ui->date_input->setDate(QDate::currentDate());
ui->time_input->setTime(QTime::currentTime());
}
AddForm::~AddForm()
{
delete ui;
}
void AddForm::on_add_button_clicked()
{
if(checkInput()) {
QList<QString> task = {ui->date_input->text(),
ui->time_input->text(),
ui->place_input->toPlainText(),
ui->task_input->toPlainText(),
ui->note_input->toPlainText()};
emit mySignal(task);
ui->date_input->setDate(QDate::currentDate());
ui->time_input->setTime(QTime::currentTime());
ui->place_input->setPlainText("");
ui->task_input->setPlainText("");
ui->note_input->setPlainText("");
}
}
bool AddForm::checkInput()
{
if(ui->date_input->date() < QDate::currentDate()) {
QMessageBox msgbox;
msgbox.critical(this, "Ошибка",
"Дата не может быть меньше нынешней!");
return false;
}
if(ui->task_input->toPlainText() == "")
{
QMessageBox msgbox;
msgbox.critical(this, "Ошибка",
"Поле задания пусто!");
return false;
}
return true;
}
void AddForm::on_back_button_clicked()
{
this->close();
}