diff --git a/data/images/d.json b/data/images/d.json new file mode 100644 index 0000000..e69de29 diff --git a/mainwindow.cpp b/mainwindow.cpp index eef3d8e..67ff713 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -22,7 +22,7 @@ MainWindow::MainWindow(QWidget *parent) , Clipboard(QGuiApplication::clipboard()) { ui->setupUi(this); - + currentPath = new Path(); connect(ui->titleEdit, &QLineEdit::editingFinished, this, [this]() { static QString previousText; @@ -95,6 +95,7 @@ void MainWindow::loadNewPath() currentPath = p; path.append(p); loadPath(p); + currentFile = fileName; int pathCount = path.length(); ui->pathNumber->setMaximum(pathCount); @@ -116,6 +117,7 @@ void MainWindow::loadPath(Path* p) { ui->depSpin->setValue(p->getDepartement()); loadImage(p->getImage()); + ui->dialogEdit->clear(); if(!steps.isEmpty()) { @@ -162,36 +164,35 @@ void MainWindow::exportHTMLMap() } void MainWindow::loadImage(QString fileName) { - QString ext[] = {"png", "jpeg", "jpg"}; QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QFile::Text)) { - QMessageBox::warning(this, "Warning", "Cannot open file: " + + QMessageBox::warning(this, "Warning", "Cannot open image: " + file.errorString()); - return; - } - QString text = file.fileName(); - bool acceptedExt = false; - for(QString e : ext) { - if(text.endsWith(e)) acceptedExt = true; + }else{ + QString text = file.fileName(); + bool acceptedExt = false; + for(QString e : ext) { + if(text.endsWith(e)) acceptedExt = true; + } + if(!acceptedExt) { + QMessageBox::warning(this, "Warning", "Format de fichier incorrect"); + return; + } + + + ui->imagePath->setText(text); + + + QPixmap px(fileName); + + ui->imageLbl->setPixmap(px); + + file.close(); } - if(!acceptedExt) { - QMessageBox::warning(this, "Warning", "Format de fichier incorrect"); - return; - } - - - ui->imagePath->setText(text); - - - QPixmap px(fileName); - - ui->imageLbl->setPixmap(px); - - file.close(); } @@ -259,7 +260,6 @@ void MainWindow::saveFile(){ steps.append(stepObject); } json["steps"] = steps; - QJsonDocument doc(json); file.write(doc.toJson()); diff --git a/path.cpp b/path.cpp index 26a2558..69a46b7 100644 --- a/path.cpp +++ b/path.cpp @@ -50,6 +50,8 @@ QList Path::getStep() const return step; } +Path::Path(){} + Path::Path(QFile *file){ if (!file->open(QIODevice::ReadOnly)) { qWarning() << "Could not open file:" << file->errorString();