Go to seleted object when opening Symbol Fields dialog.
Note: only active if there is a single item selected and it (or its parent) is a component.
This commit is contained in:
parent
5e5edd03f6
commit
ae74815ff0
|
@ -808,6 +808,54 @@ DIALOG_FIELDS_EDITOR_GLOBAL::~DIALOG_FIELDS_EDITOR_GLOBAL()
|
|||
}
|
||||
|
||||
|
||||
bool DIALOG_FIELDS_EDITOR_GLOBAL::TransferDataToWindow()
|
||||
{
|
||||
if( !wxDialog::TransferDataFromWindow() )
|
||||
return false;
|
||||
|
||||
TOOL_MANAGER* toolMgr = m_parent->GetToolManager();
|
||||
EE_SELECTION_TOOL* selectionTool = toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
EE_SELECTION& selection = selectionTool->GetSelection();
|
||||
SCH_COMPONENT* component = nullptr;
|
||||
|
||||
if( selection.GetSize() == 1 )
|
||||
{
|
||||
EDA_ITEM* item = selection.Front();
|
||||
|
||||
if( item->Type() == SCH_COMPONENT_T )
|
||||
component = (SCH_COMPONENT*) item;
|
||||
else if( item->GetParent() && item->GetParent()->Type() == SCH_COMPONENT_T )
|
||||
component = (SCH_COMPONENT*) item->GetParent();
|
||||
}
|
||||
|
||||
if( component )
|
||||
{
|
||||
for( int row = 0; row < m_dataModel->GetNumberRows(); ++row )
|
||||
{
|
||||
std::vector<SCH_REFERENCE> references = m_dataModel->GetRowReferences( row );
|
||||
bool found = false;
|
||||
|
||||
for( SCH_REFERENCE ref : references )
|
||||
{
|
||||
if( ref.GetComp() == component )
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( found )
|
||||
{
|
||||
m_grid->GoToCell( row, 1 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_FIELDS_EDITOR_GLOBAL::TransferDataFromWindow()
|
||||
{
|
||||
if( !m_grid->CommitPendingChanges() )
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent );
|
||||
virtual ~DIALOG_FIELDS_EDITOR_GLOBAL();
|
||||
|
||||
bool TransferDataToWindow() override;
|
||||
bool TransferDataFromWindow() override;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue