Sort SCH_ITEM by name on paste
This commit is contained in:
parent
e9f6ff4366
commit
eeb74dbae9
|
@ -1541,12 +1541,13 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
// SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
|
// SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
|
||||||
// else. Pull them back out to start with.
|
// else. Pull them back out to start with.
|
||||||
SCH_COMMIT commit( m_toolMgr );
|
SCH_COMMIT commit( m_toolMgr );
|
||||||
EDA_ITEMS loadedItems;
|
EDA_ITEMS loadedItems;
|
||||||
bool sheetsPasted = false;
|
std::vector<SCH_ITEM*> sortedLoadedItems;
|
||||||
SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
|
bool sheetsPasted = false;
|
||||||
SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
|
SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
|
||||||
wxFileName destFn = pasteRoot.Last()->GetFileName();
|
SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
|
||||||
|
wxFileName destFn = pasteRoot.Last()->GetFileName();
|
||||||
|
|
||||||
if( destFn.IsRelative() )
|
if( destFn.IsRelative() )
|
||||||
destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
|
destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
|
||||||
|
@ -1578,13 +1579,31 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
||||||
std::map<SCH_SHEET_PATH, SCH_SHEET_LIST> pastedSheets;
|
std::map<SCH_SHEET_PATH, SCH_SHEET_LIST> pastedSheets;
|
||||||
|
|
||||||
for( SCH_ITEM* item : tempScreen->Items() )
|
for( SCH_ITEM* item : tempScreen->Items() )
|
||||||
|
{
|
||||||
|
if( item->Type() == SCH_SHEET_T )
|
||||||
|
sortedLoadedItems.push_back( item );
|
||||||
|
else
|
||||||
|
loadedItems.push_back( item );
|
||||||
|
}
|
||||||
|
|
||||||
|
sort( sortedLoadedItems.begin(), sortedLoadedItems.end(),
|
||||||
|
[]( SCH_ITEM* firstItem, SCH_ITEM* secondItem )
|
||||||
|
{
|
||||||
|
SCH_SHEET* firstSheet = static_cast<SCH_SHEET*>( firstItem );
|
||||||
|
SCH_SHEET* secondSheet = static_cast<SCH_SHEET*>( secondItem );
|
||||||
|
return StrNumCmp( firstSheet->GetName(), secondSheet->GetName(), false ) < 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
for( SCH_ITEM* item : sortedLoadedItems )
|
||||||
{
|
{
|
||||||
loadedItems.push_back( item );
|
loadedItems.push_back( item );
|
||||||
|
|
||||||
//@todo: we might want to sort the sheets by page number before adding to loadedItems
|
|
||||||
if( item->Type() == SCH_SHEET_T )
|
if( item->Type() == SCH_SHEET_T )
|
||||||
{
|
{
|
||||||
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
|
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
|
||||||
|
SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
|
||||||
|
wxString baseName = nameField.GetText();
|
||||||
wxFileName srcFn = sheet->GetFileName();
|
wxFileName srcFn = sheet->GetFileName();
|
||||||
|
|
||||||
if( srcFn.IsRelative() )
|
if( srcFn.IsRelative() )
|
||||||
|
|
Loading…
Reference in New Issue