#include "mainwindow.h" #include "ui_mainwindow.h" #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; delete currentPath; for(Path* p : path) { delete p; } } void MainWindow::updatePathView() { } void MainWindow::updateStepView(size_t num) { } void MainWindow::onTextChanged() { textChanged = true; } void MainWindow::loadPath(QTextStream &in) { } void MainWindow::addNewPath() { } void MainWindow::addNewStep() { } void MainWindow::exportHTMLMap() { } void MainWindow::on_pushButton_clicked() { 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: " + file.errorString()); return; } 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(); } void MainWindow::on_actionOpen_triggered() { 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", "Fichier non valide" + file.errorString()); return; } }