From 71b687622b3e0cf35f467673fea764aa2f14c2df Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Wed, 25 Jan 2023 11:12:13 -0500 Subject: [PATCH] PCB Search Pane: activate item opens properties dialog Fixes: https://gitlab.com/kicad/code/kicad/-/issues/12475 --- pcbnew/widgets/search_handlers.cpp | 27 +++++++++++++++++++-------- pcbnew/widgets/search_handlers.h | 28 +++++++++++++++++++--------- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/pcbnew/widgets/search_handlers.cpp b/pcbnew/widgets/search_handlers.cpp index c413051f6b..d95f03fec2 100644 --- a/pcbnew/widgets/search_handlers.cpp +++ b/pcbnew/widgets/search_handlers.cpp @@ -30,9 +30,23 @@ #include "search_handlers.h" +PCB_SEARCH_HANDLER::PCB_SEARCH_HANDLER( wxString aName, PCB_EDIT_FRAME* aFrame ) : + SEARCH_HANDLER( aName ), m_frame( aFrame ) +{ +} + + +void PCB_SEARCH_HANDLER::ActivateItem( long aItemRow ) +{ + std::vector item = { aItemRow }; + SelectItems( item ); + + m_frame->GetToolManager()->RunAction( PCB_ACTIONS::properties, true ); +} + + FOOTPRINT_SEARCH_HANDLER::FOOTPRINT_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) : - SEARCH_HANDLER( wxT( "Footprints" ) ), - m_frame( aFrame ) + PCB_SEARCH_HANDLER( wxT( "Footprints" ), aFrame ) { m_columns.emplace_back( wxT( "Reference" ), 1 ); m_columns.emplace_back( wxT( "Value" ), 2 ); @@ -107,8 +121,7 @@ void FOOTPRINT_SEARCH_HANDLER::SelectItems( std::vector& aItemRows ) ZONE_SEARCH_HANDLER::ZONE_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) : - SEARCH_HANDLER( wxT( "Zones" ) ), - m_frame( aFrame ) + PCB_SEARCH_HANDLER( wxT( "Zones" ), aFrame ) { m_columns.emplace_back( wxT( "Name" ), 2 ); m_columns.emplace_back( wxT( "Net" ), 1 ); @@ -192,8 +205,7 @@ void ZONE_SEARCH_HANDLER::SelectItems( std::vector& aItemRows ) TEXT_SEARCH_HANDLER::TEXT_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) : - SEARCH_HANDLER( wxT( "Text" ) ), - m_frame( aFrame ) + PCB_SEARCH_HANDLER( wxT( "Text" ), aFrame ) { m_columns.emplace_back( wxT( "Type" ), 1 ); m_columns.emplace_back( wxT( "Text" ), 3 ); @@ -279,8 +291,7 @@ void TEXT_SEARCH_HANDLER::SelectItems( std::vector& aItemRows ) NETS_SEARCH_HANDLER::NETS_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ) : - SEARCH_HANDLER( wxT( "Nets" ) ), - m_frame( aFrame ) + PCB_SEARCH_HANDLER( wxT( "Nets" ), aFrame ) { m_columns.emplace_back( wxT( "Name" ), 2 ); m_columns.emplace_back( wxT( "Class" ), 2 ); diff --git a/pcbnew/widgets/search_handlers.h b/pcbnew/widgets/search_handlers.h index 3e5f635ac6..533cda349a 100644 --- a/pcbnew/widgets/search_handlers.h +++ b/pcbnew/widgets/search_handlers.h @@ -29,8 +29,21 @@ class ZONE; class FOOTPRINT; class PCB_TEXT; +class PCB_EDIT_FRAME; -class FOOTPRINT_SEARCH_HANDLER : public SEARCH_HANDLER + +class PCB_SEARCH_HANDLER : public SEARCH_HANDLER +{ +public: + PCB_SEARCH_HANDLER( wxString aName, PCB_EDIT_FRAME* aFrame ); + void ActivateItem( long aItemRow ) override; + +protected: + PCB_EDIT_FRAME* m_frame; +}; + + +class FOOTPRINT_SEARCH_HANDLER : public PCB_SEARCH_HANDLER { public: FOOTPRINT_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ); @@ -40,11 +53,11 @@ public: void SelectItems( std::vector& aItemRows ) override; private: - PCB_EDIT_FRAME* m_frame; std::vector m_hitlist; }; -class ZONE_SEARCH_HANDLER : public SEARCH_HANDLER + +class ZONE_SEARCH_HANDLER : public PCB_SEARCH_HANDLER { public: ZONE_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ); @@ -54,12 +67,11 @@ public: void SelectItems( std::vector& aItemRows ) override; private: - PCB_EDIT_FRAME* m_frame; std::vector m_hitlist; }; -class TEXT_SEARCH_HANDLER : public SEARCH_HANDLER +class TEXT_SEARCH_HANDLER : public PCB_SEARCH_HANDLER { public: TEXT_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ); @@ -69,12 +81,11 @@ public: void SelectItems( std::vector& aItemRows ) override; private: - PCB_EDIT_FRAME* m_frame; std::vector m_hitlist; }; -class NETS_SEARCH_HANDLER : public SEARCH_HANDLER +class NETS_SEARCH_HANDLER : public PCB_SEARCH_HANDLER { public: NETS_SEARCH_HANDLER( PCB_EDIT_FRAME* aFrame ); @@ -84,8 +95,7 @@ public: void SelectItems( std::vector& aItemRows ) override; private: - PCB_EDIT_FRAME* m_frame; std::vector m_hitlist; }; -#endif \ No newline at end of file +#endif