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..5af9ae0 --- /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..31154c4 100644 --- a/main.cpp +++ b/main.cpp @@ -1,17 +1,17 @@ #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; - w.show(); + w.loadAndExportPaths(); + Web u(w.getPath()); + u.siteHtml(); return a.exec(); } diff --git a/mainwindow.cpp b/mainwindow.cpp index 9129fa2..47b40a9 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,6 +22,7 @@ MainWindow::MainWindow(QWidget *parent) , Clipboard(QGuiApplication::clipboard()) { ui->setupUi(this); + indexPath++; //currentPath = new Path(); connect(ui->titleEdit, &QLineEdit::editingFinished, this, [this]() { @@ -64,16 +65,11 @@ MainWindow::~MainWindow() delete p; } } - void MainWindow::updatePathView() -{ - -} +{} void MainWindow::updateStepView(size_t num) -{ - -} +{} void MainWindow::onTextChanged() { @@ -151,19 +147,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"}; @@ -217,6 +403,46 @@ void MainWindow::on_toolButton_clicked() loadImage(fileName); } +<<<<<<< mainwindow.cpp +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; diff --git a/mainwindow.h b/mainwindow.h index 1415193..84ff04c 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(); + 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..dc728a4 --- /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..fcc03ee --- /dev/null +++ b/pages/parcours2.html @@ -0,0 +1,130 @@ + + + + + Carte du parcours + + + + + +

Fiche du parcours

+
+
+
+

parcours2

+

Ville : Paris

+

Département : 1

+

Difficulté : 2

+

Durée (heures) : 2.3

+

Longueur (km) : 17.3

+ +

Étape 1

+

Personnages :

+
  • Quentin
  • +
  • Malo
  • +
+

Dialogues :

+
  • ligne de dialogue 1 HJDDDZJJJJJJJJJJJJJJJJJJJDBJBDJZBZJDBJ
  • +
  • ligne de dialogue 2BDJJHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHBDHDBHBZHVZDHVHVHEDHJVHVDHEDJD
  • +
+

Étape 2

+

Personnages :

+
  • Antoine
  • +
  • Giovanni
  • +
+

Dialogues :

+
  • ligne de dialogue 1
  • +
  • ligne de dialogue 2
  • +
+ +
+
+ + + + + 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..c8aaa5a 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,6 +47,16 @@ 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 05bf5b0..e0ed2aa 100644 --- a/step.h +++ b/step.h @@ -26,11 +26,12 @@ 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); }; #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