/src/applications/unisim/xml_editor.cpp

https://github.com/HawkLane/UniSim · C++ · 46 lines · 27 code · 9 blank · 10 comment · 1 complexity · 5743a5fc2bc006833a081e86c8439816 MD5 · raw file

  1. /* Copyright (C) 2009-2011 by Niels Holst [niels.holst@agrsci.dk] and co-authors.
  2. ** Copyrights reserved.
  3. ** Released under the terms of the GNU General Public License version 3.0 or later.
  4. ** See www.gnu.org/copyleft/gpl.html.
  5. */
  6. #include <QDesktopServices>
  7. #include <QFile>
  8. #include <QMessageBox>
  9. #include <QProcess>
  10. #include <QUrl>
  11. #include <usbase/exception.h>
  12. #include "xml_editor.h"
  13. namespace UniSim {
  14. XmlEditor::XmlEditor()
  15. {
  16. process = new QProcess;
  17. xmlEditorPath = "C:/Program Files/Notepad++/notepad++.exe";
  18. //xmlEditorPath = "C:/WINDOWS/system32/notepad.exe";
  19. }
  20. XmlEditor::~XmlEditor() {
  21. process->close();
  22. delete process;
  23. }
  24. void XmlEditor::execute(QString filePath) {
  25. if (!QFile(xmlEditorPath).exists())
  26. throw UniSim::Exception("Could not find dot program to edit XML file:\n'" + xmlEditorPath + "'");
  27. QString command = "\"" + xmlEditorPath + "\"";
  28. //QStringList arguments = QStringList() << "\"" + filePath + "\"";
  29. QStringList arguments = QStringList() << "\"C:/data/Universal Simulator/models/test.xml\"";
  30. //QMessageBox::information(0,"Test execute",command+"\n"+arguments[0]);
  31. //process->start(command, arguments);
  32. QUrl url("C:\\data\\Universal Simulator\\models\\test.xml");
  33. QMessageBox::information(0,"URL",url.path());
  34. QDesktopServices::openUrl(url);
  35. //process->start("C:/data/QDev/unisim/doc/test editor.bat", QStringList());
  36. }
  37. }