From c2151515f5e85d90731faf30fcbdb87684722c0d Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 20 Jun 2025 11:30:45 +0200 Subject: [PATCH] Possibility to change the current Path --- mainwindow.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 224cb9a..bfde8c8 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -73,7 +73,7 @@ void MainWindow::onTextChanged() textChanged = true; } -void MainWindow::loadPath() +void MainWindow::loadNewPath() { QString fileName = QFileDialog::getOpenFileName(this, "Open the file"); if(fileName.isEmpty()) return; @@ -85,9 +85,20 @@ void MainWindow::loadPath() file.close(); Path* p = new Path(&file); - QList steps = p->getStep(); 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::loadPath(Path* p) { + + QList steps = p->getStep(); + ui->titleEdit->setText(p->getName()); ui->locEdit->setText(p->getCity()); @@ -97,6 +108,8 @@ void MainWindow::loadPath() ui->imagePath->setText(p->getImage()); loadImage(p->getImage()); + ui->dialogEdit->clear(); + if(!steps.isEmpty()) { Step firstStep = p->getStep().first(); ui->stepTitle->setText(firstStep.getTitle()); @@ -108,11 +121,6 @@ void MainWindow::loadPath() ui->dialogEdit->appendPlainText(q); } } - - int pathCount = path.length(); - ui->pathNumber->setMaximum(pathCount); - ui->pathNumber->setSuffix("/" + QString::number(pathCount)); - ui->pathNumber->setValue(path.indexOf(currentPath)+1); } void MainWindow::addNewPath() @@ -174,7 +182,7 @@ void MainWindow::on_pushButton_clicked() void MainWindow::on_actionOpen_triggered() { - this->loadPath(); + this->loadNewPath(); } void MainWindow::on_toolButton_clicked() @@ -187,7 +195,7 @@ void MainWindow::on_toolButton_clicked() void MainWindow::on_actionopenFile_triggered() { - this->loadPath(); + this->loadNewPath(); } void MainWindow::on_actionEditCopy_triggered() @@ -230,3 +238,9 @@ void MainWindow::on_actionEditCut_triggered() } } + +void MainWindow::on_pathNumber_valueChanged(int arg1) +{ + this->loadPath(path.at(ui->pathNumber->value()-1)); +} +