An error occurred while loading the file. Please try again.
-
Henry Gerard authored782ffbb4
#include <MainWindow.h>
void MainWindow::inputDataSet()
{
if (objectName() != "inputData")
{
// We ask the user to give us an user name
QString userName("");
userName = QInputDialog::getText(NULL, "Nom d'utilisateur", "Dis moi quel est ton nom");
if (userName != "")
{
// we remove forbidden characters from userName
userName.remove("/");
userName.remove("\\");
userName.remove(":");
userName.remove("*");
userName.remove("?");
userName.remove("\"");
userName.remove("<");
userName.remove(">");
userName.remove("|");
// then the name of the authors of the datas
QString dataAuthor("");
dataAuthor = QInputDialog::getText(NULL, "Nom des auteurs", "Maintenant il me faut le nom des auteurs des mesures");
dataAuthor.remove("\n");
dataAuthor.remove("\t");
// then we need to have a date for the campaign
bool *dateSet;
dateSet = new bool(false);
QDate measureDate(DialogueDate::getDate(NULL, QString("Date de mesure"),QString("Il me faut la date de la campagne de mesure"), QDate::currentDate(), dateSet));
if (*dateSet)
{
QList<QVariant> datas;
datas.append(QVariant(userName));
datas.append(QVariant(dataAuthor));
datas.append(QVariant(measureDate));
userData = QVariant(datas);
// We save the database
QString folderName;
folderName = QString("%1-%2.BM").arg(QDateTime::currentDateTime().toString("dd.MM.yyyy.hh.mm.ss.zzz")).arg(userName);
QDir originDir("bin"), targetDir("historic");
targetDir.mkdir(folderName);
targetDir.cd(folderName);
QStringList fileList;
fileList = originDir.entryList(QStringList(), QDir::Files);
for (QStringList::iterator it(fileList.begin()); it != fileList.end(); it++)
{
QFile::copy(QString("bin/%1").arg(*it), QString("%1/%2").arg(targetDir.path()).arg(*it));
}
originDir.cd("dictionary");
targetDir.mkdir("dictionary");
targetDir.cd("dictionary");
fileList = originDir.entryList(QStringList(), QDir::Files);
for (QStringList::iterator it(fileList.begin()); it != fileList.end(); it++)
{
QFile::copy(QString("bin/dictionary/%1").arg(*it), QString("%1/%2").arg(targetDir.path()).arg(*it));
}
// Empty mainLayout
while(mainLayout->count() > 0){
QLayoutItem *item = mainLayout->takeAt(0);
delete item->widget();
delete item;
}
delete mainLayout;
mainLayout = new QGridLayout;
setLayout(mainLayout);
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
// 5 buttons to create
QPushButton *controlLabel = new QPushButton;
QPushButton *rainExclusionLabel = new QPushButton;
QPushButton *lightExclusionLabel = new QPushButton;
QPushButton *irrigationLabel = new QPushButton;
QPushButton *backButton = new QPushButton;
QPushButton *backTo0 = new QPushButton;
// Labels for the buttons
controlLabel->setText("Témoin");
rainExclusionLabel->setText("Exclusion");
lightExclusionLabel->setText("Renversé");
irrigationLabel->setText("Irrigation");
backButton->setText("Retour à la fenêtre précédente");
backTo0->setText("Retour à la fenêtre principale");
controlLabel->setFlat(true);
rainExclusionLabel->setFlat(true);
lightExclusionLabel->setFlat(true);
irrigationLabel->setFlat(true);
// 4 plots button need to have a name
controlLabel->setObjectName("Témoin");
rainExclusionLabel->setObjectName("Exclusion");
lightExclusionLabel->setObjectName("Renversé");
irrigationLabel->setObjectName("Irrigation");
// Connect slots to signals clicked
QObject::connect(controlLabel, SIGNAL(clicked()), this, SLOT(inputData()));
QObject::connect(rainExclusionLabel, SIGNAL(clicked()), this, SLOT(inputData()));
QObject::connect(lightExclusionLabel, SIGNAL(clicked()), this, SLOT(inputData()));
QObject::connect(irrigationLabel, SIGNAL(clicked()), this, SLOT(inputData()));
QObject::connect(backButton, SIGNAL(clicked()), this, SLOT(saveDataContext()));
QObject::connect(backTo0, SIGNAL(clicked()), this, SLOT(backTo0Slot()));
//Display buttons into the mainLayout
mainLayout->addWidget(controlLabel, 0, 0);
mainLayout->addWidget(rainExclusionLabel, 1, 0);
mainLayout->addWidget(lightExclusionLabel, 0, 1);
mainLayout->addWidget(irrigationLabel, 1, 1);
mainLayout->addWidget(backButton, 2, 0, 1, 2);
mainLayout->addWidget(backTo0, 3, 0, 1, 2);
setObjectName("inputDataSet");
}
}
}else{
// Empty mainLayout
while(mainLayout->count() > 0){
QLayoutItem *item = mainLayout->takeAt(0);
delete item->widget();
delete item;
}
delete mainLayout;
mainLayout = new QGridLayout;
setLayout(mainLayout);
// 5 buttons to create
QPushButton *controlLabel = new QPushButton;
QPushButton *rainExclusionLabel = new QPushButton;
QPushButton *lightExclusionLabel = new QPushButton;
QPushButton *irrigationLabel = new QPushButton;
QPushButton *backButton = new QPushButton;
QPushButton *backTo0 = new QPushButton;
// Labels for the buttons
controlLabel->setText("Témoin");
rainExclusionLabel->setText("Exclusion");
lightExclusionLabel->setText("Renversé");
irrigationLabel->setText("Irrigation");
backButton->setText("Retour à la fenêtre précédente");
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
backTo0->setText("Retour à la fenêtre principale");
controlLabel->setFlat(true);
rainExclusionLabel->setFlat(true);
lightExclusionLabel->setFlat(true);
irrigationLabel->setFlat(true);
// 4 plots button need to have a name
controlLabel->setObjectName("Témoin");
rainExclusionLabel->setObjectName("Exclusion");
lightExclusionLabel->setObjectName("Renversé");
irrigationLabel->setObjectName("Irrigation");
// Connect slots to signals clicked
QObject::connect(controlLabel, SIGNAL(clicked()), this, SLOT(inputData()));
QObject::connect(rainExclusionLabel, SIGNAL(clicked()), this, SLOT(inputData()));
QObject::connect(lightExclusionLabel, SIGNAL(clicked()), this, SLOT(inputData()));
QObject::connect(irrigationLabel, SIGNAL(clicked()), this, SLOT(inputData()));
QObject::connect(backButton, SIGNAL(clicked()), this, SLOT(saveDataContext()));
QObject::connect(backTo0, SIGNAL(clicked()), this, SLOT(backTo0Slot()));
//Display buttons into the mainLayout
mainLayout->addWidget(controlLabel, 0, 0);
mainLayout->addWidget(rainExclusionLabel, 1, 0);
mainLayout->addWidget(lightExclusionLabel, 0, 1);
mainLayout->addWidget(irrigationLabel, 1, 1);
mainLayout->addWidget(backButton, 2, 0, 1, 2);
mainLayout->addWidget(backTo0, 3, 0, 1, 2);
setObjectName("inputDataSet");
}
}