DEMImport.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * Copyright (c) 2011-2018 by Andrew Mustun. All rights reserved.
  3. *
  4. * This file is part of the QCAD project.
  5. *
  6. * QCAD is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * QCAD is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with QCAD.
  18. */
  19. include("scripts/EAction.js");
  20. include("scripts/simple.js");
  21. //include("scripts/Misc/MiscIO/MiscIO.js");
  22. //include("scripts/File/File.js");
  23. /**
  24. * SAX style XML handler.
  25. */
  26. /**
  27. * \ingroup ecma_misc_examples_ioexamples
  28. * \class ExTxtImport
  29. * This action reads an XML file and outputs information to stderr.
  30. * This can be used as starting point for XML importers.
  31. */
  32. function DEMImport(guiAction) {
  33. EAction.call(this, guiAction);
  34. // this.setUiOptions("DEMImport.ui");
  35. }
  36. DEMImport.prototype = new EAction();
  37. DEMImport.includeBasePath = includeBasePath;
  38. DEMImport.prototype.beginEvent = function() {
  39. EAction.prototype.beginEvent.call(this);
  40. var appWin = EAction.getMainWindow();
  41. var initialPath = QDir.homePath();
  42. var filterAll = qsTr("DEM文件") + " (*.dem);";//+ qsTr("All Files") + " (*)";
  43. var fileDialog = new QFileDialog(appWin, qsTr("请导入DEM文件"), initialPath, "");
  44. fileDialog.setNameFilters([ filterAll ]);
  45. fileDialog.selectNameFilter(filterAll);
  46. fileDialog.setOption(QFileDialog.DontUseNativeDialog, getDontUseNativeDialog());
  47. fileDialog.fileMode = QFileDialog.ExistingFiles;
  48. if (!fileDialog.exec()) {
  49. destr(fileDialog);
  50. EAction.activateMainWindow();
  51. this.terminate();
  52. return;
  53. }
  54. var files = fileDialog.selectedFiles();
  55. if (files.length===0) {
  56. destr(fileDialog);
  57. EAction.activateMainWindow();
  58. this.terminate();
  59. return;
  60. }
  61. destr(fileDialog);
  62. EAction.activateMainWindow();
  63. var fileName = files[0];
  64. //var file = new QFile(fileName);
  65. EAction.handleUserMessage("Starting to load file: " + fileName);
  66. };