| 368 | |
| 369 | |
| 370 | void MainWindow::on_actionLoad_triggered() |
| 371 | { |
| 372 | QSettings settings; |
| 373 | QString directory_path = settings.value("MainWindow.lastLoadDirectory", |
| 374 | QDir::homePath() ).toString(); |
| 375 | |
| 376 | QString fileName = QFileDialog::getOpenFileName(this, |
| 377 | tr("Load BehaviorTree from file"), directory_path, |
| 378 | tr("BehaviorTree files (*.xml)")); |
| 379 | if (!QFileInfo::exists(fileName)){ |
| 380 | return; |
| 381 | } |
| 382 | |
| 383 | QFile file(fileName); |
| 384 | |
| 385 | if (!file.open(QIODevice::ReadOnly)){ |
| 386 | return; |
| 387 | } |
| 388 | |
| 389 | directory_path = QFileInfo(fileName).absolutePath(); |
| 390 | settings.setValue("MainWindow.lastLoadDirectory", directory_path); |
| 391 | settings.sync(); |
| 392 | |
| 393 | QString xml_text; |
| 394 | |
| 395 | QTextStream in(&file); |
| 396 | while (!in.atEnd()) { |
| 397 | xml_text += in.readLine(); |
| 398 | } |
| 399 | |
| 400 | loadFromXML(xml_text); |
| 401 | } |
| 402 | |
| 403 | QString MainWindow::saveToXML() const |
| 404 | { |
nothing calls this directly
no outgoing calls
no test coverage detected