Extract loadPath function
This commit is contained in:
parent
29054c76a2
commit
e3f79d95b7
@ -37,9 +37,29 @@ void MainWindow::onTextChanged()
|
|||||||
textChanged = true;
|
textChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::loadPath(QTextStream &in)
|
void MainWindow::loadPath()
|
||||||
{
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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::addNewPath()
|
void MainWindow::addNewPath()
|
||||||
@ -101,28 +121,7 @@ void MainWindow::on_pushButton_clicked()
|
|||||||
|
|
||||||
void MainWindow::on_actionOpen_triggered()
|
void MainWindow::on_actionOpen_triggered()
|
||||||
{
|
{
|
||||||
|
this->loadPath();
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
void MainWindow::on_toolButton_clicked()
|
||||||
|
|||||||
@ -21,7 +21,7 @@ public:
|
|||||||
void updatePathView();
|
void updatePathView();
|
||||||
void updateStepView(size_t num);
|
void updateStepView(size_t num);
|
||||||
void onTextChanged();
|
void onTextChanged();
|
||||||
void loadPath(QTextStream &in);
|
void loadPath();
|
||||||
void addNewPath();
|
void addNewPath();
|
||||||
void addNewStep();
|
void addNewStep();
|
||||||
void exportHTMLMap();
|
void exportHTMLMap();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user