This repository was archived by the owner on Aug 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodifiernote.cpp
More file actions
64 lines (58 loc) · 1.43 KB
/
modifiernote.cpp
File metadata and controls
64 lines (58 loc) · 1.43 KB
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
#include "modifiernote.h"
#include "ui_modifiernote.h"
ModifierNote::ModifierNote(QWidget *parent) :
QDialog(parent),
ui(new Ui::ModifierNote),
b(0),note(NULL)
{
ui->setupUi(this);
this->connect();
}
ModifierNote::ModifierNote(Note& n, QWidget *parent) :
QDialog(parent), note(&n), b(1),
ui(new Ui::ModifierNote)
{
ui->setupUi(this);
ui->Nom->setText(note->getNote());
ui->Nom->setDisabled(1);
ui->Description->setText(note->getDescription());
ui->Eliminatoire->setValue(note->getEliminatoire());
ui->Rang->setValue(note->getRang());
ui->Eliminatoire->setDisabled(1);
this->connect();
}
void ModifierNote::connect()
{
QObject::connect(ui->Valider, SIGNAL(clicked()), this, SLOT(ok()) );
QObject::connect(ui->Annuler, SIGNAL(clicked()), this, SLOT(cancel()) );
ui->Eliminatoire->setRange(0,2);
}
void ModifierNote::ok()
{
try
{
if(b)
{
note->setDescription(ui->Description->toPlainText());
note->setRang(ui->Rang->value());
}
else
{
note=new Note(ui->Nom->text(), ui->Description->toPlainText(), ui->Rang->value(), ui->Eliminatoire->value());
delete note;
}
this->close();
}
catch(std::exception& e)
{
QMessageBox::warning(this, "Erreur", e.what());
}
}
void ModifierNote::cancel()
{
this->close();
}
ModifierNote::~ModifierNote()
{
delete ui;
}