From f75d18c7c8b5ee5033c5a5a7525ca5fe0c5ba8f6 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 12 Dec 2022 11:00:18 +0000 Subject: [PATCH] Slight improvement to schematic editor title bar. Also improves some other clients of PathHumanReadable(), such as the set page number dialog. --- eeschema/hierarch.cpp | 6 +++--- eeschema/sch_edit_frame.cpp | 6 +++++- eeschema/sch_sheet.cpp | 2 +- eeschema/sch_sheet_path.cpp | 6 +++++- eeschema/sch_sheet_path.h | 3 ++- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index d3aa4632f8..f345cabb36 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -277,12 +277,12 @@ void HIERARCHY_NAVIG_PANEL::onRightClick( wxTreeEvent& aEvent ) if( GetPopupMenuSelectionFromUser( ctxMenu ) == 1 ) { wxString msg; - wxString sheetPath = itemData->m_SheetPath.PathHumanReadable( false ); + wxString sheetPath = itemData->m_SheetPath.PathHumanReadable( false, true ); wxString pageNumber = itemData->m_SheetPath.GetPageNumber(); msg.Printf( _( "Enter page number for sheet path %s" ), - ( sheetPath.Length() > 20 ) ? wxS( " \n" ) + sheetPath + wxT( ": " ) - : sheetPath + wxT( ": " ) ); + ( sheetPath.Length() > 20 ) ? wxS( " \n" ) + sheetPath + wxT( ": " ) + : sheetPath + wxT( ": " ) ); wxTextEntryDialog dlg( m_frame, msg, _( "Edit Sheet Page Number" ), pageNumber ); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index c524029358..5b6f8fdfb8 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1402,7 +1402,11 @@ void SCH_EDIT_FRAME::UpdateTitle() title = wxT( "*" ); title += fn.GetName(); - title += wxString::Format( wxT( " [%s]" ), GetCurrentSheet().PathHumanReadable( false ) ); + + wxString sheetPath = GetCurrentSheet().PathHumanReadable( false, true ); + + if( sheetPath != title ) + title += wxString::Format( wxT( " [%s]" ), sheetPath ); if( readOnly ) title += wxS( " " ) + _( "[Read Only]" ); diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 97df9240fc..f460324860 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -787,7 +787,7 @@ void SCH_SHEET::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetCurrentSheet(); path.push_back( this ); - aList.emplace_back( _( "Hierarchical Path" ), path.PathHumanReadable( false ) ); + aList.emplace_back( _( "Hierarchical Path" ), path.PathHumanReadable( false, true ) ); } aList.emplace_back( _( "File Name" ), m_fields[ SHEETFILENAME ].GetText() ); diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index 4daf842092..6a17f60c20 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -288,7 +288,8 @@ KIID_PATH SCH_SHEET_PATH::Path() const } -wxString SCH_SHEET_PATH::PathHumanReadable( bool aUseShortRootName ) const +wxString SCH_SHEET_PATH::PathHumanReadable( bool aUseShortRootName, + bool aStripTrailingSeparator ) const { wxString s; @@ -312,6 +313,9 @@ wxString SCH_SHEET_PATH::PathHumanReadable( bool aUseShortRootName ) const for( unsigned i = 1; i < size(); i++ ) s << at( i )->GetFields()[SHEETNAME].GetShownText() << wxS( "/" ); + if( aStripTrailingSeparator && s.EndsWith( "/" ) ) + s = s.Left( s.length() - 1 ); + return s; } diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index 05e6948f7e..109e0bfc0c 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -287,7 +287,8 @@ public: * The "normal" path instead uses the #KIID objects in the path that do not change * even when editing sheet parameters. */ - wxString PathHumanReadable( bool aUseShortRootName = true ) const; + wxString PathHumanReadable( bool aUseShortRootName = true, + bool aStripTrailingSeparator = false ) const; /** * Update all the symbol references for this sheet path.