KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_import_symbol_select.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
24#include <sch_io/sch_io_mgr.h>
25#include <sch_io/sch_io.h>
26
27#include <map>
28#include <vector>
29
30class LIB_SYMBOL;
34
35
40{
41public:
49 const wxString& aFilePath,
50 const wxString& aDestLibrary,
51 SCH_IO_MGR::SCH_FILE_T aPluginType );
52
54
60 std::vector<wxString> GetSelectedSymbols() const;
61
66 const std::map<wxString, CONFLICT_RESOLUTION>& GetConflictResolutions() const
67 {
69 }
70
71protected:
72 void OnFilterTextChanged( wxCommandEvent& event ) override;
73 void OnSymbolSelected( wxDataViewEvent& event ) override;
74 void OnSelectAll( wxCommandEvent& event ) override;
75 void OnSelectNone( wxCommandEvent& event ) override;
76 void OnUnitChanged( wxCommandEvent& event ) override;
77
78 bool TransferDataToWindow() override;
79 bool TransferDataFromWindow() override;
80
81private:
86 bool loadSymbols();
87
91 void refreshList();
92
96 void updatePreview();
97
101 void updateStatusLine();
102
106 void updateImportButton();
107
111 void onItemChecked( wxDataViewEvent& event );
112
120 bool toggleSymbolSelection( const wxString& aSymbolName, bool aChecked );
121
125 bool matchesFilter( const wxString& aSymbolName ) const;
126
131 bool resolveConflicts();
132
133private:
135 wxString m_filePath;
137 SCH_IO_MGR::SCH_FILE_T m_pluginType;
138
141
143
146
148 std::map<wxString, int> m_listIndices;
149
152
155
157 std::map<wxString, CONFLICT_RESOLUTION> m_conflictResolutions;
158
160 enum
161 {
165 };
166};
DIALOG_IMPORT_SYMBOL_SELECT_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Import Symbols from %s"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(900, 650), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
bool loadSymbols()
Load symbols from the source file and populate the manager.
SYMBOL_IMPORT_MANAGER m_manager
Manager for symbol selection logic.
void refreshList()
Refresh the list control based on current filter and selections.
std::vector< wxString > GetSelectedSymbols() const
Get the list of symbols selected for import.
bool toggleSymbolSelection(const wxString &aSymbolName, bool aChecked)
Toggle selection state for a symbol.
wxString m_filterString
Current filter string.
wxString m_selectedSymbol
Currently selected symbol for preview.
const std::map< wxString, CONFLICT_RESOLUTION > & GetConflictResolutions() const
Get the conflict resolutions chosen by the user.
bool matchesFilter(const wxString &aSymbolName) const
Check if a symbol matches the current filter.
std::map< wxString, CONFLICT_RESOLUTION > m_conflictResolutions
Conflict resolutions chosen by user.
void OnSymbolSelected(wxDataViewEvent &event) override
bool resolveConflicts()
Show conflict resolution dialog.
void updateImportButton()
Update import button enabled state based on selection.
void updateStatusLine()
Update the status line with selection counts.
void OnFilterTextChanged(wxCommandEvent &event) override
void OnSelectAll(wxCommandEvent &event) override
std::map< wxString, int > m_listIndices
Map from symbol name to list index (UI-only, -1 if filtered out)
void OnSelectNone(wxCommandEvent &event) override
void onItemChecked(wxDataViewEvent &event)
Handle checkbox toggle in the list.
void OnUnitChanged(wxCommandEvent &event) override
DIALOG_IMPORT_SYMBOL_SELECT(SYMBOL_EDIT_FRAME *aParent, const wxString &aFilePath, const wxString &aDestLibrary, SCH_IO_MGR::SCH_FILE_T aPluginType)
void updatePreview()
Update the preview for the currently selected symbol.
IO_RELEASER< SCH_IO > m_plugin
Plugin kept alive for symbol access during dialog lifetime.
Define a library symbol object.
Definition lib_symbol.h:83
The symbol library editor main window.
Manages the logic for selecting symbols to import from a library file.
Class to handle modifications to the symbol libraries.
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
Definition io_mgr.h:33