21#ifndef KICAD_DIALOG_DATABASE_LIB_SETTINGS_H
22#define KICAD_DIALOG_DATABASE_LIB_SETTINGS_H
57 const wxString& aDefaultDir = wxEmptyString );
87 void OnAddField( wxCommandEvent& aEvent )
override;
125 std::unique_ptr<DATABASE_CONNECTION>
conn;
201 void onCancel( wxCommandEvent& aEvent );
210 const std::vector<std::string>&
columnsFor(
const std::string& aTable );
221 void showInfo(
const wxString& aMessage,
int aIcon );
225 void setConnectionStatus(
const wxString& aText,
bool aError,
const wxString& aDetails = wxEmptyString );
231 std::unique_ptr<DATABASE_CONNECTION>
m_conn;
279 std::map<std::string, std::vector<std::string>>
m_columns;
Shows symbols that are not in any library table the way the symbol chooser does: a searchable library...
DIALOG_DATABASE_LIB_SETTINGS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Database Library Settings"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(1200, 760), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void updateTableWarning()
Marks the table field when it is required and missing or could not be read.
void onConnectFinished(const std::shared_ptr< CONNECT_JOB > &aJob)
void onSplitterIdle(wxIdleEvent &aEvent)
bool m_loading
Set while controls are filled from the settings, so their change events are ignored.
SYMBOL_LIBRARY_ADAPTER * m_libs
int m_currentLibrary
Index into m_settings->m_Tables of the library shown on the Libraries page, or -1.
void updateLibraryListHints()
Shows the empty state of the library list only while it is empty.
std::set< wxComboBox * > m_userRoles
Role combos the user set for the current library, which autofill leaves alone.
std::map< std::string, std::string > m_newChoices
Columns the user chose this session, keyed like EESCHEMA_SETTINGS::m_DatabaseColumnChoices.
std::map< std::string, size_t > m_sampleRepeats
void OnSourceSpinChanged(wxSpinEvent &aEvent) override
wxArrayString previewIssues(SCH_IO_DATABASE::PREVIEW_ISSUE::FIELD aField) const
void markUserRole(const COLUMN_ROLE &aRole, const std::string &aValue)
Records that the user chose aValue for aRole, so autofill leaves it alone.
void autofillColumns()
Maps columns of the chosen table to roles and fields the user has not set.
bool m_canSave
False when the file is unreadable or from a newer KiCad, since saving would lose its contents.
void markDirty()
Restarts the debounce before the preview is rebuilt.
void updateDsnDriver()
Shows which driver the chosen data source uses.
void loadDataSources()
Fills the data source list from the ODBC driver manager, keeping what is typed.
bool TransferDataFromWindow() override
void autofillTable()
Picks the table named like the library while the user has not chosen one.
bool ensureSample(const std::string &aTable)
Reads aTable's first rows unless they are already loaded; false if they could not be read.
std::vector< DATABASE_CONNECTION::ROW > m_sampleRows
void onCancel(wxCommandEvent &aEvent)
DATABASE_SOURCE m_keyringLogin
DSN login and keyring password at load, so an untouched login never rewrites the keyring.
void updateAutofillStyle()
Italicizes the role combos that still hold an autofilled value.
@ STAY
The user wants to keep editing.
@ SAVED
The user chose to save, which ended the dialog with wxID_OK.
@ DISCARD
Nothing to keep, or the user chose to discard it.
bool m_unnamed
True until a new library has been given a file.
void OnSourceChanged(wxCommandEvent &aEvent) override
const wxString & GetSettingsPath() const
void updateSourceControls()
void OnDataLabelRightClick(wxGridEvent &aEvent) override
void OnMoveFieldUp(wxCommandEvent &aEvent) override
void OnAddField(wxCommandEvent &aEvent) override
~DIALOG_DATABASE_LIB_SETTINGS() override
DIALOG_DATABASE_LIB_SETTINGS(wxWindow *aParent, const wxString &aDblPath, SYMBOL_LIBRARY_ADAPTER *aLibs, const wxString &aDefaultDir=wxEmptyString)
WX_DEBOUNCED_ACTION m_previewDebounce
Coalesces edits into one preview refresh.
std::vector< COLUMN_ROLE > m_roles
std::vector< std::string > m_sampleColumns
void refreshTables()
Refreshes the table list and everything built on it after the connection changes.
void moveLibrary(int aDelta)
void OnAddLibrary(wxCommandEvent &aEvent) override
void OnAddUnmappedColumns(wxCommandEvent &aEvent) override
void updateSymbolExample()
Shows how the current library's symbols will be named.
void updateDataLabels()
Refreshes only the Data page column labels, which follow mapping edits.
void OnMoveLibraryDown(wxCommandEvent &aEvent) override
bool m_flagMissing
Set once OK found a missing table or key, which is then flagged inline.
void connect()
Starts connecting with the current settings; the table list refreshes when it finishes.
std::map< std::string, std::vector< std::string > > m_columns
void OnInsertDriver(wxCommandEvent &aEvent) override
void OnLibraryChanged(wxCommandEvent &aEvent) override
DB_LIB_PREVIEW_PANEL * m_preview
std::string m_cleanSnapshot
settingsSnapshot() when the dialog opened, to tell whether closing loses anything
void swapFields(DATABASE_LIB_TABLE &aLib, int aRow, int aOther)
wxString m_tableError
Why the table could not be read, shown on the table warning icon.
void OnMoveLibraryUp(wxCommandEvent &aEvent) override
bool chooseSavePath()
Asks where to save a library that has no file yet; false if the user cancelled.
bool TransferDataToWindow() override
void onCloseWindow(wxCloseEvent &aEvent)
const DATABASE_FIELD_MAPPING * fieldForColumn(const std::string &aColumn)
std::map< std::string, std::string > m_autoFields
void OnTestConnection(wxCommandEvent &aEvent) override
std::vector< FIELD_WARNING_ICON * > m_roleIcons
One per entry of m_roles.
SCH_IO_DATABASE::PREVIEW_ISSUES m_previewIssues
Problems found while building the preview symbols, shown on the icons of the fields they came from.
void updateColumnWarnings()
Marks each column field for a missing key, a column the table does not have, keys that repeat in the ...
std::vector< DATABASE_CONNECTION::DATA_SOURCE > m_dataSources
FIELD_WARNING_ICON * m_tableIcon
void OnMoveFieldDown(wxCommandEvent &aEvent) override
std::map< wxComboBox *, std::string > m_autoRoles
CLOSE_ACTION confirmClose()
Asks what to do with unsaved edits before the dialog closes without OK.
void OnSourceTypeChanged(wxCommandEvent &aEvent) override
std::unique_ptr< DATABASE_CONNECTION > m_conn
void OnRemoveLibrary(wxCommandEvent &aEvent) override
void showInfo(const wxString &aMessage, int aIcon)
Replaces the info bar message, which can be dismissed.
void OnTableChanged(wxCommandEvent &aEvent) override
void OnManageDataSources(wxCommandEvent &aEvent) override
std::string m_autoTable
Autofilled values for the current library, which a later autofill may replace.
std::vector< std::string > m_tables
void OnSettingChanged(wxCommandEvent &aEvent) override
std::shared_ptr< CONNECT_JOB > m_connectJob
const std::vector< std::string > & columnsFor(const std::string &aTable)
bool validateLibraries()
Shows the first problem that stops the settings from being saved.
void OnRemoveField(wxCommandEvent &aEvent) override
std::string m_sampleTable
Rows of m_sampleTable shared by the Data page and the preview.
void OnDuplicateLibrary(wxCommandEvent &aEvent) override
void OnLibrarySelected(wxCommandEvent &aEvent) override
DATABASE_LIB_TABLE * currentLibrary()
void OnFieldCellChanged(wxGridEvent &aEvent) override
void cancelConnect()
Abandons a connection attempt in progress, whose result is then discarded.
std::unique_ptr< DATABASE_LIB_SETTINGS > m_settings
void setConnectionStatus(const wxString &aText, bool aError, const wxString &aDetails=wxEmptyString)
Shows a one-line status; the full driver report goes in the tooltip.
void OnDataCellSelected(wxGridEvent &aEvent) override
void OnSettingSpinChanged(wxSpinEvent &aEvent) override
std::string settingsSnapshot()
Every setting as the file would hold it, plus where the password is kept.
A warning icon drawn inside the right edge of a field, left of its dropdown button when it has one,...
std::vector< PREVIEW_ISSUE > PREVIEW_ISSUES
An interface to the global shared library manager that is schematic-specific and linked to one projec...
Debounces an action: runs it only after a quiet period following the last trigger.
A database library table will be mapped to a sub-library provided by the database library entry in th...
One column mapping on the Libraries page: its combo, its setting and its Data page label.
const char * autofillId
Key of the remembered column choices for this role.
std::vector< wxString > terms
English names to autofill from.
Result of a connection attempt made on a worker thread.
std::vector< std::string > tables
DIALOG_DATABASE_LIB_SETTINGS * owner
Cleared on the UI thread when the attempt is abandoned; the worker never reads it.
std::unique_ptr< DATABASE_CONNECTION > conn