LevelFileDialog.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #ifndef CRYINCLUDE_EDITOR_LEVELFILEDIALOG_H
  9. #define CRYINCLUDE_EDITOR_LEVELFILEDIALOG_H
  10. #pragma once
  11. #if !defined(Q_MOC_RUN)
  12. #include <QDialog>
  13. #include <QScopedPointer>
  14. #endif
  15. namespace Ui {
  16. class LevelFileDialog;
  17. }
  18. class LevelTreeModel;
  19. class LevelTreeModelFilter;
  20. class CLevelFileDialog
  21. : public QDialog
  22. {
  23. Q_OBJECT
  24. public:
  25. explicit CLevelFileDialog(bool openDialog, QWidget* parent = nullptr);
  26. ~CLevelFileDialog();
  27. QString GetFileName() const;
  28. static bool CheckLevelFolder(const QString folder, QStringList* levelFiles = nullptr);
  29. protected Q_SLOTS:
  30. void OnOK();
  31. void OnCancel();
  32. void OnTreeSelectionChanged();
  33. void OnNewFolder();
  34. void OnFilterChanged();
  35. void OnNameChanged();
  36. protected:
  37. void ReloadTree();
  38. bool ValidateSaveLevelPath(QString& errorMessage) const;
  39. bool ValidateLevelPath(const QString& folder) const;
  40. void SaveLastUsedLevelPath();
  41. void LoadLastUsedLevelPath();
  42. private:
  43. bool eventFilter(QObject* watched, QEvent* event) override;
  44. QString NameForIndex(const QModelIndex& index) const;
  45. bool IsValidLevelSelected();
  46. QString GetLevelPath() const;
  47. QString GetEnteredPath() const;
  48. QString GetFileName(QString levelPath);
  49. QScopedPointer<Ui::LevelFileDialog> ui;
  50. QString m_fileName;
  51. QString m_filter;
  52. const bool m_bOpenDialog;
  53. LevelTreeModel* const m_model;
  54. LevelTreeModelFilter* const m_filterModel;
  55. };
  56. #endif // CRYINCLUDE_EDITOR_LEVELFILEDIALOG_H