Be a bit smarter about moving files through a rename.
Don't rely on rebuilding the tree as it collapses all open directories. Try and follow the file instead. Fixes: lp:1852431 * https://bugs.launchpad.net/kicad/+bug/1852431
This commit is contained in:
parent
1df7b718d9
commit
f8aea249df
|
@ -292,8 +292,8 @@ wxString TREE_PROJECT_FRAME::GetFileExt( TreeFileType type )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
|
wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName, wxTreeItemId& aRoot,
|
||||||
wxTreeItemId& aRoot, bool aRecurse )
|
bool aRecurse )
|
||||||
{
|
{
|
||||||
wxTreeItemId cellule;
|
wxTreeItemId cellule;
|
||||||
TreeFileType type = TREE_UNKNOWN;
|
TreeFileType type = TREE_UNKNOWN;
|
||||||
|
@ -302,7 +302,7 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
|
||||||
// Files/dirs names starting by "." are not visible files under unices.
|
// Files/dirs names starting by "." are not visible files under unices.
|
||||||
// Skip them also under Windows
|
// Skip them also under Windows
|
||||||
if( fn.GetName().StartsWith( wxT( "." ) ) )
|
if( fn.GetName().StartsWith( wxT( "." ) ) )
|
||||||
return false;
|
return 0;
|
||||||
|
|
||||||
if( wxDirExists( aName ) )
|
if( wxDirExists( aName ) )
|
||||||
{
|
{
|
||||||
|
@ -333,7 +333,7 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !addFile )
|
if( !addFile )
|
||||||
return false;
|
return 0;
|
||||||
|
|
||||||
// only show the schematic if it is a top level schematic. Eeschema
|
// only show the schematic if it is a top level schematic. Eeschema
|
||||||
// cannot open a schematic and display it properly unless it starts
|
// cannot open a schematic and display it properly unless it starts
|
||||||
|
@ -365,7 +365,7 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
|
||||||
fp = wxFopen( fullFileName, wxT( "rt" ) );
|
fp = wxFopen( fullFileName, wxT( "rt" ) );
|
||||||
|
|
||||||
if( fp == NULL )
|
if( fp == NULL )
|
||||||
return false;
|
return 0;
|
||||||
|
|
||||||
addFile = false;
|
addFile = false;
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
|
||||||
fclose( fp );
|
fclose( fp );
|
||||||
|
|
||||||
if( !addFile )
|
if( !addFile )
|
||||||
return false; // it is a non-top-level schematic
|
return 0; // it is a non-top-level schematic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
|
||||||
if( itemData )
|
if( itemData )
|
||||||
{
|
{
|
||||||
if( itemData->GetFileName() == aName )
|
if( itemData->GetFileName() == aName )
|
||||||
return true; // well, we would have added it, but it is already here!
|
return kid;
|
||||||
}
|
}
|
||||||
|
|
||||||
kid = m_TreeProject->GetNextChild( aRoot, cookie );
|
kid = m_TreeProject->GetNextChild( aRoot, cookie );
|
||||||
|
@ -467,7 +467,7 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
|
||||||
m_TreeProject->SortChildren( cellule );
|
m_TreeProject->SortChildren( cellule );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return data->GetId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -704,9 +704,27 @@ void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& )
|
||||||
if( tree_data->Rename( buffer, true ) )
|
if( tree_data->Rename( buffer, true ) )
|
||||||
{
|
{
|
||||||
if( tree_data->GetDir() != oldDir )
|
if( tree_data->GetDir() != oldDir )
|
||||||
ReCreateTreePrj();
|
{
|
||||||
|
wxFileName filename( tree_data->GetFileName() );
|
||||||
|
filename.Normalize();
|
||||||
|
|
||||||
|
wxTreeItemId parent = findSubdirTreeItem( filename.GetPath() );
|
||||||
|
m_TreeProject->SelectItem( tree_data->GetId(), false );
|
||||||
|
m_TreeProject->Delete( tree_data->GetId() );
|
||||||
|
|
||||||
|
wxTreeItemId new_item = AddItemToTreeProject( filename.GetFullPath(), parent, false );
|
||||||
|
|
||||||
|
if( new_item )
|
||||||
|
{
|
||||||
|
m_TreeProject->SortChildren( parent );
|
||||||
|
m_TreeProject->ScrollTo( new_item );
|
||||||
|
m_TreeProject->SelectItem( new_item, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_TreeProject->SetItemText( curr_item, buffer );
|
m_TreeProject->SetItemText( curr_item, buffer );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,9 +158,9 @@ private:
|
||||||
* @param aRoot = the wxTreeItemId item where to add sub tree items
|
* @param aRoot = the wxTreeItemId item where to add sub tree items
|
||||||
* @param aRecurse = true to add file or subdir names to the current tree item
|
* @param aRecurse = true to add file or subdir names to the current tree item
|
||||||
* false to stop file add.
|
* false to stop file add.
|
||||||
* @return true if the file (or directory) is added.
|
|
||||||
*/
|
*/
|
||||||
bool AddItemToTreeProject( const wxString& aName, wxTreeItemId& aRoot, bool aRecurse = true );
|
wxTreeItemId AddItemToTreeProject( const wxString& aName, wxTreeItemId& aRoot,
|
||||||
|
bool aRecurse = true );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function findSubdirTreeItem
|
* Function findSubdirTreeItem
|
||||||
|
|
Loading…
Reference in New Issue