Browse Source

Fp editor and Fp viewer: fix missing info on msg panel after loading a fp

Fix also duplicate/not used code
Fixes #11404
https://gitlab.com/kicad/code/kicad/issues/11404
7.0
jean-pierre charras 3 years ago
parent
commit
b2f6c13b6a
  1. 24
      pcbnew/footprint.cpp
  2. 15
      pcbnew/footprint_edit_frame.cpp
  3. 5
      pcbnew/footprint_edit_frame.h
  4. 15
      pcbnew/footprint_viewer_frame.cpp
  5. 3
      pcbnew/footprint_viewer_frame.h
  6. 11
      pcbnew/tools/pcb_control.cpp

24
pcbnew/footprint.cpp

@ -1024,20 +1024,22 @@ void FOOTPRINT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
|| aFrame->IsType( FRAME_FOOTPRINT_VIEWER_MODAL ) || aFrame->IsType( FRAME_FOOTPRINT_VIEWER_MODAL )
|| aFrame->IsType( FRAME_FOOTPRINT_EDITOR ) ) || aFrame->IsType( FRAME_FOOTPRINT_EDITOR ) )
{ {
wxDateTime date( static_cast<time_t>( m_lastEditTime ) );
size_t padCount = GetPadCount( DO_NOT_INCLUDE_NPTH );
// Date format: see http://www.cplusplus.com/reference/ctime/strftime
if( m_lastEditTime && date.IsValid() )
msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year
else
msg = _( "Unknown" );
aList.emplace_back( _( "Library" ), GetFPID().GetLibNickname().wx_str() );
aList.emplace_back( _( "Footprint Name" ), GetFPID().GetLibItemName().wx_str() );
aList.emplace_back( _( "Pads" ), wxString::Format( wxT( "%zu" ), padCount ) );
aList.emplace_back( _( "Last Change" ), msg );
aList.emplace_back( wxString::Format( _( "Doc: %s" ), GetDescription() ),
wxString::Format( _( "Keywords: %s" ), GetKeywords() ) );
return;
} }
else if( aFrame->IsType( FRAME_PCB_EDITOR ) )
{
// aFrame is the board editor:
aList.emplace_back( _( "Board Side" ), IsFlipped() ? _( "Back (Flipped)" ) : _( "Front" ) ); aList.emplace_back( _( "Board Side" ), IsFlipped() ? _( "Back (Flipped)" ) : _( "Front" ) );
}
auto addToken = []( wxString* aStr, const wxString& aAttr ) auto addToken = []( wxString* aStr, const wxString& aAttr )
{ {
@ -1050,7 +1052,7 @@ void FOOTPRINT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
wxString status; wxString status;
wxString attrs; wxString attrs;
if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
if( IsLocked() )
addToken( &status, _( "Locked" ) ); addToken( &status, _( "Locked" ) );
if( m_fpStatus & FP_is_PLACED ) if( m_fpStatus & FP_is_PLACED )

15
pcbnew/footprint_edit_frame.cpp

@ -334,6 +334,21 @@ FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
} }
void FOOTPRINT_EDIT_FRAME::UpdateMsgPanel()
{
EDA_DRAW_FRAME::UpdateMsgPanel();
FOOTPRINT* fp = static_cast<FOOTPRINT*>( GetModel() );
if( fp )
{
std::vector<MSG_PANEL_ITEM> msgItems;
fp->GetMsgPanelInfo( this, msgItems );
SetMsgPanel( msgItems );
}
}
bool FOOTPRINT_EDIT_FRAME::IsContentModified() const bool FOOTPRINT_EDIT_FRAME::IsContentModified() const
{ {
return GetScreen() && GetScreen()->IsContentModified() return GetScreen() && GetScreen()->IsContentModified()

5
pcbnew/footprint_edit_frame.h

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the
@ -103,6 +103,9 @@ public:
*/ */
void UpdateUserInterface(); void UpdateUserInterface();
///< @copydoc EDADRAW_FRAME::UpdateMsgPanel
void UpdateMsgPanel() override;
/** /**
* Refresh the library tree and redraw the window * Refresh the library tree and redraw the window
*/ */

15
pcbnew/footprint_viewer_frame.cpp

@ -370,6 +370,21 @@ SELECTION& FOOTPRINT_VIEWER_FRAME::GetCurrentSelection()
} }
void FOOTPRINT_VIEWER_FRAME::UpdateMsgPanel()
{
EDA_DRAW_FRAME::UpdateMsgPanel();
FOOTPRINT* fp = static_cast<FOOTPRINT*>( GetModel() );
if( fp )
{
std::vector<MSG_PANEL_ITEM> msgItems;
fp->GetMsgPanelInfo( this, msgItems );
SetMsgPanel( msgItems );
}
}
void FOOTPRINT_VIEWER_FRAME::setupUIConditions() void FOOTPRINT_VIEWER_FRAME::setupUIConditions()
{ {
PCB_BASE_FRAME::setupUIConditions(); PCB_BASE_FRAME::setupUIConditions();

3
pcbnew/footprint_viewer_frame.h

@ -72,6 +72,9 @@ public:
*/ */
void OnUpdateFootprintButton( wxUpdateUIEvent& aEvent ); void OnUpdateFootprintButton( wxUpdateUIEvent& aEvent );
///< @copydoc EDADRAW_FRAME::UpdateMsgPanel
void UpdateMsgPanel() override;
/** /**
* Run the footprint viewer as a modal dialog. * Run the footprint viewer as a modal dialog.
* *

11
pcbnew/tools/pcb_control.cpp

@ -1359,16 +1359,7 @@ int PCB_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
if( !pcbFrame ) if( !pcbFrame )
{ {
FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_frame->GetModel() ); FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_frame->GetModel() );
size_t padCount = fp->GetPadCount( DO_NOT_INCLUDE_NPTH );
msgItems.emplace_back( _( "Library" ), fp->GetFPID().GetLibNickname().wx_str() );
msgItems.emplace_back( _( "Footprint Name" ), fp->GetFPID().GetLibItemName().wx_str() );
msgItems.emplace_back( _( "Pads" ), wxString::Format( wxT( "%zu" ), padCount ) );
msgItems.emplace_back( wxString::Format( _( "Doc: %s" ), fp->GetDescription() ),
wxString::Format( _( "Keywords: %s" ), fp->GetKeywords() ) );
fp->GetMsgPanelInfo( m_frame, msgItems );
} }
else else
{ {

Loading…
Cancel
Save