Load data
This commit is contained in:
+27
-4
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user