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