First version of program
parent
6a96dcdc47
commit
d0a0d6743b
@ -0,0 +1,6 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
@ -0,0 +1 @@
|
|||||||
|
Extract_etab_a_fiab
|
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
@ -0,0 +1,5 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||||
|
</state>
|
||||||
|
</component>
|
@ -0,0 +1,3 @@
|
|||||||
|
<component name="ProjectDictionaryState">
|
||||||
|
<dictionary name="darkelfe" />
|
||||||
|
</component>
|
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="ClangTidy" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||||
|
</project>
|
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/Extract_etab_a_fiab.iml" filepath="$PROJECT_DIR$/.idea/Extract_etab_a_fiab.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,17 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
project(Extract_etab_a_fiab)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
|
find_package(Qt5Widgets REQUIRED)
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_AUTOUIC ON)
|
||||||
|
set(CMAKE_AUTORCC ON)
|
||||||
|
|
||||||
|
add_executable(
|
||||||
|
Extract_etab_a_fiab
|
||||||
|
|
||||||
|
main.cpp
|
||||||
|
MainDialog.ui MainDialog.cpp MainDialog.h
|
||||||
|
)
|
||||||
|
target_link_libraries(Extract_etab_a_fiab Qt5::Widgets)
|
@ -0,0 +1,83 @@
|
|||||||
|
#include <QtCore/QRegularExpression>
|
||||||
|
#include <QtCore/QTextStream>
|
||||||
|
|
||||||
|
#include <QtWidgets/QFileDialog>
|
||||||
|
#include <QtWidgets/QMessageBox>
|
||||||
|
#include <QtWidgets/QPushButton>
|
||||||
|
|
||||||
|
#include "MainDialog.h"
|
||||||
|
#include "ui_MainDialog.h"
|
||||||
|
|
||||||
|
MainDialog::MainDialog (QWidget* parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
m_ui(new Ui::MainDialog) {
|
||||||
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
|
connect(m_ui->input_button, &QPushButton::clicked, this, &MainDialog::onInputButtonClick);
|
||||||
|
connect(m_ui->csv_button, &QPushButton::clicked, this, &MainDialog::onCsvButtonClick);
|
||||||
|
|
||||||
|
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &MainDialog::onAccepted);
|
||||||
|
}
|
||||||
|
|
||||||
|
MainDialog::~MainDialog () {
|
||||||
|
delete m_ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainDialog::onInputButtonClick () {
|
||||||
|
m_ui->input_input
|
||||||
|
->setText(QFileDialog::getOpenFileName(this, "Fichier à traiter", QString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainDialog::onCsvButtonClick () {
|
||||||
|
m_ui->csv_input
|
||||||
|
->setText(QFileDialog::getSaveFileName(this, "CSV de sortie", QString(), "Fichier CSV (*.csv)"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainDialog::onAccepted () {
|
||||||
|
if (m_ui->input_input->text().isEmpty()) {
|
||||||
|
QMessageBox::critical(this, "Erreur", "Vous devez sélectioner un fichier à traiter");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_ui->csv_input->text().isEmpty()) {
|
||||||
|
QMessageBox::critical(this, "Erreur", "Vous devez indiquer le fichier CSV de sortie");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile input(m_ui->input_input->text());
|
||||||
|
if (!input.exists()) {
|
||||||
|
QMessageBox::critical(this, "Erreur", "Le fichier à traiter n'existe pas !");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!input.open(QIODevice::Text | QIODevice::ReadOnly)) {
|
||||||
|
QMessageBox::critical(this, "Erreur", "Impossible de lire le fichier à traiter");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const QString data = input.readAll();
|
||||||
|
input.close();
|
||||||
|
|
||||||
|
QFile outputFile(m_ui->csv_input->text());
|
||||||
|
if (!outputFile.open(QIODevice::Text | QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||||
|
QMessageBox::critical(this, "Erreur", "Impossible d'écrire dans le fichier CSV");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QTextStream output(&outputFile);
|
||||||
|
|
||||||
|
// language=RegExp
|
||||||
|
const QRegularExpression regex("\\*\\*\\* Etablissement ([0-9][AB0-9][0-9]{7}) \\*\\*\\*[\\s\\S]*?(?:(?:Champs a fiabiliser : ([^\\s]+))|(?=\\*\\*\\* Etablissement )|$)");
|
||||||
|
QRegularExpressionMatchIterator it_regex = regex.globalMatch(data);
|
||||||
|
|
||||||
|
int nbMatch = 0;
|
||||||
|
while (it_regex.hasNext()) {
|
||||||
|
nbMatch++;
|
||||||
|
|
||||||
|
QRegularExpressionMatch match = it_regex.next();
|
||||||
|
output << "\"" + match.captured(1).replace("\"", "\\\"") + "\";\"" + match.captured(2).replace("\"", "\\\"") + "\"\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
outputFile.close();
|
||||||
|
|
||||||
|
QMessageBox::information(this, "Fin", QString::number(nbMatch) + " lignes générées");
|
||||||
|
if (nbMatch > 0) {
|
||||||
|
this->accept();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef EXTRACTIONFINESS_MAINDIALOG_H
|
||||||
|
#define EXTRACTIONFINESS_MAINDIALOG_H
|
||||||
|
|
||||||
|
#include <QtWidgets/QDialog>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class MainDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MainDialog : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit MainDialog(QWidget* parent = nullptr);
|
||||||
|
~MainDialog() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::MainDialog* m_ui;
|
||||||
|
|
||||||
|
void onInputButtonClick();
|
||||||
|
void onCsvButtonClick();
|
||||||
|
void onAccepted();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EXTRACTIONFINESS_MAINDIALOG_H
|
@ -0,0 +1,139 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MainDialog</class>
|
||||||
|
<widget class="QDialog" name="MainDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>425</width>
|
||||||
|
<height>177</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Extraction Finess</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="MainDialog_layout">
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="form_layout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="input_label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Fichier à traiter</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>input_input</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="csv_input"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="input_input"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="csv_label">
|
||||||
|
<property name="text">
|
||||||
|
<string>CSV de sortie</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>csv_input</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QToolButton" name="csv_button">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Parcourir</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QToolButton" name="input_button">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Parcourir</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
<property name="centerButtons">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>input_input</tabstop>
|
||||||
|
<tabstop>input_button</tabstop>
|
||||||
|
<tabstop>csv_input</tabstop>
|
||||||
|
<tabstop>csv_button</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>MainDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>292</x>
|
||||||
|
<y>158</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>176</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
@ -0,0 +1,2 @@
|
|||||||
|
// This file is autogenerated. Changes will be overwritten.
|
||||||
|
#include "EWIEGA46WW/moc_MainDialog.cpp"
|
Loading…
Reference in New Issue