KiCad PCB EDA Suite
symbol_tree_synchronizing_adapter.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2017 CERN
5  * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Maciej Suminski <maciej.suminski@cern.ch>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 3
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * https://www.gnu.org/licenses/gpl-3.0.html
22  * or you may search the http://www.gnu.org website for the version 3 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #ifndef SYMBOL_TREE_SYNCHRONIZING_ADAPTER_H
28 #define SYMBOL_TREE_SYNCHRONIZING_ADAPTER_H
29 
30 #include <lib_tree_model_adapter.h>
31 #include <map>
32 
33 class SYMBOL_EDIT_FRAME;
35 
37 {
38 public:
39  static wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> Create( SYMBOL_EDIT_FRAME* aParent,
40  SYMBOL_LIBRARY_MANAGER* aLibs );
41 
42  bool IsContainer( const wxDataViewItem& aItem ) const override;
43 
44  void Sync( const wxString& aForceRefresh,
45  std::function<void( int, int, const wxString&)> aProgressCallback );
46 
47  int GetLibrariesCount() const override;
48 
50 
51 protected:
52  void updateLibrary( LIB_TREE_NODE_LIB& aLibNode );
53 
54  LIB_TREE_NODE::PTR_VECTOR::iterator deleteLibrary( LIB_TREE_NODE::PTR_VECTOR::iterator& aLibNodeIt );
55 
56  void GetValue( wxVariant& aVariant, wxDataViewItem const& aItem,
57  unsigned int aCol ) const override;
58  bool GetAttr( wxDataViewItem const& aItem, unsigned int aCol,
59  wxDataViewItemAttr& aAttr ) const override;
60 
62  SYMBOL_LIBRARY_MANAGER* aLibMgr );
63 
64 protected:
67 
69  std::map<wxString, int> m_libHashes;
70 
73 };
74 
75 #endif /* SYMBOL_TREE_SYNCHRONIZING_ADAPTER_H */
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(SYMBOL_EDIT_FRAME *aParent, SYMBOL_LIBRARY_MANAGER *aLibs)
bool IsContainer(const wxDataViewItem &aItem) const override
SYMBOL_TREE_SYNCHRONIZING_ADAPTER(SYMBOL_EDIT_FRAME *aParent, SYMBOL_LIBRARY_MANAGER *aLibMgr)
std::map< wxString, int > m_libHashes
SYMBOL_LIBRARY_MANAGER hash value returned in the last synchronization.
int GetLibrariesCount() const override
Return the number of libraries loaded in the tree.
void Sync(const wxString &aForceRefresh, std::function< void(int, int, const wxString &)> aProgressCallback)
Class to handle modifications to the symbol libraries.
Node type: library.
bool GetAttr(wxDataViewItem const &aItem, unsigned int aCol, wxDataViewItemAttr &aAttr) const override
SYMBOL_LIBRARY_MANAGER * m_libMgr
Hashes to decide whether a library needs an update.
LIB_TREE_NODE::PTR_VECTOR::iterator deleteLibrary(LIB_TREE_NODE::PTR_VECTOR::iterator &aLibNodeIt)
void GetValue(wxVariant &aVariant, wxDataViewItem const &aItem, unsigned int aCol) const override
The symbol library editor main window.