KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_database_lib_settings.cpp File Reference
#include <algorithm>
#include <set>
#include <wx/app.h>
#include <wx/display.h>
#include <wx/filedlg.h>
#include <wx/filefn.h>
#include <wx/filename.h>
#include <wx/menu.h>
#include <wx/regex.h>
#include <wx/settings.h>
#include <wx/stdpaths.h>
#include <wx/thread.h>
#include <wx/utils.h>
#include <bitmaps.h>
#include <confirm.h>
#include <core/kicad_algo.h>
#include <database/database_autofill.h>
#include <database/database_lib_settings.h>
#include <dialogs/dialog_database_lib_settings.h>
#include <eda_draw_frame.h>
#include <eeschema_settings.h>
#include <grid_tricks.h>
#include <i18n_utility.h>
#include <kiplatform/ui.h>
#include <lib_symbol.h>
#include <pgm_base.h>
#include <reporter.h>
#include <sch_io/database/sch_io_database.h>
#include <thread_pool.h>
#include <scoped_set_reset.h>
#include <settings/json_settings_internals.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <string_utils.h>
#include <widgets/db_lib_preview_panel.h>
#include <widgets/grid_combobox.h>
#include <widgets/std_bitmap_button.h>
#include <widgets/wx_grid.h>
#include <widgets/wx_infobar.h>
#include <wildcards_and_files_ext.h>

Go to the source code of this file.

Classes

struct  AUTOFILL_FIELD
 A symbol field that autofill maps from a like-named column. More...
 

Enumerations

enum class  ACCESS_PROVIDER { MISSING , PENDING , AVAILABLE }
 
enum  FIELD_COLUMNS {
  FIELD_COL_COLUMN = 0 , FIELD_COL_NAME , FIELD_COL_VISIBLE_ON_ADD , FIELD_COL_VISIBLE_IN_CHOOSER ,
  FIELD_COL_SHOW_NAME , FIELD_COL_INHERIT
}
 

Functions

static ACCESS_PROVIDER accessProvider ()
 Whether this computer can read Access files, which never blocks.
 
static void relayoutPage (wxScrolledWindow *aPage)
 Re-lays out a scrolled page and refits its scroll area after its contents change size.
 
template<typename MAP>
static bool isAutofilled (const MAP &aAutofilled, const typename MAP::key_type &aKey, const std::string &aValue)
 True if autofill wrote aValue for aKey and the user has not changed it since.
 
static wxString displayName (const DATABASE_LIB_TABLE &aTable)
 
static wxString describeFailure (DB_FAILURE aFailure, const DATABASE_SOURCE &aSource)
 
static const std::vector< AUTOFILL_FIELD > & autofillFields ()
 
static std::string fieldChoiceId (const char *aFieldName)
 
static DB_AUTOFILL::ROLE autofillRole (const std::string &aChoiceId, const std::vector< wxString > &aTerms)
 
static DATABASE_FIELD_MAPPING * findField (DATABASE_LIB_TABLE &aLib, const char *aName)
 
static void releaseConnection (std::unique_ptr< DATABASE_CONNECTION > aConn)
 A connection closes with a bounded wait that a dead share can use up, so the UI thread hands it to the pool while a pool thread closes it inline, as detaching from inside purge() would lock the queue twice.
 
static wxString accessLabel (ACCESS_PROVIDER aProvider)
 

Variables

static constexpr size_t PREVIEW_ROW_LIMIT = 200
 Rows read for the Data page and preview; enough to judge a mapping without loading a whole table.
 
static constexpr int PREVIEW_MIN_WIDTH_DIP = 450
 Narrowest the preview next to the settings can be before its tree columns are cut off.
 
static constexpr int PREVIEW_DEBOUNCE_MS = 750
 Delay after the last edit before the preview is rebuilt.
 
static constexpr int PROVIDER_POLL_MS = 250
 How often the Access provider check is asked whether it has finished, and for how long.
 
static constexpr int PROVIDER_POLL_LIMIT = 80
 
static constexpr int CONNECT_DEBOUNCE_MS = 500
 Pause in typing a database file path before the connection is tried.
 

Enumeration Type Documentation

◆ ACCESS_PROVIDER

enum class ACCESS_PROVIDER
strong
Enumerator
MISSING 
PENDING 
AVAILABLE 

Definition at line 86 of file dialog_database_lib_settings.cpp.

◆ FIELD_COLUMNS

Enumerator
FIELD_COL_COLUMN 
FIELD_COL_NAME 
FIELD_COL_VISIBLE_ON_ADD 
FIELD_COL_VISIBLE_IN_CHOOSER 
FIELD_COL_SHOW_NAME 
FIELD_COL_INHERIT 

Definition at line 129 of file dialog_database_lib_settings.cpp.

Function Documentation

◆ accessLabel()

static wxString accessLabel ( ACCESS_PROVIDER aProvider)
static

◆ accessProvider()

static ACCESS_PROVIDER accessProvider ( )
static

◆ autofillFields()

static const std::vector< AUTOFILL_FIELD > & autofillFields ( )
static

◆ autofillRole()

static DB_AUTOFILL::ROLE autofillRole ( const std::string & aChoiceId,
const std::vector< wxString > & aTerms )
static

◆ describeFailure()

◆ displayName()

◆ fieldChoiceId()

static std::string fieldChoiceId ( const char * aFieldName)
static

◆ findField()

◆ isAutofilled()

template<typename MAP>
static bool isAutofilled ( const MAP & aAutofilled,
const typename MAP::key_type & aKey,
const std::string & aValue )
static

True if autofill wrote aValue for aKey and the user has not changed it since.

Definition at line 121 of file dialog_database_lib_settings.cpp.

Referenced by DIALOG_DATABASE_LIB_SETTINGS::autofillColumns(), and DIALOG_DATABASE_LIB_SETTINGS::updateAutofillStyle().

◆ relayoutPage()

◆ releaseConnection()

static void releaseConnection ( std::unique_ptr< DATABASE_CONNECTION > aConn)
static

A connection closes with a bounded wait that a dead share can use up, so the UI thread hands it to the pool while a pool thread closes it inline, as detaching from inside purge() would lock the queue twice.

Definition at line 508 of file dialog_database_lib_settings.cpp.

References GetKiCadThreadPool().

Referenced by DIALOG_DATABASE_LIB_SETTINGS::connect(), DIALOG_DATABASE_LIB_SETTINGS::CONNECT_JOB::~CONNECT_JOB(), and DIALOG_DATABASE_LIB_SETTINGS::~DIALOG_DATABASE_LIB_SETTINGS().

Variable Documentation

◆ CONNECT_DEBOUNCE_MS

int CONNECT_DEBOUNCE_MS = 500
staticconstexpr

Pause in typing a database file path before the connection is tried.

Definition at line 83 of file dialog_database_lib_settings.cpp.

◆ PREVIEW_DEBOUNCE_MS

int PREVIEW_DEBOUNCE_MS = 750
staticconstexpr

Delay after the last edit before the preview is rebuilt.

Definition at line 76 of file dialog_database_lib_settings.cpp.

◆ PREVIEW_MIN_WIDTH_DIP

int PREVIEW_MIN_WIDTH_DIP = 450
staticconstexpr

Narrowest the preview next to the settings can be before its tree columns are cut off.

Definition at line 73 of file dialog_database_lib_settings.cpp.

Referenced by DIALOG_DATABASE_LIB_SETTINGS::onSplitterIdle().

◆ PREVIEW_ROW_LIMIT

size_t PREVIEW_ROW_LIMIT = 200
staticconstexpr

Rows read for the Data page and preview; enough to judge a mapping without loading a whole table.

Definition at line 70 of file dialog_database_lib_settings.cpp.

Referenced by DIALOG_DATABASE_LIB_SETTINGS::ensureSample(), DIALOG_DATABASE_LIB_SETTINGS::updateDataLabels(), and DIALOG_DATABASE_LIB_SETTINGS::updatePreview().

◆ PROVIDER_POLL_LIMIT

int PROVIDER_POLL_LIMIT = 80
staticconstexpr

◆ PROVIDER_POLL_MS

int PROVIDER_POLL_MS = 250
staticconstexpr

How often the Access provider check is asked whether it has finished, and for how long.

Definition at line 79 of file dialog_database_lib_settings.cpp.

Referenced by DIALOG_DATABASE_LIB_SETTINGS::loadBackends().