AssetListFileTableModel.h 3.3 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 <QDateTime>
  11. #include <QSharedPointer>
  12. namespace AssetBundler
  13. {
  14. class AssetListTableModel;
  15. struct AssetListFileInfo
  16. {
  17. /**
  18. * Stores information about an Asset List File on disk.
  19. *
  20. * @param absolutePath The absolute path of the Asset List File
  21. * @param fileName The name of the Asset List File. This does not include the platform ID
  22. * @param platform The platform for the Asset List File
  23. */
  24. AssetListFileInfo(const AZStd::string& absolutePath, const QString& fileName, const AZStd::string& platform);
  25. AZStd::string m_absolutePath;
  26. QDateTime m_fileCreationTime;
  27. /// Use QString for display purpose. This can help to avoid losts of string conversion
  28. QString m_fileName;
  29. QString m_platform;
  30. QSharedPointer<AssetListTableModel> m_assetListModel;
  31. };
  32. using AssetListFileInfoPtr = AZStd::shared_ptr<AssetListFileInfo>;
  33. /// Stores AssetListFileInfo, using the absolute path (without the drive letter) of the Asset List file as the key
  34. using AssetListFileInfoMap = AZStd::unordered_map<AZStd::string, AssetListFileInfoPtr>;
  35. class AssetListFileTableModel
  36. : public AssetBundlerAbstractFileTableModel
  37. {
  38. public:
  39. explicit AssetListFileTableModel();
  40. virtual ~AssetListFileTableModel() {}
  41. QSharedPointer<AssetListTableModel> GetAssetListFileContents(const QModelIndex& index);
  42. //////////////////////////////////////////////////////////////////////////
  43. // AssetBundlerAbstractFileTableModel overrides
  44. AZStd::vector<AZStd::string> CreateNewFiles(
  45. const AZStd::string& /*absoluteFilePath*/,
  46. const AzFramework::PlatformFlags& /*platforms*/,
  47. const QString& /*project*/) override { return {}; }
  48. bool DeleteFile(const QModelIndex& index) override;
  49. void LoadFile(const AZStd::string& absoluteFilePath, const AZStd::string& projectName = "", bool isDefaultFile = false) override;
  50. bool WriteToDisk(const AZStd::string& key) override;
  51. AZStd::string GetFileAbsolutePath(const QModelIndex& index) const override;
  52. int GetFileNameColumnIndex() const override;
  53. int GetTimeStampColumnIndex() const override;
  54. //////////////////////////////////////////////////////////////////////////
  55. // QAbstractListModel overrides
  56. int columnCount(const QModelIndex& parent = QModelIndex()) const override;
  57. QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
  58. QVariant data(const QModelIndex& index, int role) const override;
  59. //////////////////////////////////////////////////////////////////////////
  60. enum Column
  61. {
  62. ColumnFileName,
  63. ColumnPlatform,
  64. ColumnFileCreationTime,
  65. Max
  66. };
  67. private:
  68. AZ::Outcome<AssetListFileInfoPtr, void> GetAssetFileInfo(const QModelIndex& index) const;
  69. AssetListFileInfoMap m_assetListFileInfoMap;
  70. };
  71. } // namespace AssetBundler