Code cleanup for readibility.

This commit is contained in:
Jeff Young 2020-01-11 21:14:09 +00:00
parent 116e3d6816
commit b343391723
7 changed files with 60 additions and 116 deletions

View File

@ -117,7 +117,7 @@ void HOTKEY_STORE::Init( std::vector<TOOL_MANAGER*> aToolManagerList, bool aIncl
TOOL_ACTION* entryAction = entry.second.m_Actions[ 0 ];
wxString entryApp = GetAppName( entryAction );
if( entryApp != currentApp )
if( !currentSection || entryApp != currentApp )
{
m_hk_sections.emplace_back( HOTKEY_SECTION() );
currentApp = entryApp;

View File

@ -32,9 +32,8 @@
#include <cvpcb_id.h>
COMPONENTS_LISTBOX::COMPONENTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id,
const wxPoint& loc, const wxSize& size ) :
ITEMS_LISTBOX_BASE( parent, id, loc, size, 0 )
COMPONENTS_LISTBOX::COMPONENTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id ) :
ITEMS_LISTBOX_BASE( parent, id )
{
}

View File

@ -439,13 +439,10 @@ void CVPCB_MAINFRAME::RedoAssociation()
void CVPCB_MAINFRAME::AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation,
bool aNewEntry, bool aAddUndoItem )
{
// Ensure there is data to work with
COMPONENT* component;
if( m_netlist.IsEmpty() )
return;
component = m_netlist.GetComponent( aAssociation.GetComponentIndex() );
COMPONENT* component = m_netlist.GetComponent( aAssociation.GetComponentIndex() );
if( component == NULL )
return;
@ -466,9 +463,11 @@ void CVPCB_MAINFRAME::AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation,
component->SetFPID( fpid );
// create the new component description and set it
wxString description = wxString::Format( CMP_FORMAT, aAssociation.GetComponentIndex() + 1,
GetChars( component->GetReference() ), GetChars( component->GetValue() ),
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
wxString description = wxString::Format( CMP_FORMAT,
aAssociation.GetComponentIndex() + 1,
component->GetReference(),
component->GetValue(),
component->GetFPID().Format().wx_str() );
m_compListBox->SetString( aAssociation.GetComponentIndex(), description );
// Mark the data as being modified
@ -487,7 +486,7 @@ void CVPCB_MAINFRAME::AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation,
// Create a new entry for this association
CVPCB_UNDO_REDO_ENTRIES newEntry;
newEntry.emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(), oldFpid,
aAssociation.GetNewFootprint() ) );
aAssociation.GetNewFootprint() ) );
m_undoList.emplace_back( newEntry );
// Clear the redo list
@ -495,7 +494,7 @@ void CVPCB_MAINFRAME::AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation,
}
else
m_undoList.back().emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(),
oldFpid, aAssociation.GetNewFootprint() ) );
oldFpid, aAssociation.GetNewFootprint() ) );
}
@ -554,27 +553,15 @@ void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component )
}
void CVPCB_MAINFRAME::SetFootprintFilter(
FOOTPRINTS_LISTBOX::FP_FILTER_T aFilter, CVPCB_MAINFRAME::CVPCB_FILTER_ACTION aAction )
void CVPCB_MAINFRAME::SetFootprintFilter( FOOTPRINTS_LISTBOX::FP_FILTER_T aFilter,
CVPCB_MAINFRAME::CVPCB_FILTER_ACTION aAction )
{
int option = FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST;
int option = aFilter;
// Extract the needed information about the filter
switch( aFilter )
{
case FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN:
// Extract the current search patten when needed
// Extract the current search patten when needed
if( option == FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN )
m_currentSearchPattern = m_tcFilterString->GetValue();
// Intentionally fall through since this uses the filter options passed in
case FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST:
case FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT:
case FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY:
case FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_FP_FILTERS:
option = aFilter;
}
// Apply the filter accordingly
switch( aAction )
{
@ -812,12 +799,9 @@ void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX()
if( m_footprintListBox == NULL )
{
m_footprintListBox = new FOOTPRINTS_LISTBOX( this, ID_CVPCB_FOOTPRINT_LIST,
wxDefaultPosition, wxDefaultSize );
m_footprintListBox->SetFont( wxFont( guiFont.GetPointSize(),
wxFONTFAMILY_MODERN,
wxFONTSTYLE_NORMAL,
wxFONTWEIGHT_NORMAL ) );
m_footprintListBox = new FOOTPRINTS_LISTBOX( this, ID_CVPCB_FOOTPRINT_LIST );
m_footprintListBox->SetFont( wxFont( guiFont.GetPointSize(), wxFONTFAMILY_MODERN,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ) );
}
m_footprintListBox->SetFootprints( *m_FootprintsList, wxEmptyString, NULL,
@ -834,12 +818,9 @@ void CVPCB_MAINFRAME::BuildCmpListBox()
if( m_compListBox == NULL )
{
m_compListBox = new COMPONENTS_LISTBOX( this, ID_CVPCB_COMPONENT_LIST,
wxDefaultPosition, wxDefaultSize );
m_compListBox->SetFont( wxFont( guiFont.GetPointSize(),
wxFONTFAMILY_MODERN,
wxFONTSTYLE_NORMAL,
wxFONTWEIGHT_NORMAL ) );
m_compListBox = new COMPONENTS_LISTBOX( this, ID_CVPCB_COMPONENT_LIST );
m_compListBox->SetFont( wxFont( guiFont.GetPointSize(), wxFONTFAMILY_MODERN,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ) );
}
m_compListBox->m_ComponentList.Clear();
@ -848,10 +829,11 @@ void CVPCB_MAINFRAME::BuildCmpListBox()
{
component = m_netlist.GetComponent( i );
msg.Printf( CMP_FORMAT, m_compListBox->GetCount() + 1,
GetChars( component->GetReference() ),
GetChars( component->GetValue() ),
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
msg.Printf( CMP_FORMAT,
m_compListBox->GetCount() + 1,
component->GetReference(),
component->GetValue(),
component->GetFPID().Format().wx_str() );
m_compListBox->m_ComponentList.Add( msg );
}
@ -871,12 +853,9 @@ void CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX()
if( m_libListBox == NULL )
{
m_libListBox = new LIBRARY_LISTBOX( this, ID_CVPCB_LIBRARY_LIST,
wxDefaultPosition, wxDefaultSize );
m_libListBox->SetFont( wxFont( guiFont.GetPointSize(),
wxFONTFAMILY_MODERN,
wxFONTSTYLE_NORMAL,
wxFONTWEIGHT_NORMAL ) );
m_libListBox = new LIBRARY_LISTBOX( this, ID_CVPCB_LIBRARY_LIST );
m_libListBox->SetFont( wxFont( guiFont.GetPointSize(), wxFONTFAMILY_MODERN,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ) );
}
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs( Kiway() );
@ -887,8 +866,8 @@ void CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX()
std::vector< wxString > libNickNames = tbl->GetLogicalLibs();
for( unsigned ii = 0; ii < libNickNames.size(); ii++ )
libNames.Add( libNickNames[ii] );
for( const wxString& libNickName : libNickNames )
libNames.Add( libNickName );
m_libListBox->SetLibraryList( libNames );
}
@ -1021,20 +1000,10 @@ void CVPCB_MAINFRAME::SetFocusedControl( CVPCB_MAINFRAME::CONTROL_TYPE aLB )
{
switch( aLB )
{
case CVPCB_MAINFRAME::CONTROL_LIBRARY:
m_libListBox->SetFocus();
break;
case CVPCB_MAINFRAME::CONTROL_COMPONENT:
m_compListBox->SetFocus();
break;
case CVPCB_MAINFRAME::CONTROL_FOOTPRINT:
m_footprintListBox->SetFocus();
break;
default:
break;
case CVPCB_MAINFRAME::CONTROL_LIBRARY: m_libListBox->SetFocus(); break;
case CVPCB_MAINFRAME::CONTROL_COMPONENT: m_compListBox->SetFocus(); break;
case CVPCB_MAINFRAME::CONTROL_FOOTPRINT: m_footprintListBox->SetFocus(); break;
default: break;
}
}
@ -1051,20 +1020,10 @@ void CVPCB_MAINFRAME::SetStatusText( const wxString& aText, int aNumber )
{
switch( aNumber )
{
case 0:
m_statusLine1->SetLabel( aText );
break;
case 1:
m_statusLine2->SetLabel( aText );
break;
case 2:
m_statusLine3->SetLabel( aText );
break;
default:
wxASSERT_MSG( false, "Invalid status row number" );
case 0: m_statusLine1->SetLabel( aText ); break;
case 1: m_statusLine2->SetLabel( aText ); break;
case 2: m_statusLine3->SetLabel( aText ); break;
default: wxFAIL_MSG( "Invalid status row number" ); break;
}
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2020 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
@ -22,11 +22,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file footprints_listbox.cpp
* class to display the list of available footprints
*/
#include <footprint_filter.h>
#include <tool/tool_manager.h>
#include <trace_helpers.h>
@ -37,10 +32,8 @@
#include <listboxes.h>
#include <tools/cvpcb_actions.h>
FOOTPRINTS_LISTBOX::FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent,
wxWindowID id, const wxPoint& loc,
const wxSize& size ) :
ITEMS_LISTBOX_BASE( parent, id, loc, size, wxLC_SINGLE_SEL | wxNO_BORDER )
FOOTPRINTS_LISTBOX::FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id ) :
ITEMS_LISTBOX_BASE( parent, id, wxDefaultPosition, wxDefaultSize, wxLC_SINGLE_SEL|wxNO_BORDER )
{
}
@ -63,6 +56,7 @@ void FOOTPRINTS_LISTBOX::SetString( unsigned linecount, const wxString& text )
{
if( linecount >= count )
linecount = count - 1;
m_footprintList[linecount] = text;
}
UpdateWidth( linecount );
@ -120,9 +114,7 @@ void FOOTPRINTS_LISTBOX::SetSelection( int index, bool State )
void FOOTPRINTS_LISTBOX::SetSelectedFootprint( const LIB_ID& aFPID )
{
wxString id = wxString::Format( "%s:%s",
GetChars( aFPID.GetLibNickname() ),
GetChars( aFPID.GetLibItemName() ) );
wxString id = aFPID.Format().wx_str();
for( int i = 0; i < GetCount(); ++i )
{
@ -165,9 +157,10 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a
for( auto& i: filter )
{
msg.Printf( "%3d %s:%s", int( newList.GetCount() + 1 ),
GetChars( i.GetLibNickname() ),
GetChars( i.GetFootprintName() ) );
msg.Printf( "%3d %s:%s",
int( newList.GetCount() + 1 ),
i.GetLibNickname(),
i.GetFootprintName() );
newList.Add( msg );
}

View File

@ -37,9 +37,8 @@
/* ListBox handling the library list */
/***************************************/
LIBRARY_LISTBOX::LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id,
const wxPoint& loc, const wxSize& size ) :
ITEMS_LISTBOX_BASE( parent, id, loc, size, wxLC_SINGLE_SEL )
LIBRARY_LISTBOX::LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id ) :
ITEMS_LISTBOX_BASE( parent, id, wxDefaultPosition, wxDefaultSize, wxLC_SINGLE_SEL )
{
}

View File

@ -38,7 +38,8 @@
ITEMS_LISTBOX_BASE::ITEMS_LISTBOX_BASE( CVPCB_MAINFRAME* aParent, wxWindowID aId,
const wxPoint& aLocation, const wxSize& aSize,
long aStyle) :
wxListView( aParent, aId, aLocation, aSize, LISTBOX_STYLE | aStyle ), columnWidth(0)
wxListView( aParent, aId, aLocation, aSize, LISTBOX_STYLE | aStyle ),
columnWidth( 0 )
{
InsertColumn( 0, wxEmptyString );
}

View File

@ -21,10 +21,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file listboxes.h
*/
#ifndef LISTBOXES_H
#define LISTBOXES_H
@ -46,8 +42,8 @@ class ITEMS_LISTBOX_BASE : public wxListView
{
public:
ITEMS_LISTBOX_BASE( CVPCB_MAINFRAME* aParent, wxWindowID aId,
const wxPoint& aLocation, const wxSize& aSize,
long aStyle = 0 );
const wxPoint& aLocation = wxDefaultPosition,
const wxSize& aSize = wxDefaultSize, long aStyle = 0 );
~ITEMS_LISTBOX_BASE();
@ -104,8 +100,7 @@ public:
FILTERING_BY_TEXT_PATTERN = 0x0008
};
FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id,
const wxPoint& loc, const wxSize& size );
FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
~FOOTPRINTS_LISTBOX();
int GetCount();
@ -126,8 +121,8 @@ public:
* @param aFootPrintFilterPattern = a filter used to filter list by names
* @param aFilterType defines the criteria to filter \a aList.
*/
void SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName,
COMPONENT* aComponent, const wxString &aFootPrintFilterPattern, int aFilterType );
void SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName, COMPONENT* aComponent,
const wxString &aFootPrintFilterPattern, int aFilterType );
wxString GetSelectedFootprint();
@ -155,8 +150,7 @@ class LIBRARY_LISTBOX : public ITEMS_LISTBOX_BASE
wxArrayString m_libraryList;
public:
LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id,
const wxPoint& loc, const wxSize& size );
LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
~LIBRARY_LISTBOX();
int GetCount();
@ -201,8 +195,7 @@ public:
public:
COMPONENTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id,
const wxPoint& loc, const wxSize& size );
COMPONENTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
~COMPONENTS_LISTBOX();