diff --git a/data.qrc b/data.qrc
index 9c654af..1ba19aa 100644
--- a/data.qrc
+++ b/data.qrc
@@ -20,4 +20,7 @@
data/images/underline.png
data/images/add.png
+
+ data/parcours1.json
+
diff --git a/main.cpp b/main.cpp
index d268092..37e1cf6 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,7 +1,5 @@
#include "mainwindow.h"
-
#include "path.h"
-
#include
#include
#include
@@ -11,7 +9,19 @@ int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
- w.show();
+ QFile file("data/parcours1.json");
+ if (!file.open(QIODevice::ReadOnly)) {
+ qWarning() << "Impossible d'ouvrir le fichier data/parcours1.json";
+ return -1;
+ }
+ Path* p = new Path(&file);
+ file.close();
+ QList paths = w.getPath();
+ paths.append(p);
+ w.setPath(paths);
+ w.setCurrentPath(p);
+ w.exportHTMLMap();
+ //w.show();
return a.exec();
}
diff --git a/mainwindow.cpp b/mainwindow.cpp
index bee0fdd..eb79c08 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -4,6 +4,7 @@
#include
#include
+#include
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
@@ -74,6 +75,94 @@ void MainWindow::addNewStep()
void MainWindow::exportHTMLMap()
{
+ std::ofstream file("parcours.html");
+ if (!file.is_open()) {
+ QMessageBox::warning(this, "Erreur", "Impossible d'ouvrir le fichier.");
+ return;
+ }
+
+ file << R"(
+
+
+
+ Carte du parcours
+
+
+
+
+
+ Carte du parcours
+
+
+
+
+
+
+)";
+ file.close();
}
@@ -131,3 +220,33 @@ void MainWindow::on_toolButton_clicked()
loadImage(fileName);
}
+QString MainWindow::getCurrentFile() const
+{
+ return currentFile;
+}
+
+void MainWindow::setCurrentFile(const QString &newCurrentFile)
+{
+ currentFile = newCurrentFile;
+}
+
+QList MainWindow::getPath() const
+{
+ return path;
+}
+
+void MainWindow::setPath(const QList &newPath)
+{
+ path = newPath;
+}
+
+Path *MainWindow::getCurrentPath() const
+{
+ return currentPath;
+}
+
+void MainWindow::setCurrentPath(Path *newCurrentPath)
+{
+ currentPath = newCurrentPath;
+}
+
diff --git a/mainwindow.h b/mainwindow.h
index 24fc256..9068a75 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -26,6 +26,13 @@ public:
void addNewStep();
void exportHTMLMap();
+ QString getCurrentFile() const;
+ void setCurrentFile(const QString &newCurrentFile);
+ QList getPath() const;
+ void setPath(const QList &newPath);
+ Path *getCurrentPath() const;
+ void setCurrentPath(Path *newCurrentPath);
+
private slots:
void on_pushButton_clicked();
diff --git a/parcours.html b/parcours.html
new file mode 100644
index 0000000..ed92a87
--- /dev/null
+++ b/parcours.html
@@ -0,0 +1,44 @@
+
+
+
+
+ Carte du parcours
+
+
+
+
+
+ Carte du parcours
+
+
+
+
+
+
diff --git a/path.cpp b/path.cpp
index 7a421f7..6eee8cd 100644
--- a/path.cpp
+++ b/path.cpp
@@ -51,10 +51,10 @@ QList Path::getStep() const
}
Path::Path(QFile *file){
- if (!file->open(QIODevice::ReadOnly)) {
+ /*if (!file->open(QIODevice::ReadOnly)) {
qWarning() << "Could not open file:" << file->errorString();
return;
- }
+ }*/
QByteArray data = file->readAll();
file->close();
QJsonDocument doc = QJsonDocument::fromJson(data);
@@ -75,7 +75,7 @@ Path::Path(QFile *file){
QJsonArray stepsArray = json["steps"].toArray();
for (const QJsonValue &stepValue : stepsArray) {
QJsonObject stepObj = stepValue.toObject();
- //step.append(Step(stepObj));
+ step.append(Step(stepObj));
}
}
diff --git a/step.cpp b/step.cpp
index 861f414..6b81de9 100644
--- a/step.cpp
+++ b/step.cpp
@@ -27,6 +27,36 @@ int Step::getResponse() const
return response;
}
+QList Step::getPersonnage() const
+{
+ return personnage;
+}
+
+QList Step::getTexte() const
+{
+ return texte;
+}
+
+void Step::setTitle(const QString &newTitle)
+{
+ title = newTitle;
+}
+
+void Step::setResponse(int newResponse)
+{
+ response = newResponse;
+}
+
+void Step::setPersonnage(const QList &newPersonnage)
+{
+ personnage = newPersonnage;
+}
+
+void Step::setTexte(const QList &newTexte)
+{
+ texte = newTexte;
+}
+
Step::Step() {
latitude = 0.0;
longitude = 0.0;
diff --git a/step.h b/step.h
index 8d93c46..e0ed2aa 100644
--- a/step.h
+++ b/step.h
@@ -26,6 +26,12 @@ public:
float getLatitude() const;
float getLongitude() const;
int getResponse() const;
+ QList getPersonnage() const;
+ QList getTexte() const;
+ void setTitle(const QString &newTitle);
+ void setResponse(int newResponse);
+ void setPersonnage(const QList &newPersonnage);
+ void setTexte(const QList &newTexte);
};
#endif // STEP_H