BundleFileListModel.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 <AzFramework/StringFunc/StringFunc.h>
  11. #include <AzToolsFramework/Asset/AssetBundler.h>
  12. #include <QDateTime>
  13. namespace AssetBundler
  14. {
  15. struct BundleFileInfo
  16. {
  17. AZStd::string m_absolutePath;
  18. QString m_fileName;
  19. QDateTime m_fileCreationTime;
  20. AZ::u64 m_compressedSize;
  21. QStringList m_relatedBundles;
  22. BundleFileInfo(const AZStd::string& absolutePath);
  23. };
  24. using BundleFileInfoPtr = AZStd::shared_ptr<BundleFileInfo>;
  25. using BundleFileInfoMap = AZStd::unordered_map<AZStd::string, BundleFileInfoPtr>;
  26. class BundleFileListModel
  27. : public AssetBundlerAbstractFileTableModel
  28. {
  29. public:
  30. explicit BundleFileListModel();
  31. virtual ~BundleFileListModel() {}
  32. AZStd::vector<AZStd::string> CreateNewFiles(
  33. const AZStd::string& /*absoluteFilePath*/,
  34. const AzFramework::PlatformFlags& /*platforms*/,
  35. const QString& /*project*/) override { return {}; }
  36. bool DeleteFile(const QModelIndex& index) override;
  37. void LoadFile(const AZStd::string& absoluteFilePath, const AZStd::string& projectName = "", bool isDefaultFile = false) override;
  38. bool WriteToDisk(const AZStd::string& /*key*/) override { return true; }
  39. AZStd::string GetFileAbsolutePath(const QModelIndex& index) const override;
  40. int GetFileNameColumnIndex() const override;
  41. int GetTimeStampColumnIndex() const override;
  42. AZ::Outcome<BundleFileInfoPtr, void> GetBundleInfo(const QModelIndex& index) const;
  43. //////////////////////////////////////////////////////////////////////////
  44. // QAbstractTableModel overrides
  45. int columnCount(const QModelIndex& parent = QModelIndex()) const override;
  46. QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
  47. QVariant data(const QModelIndex& index, int role) const override;
  48. //////////////////////////////////////////////////////////////////////////
  49. enum Column
  50. {
  51. ColumnFileName,
  52. ColumnFileCreationTime,
  53. Max
  54. };
  55. private:
  56. BundleFileInfoMap m_bundleFileInfoMap;
  57. };
  58. }