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 <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 50 of file dialog_edit_symbols_libid.cpp.

◆ COL_NEW_LIBID

#define COL_NEW_LIBID   2

Definition at line 51 of file dialog_edit_symbols_libid.cpp.

◆ COL_REFS

#define COL_REFS   0

Definition at line 49 of file dialog_edit_symbols_libid.cpp.

◆ GRID_CELL_MARGIN

#define GRID_CELL_MARGIN   4

Definition at line 224 of file dialog_edit_symbols_libid.cpp.

Function Documentation

◆ getLibIdValue()

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

Definition at line 509 of file dialog_edit_symbols_libid.cpp.

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

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 836 of file dialog_edit_symbols_libid.cpp.

837 {
838  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
839  // frame. Therefore this dialog as a modal frame parent, MUST be run under
840  // quasimodal mode for the quasimodal frame support to work. So don't use
841  // the QUASIMODAL macros here.
842  DIALOG_EDIT_SYMBOLS_LIBID dlg( aCaller );
843 
844  // DO NOT use ShowModal() here, otherwise the library browser will not work properly.
845  dlg.ShowQuasiModal();
846 
847  return dlg.IsSchematicModified();
848 }
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 371 of file dialog_edit_symbols_libid.cpp.

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

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

Referenced by DIALOG_EDIT_SYMBOLS_LIBID::initDlg().