Add support for cut/paste of unsaved sheet content.
Fixes: lp:1841801 * https://bugs.launchpad.net/kicad/+bug/1841801
This commit is contained in:
parent
94022116a2
commit
33625dbd9d
|
@ -864,6 +864,17 @@ bool SCH_EDITOR_CONTROL::doCopy()
|
||||||
if( !selection.GetSize() )
|
if( !selection.GetSize() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
m_supplementaryClipboard.clear();
|
||||||
|
|
||||||
|
for( EDA_ITEM* item : selection )
|
||||||
|
{
|
||||||
|
if( item->Type() == SCH_SHEET_T )
|
||||||
|
{
|
||||||
|
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
||||||
|
m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
STRING_FORMATTER formatter;
|
STRING_FORMATTER formatter;
|
||||||
SCH_LEGACY_PLUGIN plugin;
|
SCH_LEGACY_PLUGIN plugin;
|
||||||
|
|
||||||
|
@ -873,6 +884,19 @@ bool SCH_EDITOR_CONTROL::doCopy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SCH_EDITOR_CONTROL::searchSupplementaryClipboard( const wxString& aSheetFilename,
|
||||||
|
SCH_SCREEN** aScreen )
|
||||||
|
{
|
||||||
|
if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
|
||||||
|
{
|
||||||
|
*aScreen = m_supplementaryClipboard[ aSheetFilename ];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCH_EDITOR_CONTROL::Cut( const TOOL_EVENT& aEvent )
|
int SCH_EDITOR_CONTROL::Cut( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
|
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
|
||||||
|
@ -1035,7 +1059,8 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
||||||
fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
|
fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( g_RootSheet->SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ), &existingScreen ) )
|
if( g_RootSheet->SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ), &existingScreen )
|
||||||
|
|| searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen ) )
|
||||||
{
|
{
|
||||||
sheet->SetScreen( existingScreen );
|
sheet->SetScreen( existingScreen );
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,8 @@ private:
|
||||||
///> copy selection to clipboard
|
///> copy selection to clipboard
|
||||||
bool doCopy();
|
bool doCopy();
|
||||||
|
|
||||||
|
bool searchSupplementaryClipboard( const wxString& aSheetFilename, SCH_SCREEN** aScreen );
|
||||||
|
|
||||||
void doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce );
|
void doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,7 +181,10 @@ private:
|
||||||
private:
|
private:
|
||||||
bool m_probingPcbToSch; // Recursion guard when cross-probing to PCBNew
|
bool m_probingPcbToSch; // Recursion guard when cross-probing to PCBNew
|
||||||
EDA_ITEM* m_pickerItem; // Current item for picker highlighting.
|
EDA_ITEM* m_pickerItem; // Current item for picker highlighting.
|
||||||
wxString m_pickerNet;
|
|
||||||
|
// A map of sheet paths --> screens for the clipboard contents. We use these to hook up
|
||||||
|
// cut/paste operations for unsaved sheet content.
|
||||||
|
std::map<wxString, SCH_SCREEN*> m_supplementaryClipboard;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue