You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.7 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2017 Chris Pavlina <pavlina.chris@gmail.com>
  5. * Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
  6. * Copyright (C) 2014-2022 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software: you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation, either version 3 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef SYMBOL_TREE_MODEL_ADAPTER_H
  22. #define SYMBOL_TREE_MODEL_ADAPTER_H
  23. #include <lib_tree_model_adapter.h>
  24. class LIB_TABLE;
  25. class SYMBOL_LIB_TABLE;
  26. class SCH_BASE_FRAME;
  27. class SYMBOL_TREE_MODEL_ADAPTER : public LIB_TREE_MODEL_ADAPTER
  28. {
  29. public:
  30. /**
  31. * Destructor. Do NOT delete this class manually; it is reference-counted by wxObject.
  32. */
  33. ~SYMBOL_TREE_MODEL_ADAPTER();
  34. /**
  35. * Factory function: create a model adapter in a reference-counting container.
  36. *
  37. * @param aLibs library set from which parts will be loaded
  38. */
  39. static wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> Create( EDA_BASE_FRAME* aParent,
  40. LIB_TABLE* aLibs );
  41. /**
  42. * Add all the libraries in a SYMBOL_LIB_TABLE to the model.
  43. * Displays a progress dialog attached to the parent frame the first time it is run.
  44. *
  45. * @param aNicknames is the list of library nicknames
  46. * @param aParent is the parent window to display the progress dialog
  47. * @return false if loading was cancelled by the user
  48. */
  49. bool AddLibraries( const std::vector<wxString>& aNicknames, SCH_BASE_FRAME* aFrame );
  50. void AddLibrary( wxString const& aLibNickname, bool pinned );
  51. wxString GenerateInfo( LIB_ID const& aLibId, int aUnit ) override;
  52. protected:
  53. /**
  54. * Constructor; takes a set of libraries to be included in the search.
  55. */
  56. SYMBOL_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs );
  57. PROJECT::LIB_TYPE_T getLibType() override { return PROJECT::LIB_TYPE_T::SYMBOL_LIB; }
  58. private:
  59. friend class SYMBOL_ASYNC_LOADER;
  60. /**
  61. * Flag to only show the symbol library table load progress dialog the first time.
  62. */
  63. static bool m_show_progress;
  64. SYMBOL_LIB_TABLE* m_libs;
  65. };
  66. #endif // SYMBOL_TREE_MODEL_ADAPTER_H