Commit 782ffbb4 authored by Henry Gerard's avatar Henry Gerard
Browse files

Initial commit

parents
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.dylib
# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
Makefile*
*build-*
# Qt unit tests
target_wrapper.*
# QtCreator
*.autosave
# QtCtreator Qml
*.qmlproject.user
*.qmlproject.user.*
# QtCtreator CMake
CMakeLists.txt.user*
#include "MainWindow.h"
MainWindow::MainWindow(QString* line)
{
// 3 buttons when created
QPushButton *button0 = new QPushButton("Consulter/Exporter les données");
QPushButton *button1 = new QPushButton("Enregistrer des données");
QPushButton *button2 = new QPushButton("Modifier la base de données");
QPushButton *button3 = new QPushButton("Charger la saisie de terrain");
state = line;
setObjectName("MainWindow");
// Add buttons to the mainLayout
mainLayout = new QGridLayout;
mainLayout -> addWidget(button0, 0, 0);
mainLayout -> addWidget(button1, 0, 1);
mainLayout -> addWidget(button2, 0, 2);
mainLayout -> addWidget(button3, 0, 3);
// Hide buttons in case of state different than 0
if (*state != "0")
{
if (*state != "4")
{
button1->hide();
}
button2->hide();
if (*state != "3")
{
button3->hide();
}
}else{
QFile stateFile("state");
stateFile.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream in(&stateFile);
in << 1;
stateFile.close();
button3->hide();
}
// Connexion slots to button clicks
QObject::connect(button0, SIGNAL(clicked()), this, SLOT(consultOrExportData()));
QObject::connect(button1, SIGNAL(clicked()), this, SLOT(saveDataContext()));
QObject::connect(button2, SIGNAL(clicked()), this, SLOT(modifiesDataBase()));
QObject::connect(button3, SIGNAL(clicked()), this, SLOT(loadBoardInput()));
// Show the mainLayout
setLayout(mainLayout);
setObjectName("MainWindow");
}
void MainWindow::closeEvent(QCloseEvent* event)
{
if (*state == "0")
{
QFile stateFile("state");
stateFile.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream in(&stateFile);
in << 0;
stateFile.close();
}else if (*state == "3")
{
QFile stateFile("state");
stateFile.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream in(&stateFile);
in << 3;
stateFile.close();
}else if (*state == "4")
{
QFile stateFile("state");
stateFile.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream in(&stateFile);
in << 4;
stateFile.close();
}
event->accept();
}
MainWindow::~MainWindow()
{
while(mainLayout->count() > 0){
QLayoutItem *item = mainLayout->takeAt(0);
delete item->widget();
delete item;
}
//delete mainLayout;
//delete state;
}
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWidget>
#include <QGridLayout>
#include <QPushButton>
#include <QFile>
#include <QTextStream>
#include <QCloseEvent>
#include <QString>
#include <QLabel>
#include <QTableView>
#include <QStringList>
#include <QMessageBox>
#include <QMap>
#include <QTableWidget>
#include <QTableWidgetItem>
#include <QList>
#include <QHeaderView>
#include <Qt>
#include <QPair>
#include <QDate>
#include <QVariant>
#include <QComboBox>
#include <QFileDialog>
#include <QTextEdit>
#include <QLineEdit>
#include <QDateEdit>
#include <QInputDialog>
#include <dialogdate.h>
#include <QDateTime>
#include <QDir>
#include <QRegExp>
#include <QRegExpValidator>
#include <QValidator>
#include <addaxisclass.h>
#include <QFont>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QColor>
#include <QPalette>
#include <QHeaderView>
#include <QKeyEvent>
#include <QShortcut>
#include <newstatus.h>
#include <focuschangepolicy.h>
#include <QApplication>
#include <changeparameterclass.h>
class MainWindow : public QWidget
{
Q_OBJECT
public:
MainWindow(QString* line);
~MainWindow();
private slots:
void consultOrExportData();
void backTo0Slot();
void consultData();
void whoClickedMe();
void backToConsultOrExport();
void expandDataConsult(int a, int b);
void changeDateDataConsult(int index);
void exportDatasSlot();
void exportAllSlot();
void exportFinalSlot();
void prepareCampaignSlot();
void saveDataContext();
void inputDataSet();
void boardInputSet();
void inputData();
void expandDataInput(int a, int b);
void addComment();
void deleteComment(int a, int b);
void addAxis();
void updateCommentAndModifyMeasure(int a, int b);
void changeComment(int a);
void checkValue(int a);
void checkValue(double a);
void checkValue(QString a);
void modifiesInputTable(int a, int b);
void modifiesInputTable(int b);
void modifiesInputTable();
void modifiesStatus();
void saveRecord();
void modifiesDataBase();
void modifiesDatas();
void changeAxisCharacteristics();
void addParameter();
void loadPreviousDatas();
void modifiesDataPlot();
void deleteRow();
void moveUp();
void moveRight();
void moveDown();
void moveLeft();
void eraseContent();
void loadBoardInput();
void loadDatas();
void changeLocalisationParameter(int a);
void changeTypeParameter(int a);
void addParameterSlot();
void changeCharacteristics();
void expandModifiesData(int a, int b);
void deleteMeasure();
void modifiesValueData(int a, int b);
void expandchangeCharacteristics(int a, int b);
void newParameter();
void deleteParameter(int a, int b);
void updateCommentConsult(int a, int b);
private:
QGridLayout *mainLayout;
QString *state;
void urgentStop();
QVariant userData;
protected:
void closeEvent(QCloseEvent* event);
};
#endif // MAINWINDOW_H
#include <MainWindow.h>
void MainWindow::addAxis()
{
QList<QVariant> axisProperties;
int plotCode;
plotCode = qobject_cast<QComboBox *>(mainLayout->itemAtPosition(2, 2)->widget())->itemData(0).toInt();
axisProperties = addAxisClass::addAxis(NULL, "Nouvel axe", plotCode);
QTableWidget *tab;
tab = qobject_cast<QTableWidget*>(mainLayout->itemAtPosition(2, 0)->widget());
tab->setSortingEnabled(false);
if (axisProperties.size() > 0)
{
tab->insertRow(0);
QTableWidgetItem *cell;
cell = new QTableWidgetItem;
cell->setData(Qt::UserRole, axisProperties);
if (axisProperties.size() > 11) cell->setText(axisProperties.at(11).toString());
cell->setFlags(cell->flags() & ~ Qt::ItemIsEditable);
tab->setItem(0, 0, cell);
cell = new QTableWidgetItem;
cell->setData(Qt::UserRole, axisProperties);
if (axisProperties.size() > 12) cell->setText(axisProperties.at(12).toString());
cell->setFlags(cell->flags() & ~ Qt::ItemIsEditable);
tab->setItem(0, 1, cell);
cell = new QTableWidgetItem;
cell->setData(Qt::UserRole, axisProperties);
cell->setText("0");
cell->setFlags(cell->flags() & ~ Qt::ItemIsEditable);
tab->setItem(0, 2, cell);
cell = new QTableWidgetItem;
cell->setData(Qt::UserRole, axisProperties);
cell->setText("0");
cell->setFlags(cell->flags() & ~ Qt::ItemIsEditable);
tab->setItem(0, 3, cell);
cell = new QTableWidgetItem;
cell->setData(Qt::UserRole, axisProperties);
cell->setText("00/00/0000");
cell->setFlags(cell->flags() & ~ Qt::ItemIsEditable);
tab->setItem(0, 4, cell);
cell = new QTableWidgetItem;
cell->setData(Qt::UserRole, axisProperties);
cell->setText("00/00/0000");
cell->setFlags(cell->flags() & ~ Qt::ItemIsEditable);
tab->setItem(0, 5, cell);
}
tab->setSortingEnabled(true);
}
This diff is collapsed.
#ifndef ADDAXISCLASS
#define ADDAXISCLASS
#include <QDialog>
#include <QComboBox>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QGridLayout>
#include <QList>
#include <QVariant>
#include <QFile>
#include <QMessageBox>
#include <QTextStream>
#include <QMap>
#include <QStringList>
#include <QString>
#include <QRegExp>
#include <QValidator>
#include <QInputDialog>
#include <QDate>
class addAxisClass : public QDialog
{
Q_OBJECT
public:
addAxisClass(int plot);
static QList<QVariant> addAxis(QWidget *parent, QString title, int plot);
void setTitle(QString title);
int getAxisCode();
QString getAxisName();
QString getStatusName();
int getTreeCode();
int getPosCode();
int getExpCode();
int getDomCode();
QString getNRam();
int getStatCode();
private:
void urgentStop();
public slots:
void changeName(QString a);
void validation();
private:
QComboBox *tree;
QComboBox *position;
QComboBox *exposition;
QComboBox *dominance;
QLineEdit *axisNumber;
QLabel *axisName;
QPushButton *validate;
QList<QString> axisNames;
int plotCode;
int axisCode;
QString statusName;
int treeCode;
int posCode;
int expCode;
int domCode;
QString nRam;
int statCode;
};
#endif // ADDAXISCLASS
#include <MainWindow.h>
void MainWindow::addComment()
{
QComboBox *levelCB;
QTextEdit *commentTE;
QLineEdit *authorLE;
QDateEdit *dateDE;
QList<QVariant> datas(userData.toList());
levelCB = qobject_cast<QComboBox *>(mainLayout->itemAtPosition(2, 2)->widget());
commentTE = qobject_cast<QTextEdit *>(mainLayout->itemAtPosition(3, 2)->widget());
authorLE = qobject_cast<QLineEdit *>(mainLayout->itemAtPosition(4, 2)->widget());
dateDE = qobject_cast<QDateEdit *>(mainLayout->itemAtPosition(5, 2)->widget());
QString commentText;
commentText = commentTE->toPlainText();
if ((levelCB->currentIndex() != -1) && (commentText != "") && (dateDE->hasAcceptableInput()))
{
commentText.remove("\t");
commentText.remove("\n");
QFile commentFile("bin/comment");
QString line;
int countLine(0);
QStringList dataRow;
QMap<int, QString> commentPosition;
QList<int> commentId;
int Id(-1);
if (!commentFile.open(QIODevice::ReadWrite | QIODevice::Text))
{
// Error
QMessageBox::critical(NULL, "Erreur", "Le programme n'a pas réussi à lire le fichier de données : bin/comment.");
urgentStop();
return;
}else{
QTextStream commentStream(&commentFile);
line = commentStream.readLine();
if (line != "###")
{
// Error
QMessageBox::critical(NULL, "Erreur", "Une erreur est survenue à la lecture de la première ligne du fichier : bin/comment\nMauvaise entête (\"###\" attendu)");
urgentStop();
return;
}else{
line = "";
while (!commentStream.atEnd() && line != "###")
{
line = commentStream.readLine();
commentPosition.insert(countLine, line.split("\t").at(0));
countLine++;
}
while(!commentStream.atEnd())
{
dataRow = commentStream.readLine().split("\t");
Id = dataRow.at(0).toInt();
commentId.append(Id);
}
qSort(commentId.begin(), commentId.end());
if (Id != -1)
{
Id = commentId.last() + 1;
}else{
Id = 0;
}
commentStream << Id;
for (QMap<int, QString>::iterator it(commentPosition.begin()); it != (commentPosition.end()); it++)
{
if (it.value() == "Level")
{
commentStream << "\t" << levelCB->currentIndex();
}else if (it.value() == "IdLev")
{
commentStream << "\t" << levelCB->itemData(levelCB->currentIndex()).toString();
}else if (it.value() == "DateC")
{
commentStream << "\t" << dateDE->date().toString("yyyy.MM.dd");
}else if (it.value() == "Comment")
{
commentStream << "\t" << commentText;
}else if (it.value() == "AuthorC")
{
commentStream << "\t" << authorLE->text();
}else if ((it.value() != "IdC") && (it.value() != "###"))
{
commentStream << "\t";
}
}
commentStream << "\n";
}
QTableWidget * commentTable(qobject_cast<QTableWidget *>(mainLayout->itemAtPosition(7, 1)->widget()));
QTableWidgetItem *cell;
int row(commentTable->rowCount());
commentTable->insertRow(row);
cell = new QTableWidgetItem;
cell->setText(dateDE->date().toString("dd-MM-yyyy"));
cell->setFlags(cell->flags() & ~ Qt::ItemIsEditable);
cell->setData(Qt::UserRole, QVariant(Id));
commentTable->setItem(row, 0, cell);
cell = new QTableWidgetItem;
cell->setText(authorLE->text());
cell->setFlags(cell->flags() & ~ Qt::ItemIsEditable);
cell->setData(Qt::UserRole, QVariant(Id));
commentTable->setItem(row, 1, cell);
cell = new QTableWidgetItem;
cell->setText(commentText);
cell->setFlags(cell->flags() & ~ Qt::ItemIsEditable);
cell->setData(Qt::UserRole, QVariant(Id));
commentTable->setItem(row, 2, cell);
commentFile.close();
commentTE->setText("");
if (userData.toList().size() > 2)
{
dateDE->setDate(userData.toList().at(2).toDate());
authorLE->setText(userData.toList().at(1).toString());
}
}
}
}
#include <MainWindow.h>
void MainWindow::addParameter()
{
// Empty mainLayout
while(mainLayout->count() > 0){
QLayoutItem *item = mainLayout->takeAt(0);
delete item->widget();
delete item;
}
delete mainLayout;
mainLayout = new QGridLayout;
setLayout(mainLayout);
// We save the database
QString userName("");
userName = QInputDialog::getText(NULL, "Nom de l'opérateur", "Dis moi quel est ton nom?");
userName.remove("\n");
userName.remove("\t");
QString folderName;
folderName = QString("%1-%2.BNV").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));
}
// QLabels
QLabel *overallTitle = new QLabel("Ajouter des variables");
QLabel *GUTitle = new QLabel("Variables d'UC");
QLabel *reproTitle = new QLabel("Variables de reproduction");
QLabel *newParameterTitle = new QLabel("Nouvelle variable");
// QPushButtons
QPushButton *addParameterButton = new QPushButton("Ajouter cette variable");
QPushButton *backButton = new QPushButton("Retour");
QPushButton *backToMainButton = new QPushButton("Retour à la fenêtre principale");
// QTableWidgets
QTableWidget *GUVarTab = new QTableWidget(0, 2);
QTableWidget *reproVarTab = new QTableWidget(0, 2);
QTableWidget *newVarTab = new QTableWidget(1, 12);
// Now we fill GUVarTab
QFile varFile("bin/dictionary/variables");
QString line;
int countLine(0);
QStringList dataRow;
int typePosition(-1);
int namePosition(-1);
QMap<int, QStringList> varList;
if (!varFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
// Error
QMessageBox::critical(NULL, "Erreur", "Le programme n'a pas réussi à lire le fichier de données : bin/dictionary/variables.");
urgentStop();
return;
}else{
QTextStream varStream(&varFile);
line = varStream.readLine();
if (line != "###")
{
// Error
QMessageBox::critical(NULL, "Erreur", "Une erreur est survenue à la lecture de la première ligne du fichier : bin/dictionary/variables\nMauvaise entête (\"###\" attendu)");
urgentStop();
return;
}else{
line = "";
while (!varStream.atEnd() && line != "###")
{
line = varStream.readLine();
if (line == "Name\tSTRING")
{
namePosition = countLine;
}else if (line.startsWith("TypeVar"))
{
typePosition = countLine;
}
countLine++;
}
if ((namePosition == -1) || (typePosition == -1))
{
// Error
QMessageBox::critical(NULL, "Erreur", "Une erreur est survenue à la lecture de l'entête du fichier : bin/dictionary/variables\nLe nom des variables ou le type des variables n'est pas trouvé dans le fichier.");