diff --git a/mainwindow.cpp b/mainwindow.cpp index 69a8d9e..837a7b4 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,5 +1,6 @@ #include "mainwindow.h" #include "ui_mainwindow.h" +#include "path.h" #include #include @@ -56,13 +57,10 @@ void MainWindow::exportHTMLMap() } -void MainWindow::on_pushButton_clicked() -{ +void MainWindow::loadImage(QString fileName) { QString ext[] = {"png", "jpeg", "jpg"}; - QString fileName = QFileDialog::getOpenFileName(this, "Open the file"); - if (fileName.isEmpty()) return; QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QFile::Text)) { QMessageBox::warning(this, "Warning", "Cannot open file: " + @@ -91,7 +89,13 @@ void MainWindow::on_pushButton_clicked() file.close(); +} +void MainWindow::on_pushButton_clicked() +{ + QString fileName = QFileDialog::getOpenFileName(this, "Open the file"); + if (fileName.isEmpty()) return; + this->loadImage(fileName); } @@ -106,6 +110,25 @@ void MainWindow::on_actionOpen_triggered() return; } + file.close(); + Path* p = new Path(&file); + currentPath = p; + path.append(p); + ui->titleEdit->setText(p->getName()); + ui->locEdit->setText(p->getCity()); + ui->diffSpin->setValue(p->getDifficulty()); + ui->lengthSpin->setValue(p->getLength()); + ui->durationSpin->setValue(p->getDuration()); + ui->imagePath->setText(p->getImage()); + + loadImage(p->getImage()); +} + +void MainWindow::on_toolButton_clicked() +{ + QString fileName = ui->imagePath->text(); + if(fileName.isEmpty()) return; + loadImage(fileName); } diff --git a/mainwindow.h b/mainwindow.h index 38e219a..8757459 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -31,11 +31,14 @@ private slots: void on_actionOpen_triggered(); + void on_toolButton_clicked(); + private: Ui::MainWindow *ui; QString currentFile; bool textChanged; QList path; Path* currentPath; + void loadImage(QString fileName); }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index 8c3b28b..0af09fa 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -67,7 +67,7 @@ - + 60 @@ -101,7 +101,7 @@ - + @@ -148,7 +148,7 @@ - + /5 @@ -171,7 +171,7 @@ - + h @@ -197,7 +197,7 @@ - + Km @@ -243,6 +243,16 @@ + + + + ... + + + + + +