RulesFileTableModel.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #pragma once
  9. #include <source/models/AssetBundlerAbstractFileTableModel.h>
  10. #include <source/utils/utils.h>
  11. #include <AzToolsFramework/Asset/AssetBundler.h>
  12. #include <QDateTime>
  13. namespace AssetBundler
  14. {
  15. //! Stores information about a Rules file on disk.
  16. struct RulesFileInfo
  17. {
  18. RulesFileInfo(const AZStd::string& absolutePath, const QString& fileName, bool loadFromFile);
  19. bool SaveRulesFile();
  20. AZStd::string m_absolutePath;
  21. QString m_fileName;
  22. QDateTime m_fileModificationTime;
  23. bool m_hasUnsavedChanges = false;
  24. AZStd::shared_ptr<AzToolsFramework::AssetFileInfoListComparison> m_comparisonSteps;
  25. };
  26. using RulesFileInfoPtr = AZStd::shared_ptr<RulesFileInfo>;
  27. using RulesFileInfoMap = AZStd::unordered_map<AZStd::string, RulesFileInfoPtr>;
  28. class RulesFileTableModel
  29. : public AssetBundlerAbstractFileTableModel
  30. {
  31. public:
  32. RulesFileTableModel();
  33. virtual ~RulesFileTableModel() {}
  34. AZStd::vector<AZStd::string> CreateNewFiles(
  35. const AZStd::string& absoluteFilePath,
  36. const AzFramework::PlatformFlags& platforms = AzFramework::PlatformFlags::Platform_NONE,
  37. const QString& project = QString()) override;
  38. bool DeleteFile(const QModelIndex& index) override;
  39. void LoadFile(const AZStd::string& absoluteFilePath, const AZStd::string& projectName = "", bool isDefaultFile = false) override;
  40. bool WriteToDisk(const AZStd::string& key) override;
  41. AZStd::string GetFileAbsolutePath(const QModelIndex& index) const override;
  42. int GetFileNameColumnIndex() const override;
  43. int GetTimeStampColumnIndex() const override;
  44. AZStd::shared_ptr<AzToolsFramework::AssetFileInfoListComparison> GetComparisonSteps(const QModelIndex& index) const;
  45. bool MarkFileChanged(const QModelIndex& index);
  46. //////////////////////////////////////////////////////////////////////////
  47. // QAbstractTableModel overrides
  48. int columnCount(const QModelIndex& parent = QModelIndex()) const override;
  49. QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
  50. QVariant data(const QModelIndex& index, int role) const override;
  51. //////////////////////////////////////////////////////////////////////////
  52. enum Column
  53. {
  54. ColumnFileName,
  55. ColumnFileModificationTime,
  56. Max
  57. };
  58. private:
  59. RulesFileInfoMap m_rulesFileInfoMap;
  60. RulesFileInfoPtr GetRulesFileInfoPtr(const QModelIndex& index) const;
  61. };
  62. } // namespace AssetBundler