MCPcopy Create free account
hub / github.com/BehaviorTree/Groot / on_actionLoad_triggered

Method on_actionLoad_triggered

bt_editor/mainwindow.cpp:370–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368
369
370void 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
403QString MainWindow::saveToXML() const
404{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected