structuresavingdialog.cpp 1.41 KB
Newer Older
1
2
3
4
#include "structuresavingdialog.hpp"
#include "ui_structuresavingdialog.h"

#include <QDate>
5
#include <QMessageBox>
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

StructureSavingDialog::StructureSavingDialog(QWidget *parent) :
      QDialog(parent),
      ui(new Ui::StructureSavingDialog)
{
    ui->setupUi(this);

    // récupérer le nom de l'utilisateur actuel
    QString name;
    name = qgetenv("USER"); // get the user name in Linux
    if (name.isEmpty())
        name = qgetenv("USERNAME"); // get the name in Windows

    ui->auteur->setText(name);
    ui->date->setDate(QDate::currentDate());
}

StructureSavingDialog::~StructureSavingDialog()
{
    delete ui;
}

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
void StructureSavingDialog::done(int r)
{
    if(QDialog::Accepted == r)  // ok was pressed
    {
        if(ui->nom->text().isEmpty())   // validate the data somehow
        {
            QMessageBox::information(this, "Erreur", "Le champ 'Titre' doit être rempli.");
            return;
        }
        else
        {
            QDialog::done(r);
            return;
        }
    }
    else    // cancel, close or exc was pressed
    {
        QDialog::done(r);
        return;
    }
}

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
QString StructureSavingDialog::auteur() const
{
    return ui->auteur->text();
}

QString StructureSavingDialog::titre() const
{
    return ui->nom->text();
}

QString StructureSavingDialog::desc() const
{
    return ui->desc->toPlainText();
}

QDate StructureSavingDialog::date() const
{
    return ui->date->date();
}