Symbol editor: fix read only dialogs when symbol is from schematic.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/6968
This commit is contained in:
Wayne Stambaugh 2021-01-13 09:40:30 -05:00
parent 6f0319e29f
commit e34756d596
3 changed files with 24 additions and 20 deletions

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2006-2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2006-2021 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -31,7 +31,8 @@
#include <symbol_edit_frame.h> #include <symbol_edit_frame.h>
DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( SYMBOL_EDIT_FRAME* aParent, LIB_ITEM* aItem ) : DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( SYMBOL_EDIT_FRAME* aParent,
LIB_ITEM* aItem ) :
DIALOG_LIB_EDIT_DRAW_ITEM_BASE( aParent ), DIALOG_LIB_EDIT_DRAW_ITEM_BASE( aParent ),
m_frame( aParent ), m_frame( aParent ),
m_item( aItem ), m_item( aItem ),
@ -44,7 +45,7 @@ DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( SYMBOL_EDIT_FRAME* aParent
// Required under wxGTK if we want to dismiss the dialog with the ESC key // Required under wxGTK if we want to dismiss the dialog with the ESC key
SetFocus(); SetFocus();
if( aParent->IsSymbolFromLegacyLibrary() ) if( !aParent->IsSymbolEditable() )
{ {
m_sdbSizerCancel->SetDefault(); m_sdbSizerCancel->SetDefault();
m_sdbSizerOK->SetLabel( _( "Read Only" ) ); m_sdbSizerOK->SetLabel( _( "Read Only" ) );
@ -70,6 +71,7 @@ bool DIALOG_LIB_EDIT_DRAW_ITEM::TransferDataToWindow()
m_checkApplyToAllConversions->SetValue( m_item->GetConvert() == 0 ); m_checkApplyToAllConversions->SetValue( m_item->GetConvert() == 0 );
bool enblConvOptStyle = symbol && symbol->HasConversion(); bool enblConvOptStyle = symbol && symbol->HasConversion();
// if a symbol contains no graphic items, symbol->HasConversion() returns false. // if a symbol contains no graphic items, symbol->HasConversion() returns false.
// but when creating a new symbol, with DeMorgan option set, the ApplyToAllConversions // but when creating a new symbol, with DeMorgan option set, the ApplyToAllConversions
// must be enabled even if symbol->HasConversion() returns false in order to be able // must be enabled even if symbol->HasConversion() returns false in order to be able

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -37,16 +37,6 @@
class PIN_TABLE_DATA_MODEL : public wxGridTableBase class PIN_TABLE_DATA_MODEL : public wxGridTableBase
{ {
private:
// Because the rows of the grid can either be a single pin or a group of pins, the
// data model is a 2D vector. If we're in the single pin case, each row's LIB_PINS
// contains only a single pin.
std::vector<LIB_PINS> m_rows;
EDA_UNITS m_userUnits;
bool m_edited;
public: public:
PIN_TABLE_DATA_MODEL( EDA_UNITS aUserUnits ) : m_userUnits( aUserUnits ), m_edited( false ) PIN_TABLE_DATA_MODEL( EDA_UNITS aUserUnits ) : m_userUnits( aUserUnits ), m_edited( false )
{ {
@ -380,6 +370,15 @@ public:
{ {
return m_edited; return m_edited;
} }
private:
// Because the rows of the grid can either be a single pin or a group of pins, the
// data model is a 2D vector. If we're in the single pin case, each row's LIB_PINS
// contains only a single pin.
std::vector<LIB_PINS> m_rows;
EDA_UNITS m_userUnits;
bool m_edited;
}; };
@ -426,7 +425,8 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent,
attr = new wxGridCellAttr; attr = new wxGridCellAttr;
wxArrayString orientationNames = PinOrientationNames(); wxArrayString orientationNames = PinOrientationNames();
orientationNames.push_back( INDETERMINATE_STATE ); orientationNames.push_back( INDETERMINATE_STATE );
attr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinOrientationIcons(), orientationNames ) ); attr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinOrientationIcons(),
orientationNames ) );
attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( PinOrientationIcons(), orientationNames ) ); attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( PinOrientationIcons(), orientationNames ) );
m_grid->SetColAttr( COL_ORIENTATION, attr ); m_grid->SetColAttr( COL_ORIENTATION, attr );
@ -449,7 +449,7 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent,
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints(this);
Centre(); Centre();
if( parent->IsSymbolFromLegacyLibrary() ) if( parent->IsSymbolEditable() )
{ {
m_ButtonsCancel->SetDefault(); m_ButtonsCancel->SetDefault();
m_ButtonsOK->SetLabel( _( "Read Only" ) ); m_ButtonsOK->SetLabel( _( "Read Only" ) );
@ -466,7 +466,8 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent,
m_width = 0; m_width = 0;
// Connect Events // Connect Events
m_grid->Connect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_LIB_EDIT_PIN_TABLE::OnColSort ), nullptr, this ); m_grid->Connect( wxEVT_GRID_COL_SORT,
wxGridEventHandler( DIALOG_LIB_EDIT_PIN_TABLE::OnColSort ), nullptr, this );
} }
@ -476,7 +477,8 @@ DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE()
cfg->m_PinTableVisibleColumns = m_grid->GetShownColumns().ToStdString(); cfg->m_PinTableVisibleColumns = m_grid->GetShownColumns().ToStdString();
// Disconnect Events // Disconnect Events
m_grid->Disconnect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_LIB_EDIT_PIN_TABLE::OnColSort ), nullptr, this ); m_grid->Disconnect( wxEVT_GRID_COL_SORT,
wxGridEventHandler( DIALOG_LIB_EDIT_PIN_TABLE::OnColSort ), nullptr, this );
// Prevents crash bug in wxGrid's d'tor // Prevents crash bug in wxGrid's d'tor
m_grid->DestroyTable( m_dataModel ); m_grid->DestroyTable( m_dataModel );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2001 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2001 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004-2020 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -52,7 +52,7 @@ DIALOG_LIB_EDIT_TEXT::DIALOG_LIB_EDIT_TEXT( SYMBOL_EDIT_FRAME* aParent, LIB_TEXT
SetInitialFocus( m_TextCtrl ); SetInitialFocus( m_TextCtrl );
m_StyledTextCtrl->Show( false ); m_StyledTextCtrl->Show( false );
if( aParent->IsSymbolFromLegacyLibrary() ) if( !aParent->IsSymbolEditable() )
{ {
m_sdbSizerButtonsCancel->SetDefault(); m_sdbSizerButtonsCancel->SetDefault();
m_sdbSizerButtonsOK->SetLabel( _( "Read Only" ) ); m_sdbSizerButtonsOK->SetLabel( _( "Read Only" ) );