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/data/parcours.html b/data/parcours.html new file mode 100644 index 0000000..325521a --- /dev/null +++ b/data/parcours.html @@ -0,0 +1,100 @@ + + + + + Carte du parcours + + + + + +

Fiche du parcours

+
+
+
+

parcous1

+

Ville : Bourg en bresse

+

Département : 1

+

Difficulté : 2

+

Durée (heures) : 2.3

+

Longueur (km) : 17.3

+ + +
+
+ + + + + diff --git a/data/parcours1.json b/data/parcours1.json index bb5a755..f3bba0a 100644 --- a/data/parcours1.json +++ b/data/parcours1.json @@ -5,7 +5,7 @@ "difficulty": 2, "duration": 2.3, "length": 17.3, - "image": "data/parcours1.png", + "image": "../data/parcours1.png", "steps": [ { "numero": 1, diff --git a/index.html b/index.html new file mode 100644 index 0000000..5895d48 --- /dev/null +++ b/index.html @@ -0,0 +1,53 @@ + + + + + Liste des parcours + + + +

Liste des parcours

+ + + diff --git a/main.cpp b/main.cpp index d268092..a0d1a0e 100644 --- a/main.cpp +++ b/main.cpp @@ -1,16 +1,19 @@ #include "mainwindow.h" - #include "path.h" - #include #include #include - +#include using namespace std; int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; + QStringList fichiers = {"data/parcours1.json", "data/parcours2.json"}; + w.loadAndExportPaths(fichiers); + Web u(w.getPath()); + u.siteHtml(); + w.show(); return a.exec(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 285365b..617be1b 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -5,15 +5,15 @@ #include "Undo.h" #include #include +#include #include #include - - #include #include #include #include +int MainWindow::indexPath = 0; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) @@ -22,8 +22,10 @@ MainWindow::MainWindow(QWidget *parent) , Clipboard(QGuiApplication::clipboard()) { ui->setupUi(this); + indexPath++; currentPath = new Path(); + connect(ui->titleEdit, &QLineEdit::editingFinished, this, [this]() { static QString previousText; QString currentText = ui->titleEdit->text(); @@ -65,16 +67,11 @@ MainWindow::~MainWindow() delete p; } } - void MainWindow::updatePathView() -{ - -} +{} void MainWindow::updateStepView(size_t num) -{ - -} +{} void MainWindow::onTextChanged() { @@ -152,19 +149,209 @@ void MainWindow::loadStep(Step s) { void MainWindow::addNewPath() { - + path.append(currentPath); } void MainWindow::addNewStep() { - } - -void MainWindow::exportHTMLMap() +void MainWindow::exportHTMLMap(int index) { + std::ofstream file("./pages/parcours" + std::to_string(index) + ".html"); + if (!file.is_open()) { + QMessageBox::warning(this, "Erreur", "Impossible d'ouvrir le fichier."); + return; + } + + file << R"( + + + + Carte du parcours + + + + + +

Fiche du parcours

+
+
+
+)"; + + if (currentPath) { + Path* p = currentPath; + file << "

" << p->getName().toStdString() << "

\n"; + file << "

Ville : " << p->getCity().toStdString() << "

\n"; + file << "

Département : " << p->getDepartement() << "

\n"; + file << "

Difficulté : " << p->getDifficulty() << "

\n"; + file << "

Durée (heures) : " << p->getDuration() << "

\n"; + file << "

Longueur (km) : " << p->getLength() << "

\n"; + if (!p->getImage().isEmpty()) { + file << "getImage().toStdString() << "\">\n"; + } + int stepNum = 1; + for (const Step& s : p->getStep()) { + file << "

Étape " << stepNum << "

\n"; + const QList persos = s.getPersonnage(); + const QList textes = s.getTexte(); + + if (!persos.isEmpty()) { + file << "

Personnages :

\n
    "; + for (const QString& pers : persos) { + file << "
  • " << pers.toStdString() << "
  • \n"; + } + file << "
\n"; + } + + if (!textes.isEmpty()) { + file << "

Dialogues :

\n
    "; + for (const QString& txt : textes) { + file << "
  • " << txt.toStdString() << "
  • \n"; + } + file << "
\n"; + } + + stepNum++; + } + } + + file << R"( +
+
+ + + + + +)"; + file.close(); +} + + + void MainWindow::loadImage(QString fileName) { QString ext[] = {"png", "jpeg", "jpg"}; @@ -218,6 +405,45 @@ void MainWindow::on_toolButton_clicked() loadImage(fileName); } +int MainWindow::getIndexPath() const +{ + return indexPath; +} + +void MainWindow::setIndexPath(int newIndexPath) +{ + indexPath = newIndexPath; +} + +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; +} void MainWindow::saveFile(){ QString fileName; @@ -344,3 +570,19 @@ void MainWindow::on_validateBtn_clicked() currentPath->getStep()[ui->stepNumber->value()-1].setResponse(ui->responseSpin->value()); } +void MainWindow::loadAndExportPaths(QStringList fichiers) { + + + for (const QString& nomFichier : fichiers) { + QFile* f = new QFile(nomFichier); + + Path* p = new Path(f); + path.append(p); + } + + int exportIndex = 1; + for (Path* p : path) { + currentPath = p; + exportHTMLMap(exportIndex++); + } +} diff --git a/mainwindow.h b/mainwindow.h index 1415193..191d6f7 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -27,6 +27,17 @@ public: void loadStep(Step s); void addNewPath(); void addNewStep(); + void exportHTMLMap(int index); + void loadAndExportPaths(QStringList fichiers); + QString getCurrentFile() const; + void setCurrentFile(const QString &newCurrentFile); + QList getPath() const; + void setPath(const QList &newPath); + Path *getCurrentPath() const; + void setCurrentPath(Path *newCurrentPath); + + int getIndexPath() const; + void setIndexPath(int newIndexPath); void exportHTMLMap(); void saveFile(); @@ -56,6 +67,7 @@ private slots: private: Ui::MainWindow *ui; QString currentFile; + static int indexPath; bool textChanged; QList path; Path* currentPath; diff --git a/pages/parcours1.html b/pages/parcours1.html new file mode 100644 index 0000000..8fee53f --- /dev/null +++ b/pages/parcours1.html @@ -0,0 +1,130 @@ + + + + + Carte du parcours + + + + + +

Fiche du parcours

+
+
+
+

parcous1

+

Ville : Bourg en bresse

+

Département : 1

+

Difficulté : 2

+

Durée (heures) : 2.3

+

Longueur (km) : 17.3

+ +

Étape 1

+

Personnages :

+
  • Quentin
  • +
  • Malo
  • +
+

Dialogues :

+
  • ligne de dialogue 1
  • +
  • ligne de dialogue 2
  • +
+

Étape 2

+

Personnages :

+
  • Antoine
  • +
  • Giovanni
  • +
+

Dialogues :

+
  • ligne de dialogue 1
  • +
  • ligne de dialogue 2
  • +
+ +
+
+ + + + + diff --git a/pages/parcours2.html b/pages/parcours2.html new file mode 100644 index 0000000..0049325 --- /dev/null +++ b/pages/parcours2.html @@ -0,0 +1,148 @@ + + + + + Carte du parcours + + + + + +

Fiche du parcours

+
+
+
+

Chemin des

+

Ville : Bourg en Bresse

+

Département : 0

+

Difficulté : 3

+

Durée (heures) : 3.8

+

Longueur (km) : 24.6

+ +

Étape 1

+

Personnages :

+
  • Clémentine
  • +
  • Léo
  • +
+

Dialogues :

+
  • Bienvenue à tous, voici le centre historique !
  • +
  • Regardez cette magnifique horloge, elle date du XIXe siècle !
  • +
+

Étape 2

+

Personnages :

+
  • Aurélie
  • +
  • Sami
  • +
+

Dialogues :

+
  • Ici, on trouve les meilleurs fromages de la région !
  • +
  • Combien de colonnes vois-tu à l'entrée ?
  • +
+

Étape 3

+

Personnages :

+
  • Juliette
  • +
  • Marc
  • +
+

Dialogues :

+
  • La Reyssouze apporte de la fraîcheur en été.
  • +
  • Regarde cette inscription ancienne sur la pierre, tu arrives à la lire ?
  • +
+

Étape 4

+

Personnages :

+
  • Claire
  • +
  • Nathalie
  • +
+

Dialogues :

+
  • Voilà l'abbaye ! Admire l'architecture.
  • +
  • C'est ici la dernière étape. Observez bien la date !
  • +
+ +
+
+ + + + + diff --git a/sae201.pro b/sae201.pro index 04a7b14..e046919 100644 --- a/sae201.pro +++ b/sae201.pro @@ -13,12 +13,14 @@ SOURCES += \ mainwindow.cpp \ step.cpp \ path.cpp \ + web.cpp HEADERS += \ Undo.h \ mainwindow.h \ step.h \ path.h \ + web.h FORMS += \ mainwindow.ui diff --git a/step.cpp b/step.cpp index 33f9a2e..419f676 100644 --- a/step.cpp +++ b/step.cpp @@ -27,6 +27,16 @@ 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; @@ -37,23 +47,22 @@ 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; response = 0; } - -QList Step::getPersonnage() const -{ - return personnage; -} - -QList Step::getTexte() const -{ - return texte; -} - Step::Step( QJsonObject &in) { title = in["title"].toString(); diff --git a/step.h b/step.h index 05bf5b0..eb2bc9e 100644 --- a/step.h +++ b/step.h @@ -26,11 +26,13 @@ public: float getLatitude() const; float getLongitude() const; int getResponse() const; - QString toGPSFormat(); 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); + QString toGPSFormat(); }; #endif // STEP_H diff --git a/web.cpp b/web.cpp new file mode 100644 index 0000000..f59a9a0 --- /dev/null +++ b/web.cpp @@ -0,0 +1,85 @@ +#include "web.h" +#include +Web::Web() +{} + +Web::Web(const QList& list) : list(list) +{} + +void Web::siteHtml() +{ + std::ofstream file("index.html"); + if (!file.is_open()) { + qWarning("Impossible d'ouvrir le fichier index.html"); + return; + } + + file << R"( + + + + Liste des parcours + + + +

Liste des parcours

+
    +)"; + + int index = 1; + for (const Path* p : list) { + QString fileName = QString("parcours%1.html").arg(index); + QString name = p->getName(); + file << "
  • " + << name.toStdString() + << "
  • \n"; + ++index; + } + + file << R"(
+ + +)"; + + file.close(); +} diff --git a/web.h b/web.h new file mode 100644 index 0000000..81a4b6b --- /dev/null +++ b/web.h @@ -0,0 +1,17 @@ +#ifndef WEB_H +#define WEB_H +#include +#include +#include "path.h" +class Web +{ +private: + QList list; +public: + Web(); + Web(const QList &list); + void siteHtml(); + +}; + +#endif // WEB_H