Add Make selected active/inactive actions to the symbol libraries

context menu

Fixes #11372
This commit is contained in:
Miklós Márton 2022-06-08 23:05:47 +02:00 committed by Seth Hillbrand
parent aeef5b00a8
commit f2382a7bd1
6 changed files with 119 additions and 13 deletions

View File

@ -320,6 +320,7 @@ set( COMMON_SRCS
layer_id.cpp layer_id.cpp
lib_id.cpp lib_id.cpp
lib_table_base.cpp lib_table_base.cpp
lib_table_grid_tricks.cpp
lib_tree_model.cpp lib_tree_model.cpp
lib_tree_model_adapter.cpp lib_tree_model_adapter.cpp
locale_io.cpp locale_io.cpp

View File

@ -0,0 +1,73 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lib_table_grid_tricks.h"
#include "lib_table_grid.h"
LIB_TABLE_GRID_TRICKS::LIB_TABLE_GRID_TRICKS( WX_GRID* aGrid ) : GRID_TRICKS( aGrid )
{
}
void LIB_TABLE_GRID_TRICKS::showPopupMenu( wxMenu& menu )
{
bool showActivate = false;
bool showDeactivate = false;
LIB_TABLE_GRID* tbl = static_cast<LIB_TABLE_GRID*>( m_grid->GetTable() );
for( int row = m_sel_row_start; row < m_sel_row_start + m_sel_row_count; ++row )
{
if( tbl->GetValueAsBool( row, 0 ) )
{
showDeactivate = true;
}
else
{
showActivate = true;
}
if( showActivate && showDeactivate )
break;
}
if( showActivate )
menu.Append( LIB_TABLE_GRID_TRICKS_ACTIVATE_SELECTED, _( "Activate selected" ) );
if( showDeactivate )
menu.Append( LIB_TABLE_GRID_TRICKS_DEACTIVATE_SELECTED, _( "Deactivate selected" ) );
menu.AppendSeparator();
GRID_TRICKS::showPopupMenu( menu );
}
void LIB_TABLE_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
{
int menu_id = event.GetId();
if( menu_id == LIB_TABLE_GRID_TRICKS_ACTIVATE_SELECTED
|| menu_id == LIB_TABLE_GRID_TRICKS_DEACTIVATE_SELECTED )
{
LIB_TABLE_GRID* tbl = (LIB_TABLE_GRID*) m_grid->GetTable();
for( int row = m_sel_row_start; row < m_sel_row_start + m_sel_row_count; ++row )
{
tbl->SetValueAsBool( row, 0, menu_id == LIB_TABLE_GRID_TRICKS_ACTIVATE_SELECTED );
}
}
else
{
GRID_TRICKS::doPopupSelection( event );
}
}

View File

@ -28,7 +28,7 @@
#include <lib_id.h> #include <lib_id.h>
#include <symbol_lib_table.h> #include <symbol_lib_table.h>
#include <lib_table_lexer.h> #include <lib_table_lexer.h>
#include <grid_tricks.h> #include <lib_table_grid_tricks.h>
#include <widgets/wx_grid.h> #include <widgets/wx_grid.h>
#include <confirm.h> #include <confirm.h>
#include <bitmaps.h> #include <bitmaps.h>
@ -133,12 +133,11 @@ public:
} }
}; };
class SYMBOL_GRID_TRICKS : public LIB_TABLE_GRID_TRICKS
class SYMBOL_GRID_TRICKS : public GRID_TRICKS
{ {
public: public:
SYMBOL_GRID_TRICKS( DIALOG_EDIT_LIBRARY_TABLES* aParent, WX_GRID* aGrid ) : SYMBOL_GRID_TRICKS( DIALOG_EDIT_LIBRARY_TABLES* aParent, WX_GRID* aGrid ) :
GRID_TRICKS( aGrid ), LIB_TABLE_GRID_TRICKS( aGrid ),
m_dialog( aParent ) m_dialog( aParent )
{ {
} }

View File

@ -21,14 +21,14 @@
#ifndef PANEL_SYM_LIB_TABLE_H #ifndef PANEL_SYM_LIB_TABLE_H
#define PANEL_SYM_LIB_TABLE_H #define PANEL_SYM_LIB_TABLE_H
#include <grid_tricks.h>
#include <dialogs/dialog_edit_library_tables.h> #include <dialogs/dialog_edit_library_tables.h>
#include <panel_sym_lib_table_base.h> #include <panel_sym_lib_table_base.h>
#include <lib_table_grid.h>
class SYMBOL_LIB_TABLE; class SYMBOL_LIB_TABLE;
class SYMBOL_LIB_TABLE_GRID; class SYMBOL_LIB_TABLE_GRID;
/** /**
* Dialog to show and edit symbol library tables. * Dialog to show and edit symbol library tables.
*/ */

View File

@ -0,0 +1,35 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "grid_tricks.h"
class LIB_TABLE_GRID_TRICKS : public GRID_TRICKS
{
enum
{
LIB_TABLE_GRID_TRICKS_ACTIVATE_SELECTED = GRIDTRICKS_FIRST_CLIENT_ID,
LIB_TABLE_GRID_TRICKS_DEACTIVATE_SELECTED
};
public:
explicit LIB_TABLE_GRID_TRICKS( WX_GRID* aGrid );
void showPopupMenu( wxMenu& menu ) override;
void doPopupSelection( wxCommandEvent& event ) override;
};

View File

@ -46,7 +46,7 @@
#include <lib_table_lexer.h> #include <lib_table_lexer.h>
#include <invoke_pcb_dialog.h> #include <invoke_pcb_dialog.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <grid_tricks.h> #include <lib_table_grid_tricks.h>
#include <widgets/wx_grid.h> #include <widgets/wx_grid.h>
#include <confirm.h> #include <confirm.h>
#include <lib_table_grid.h> #include <lib_table_grid.h>
@ -64,7 +64,6 @@
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
#include <paths.h> #include <paths.h>
#include <macros.h> #include <macros.h>
// clang-format off // clang-format off
/** /**
@ -246,12 +245,11 @@ public:
#define MYID_OPTIONS_EDITOR 15151 #define MYID_OPTIONS_EDITOR 15151
class FP_GRID_TRICKS : public GRID_TRICKS class FP_GRID_TRICKS : public LIB_TABLE_GRID_TRICKS
{ {
public: public:
FP_GRID_TRICKS( DIALOG_EDIT_LIBRARY_TABLES* aParent, WX_GRID* aGrid ) : FP_GRID_TRICKS( DIALOG_EDIT_LIBRARY_TABLES* aParent, WX_GRID* aGrid ) :
GRID_TRICKS( aGrid ), LIB_TABLE_GRID_TRICKS( aGrid ), m_dialog( aParent )
m_dialog( aParent )
{ } { }
protected: protected:
@ -297,7 +295,7 @@ protected:
menu.AppendSeparator(); menu.AppendSeparator();
} }
GRID_TRICKS::showPopupMenu( menu ); LIB_TABLE_GRID_TRICKS::showPopupMenu( menu );
} }
void doPopupSelection( wxCommandEvent& event ) override void doPopupSelection( wxCommandEvent& event ) override
@ -305,7 +303,7 @@ protected:
if( event.GetId() == MYID_OPTIONS_EDITOR ) if( event.GetId() == MYID_OPTIONS_EDITOR )
optionsEditor( m_grid->GetGridCursorRow() ); optionsEditor( m_grid->GetGridCursorRow() );
else else
GRID_TRICKS::doPopupSelection( event ); LIB_TABLE_GRID_TRICKS::doPopupSelection( event );
} }
/// handle specialized clipboard text, with leading "(fp_lib_table", OR /// handle specialized clipboard text, with leading "(fp_lib_table", OR