Sort SCH_ITEM by name on paste
This commit is contained in:
parent
e9f6ff4366
commit
eeb74dbae9
|
@ -1543,6 +1543,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
||||||
// 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;
|
||||||
|
std::vector<SCH_ITEM*> sortedLoadedItems;
|
||||||
bool sheetsPasted = false;
|
bool sheetsPasted = false;
|
||||||
SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
|
SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
|
||||||
SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
|
SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
|
||||||
|
@ -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