Merge branch 'dev' into 'feature/styleTool'

# Conflicts:
#   mainwindow.cpp
#   mainwindow.h
#   mainwindow.ui
This commit is contained in:
JOSSERAND GIOVANNI p2405212 2025-06-20 21:57:30 +00:00
commit e85e3f9c07
17 changed files with 1445 additions and 431 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
*.json
*.html
## Ignore Visual Studio temporary files, build results, and ## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons. ## files generated by popular Visual Studio add-ons.
## and Ignore Qt objects and libs. ## and Ignore Qt objects and libs.

0
data/images/d.json Normal file
View File

View File

@ -1,44 +0,0 @@
{
"name": "parcous1",
"city": "Bourg en bresse",
"departement": 1,
"difficulty": 2,
"duration": 2.3,
"length": 17.3,
"image": "data/parcours1.png",
"steps": [
{
"numero": 1,
"title": "Première étape",
"GPS": "N 45 37.199 W 1 2.009",
"reponse": -1,
"dialogue": [
{
"personnage": "Quentin",
"texte": "ligne de dialogue 1"
},
{
"personnage": "Malo",
"texte": "ligne de dialogue 2"
}
]
},
{
"numero": 2,
"title": "Deuxième étape",
"GPS": "S 45 37.199 E 1 2.009",
"reponse": 4156,
"dialogue": [
{
"personnage": "Antoine",
"texte": "ligne de dialogue 1"
},
{
"personnage": "Giovanni",
"texte": "ligne de dialogue 2"
}
]
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 KiB

53
index.html Normal file
View File

@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<title>Liste des parcours</title>
<style>
body {
font-family: Arial;
margin: 40px;
background-color: whitesmoke;
}
h1 {
text-align: center;
color: black;
font-style: bold;
}
ul {
max-width: 600px;
margin: 0 auto;
padding: 0;
list-style-type: none;
}
li {
background: white;
margin: 10px 0;
padding: 15px;
border-radius: 8px;
box-shadow: 0 0 6px rgba(0,0,0,0.1);
transition: background-color 0.3s ease;
}
li:hover {
background-color:black;
}
a {
text-decoration: none;
color: purple;
font-weight: bold;
font-size: 1.2em;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<h1>Liste des parcours</h1>
<ul>
<li><a href="./pages/parcours0.html">azea</a></li>
<li><a href="./pages/parcours1.html">parcous123</a></li>
</ul>
</body>
</html>

View File

@ -1,12 +1,11 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "path.h" #include "path.h"
#include <QApplication> #include <QApplication>
#include <step.h> #include <step.h>
#include <QFile> #include <QFile>
using namespace std; using namespace std;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);

View File

@ -1,9 +1,11 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "path.h" #include "path.h"
#include "step.h"
#include "Undo.h" #include "Undo.h"
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <fstream>
#include <QLineEdit> #include <QLineEdit>
#include <QTimer> #include <QTimer>
#include <QTextEdit> #include <QTextEdit>
@ -11,6 +13,13 @@
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QInputDialog> #include <QInputDialog>
#include <QFontDialog> #include <QFontDialog>
#include <QFile>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include "web.h"
int MainWindow::indexPath = 0;
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
@ -19,6 +28,14 @@ MainWindow::MainWindow(QWidget *parent)
, Clipboard(QGuiApplication::clipboard()) , Clipboard(QGuiApplication::clipboard())
{ {
ui->setupUi(this); ui->setupUi(this);
indexPath++;
Path* p = new Path();
currentPath = p;
path.append(p);
loadPath(p);
int pathCount = path.length();
ui->pathNumber->setMaximum(pathCount);
ui->pathNumber->setSuffix("/" + QString::number(pathCount));
connect(ui->titleEdit, &QLineEdit::editingFinished, this, [this]() { connect(ui->titleEdit, &QLineEdit::editingFinished, this, [this]() {
@ -50,6 +67,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->actionEditUndo, &QAction::triggered, undoStack, &QUndoStack::undo); connect(ui->actionEditUndo, &QAction::triggered, undoStack, &QUndoStack::undo);
connect(ui->actionEditRedo, &QAction::triggered, undoStack, &QUndoStack::redo); connect(ui->actionEditRedo, &QAction::triggered, undoStack, &QUndoStack::redo);
currentPath->getStep().append(Step());
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -61,23 +79,18 @@ MainWindow::~MainWindow()
delete p; delete p;
} }
} }
void MainWindow::updatePathView() void MainWindow::updatePathView()
{ {}
}
void MainWindow::updateStepView(size_t num) void MainWindow::updateStepView(size_t num)
{ {}
}
void MainWindow::onTextChanged() void MainWindow::onTextChanged()
{ {
textChanged = true; textChanged = true;
} }
void MainWindow::loadPath() void MainWindow::loadNewPath()
{ {
QString fileName = QFileDialog::getOpenFileName(this, "Open the file"); QString fileName = QFileDialog::getOpenFileName(this, "Open the file");
if(fileName.isEmpty()) return; if(fileName.isEmpty()) return;
@ -91,6 +104,19 @@ void MainWindow::loadPath()
Path* p = new Path(&file); Path* p = new Path(&file);
currentPath = p; currentPath = p;
path.append(p); path.append(p);
loadPath(p);
currentFile = fileName;
int pathCount = path.length();
ui->pathNumber->setMaximum(pathCount);
ui->pathNumber->setSuffix("/" + QString::number(pathCount));
ui->pathNumber->setValue(path.indexOf(currentPath)+1);
}
void MainWindow::loadPath(Path* p) {
QList<Step> steps = p->getStep();
ui->titleEdit->setText(p->getName()); ui->titleEdit->setText(p->getName());
ui->locEdit->setText(p->getCity()); ui->locEdit->setText(p->getCity());
@ -98,42 +124,260 @@ void MainWindow::loadPath()
ui->lengthSpin->setValue(p->getLength()); ui->lengthSpin->setValue(p->getLength());
ui->durationSpin->setValue(p->getDuration()); ui->durationSpin->setValue(p->getDuration());
ui->imagePath->setText(p->getImage()); ui->imagePath->setText(p->getImage());
ui->depSpin->setValue(p->getDepartement());
loadImage(p->getImage()); loadImage(p->getImage());
ui->dialogEdit->clear();
if(!steps.isEmpty()) {
Step firstStep = p->getStep().first();
ui->stepTitle->setText(firstStep.getTitle());
ui->LatitudeSpin->setValue(firstStep.getLatitude());
ui->longitudeSpin->setValue(firstStep.getLongitude());
for(int i = 0; i < firstStep.getTexte().length(); i++) {
QString q = firstStep.getPersonnage().at(i) + ": " + firstStep.getTexte().at(i);
ui->dialogEdit->appendPlainText(q);
}
ui->stepNumber->setValue(1);
ui->stepNumber->setSuffix("/" + QString::number(steps.length()));
ui->stepNumber->setMaximum(steps.length());
}
}
void MainWindow::loadStep(Step s) {
ui->stepTitle->setText(s.getTitle());
ui->LatitudeSpin->setValue(s.getLatitude());
ui->longitudeSpin->setValue(s.getLongitude());
ui->responseSpin->setValue(s.getResponse());
for(int i = 0; i < s.getTexte().length(); i++) {
QString q = s.getPersonnage().at(i) + ": " + s.getTexte().at(i);
ui->dialogEdit->appendPlainText(q);
}
} }
void MainWindow::addNewPath() void MainWindow::addNewPath()
{ {
path.append(currentPath);
} }
void MainWindow::addNewStep() void MainWindow::addNewStep()
{ {
} }
void MainWindow::exportHTMLMap(int index)
void MainWindow::exportHTMLMap()
{ {
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"(<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Carte du parcours</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: whitesmoke;
}
#container {
display: flex;
gap: 20px;
}
#map {
height: 600px;
width: 60%;
border-radius: 5%;
border: 1px solid #aaa;
}
#fiche {
padding-right:20px;
width: 40%;
max-height: 600px;
overflow-y: auto;
border: 1px solid #aaa;
padding: 10px;
box-sizing: border-box;
background-color:#095228;
border-radius: 5%;
}
#fiche ul {
padding-left: 20px;
list-style-type: disc;
overflow-wrap: break-word;
word-wrap: break-word;
word-break: break-word;
white-space: normal;
max-width: 90%;
} }
#fiche li {
white-space: normal;
overflow-wrap: break-word;
}
body h1 {
display:flex;
align-items:center;
justify-content:center;
text-align: center;
color: black;
font-style: bold;
margin-bottom: 20px;
background-color:brown;
border-radius:12px;
height: 75px;
}
#fiche h2, #fiche h3, #fiche p, #fiche li {
color: white;
}
#fiche img {
max-width: 100%;
height: auto;
margin-top: 10px;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>Fiche du parcours</h1>
<div id="container">
<div id="map"></div>
<div id="fiche">
)";
if (currentPath) {
Path* p = currentPath;
file << "<h2>" << p->getName().toStdString() << "</h2>\n";
file << "<p><strong>Ville :</strong> " << p->getCity().toStdString() << "</p>\n";
file << "<p><strong>Département :</strong> " << p->getDepartement() << "</p>\n";
file << "<p><strong>Difficulté :</strong> " << p->getDifficulty() << "</p>\n";
file << "<p><strong>Durée (heures) :</strong> " << p->getDuration() << "</p>\n";
file << "<p><strong>Longueur (km) :</strong> " << p->getLength() << "</p>\n";
if (!p->getImage().isEmpty()) {
file << "<img src=\"" << p->getImage().toStdString() << "\">\n";
}
int stepNum = 1;
for (const Step& s : p->getStep()) {
file << "<h3>Étape " << stepNum << "</h3>\n";
const QList<QString> persos = s.getPersonnage();
const QList<QString> textes = s.getTexte();
if (!persos.isEmpty()) {
file << "<p><strong>Personnages :</strong></p>\n<ul>";
for (const QString& pers : persos) {
file << "<li>" << pers.toStdString() << "</li>\n";
}
file << "</ul>\n";
}
if (!textes.isEmpty()) {
file << "<p><strong>Dialogues :</strong></p>\n<ul>";
for (const QString& txt : textes) {
file << "<li>" << txt.toStdString() << "</li>\n";
}
file << "</ul>\n";
}
stepNum++;
}
}
file << R"(
</div>
</div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script>
var map = L.map('map').setView([45.5, 1.5], 10); // Vue centrée
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
)";
if (!path.isEmpty() && path[0]) {
Path* p = path[0];
int stepNum = 1;
for (const Step& s : p->getStep()) {
float lat = s.getLatitude();
float lon = s.getLongitude();
QList<QString> personnages = s.getPersonnage();
QList<QString> textes = s.getTexte();
QString popupHtml = "<b>Étape " + QString::number(stepNum) + "</b><br>";
if (!personnages.isEmpty()) {
popupHtml += "<b>Personnages :</b><ul>";
for (const QString& pers : personnages) {
popupHtml += "<li>" + pers + "</li>";
}
popupHtml += "</ul>";
}
if (!textes.isEmpty()) {
popupHtml += "<b>Textes :</b><ul>";
for (const QString& txt : textes) {
popupHtml += "<li>" + txt + "</li>";
}
popupHtml += "</ul>";
}
file << "L.marker([" << lat << ", " << lon << "]).addTo(map)"
<< ".bindPopup(\"" << popupHtml.toStdString() << "\");\n";
++stepNum;
}
file << "var latlngs = [\n";
for (const Step& s : p->getStep()) {
float lat = s.getLatitude();
float lon = s.getLongitude();
file << " [" << lat << ", " << lon << "],\n";
}
file << "];\n";
file << R"(
var polyline = L.polyline(latlngs, {
color: 'purple',
weight: 2,
dashArray: '10, 10',
opacity: 0.7
}).addTo(map);
map.fitBounds(polyline.getBounds());
)";
}
file << R"(
</script>
</body>
</html>
)";
file.close();
}
void MainWindow::loadImage(QString fileName) { void MainWindow::loadImage(QString fileName) {
QString ext[] = {"png", "jpeg", "jpg"}; QString ext[] = {"png", "jpeg", "jpg"};
QFile file(fileName); QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QFile::Text)) { if (!file.open(QIODevice::ReadOnly | QFile::Text)) {
QMessageBox::warning(this, "Warning", "Cannot open file: " + QMessageBox::warning(this, "Warning", "Cannot open image: " +
file.errorString()); file.errorString());
return;
}
QString text = file.fileName();
}else{
QString text = file.fileName();
bool acceptedExt = false; bool acceptedExt = false;
for(QString e : ext) { for(QString e : ext) {
if(text.endsWith(e)) acceptedExt = true; if(text.endsWith(e)) acceptedExt = true;
} }
if(!acceptedExt) { if(!acceptedExt) {
QMessageBox::warning(this, "Warning", "Format de fichier incorrect"); QMessageBox::warning(this, "Warning", "Format de fichier incorrect");
return; return;
@ -148,6 +392,8 @@ void MainWindow::loadImage(QString fileName) {
ui->imageLbl->setPixmap(px); ui->imageLbl->setPixmap(px);
file.close(); file.close();
}
} }
@ -161,7 +407,7 @@ void MainWindow::on_pushButton_clicked()
void MainWindow::on_actionOpen_triggered() void MainWindow::on_actionOpen_triggered()
{ {
this->loadPath(); this->loadNewPath();
} }
void MainWindow::on_toolButton_clicked() void MainWindow::on_toolButton_clicked()
@ -171,49 +417,207 @@ void MainWindow::on_toolButton_clicked()
loadImage(fileName); 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<Path *> MainWindow::getPath() const
{
return path;
}
void MainWindow::setPath(const QList<Path *> &newPath)
{
path = newPath;
}
Path *MainWindow::getCurrentPath() const
{
return currentPath;
}
void MainWindow::setCurrentPath(Path *newCurrentPath)
{
currentPath = newCurrentPath;
}
void MainWindow::saveFile(){
QString fileName;
if (currentFile.isEmpty()) {
fileName = QFileDialog::getSaveFileName(this, "Save");
currentFile = fileName;
} else {
fileName = currentFile;
}
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QFile::Text)) {
QMessageBox::warning(this, "Warning", "Cannot save file: " + file.errorString());
return;
}
setWindowTitle(fileName);
QJsonObject json;
json["name"] = ui->titleEdit->text();
json["city"] =ui->locEdit->text();
json["departement"] = ui->depSpin->text();
json["difficulty"] = ui->diffSpin->value();
json["duration"] = ui->durationSpin->value();
json["length"] = ui->lengthSpin->value();
json["image"] = ui->imagePath->text();
QJsonArray steps;
int cpt=0;
for(Step step: currentPath->getStep()){
cpt++;
QJsonObject stepObject;
stepObject["numero"] = cpt;
stepObject["title"] = step.getTitle();
stepObject["GPS"] = step.toGPSFormat();
stepObject["reponse"] = step.getResponse();
QJsonArray dialogues;
for(int i=0; i<step.getTexte().size(); i++){
QJsonObject dialogueObject;
dialogueObject["personnage"] = step.getPersonnage()[i];
dialogueObject["texte"] = step.getTexte()[i];
dialogues.append(dialogueObject);
}
stepObject["dialogue"] = dialogues;
steps.append(stepObject);
}
json["steps"] = steps;
QJsonDocument doc(json);
file.write(doc.toJson());
file.close();
}
void MainWindow::on_actionSave_triggered()
{
this->saveFile();
}
void MainWindow::on_actionopenFile_triggered() void MainWindow::on_actionopenFile_triggered()
{ {
this->loadPath(); this->loadNewPath();
}
void MainWindow::copyText(){
QWidget *focused = QApplication::focusWidget();
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(focused);
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(focused);
if (lineEdit && !lineEdit->selectedText().isEmpty()) {
Clipboard->setText(lineEdit->selectedText());
} else if (plainTextEdit) {
QTextCursor cursor = plainTextEdit->textCursor();
if (cursor.hasSelection()) {
Clipboard->setText(cursor.selectedText());
}
}
} }
void MainWindow::on_actionEditCopy_triggered() void MainWindow::on_actionEditCopy_triggered()
{ {
QWidget *focused = QApplication::focusWidget(); this->copyText();
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(focused);
if(lineEdit) {
Clipboard->setText(lineEdit->selectedText());
}
} }
void MainWindow::pastText(){
QWidget *focused = QApplication::focusWidget();
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(focused);
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(focused);
if (lineEdit) {
lineEdit->insert(Clipboard->text());
} else if (plainTextEdit) {
plainTextEdit->insertPlainText(Clipboard->text());
}
}
void MainWindow::on_actionEditPaste_triggered() void MainWindow::on_actionEditPaste_triggered()
{ {
QWidget *focused = QApplication::focusWidget(); this->pastText();
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(focused);
if(lineEdit) {
QString text = lineEdit->text();
int pos = lineEdit->cursorPosition();
text.insert(pos, Clipboard->text());
lineEdit->setText(text);
}
} }
void MainWindow::on_actionEditCut_triggered() void MainWindow::cutText(){
{
QWidget *focused = QApplication::focusWidget(); QWidget *focused = QApplication::focusWidget();
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(focused); QLineEdit* lineEdit = qobject_cast<QLineEdit*>(focused);
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(focused);
if(lineEdit) { if (lineEdit) {
QString text = lineEdit->text();
QString selectedText = lineEdit->selectedText(); QString selectedText = lineEdit->selectedText();
int pos = lineEdit->selectionStart(); if (!selectedText.isEmpty()) {
text.remove(pos, selectedText.length());
Clipboard->setText(selectedText); Clipboard->setText(selectedText);
lineEdit->setText(text); lineEdit->del();
}
} else if (plainTextEdit) {
QTextCursor cursor = plainTextEdit->textCursor();
if (cursor.hasSelection()) {
Clipboard->setText(cursor.selectedText());
cursor.removeSelectedText();
}
}
}
void MainWindow::on_actionEditCut_triggered()
{
this->cutText();
}
void MainWindow::on_pathNumber_valueChanged(int arg1)
{
this->loadPath(path.at(ui->pathNumber->value()-1));
currentPath = path.at(arg1-1);
}
void MainWindow::on_stepNumber_valueChanged(int arg1)
{
this->loadStep(currentPath->getStep().at(arg1-1));
}
void MainWindow::on_validateBtn_clicked()
{
currentPath->setName(ui->titleEdit->text());
currentPath->setCity(ui->locEdit->text());
currentPath->setImage(ui->imagePath->text());
currentPath->setLength(ui->lengthSpin->value());
currentPath->setDifficulty(ui->diffSpin->value());
currentPath->setDuration(ui->durationSpin->value());
currentPath->getStep()[ui->stepNumber->value()-1].setTitle(ui->stepTitle->text());
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++);
} }
} }
@ -402,3 +806,116 @@ void MainWindow::on_actionFont_size_triggered()
this->setSize(); this->setSize();
} }
void MainWindow::saveAsFile(){
QString fileName = QFileDialog::getSaveFileName(this, "Save as");
QFile file(fileName);
if (!file.open(QFile::WriteOnly | QFile::Text)) {
QMessageBox::warning(this, "Warning", "Cannot save file: " + file.errorString());
return;
}
setWindowTitle(fileName);
currentFile = fileName;
QJsonObject json;
json["name"] = ui->titleEdit->text();
json["city"] =ui->locEdit->text();
json["departement"] = ui->depSpin->text();
json["difficulty"] = ui->diffSpin->value();
json["duration"] = ui->durationSpin->value();
json["length"] = ui->lengthSpin->value();
json["image"] = ui->imagePath->text();
QJsonArray steps;
int cpt=0;
for(Step step: currentPath->getStep()){
cpt++;
QJsonObject stepObject;
stepObject["numero"] = cpt;
stepObject["title"] = step.getTitle();
stepObject["GPS"] = step.toGPSFormat();
stepObject["reponse"] = step.getResponse();
QJsonArray dialogues;
for(int i=0; i<step.getTexte().size(); i++){
QJsonObject dialogueObject;
dialogueObject["personnage"] = step.getPersonnage()[i];
dialogueObject["texte"] = step.getTexte()[i];
dialogues.append(dialogueObject);
}
stepObject["dialogue"] = dialogues;
steps.append(stepObject);
}
json["steps"] = steps;
QJsonDocument doc(json);
file.write(doc.toJson());
file.close();
}
void MainWindow::on_actionSave_as_triggered()
{
this->saveAsFile();
}
void MainWindow::on_exportHTMLBtn_clicked()
{
for(int i = 0; i < path.length(); i++) {
this->exportHTMLMap(i);
}
Web w(path);
w.siteHtml();
}
void MainWindow::on_actionSaveFile_triggered()
{
this->saveFile();
}
void MainWindow::on_actionSaveAsFile_triggered()
{
this->saveAsFile();
}
void MainWindow::on_actionCopy_triggered()
{
this->copyText();
}
void MainWindow::on_actionPast_triggered()
{
this->pastText();
}
void MainWindow::on_actionCut_triggered()
{
this->cutText();
}
void MainWindow::newPath(){
Path* p = new Path();
currentPath = p;
path.append(p);
loadPath(p);
int pathCount = path.length();
ui->pathNumber->setMaximum(pathCount);
ui->pathNumber->setSuffix("/" + QString::number(pathCount));
ui->pathNumber->setValue(path.indexOf(currentPath)+1);
}
void MainWindow::on_actionNew_triggered()
{
this->newPath();
}
void MainWindow::on_actionNewFile_triggered()
{
this->newPath();
}

View File

@ -22,9 +22,25 @@ public:
void updatePathView(); void updatePathView();
void updateStepView(size_t num); void updateStepView(size_t num);
void onTextChanged(); void onTextChanged();
void loadPath(); void loadNewPath();
void loadPath(Path* p);
void loadStep(Step s);
void addNewPath(); void addNewPath();
void addNewStep(); void addNewStep();
void exportHTMLMap(int index);
void loadAndExportPaths(QStringList fichiers);
QString getCurrentFile() const;
void setCurrentFile(const QString &newCurrentFile);
QList<Path *> getPath() const;
void setPath(const QList<Path *> &newPath);
Path *getCurrentPath() const;
void setCurrentPath(Path *newCurrentPath);
void saveAsFile();
void copyText();
void pastText();
void cutText();
int getIndexPath() const;
void setIndexPath(int newIndexPath);
void exportHTMLMap(); void exportHTMLMap();
void setBold(); void setBold();
void setItalic(); void setItalic();
@ -33,6 +49,8 @@ public:
void setOverline(); void setOverline();
void setSize(); void setSize();
void setFont(); void setFont();
void saveFile();
void newPath();
private slots: private slots:
void on_pushButton_clicked(); void on_pushButton_clicked();
@ -41,8 +59,9 @@ private slots:
void on_toolButton_clicked(); void on_toolButton_clicked();
void on_actionopenFile_triggered(); void on_actionSave_triggered();
void on_actionopenFile_triggered();
void on_actionEditCopy_triggered(); void on_actionEditCopy_triggered();
@ -78,9 +97,35 @@ private slots:
void on_actionFont_size_triggered(); void on_actionFont_size_triggered();
void on_pathNumber_valueChanged(int arg1);
void on_stepNumber_valueChanged(int arg1);
void on_validateBtn_clicked();
void on_actionSave_as_triggered();
void on_exportHTMLBtn_clicked();
void on_actionSaveFile_triggered();
void on_actionSaveAsFile_triggered();
void on_actionCopy_triggered();
void on_actionPast_triggered();
void on_actionCut_triggered();
void on_actionNew_triggered();
void on_actionNewFile_triggered();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
QString currentFile; QString currentFile;
static int indexPath;
bool textChanged; bool textChanged;
QList<Path*> path; QList<Path*> path;
Path* currentPath; Path* currentPath;

View File

@ -7,17 +7,41 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>800</width>
<height>626</height> <height>868</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>MainWindow</string> <string>MainWindow</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>30</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>800</width> <width>800</width>
<height>521</height> <height>1000</height>
</size> </size>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@ -42,6 +66,12 @@
</item> </item>
<item> <item>
<widget class="QFrame" name="frame"> <widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>16777215</width> <width>16777215</width>
@ -51,35 +81,31 @@
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<widget class="QSpinBox" name="spinBox"> <layout class="QHBoxLayout" name="horizontalLayout_13">
<property name="geometry"> <item>
<rect> <widget class="QWidget" name="widget_8" native="true">
<x>10</x> <layout class="QVBoxLayout" name="verticalLayout_2">
<y>20</y> <item>
<width>45</width> <widget class="QWidget" name="widget_7" native="true">
<height>27</height> <layout class="QHBoxLayout" name="horizontalLayout_12">
</rect> <item>
<widget class="QSpinBox" name="pathNumber">
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>1</number>
</property> </property>
</widget> </widget>
<widget class="QLineEdit" name="titleEdit"> </item>
<property name="geometry"> <item>
<rect> <widget class="QLineEdit" name="titleEdit"/>
<x>60</x> </item>
<y>20</y> </layout>
<width>391</width>
<height>26</height>
</rect>
</property>
</widget> </widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true"> <widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>441</width>
<height>45</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
@ -98,35 +124,13 @@
<widget class="QLineEdit" name="locEdit"/> <widget class="QLineEdit" name="locEdit"/>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="spinBox_2"/> <widget class="QSpinBox" name="depSpin"/>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QLabel" name="imageLbl"> </item>
<property name="geometry"> <item>
<rect>
<x>470</x>
<y>20</y>
<width>281</width>
<height>191</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QWidget" name="widget_5" native="true"> <widget class="QWidget" name="widget_5" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>110</y>
<width>451</width>
<height>63</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
@ -137,6 +141,12 @@
<item> <item>
<widget class="QWidget" name="widget_2" native="true"> <widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
@ -160,6 +170,12 @@
<item> <item>
<widget class="QWidget" name="widget_3" native="true"> <widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="text"> <property name="text">
@ -186,6 +202,12 @@
<item> <item>
<widget class="QWidget" name="widget_4" native="true"> <widget class="QWidget" name="widget_4" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
@ -214,15 +236,9 @@
</item> </item>
</layout> </layout>
</widget> </widget>
</item>
<item>
<widget class="QWidget" name="widget_6" native="true"> <widget class="QWidget" name="widget_6" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>180</y>
<width>451</width>
<height>44</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="leftMargin"> <property name="leftMargin">
<number>9</number> <number>9</number>
@ -260,6 +276,33 @@
</item> </item>
</layout> </layout>
</widget> </widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="imageLbl">
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>200</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
@ -276,20 +319,155 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QFrame" name="frame_2"> <widget class="QFrame" name="stepInformationFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<widget class="QPlainTextEdit" name="plainTextEdit"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="geometry"> <item>
<rect> <widget class="QWidget" name="steptitleFrame" native="true">
<x>200</x> <layout class="QHBoxLayout" name="horizontalLayout_7">
<y>80</y> <item>
<width>391</width> <widget class="QSpinBox" name="stepNumber">
<height>101</height> <property name="minimum">
</rect> <number>1</number>
</property> </property>
</widget> </widget>
</item>
<item>
<widget class="QLineEdit" name="stepTitle"/>
</item>
<item>
<widget class="QToolButton" name="addStep">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="data.qrc">
<normaloff>:/data/images/data/images/add.png</normaloff>:/data/images/data/images/add.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="stepCoordinatesFrame" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QWidget" name="latFrame" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="latLbl">
<property name="text">
<string>Latitude</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="LatitudeSpin">
<property name="decimals">
<number>6</number>
</property>
<property name="maximum">
<double>90.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="longFrame" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="longLbl">
<property name="text">
<string>Longitude</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="longitudeSpin">
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>-180.000000000000000</double>
</property>
<property name="maximum">
<double>180.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="responseFrame" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="responseLbl">
<property name="text">
<string>Response</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="responseSpin"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="dialogEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>255</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="backgroundVisible">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="validateBtn">
<property name="text">
<string>Valider</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="exportHTMLBtn">
<property name="text">
<string>Export HTML</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -307,6 +485,7 @@
<property name="title"> <property name="title">
<string>File</string> <string>File</string>
</property> </property>
<addaction name="actionNew"/>
<addaction name="actionOpen"/> <addaction name="actionOpen"/>
<addaction name="actionSave"/> <addaction name="actionSave"/>
<addaction name="actionSave_as"/> <addaction name="actionSave_as"/>
@ -315,6 +494,11 @@
<property name="title"> <property name="title">
<string>Edit</string> <string>Edit</string>
</property> </property>
<addaction name="actionCopy"/>
<addaction name="actionPast"/>
<addaction name="actionCut"/>
<addaction name="actionUndo"/>
<addaction name="actionRedo"/>
</widget> </widget>
<widget class="QMenu" name="menuFont"> <widget class="QMenu" name="menuFont">
<property name="title"> <property name="title">
@ -333,7 +517,6 @@
<addaction name="menuEdit"/> <addaction name="menuEdit"/>
<addaction name="menuFont"/> <addaction name="menuFont"/>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar"> <widget class="QToolBar" name="toolBar">
<property name="windowTitle"> <property name="windowTitle">
<string>toolBar</string> <string>toolBar</string>
@ -348,7 +531,6 @@
<addaction name="actionopenFile"/> <addaction name="actionopenFile"/>
<addaction name="actionSaveFile"/> <addaction name="actionSaveFile"/>
<addaction name="actionSaveAsFile"/> <addaction name="actionSaveAsFile"/>
<addaction name="actionPrintFile"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionEditCopy"/> <addaction name="actionEditCopy"/>
<addaction name="actionEditPaste"/> <addaction name="actionEditPaste"/>
@ -424,18 +606,6 @@
<enum>QAction::NoRole</enum> <enum>QAction::NoRole</enum>
</property> </property>
</action> </action>
<action name="actionPrintFile">
<property name="icon">
<iconset resource="data.qrc">
<normaloff>:/data/images/data/images/print.png</normaloff>:/data/images/data/images/print.png</iconset>
</property>
<property name="text">
<string>Print</string>
</property>
<property name="menuRole">
<enum>QAction::NoRole</enum>
</property>
</action>
<action name="actionEditCopy"> <action name="actionEditCopy">
<property name="icon"> <property name="icon">
<iconset resource="data.qrc"> <iconset resource="data.qrc">
@ -508,111 +678,52 @@
<enum>QAction::NoRole</enum> <enum>QAction::NoRole</enum>
</property> </property>
</action> </action>
<action name="actionBold"> <action name="actionNew">
<property name="icon">
<iconset resource="data.qrc">
<normaloff>:/data/images/data/images/bold.png</normaloff>:/data/images/data/images/bold.png</iconset>
</property>
<property name="text"> <property name="text">
<string>Bold</string> <string>New path</string>
</property>
</action>
<action name="actionItalic">
<property name="icon">
<iconset resource="data.qrc">
<normaloff>:/data/images/data/images/italic.png</normaloff>:/data/images/data/images/italic.png</iconset>
</property>
<property name="text">
<string>Italic</string>
</property>
</action>
<action name="actionUnderline">
<property name="icon">
<iconset resource="data.qrc">
<normaloff>:/data/images/data/images/underline.png</normaloff>:/data/images/data/images/underline.png</iconset>
</property>
<property name="text">
<string>Underline</string>
</property>
</action>
<action name="actionColor">
<property name="icon">
<iconset resource="data.qrc">
<normaloff>:/data/images/data/images/font-color.png</normaloff>:/data/images/data/images/font-color.png</iconset>
</property>
<property name="text">
<string>Color</string>
</property>
</action>
<action name="actionOverline">
<property name="icon">
<iconset resource="data.qrc">
<normaloff>:/data/images/data/images/overline.png</normaloff>:/data/images/data/images/overline.png</iconset>
</property>
<property name="text">
<string>Overline</string>
</property>
</action>
<action name="actionFont">
<property name="icon">
<iconset resource="data.qrc">
<normaloff>:/data/images/data/images/font.png</normaloff>:/data/images/data/images/font.png</iconset>
</property>
<property name="text">
<string>Font</string>
</property>
</action>
<action name="actionSize">
<property name="icon">
<iconset resource="data.qrc">
<normaloff>:/data/images/data/images/font-size.png</normaloff>:/data/images/data/images/font-size.png</iconset>
</property>
<property name="text">
<string>Size</string>
</property>
</action>
<action name="actionFont_color">
<property name="text">
<string>Font color</string>
</property>
</action>
<action name="actionFont_2">
<property name="text">
<string>Font</string>
</property>
</action>
<action name="actionFont_size">
<property name="text">
<string>Font size</string>
</property>
</action>
<action name="actionBold_2">
<property name="text">
<string>Bold</string>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+B</string> <string>Ctrl+N</string>
</property> </property>
</action> </action>
<action name="actionItalic_2"> <action name="actionCopy">
<property name="text"> <property name="text">
<string>Italic</string> <string>Copy</string>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+I</string> <string>Ctrl+C</string>
</property> </property>
</action> </action>
<action name="actionUnderline_2"> <action name="actionPast">
<property name="text"> <property name="text">
<string>Underline</string> <string>Past</string>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+U</string> <string>Ctrl+V</string>
</property> </property>
</action> </action>
<action name="actionOverline_2"> <action name="actionCut">
<property name="text"> <property name="text">
<string>Overline</string> <string>Cut</string>
</property>
<property name="shortcut">
<string>Ctrl+X</string>
</property>
</action>
<action name="actionUndo">
<property name="text">
<string>Undo</string>
</property>
<property name="shortcut">
<string>Ctrl+Z</string>
</property>
</action>
<action name="actionRedo">
<property name="text">
<string>Redo</string>
</property>
<property name="shortcut">
<string>Ctrl+Y</string>
</property> </property>
</action> </action>
</widget> </widget>

124
pages/parcours1.html Normal file
View File

@ -0,0 +1,124 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Carte du parcours</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: whitesmoke;
}
#container {
display: flex;
gap: 20px;
}
#map {
height: 600px;
width: 60%;
border-radius: 5%;
border: 1px solid #aaa;
}
#fiche {
padding-right:20px;
width: 40%;
max-height: 600px;
overflow-y: auto;
border: 1px solid #aaa;
padding: 10px;
box-sizing: border-box;
background-color:#095228;
border-radius: 5%;
}
#fiche ul {
padding-left: 20px;
list-style-type: disc;
overflow-wrap: break-word;
word-wrap: break-word;
word-break: break-word;
white-space: normal;
max-width: 90%;
}
#fiche li {
white-space: normal;
overflow-wrap: break-word;
}
body h1 {
display:flex;
align-items:center;
justify-content:center;
text-align: center;
color: black;
font-style: bold;
margin-bottom: 20px;
background-color:brown;
border-radius:12px;
height: 75px;
}
#fiche h2, #fiche h3, #fiche p, #fiche li {
color: white;
}
#fiche img {
max-width: 100%;
height: auto;
margin-top: 10px;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>Fiche du parcours</h1>
<div id="container">
<div id="map"></div>
<div id="fiche">
<h2>parcous123</h2>
<p><strong>Ville :</strong> Bourg en bresse</p>
<p><strong>Département :</strong> 0</p>
<p><strong>Difficulté :</strong> 2</p>
<p><strong>Durée (heures) :</strong> 2.3</p>
<p><strong>Longueur (km) :</strong> 17.3</p>
<img src="data/parcours1.png">
<h3>Étape 1</h3>
<p><strong>Personnages :</strong></p>
<ul><li>Quentin</li>
</ul>
<p><strong>Dialogues :</strong></p>
<ul><li>ok c'est cool</li>
</ul>
<h3>Étape 2</h3>
<p><strong>Personnages :</strong></p>
<ul><li>Quentin</li>
</ul>
<p><strong>Dialogues :</strong></p>
<ul><li>ok c'est cool</li>
</ul>
</div>
</div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script>
var map = L.map('map').setView([45.5, 1.5], 10); // Vue centrée
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
L.marker([0, 0]).addTo(map).bindPopup("<b>Étape 1</b><br>");
var latlngs = [
[0, 0],
];
var polyline = L.polyline(latlngs, {
color: 'purple',
weight: 2,
dashArray: '10, 10',
opacity: 0.7
}).addTo(map);
map.fitBounds(polyline.getBounds());
</script>
</body>
</html>

View File

@ -45,11 +45,48 @@ QString Path::getImage() const
return image; return image;
} }
QList<Step> Path::getStep() const QList<Step>& Path::getStep()
{ {
return step; return step;
} }
void Path::setCity(const QString &newCity)
{
city = newCity;
}
void Path::setDepartement(int newDepartement)
{
departement = newDepartement;
}
void Path::setName(const QString &newName)
{
name = newName;
}
void Path::setDifficulty(unsigned int newDifficulty)
{
difficulty = newDifficulty;
}
void Path::setDuration(float newDuration)
{
duration = newDuration;
}
void Path::setLength(float newLength)
{
length = newLength;
}
void Path::setImage(const QString &newImage)
{
image = newImage;
}
Path::Path(){}
Path::Path(QFile *file){ Path::Path(QFile *file){
if (!file->open(QIODevice::ReadOnly)) { if (!file->open(QIODevice::ReadOnly)) {
qWarning() << "Could not open file:" << file->errorString(); qWarning() << "Could not open file:" << file->errorString();

9
path.h
View File

@ -28,7 +28,14 @@ public:
float getDuration() const; float getDuration() const;
float getLength() const; float getLength() const;
QString getImage() const; QString getImage() const;
QList<Step> getStep() const; QList<Step>& getStep();
void setCity(const QString &newCity);
void setDepartement(int newDepartement);
void setName(const QString &newName);
void setDifficulty(unsigned int newDifficulty);
void setDuration(float newDuration);
void setLength(float newLength);
void setImage(const QString &newImage);
}; };
#endif // PATH_H #endif // PATH_H

View File

@ -13,12 +13,14 @@ SOURCES += \
mainwindow.cpp \ mainwindow.cpp \
step.cpp \ step.cpp \
path.cpp \ path.cpp \
web.cpp
HEADERS += \ HEADERS += \
Undo.h \ Undo.h \
mainwindow.h \ mainwindow.h \
step.h \ step.h \
path.h \ path.h \
web.h
FORMS += \ FORMS += \
mainwindow.ui mainwindow.ui

View File

@ -27,13 +27,42 @@ int Step::getResponse() const
return response; return response;
} }
QList<QString> Step::getPersonnage() const
{
return personnage;
}
QList<QString> 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<QString> &newPersonnage)
{
personnage = newPersonnage;
}
void Step::setTexte(const QList<QString> &newTexte)
{
texte = newTexte;
}
Step::Step() { Step::Step() {
latitude = 0.0; latitude = 0.0;
longitude = 0.0; longitude = 0.0;
response = 0; response = 0;
} }
Step::Step( QJsonObject &in) Step::Step( QJsonObject &in)
{ {
title = in["title"].toString(); title = in["title"].toString();
@ -41,7 +70,7 @@ Step::Step( QJsonObject &in)
QString gps = in["GPS"].toString(); QString gps = in["GPS"].toString();
QStringList parts = gps.split(" ", Qt::SkipEmptyParts); QStringList parts = gps.split(" ", Qt::SkipEmptyParts);
QChar latDir = parts[0][0]; // c'est le premier QChar du QString t'as capté QChar latDir = parts[0][0];
int latDeg = parts[1].toInt(); int latDeg = parts[1].toInt();
float latMin = parts[2].toFloat(); float latMin = parts[2].toFloat();
setLatitude(latDeg, latMin, latDir); setLatitude(latDeg, latMin, latDir);
@ -80,3 +109,25 @@ void Step::setLongitude(int degree, float minute, QChar EW)
if (EW.toUpper() == 'W') if (EW.toUpper() == 'W')
longitude = -longitude; longitude = -longitude;
} }
QString Step::toGPSFormat(){
int latDeg = static_cast<int>(latitude);
float latMin = (latitude - latDeg) * 60.0;
QChar latDir = latitude >= 0 ? 'N' : 'S';
latDeg = abs(latDeg);
int lonDeg = static_cast<int>(longitude);
float lonMin = (longitude - lonDeg) * 60.0;
QChar lonDir = longitude >= 0 ? 'E' : 'W';
lonDeg = abs(lonDeg);
QString gpsString = QString("%1 %2 %3 %4 %5 %6")
.arg(latDir)
.arg(latDeg, 2)
.arg(latMin, 5, 'f', 3)
.arg(lonDir)
.arg(lonDeg, 2)
.arg(lonMin, 5, 'f', 3);
return gpsString;
}

7
step.h
View File

@ -26,6 +26,13 @@ public:
float getLatitude() const; float getLatitude() const;
float getLongitude() const; float getLongitude() const;
int getResponse() const; int getResponse() const;
QList<QString> getPersonnage() const;
QList<QString> getTexte() const;
void setTitle(const QString &newTitle);
void setResponse(int newResponse);
void setPersonnage(const QList<QString> &newPersonnage);
void setTexte(const QList<QString> &newTexte);
QString toGPSFormat();
}; };
#endif // STEP_H #endif // STEP_H

85
web.cpp Normal file
View File

@ -0,0 +1,85 @@
#include "web.h"
#include <fstream>
Web::Web()
{}
Web::Web(const QList<Path*>& 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"(<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<title>Liste des parcours</title>
<style>
body {
font-family: Arial;
margin: 40px;
background-color: whitesmoke;
}
h1 {
text-align: center;
color: black;
font-style: bold;
}
ul {
max-width: 600px;
margin: 0 auto;
padding: 0;
list-style-type: none;
}
li {
background: white;
margin: 10px 0;
padding: 15px;
border-radius: 8px;
box-shadow: 0 0 6px rgba(0,0,0,0.1);
transition: background-color 0.3s ease;
}
li:hover {
background-color:black;
}
a {
text-decoration: none;
color: purple;
font-weight: bold;
font-size: 1.2em;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<h1>Liste des parcours</h1>
<ul>
)";
int index = 0;
for (const Path* p : list) {
QString fileName = QString("parcours%1.html").arg(index);
QString name = p->getName();
file << " <li><a href=\"./pages/"
<< fileName.toStdString()
<< "\">"
<< name.toStdString()
<< "</a></li>\n";
++index;
}
file << R"( </ul>
</body>
</html>
)";
file.close();
}

17
web.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef WEB_H
#define WEB_H
#include <QList>
#include <mainwindow.h>
#include "path.h"
class Web
{
private:
QList<Path*> list;
public:
Web();
Web(const QList<Path*> &list);
void siteHtml();
};
#endif // WEB_H