KiCad PCB EDA Suite
dialog_edit_symbols_libid.cpp File Reference

Dialog to remap library id of symbols to another library id. More...

#include <confirm.h>
#include <sch_edit_frame.h>
#include <sch_symbol.h>
#include <sch_reference_list.h>
#include <schematic.h>
#include <symbol_lib_table.h>
#include <trace_helpers.h>
#include <widgets/wx_grid.h>
#include <dialog_edit_symbols_libid_base.h>
#include <wx/tokenzr.h>
#include <wx/choicdlg.h>
#include <wx/dcclient.h>
#include <grid_tricks.h>
#include <widgets/grid_text_button_helpers.h>
#include <kiplatform/ui.h>
#include <string_utils.h>

Go to the source code of this file.

Classes

class  GRIDCELL_AUTOWRAP_STRINGRENDERER
 
class  SYMBOL_CANDIDATE
 A helper to handle symbols to edit. More...
 
class  DIALOG_EDIT_SYMBOLS_LIBID
 Dialog to globally edit the LIB_ID of groups if symbols having the same initial LIB_ID. More...
 

Macros

#define COL_REFS   0
 
#define COL_CURR_LIBID   1
 
#define COL_NEW_LIBID   2
 
#define GRID_CELL_MARGIN   4
 

Functions

static bool sort_by_libid (const SYMBOL_CANDIDATE &candidate1, const SYMBOL_CANDIDATE &candidate2)
 
wxString getLibIdValue (const WX_GRID *aGrid, int aRow, int aCol)
 
bool InvokeDialogEditSymbolsLibId (SCH_EDIT_FRAME *aCaller)
 Run a dialog to modify the LIB_ID of symbols for instance when a symbol has moved from a symbol library to another symbol library. More...
 

Detailed Description

Dialog to remap library id of symbols to another library id.

Definition in file dialog_edit_symbols_libid.cpp.

Macro Definition Documentation

◆ COL_CURR_LIBID

#define COL_CURR_LIBID   1

Definition at line 51 of file dialog_edit_symbols_libid.cpp.

◆ COL_NEW_LIBID

#define COL_NEW_LIBID   2

Definition at line 52 of file dialog_edit_symbols_libid.cpp.

◆ COL_REFS

#define COL_REFS   0

Definition at line 50 of file dialog_edit_symbols_libid.cpp.

◆ GRID_CELL_MARGIN

#define GRID_CELL_MARGIN   4

Definition at line 225 of file dialog_edit_symbols_libid.cpp.

Function Documentation

◆ getLibIdValue()

wxString getLibIdValue ( const WX_GRID aGrid,
int  aRow,
int  aCol 
)

Definition at line 510 of file dialog_edit_symbols_libid.cpp.

511{
512 wxString rawValue = aGrid->GetCellValue( aRow, aCol );
513
514 if( rawValue.IsEmpty() )
515 return rawValue;
516
517 wxString itemName;
518 wxString libName = rawValue.BeforeFirst( ':', &itemName );
519
520 return EscapeString( libName, CTX_LIBID ) + ':' + EscapeString( itemName, CTX_LIBID );
521}
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_LIBID
Definition: string_utils.h:55

References CTX_LIBID, and EscapeString().

Referenced by DIALOG_EDIT_SYMBOLS_LIBID::onClickOrphansButton(), DIALOG_EDIT_SYMBOLS_LIBID::setLibIdByBrowser(), DIALOG_EDIT_SYMBOLS_LIBID::TransferDataFromWindow(), and DIALOG_EDIT_SYMBOLS_LIBID::validateLibIds().

◆ InvokeDialogEditSymbolsLibId()

bool InvokeDialogEditSymbolsLibId ( SCH_EDIT_FRAME aCaller)

Run a dialog to modify the LIB_ID of symbols for instance when a symbol has moved from a symbol library to another symbol library.

Returns
true if changes are made, false if no change

Definition at line 837 of file dialog_edit_symbols_libid.cpp.

838{
839 // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
840 // frame. Therefore this dialog as a modal frame parent, MUST be run under
841 // quasimodal mode for the quasimodal frame support to work. So don't use
842 // the QUASIMODAL macros here.
843 DIALOG_EDIT_SYMBOLS_LIBID dlg( aCaller );
844
845 // DO NOT use ShowModal() here, otherwise the library browser will not work properly.
846 dlg.ShowQuasiModal();
847
848 return dlg.IsSchematicModified();
849}
Dialog to globally edit the LIB_ID of groups if symbols having the same initial LIB_ID.

References DIALOG_EDIT_SYMBOLS_LIBID::IsSchematicModified(), and DIALOG_SHIM::ShowQuasiModal().

Referenced by SCH_EDITOR_CONTROL::EditSymbolLibraryLinks().

◆ sort_by_libid()

static bool sort_by_libid ( const SYMBOL_CANDIDATE candidate1,
const SYMBOL_CANDIDATE candidate2 
)
static

Definition at line 372 of file dialog_edit_symbols_libid.cpp.

373{
374 if( candidate1.m_Symbol->GetLibId() == candidate2.m_Symbol->GetLibId() )
375 return candidate1.m_Reference.Cmp( candidate2.m_Reference ) < 0;
376
377 return candidate1.m_Symbol->GetLibId() < candidate2.m_Symbol->GetLibId();
378}
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:172

References SCH_SYMBOL::GetLibId(), SYMBOL_CANDIDATE::m_Reference, and SYMBOL_CANDIDATE::m_Symbol.

Referenced by DIALOG_EDIT_SYMBOLS_LIBID::initDlg().