AssetTreeEntry.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <AzCore/std/string/string.h>
  10. #include <AzCore/std/containers/map.h>
  11. #include <AzCore/Asset/AssetCommon.h>
  12. #include <AzToolsFramework/AssetBrowser/Search/Filter.h>
  13. #include <QString>
  14. namespace AzToolsFramework
  15. {
  16. namespace AssetBrowser
  17. {
  18. class AssetBrowserEntry;
  19. }
  20. }
  21. //! UISliceLibraryFilter locates all of the UI slices so that they can be instantiated via "Element from Slice Library" menu function
  22. class UISliceLibraryFilter
  23. : public AzToolsFramework::AssetBrowser::AssetBrowserEntryFilter
  24. {
  25. public:
  26. UISliceLibraryFilter(const AZ::Data::AssetType& assetType, const AZStd::string& pathToSearch);
  27. ~UISliceLibraryFilter() override = default;
  28. AzToolsFramework::AssetBrowser::AssetBrowserEntryFilter* Clone() const override;
  29. protected:
  30. QString GetNameInternal() const override;
  31. bool MatchInternal(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const override;
  32. private:
  33. AZ::Data::AssetType m_assetType;
  34. AZStd::string m_pathToSearch;
  35. };
  36. ////////////////////////////////////////////////////////////////////////////////////////////////////
  37. //! Class to build and represent a hierarchical tree view of files and folders containing
  38. //! assets of a given type under a given path
  39. class AssetTreeEntry
  40. {
  41. public: // types
  42. using FolderMap = AZStd::map<AZStd::string, AssetTreeEntry*>;
  43. using FileMap = AZStd::map<AZStd::string, AZ::Data::AssetId>;
  44. public: // methods
  45. ~AssetTreeEntry();
  46. static AssetTreeEntry* BuildAssetTree(const AZ::Data::AssetType& assetType, const AZStd::string& pathToSearch);
  47. public: // data
  48. FileMap m_files;
  49. FolderMap m_folders;
  50. protected:
  51. void Insert(const AZStd::string& path, const AZStd::string& menuName, const AZ::Data::AssetId& assetId);
  52. };