Revert changes in the project manager file tree for rename handling

Revert "Be a bit smarter about moving files through a rename."
Revert "Check for file moving directory and refresh entire tree if so."

This reverts commit f8aea249df.
This reverts commit 8ce04d3362.
This commit is contained in:
Ian McInerney 2019-11-16 01:46:40 +00:00
parent 9a82bc396c
commit 64e094f211
2 changed files with 11 additions and 36 deletions

View File

@ -292,8 +292,8 @@ wxString TREE_PROJECT_FRAME::GetFileExt( TreeFileType type )
}
wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName, wxTreeItemId& aRoot,
bool aRecurse )
bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
wxTreeItemId& aRoot, bool aRecurse )
{
wxTreeItemId cellule;
TreeFileType type = TREE_UNKNOWN;
@ -302,7 +302,7 @@ wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName, wx
// Files/dirs names starting by "." are not visible files under unices.
// Skip them also under Windows
if( fn.GetName().StartsWith( wxT( "." ) ) )
return 0;
return false;
if( wxDirExists( aName ) )
{
@ -333,7 +333,7 @@ wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName, wx
}
if( !addFile )
return 0;
return false;
// only show the schematic if it is a top level schematic. Eeschema
// cannot open a schematic and display it properly unless it starts
@ -365,7 +365,7 @@ wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName, wx
fp = wxFopen( fullFileName, wxT( "rt" ) );
if( fp == NULL )
return 0;
return false;
addFile = false;
@ -385,7 +385,7 @@ wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName, wx
fclose( fp );
if( !addFile )
return 0; // it is a non-top-level schematic
return false; // it is a non-top-level schematic
}
}
@ -418,7 +418,7 @@ wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName, wx
if( itemData )
{
if( itemData->GetFileName() == aName )
return kid;
return true; // well, we would have added it, but it is already here!
}
kid = m_TreeProject->GetNextChild( aRoot, cookie );
@ -467,7 +467,7 @@ wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName, wx
m_TreeProject->SortChildren( cellule );
}
return data->GetId();
return true;
}
@ -699,34 +699,9 @@ void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& )
if( buffer.IsEmpty() )
return; // empty file name not allowed
wxString oldDir = tree_data->GetDir();
if( tree_data->Rename( buffer, true ) )
{
if( tree_data->GetDir() != oldDir )
{
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
{
m_TreeProject->SetItemText( curr_item, buffer );
}
}
}
void TREE_PROJECT_FRAME::OnSelect( wxTreeEvent& Event )

View File

@ -158,9 +158,9 @@ private:
* @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
* false to stop file add.
* @return true if the file (or directory) is added.
*/
wxTreeItemId AddItemToTreeProject( const wxString& aName, wxTreeItemId& aRoot,
bool aRecurse = true );
bool AddItemToTreeProject( const wxString& aName, wxTreeItemId& aRoot, bool aRecurse = true );
/**
* Function findSubdirTreeItem