-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidget_template.cpp
More file actions
65 lines (50 loc) · 1.86 KB
/
Copy pathwidget_template.cpp
File metadata and controls
65 lines (50 loc) · 1.86 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
65
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QWidget>
#include <QCloseEvent>
#include <QStatusBar>
#include "widget_template.h"
widget_template::widget_template(Tache * tacheRacine,FirstWindow *fw, QWidget *parent) :
QWidget(parent)
{
firstW = fw;
root = tacheRacine;
QGridLayout * sauvGrid = new QGridLayout();
QLabel * nomFichier = new QLabel("Creer un type de tâche...");
nomFichierEdit = new QLineEdit();
QPushButton * ok = new QPushButton("Sauvegarder");
QPushButton * annuler = new QPushButton("Annuler");
sauvGrid->addWidget(nomFichier,0,0);
sauvGrid->addWidget(nomFichierEdit,1,0,1,3);
sauvGrid->addWidget(ok,2,2);
sauvGrid->addWidget(annuler,2,0);
this->setLayout(sauvGrid);
this->setWindowTitle("Creer un type de tache");
// centre le widget
this->setWindowFlags(Qt::Sheet | Qt::WindowStaysOnTopHint);
firstW->setDisabled(true);
QObject::connect(ok,SIGNAL(clicked()),this,SLOT(saveXml()));
QObject::connect(nomFichierEdit,SIGNAL(returnPressed()),this,SLOT(saveXml()));
QObject::connect(annuler,SIGNAL(clicked()),this,SLOT(close()));
QObject::connect(this,SIGNAL(WidgetClosed()),firstW,SLOT(resetDisable()));
}
widget_template::~widget_template()
{}
void widget_template::closeEvent(QCloseEvent *event)
{
emit WidgetClosed();
event->accept();
}
void widget_template::saveXml()
{
if(nomFichierEdit->text().toStdString()!=""){
root->setNom(nomFichierEdit->text().toStdString());
firstW->templates->addSousTache(root);
firstW->sauvegarderTemplates();
firstW->chargerXml("../Toudou/xml/templates.xml",firstW->templatesTree->invisibleRootItem(),firstW->templates);
firstW->statbar->showMessage("Le type de tache " +nomFichierEdit->text()+ " est maintenant disponible",3000);
}
this->close();
}