diff --git a/mainwindow.cpp b/mainwindow.cpp index 2740a6e..d6e2882 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,6 +1,9 @@ #include "mainwindow.h" #include "ui_mainwindow.h" +#include +#include + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) @@ -11,4 +14,82 @@ MainWindow::MainWindow(QWidget *parent) 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(); + + +} + diff --git a/mainwindow.h b/mainwindow.h index d622c71..1146f46 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -3,6 +3,8 @@ #include +#include "path.h" + QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; @@ -24,9 +26,14 @@ public: void addNewStep(); void exportHTMLMap(); +private slots: + void on_pushButton_clicked(); + private: Ui::MainWindow *ui; QString currentFile; bool textChanged; + QList path; + Path* currentPath; }; #endif // MAINWINDOW_H