Update description in footprint tree when it's edited.

Also implements a more useful message panel for Footprint Editor.

Fixes: lp:1842660
* https://bugs.launchpad.net/kicad/+bug/1842660
This commit is contained in:
Jeff Young 2019-09-04 17:18:42 +01:00
parent 3996a490a1
commit 6688e80131
4 changed files with 66 additions and 9 deletions

View File

@ -356,6 +356,8 @@ void FOOTPRINT_EDIT_FRAME::AddModuleToBoard( MODULE* aFootprint )
aFootprint->SetPadsLocked( false );
PCB_BASE_EDIT_FRAME::AddModuleToBoard( aFootprint );
UpdateMsgPanel();
}

View File

@ -324,6 +324,22 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
}
class BASIC_FOOTPRINT_INFO : public FOOTPRINT_INFO
{
public:
BASIC_FOOTPRINT_INFO( MODULE* aModule )
{
m_nickname = aModule->GetFPID().GetLibNickname().wx_str();
m_fpname = aModule->GetFPID().GetLibItemName().wx_str();
m_pad_count = aModule->GetPadCount( DO_NOT_INCLUDE_NPTH );
m_unique_pad_count = aModule->GetUniquePadCount( DO_NOT_INCLUDE_NPTH );
m_keywords = aModule->GetKeywords();
m_doc = aModule->GetDescription();
m_loaded = true;
}
};
void FOOTPRINT_EDIT_FRAME::editFootprintProperties( MODULE* aModule )
{
LIB_ID oldFPID = aModule->GetFPID();
@ -331,7 +347,15 @@ void FOOTPRINT_EDIT_FRAME::editFootprintProperties( MODULE* aModule )
DIALOG_FOOTPRINT_FP_EDITOR dialog( this, aModule );
dialog.ShowModal();
// Update library tree
BASIC_FOOTPRINT_INFO footprintInfo( aModule );
wxDataViewItem treeItem = m_adapter->FindItem( oldFPID );
static_cast<LIB_TREE_NODE_LIB_ID*>( treeItem.GetID() )->Update( &footprintInfo );
m_treePane->GetLibTree()->Refresh();
updateTitle(); // in case of a name change...
UpdateMsgPanel();
}

View File

@ -188,14 +188,7 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewIte
break;
case 1:
if( node->LibId == m_frame->GetLoadedFPID() && !m_frame->IsCurrentFPFromBoard() )
{
auto mod = m_frame->GetBoard()->GetFirstModule();
wxASSERT( mod );
aVariant = mod->GetDescription();
}
else
aVariant = node->Desc;
aVariant = node->Desc;
break;
default: // column == -1 is used for default Compare function

View File

@ -53,6 +53,7 @@
#include <view/view_controls.h>
#include <functional>
#include <footprint_viewer_frame.h>
#include <footprint_edit_frame.h>
using namespace std::placeholders;
@ -940,7 +941,44 @@ int PCBNEW_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
MSG_PANEL_ITEMS msgItems;
wxString msg = wxString::Format( wxT( "%d" ), selection.GetSize() );
msgItems.push_back( MSG_PANEL_ITEM( _( "Selected Items" ), msg, DARKCYAN ) );
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Selected Items" ), msg, DARKCYAN ) );
m_frame->SetMsgPanel( msgItems );
}
else if( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) )
{
FOOTPRINT_EDIT_FRAME* editFrame = static_cast<FOOTPRINT_EDIT_FRAME*>( m_frame );
MODULE* footprint = (MODULE*) editFrame->GetModel();
if( !footprint )
return 0;
MSG_PANEL_ITEMS msgItems;
wxString msg;
msg = footprint->GetFPID().GetLibNickname().wx_str();
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Library" ), msg, DARKCYAN ) );
msg = footprint->GetFPID().GetLibItemName().wx_str();
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Footprint Name" ), msg, DARKCYAN ) );
wxDateTime date( static_cast<time_t>( footprint->GetLastEditTime() ) );
if( footprint->GetLastEditTime() && date.IsValid() )
// Date format: see http://www.cplusplus.com/reference/ctime/strftime
msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year
else
msg = _( "Unknown" );
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Last Change" ), msg, BROWN ) );
msg.Printf( wxT( "%zu" ), (size_t) footprint->GetPadCount( DO_NOT_INCLUDE_NPTH ) );
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Pads" ), msg, BLUE ) );
wxString doc, keyword;
doc.Printf( _( "Doc: %s" ), footprint->GetDescription() );
keyword.Printf( _( "Key Words: %s" ), footprint->GetKeywords() );
msgItems.emplace_back( MSG_PANEL_ITEM( doc, keyword, BLACK ) );
m_frame->SetMsgPanel( msgItems );
}
else