Load data

This commit is contained in:
T'JAMPENS QUENTIN p2406187 2025-06-19 10:23:50 +02:00
parent 8fd2dc0df7
commit 37000d8281
3 changed files with 45 additions and 9 deletions

View File

@ -1,5 +1,6 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "path.h"
#include <QFileDialog>
#include <QMessageBox>
@ -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);
}

View File

@ -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;
Path* currentPath;
void loadImage(QString fileName);
};
#endif // MAINWINDOW_H

View File

@ -67,7 +67,7 @@
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<widget class="QLineEdit" name="titleEdit">
<property name="geometry">
<rect>
<x>60</x>
@ -101,7 +101,7 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_2"/>
<widget class="QLineEdit" name="locEdit"/>
</item>
<item>
<widget class="QSpinBox" name="spinBox_2"/>
@ -148,7 +148,7 @@
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_3">
<widget class="QSpinBox" name="diffSpin">
<property name="suffix">
<string>/5</string>
</property>
@ -171,7 +171,7 @@
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox">
<widget class="QDoubleSpinBox" name="durationSpin">
<property name="suffix">
<string>h</string>
</property>
@ -197,7 +197,7 @@
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox_2">
<widget class="QDoubleSpinBox" name="lengthSpin">
<property name="suffix">
<string>Km</string>
</property>
@ -243,6 +243,16 @@
<item>
<widget class="QLineEdit" name="imagePath"/>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="QIcon::ThemeIcon::ListAdd"/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">