Commit 7dbcbf6d authored by jean-pierre charras's avatar jean-pierre charras

Kicad manager: cleanup code, remove dead or not working code. Fix minor isssues

parent 7ae228d7
......@@ -34,7 +34,6 @@
#include <wxEeschemaStruct.h>
#include <general.h>
//#include <protos.h>
#include <viewlib_frame.h>
#include <class_library.h>
#include <hotkeys.h>
......
......@@ -77,94 +77,11 @@ wxString TREEPROJECT_ITEM::GetDir() const
wxFileName filename = wxFileName( m_FileName );
filename.MakeRelativeTo( wxGetCwd() );
wxArrayString dirs = filename.GetDirs();
wxString dir;
for( unsigned int i = 0; i < dirs.Count(); i++ )
{
dir += dirs[i] + filename.GetPathSeparator();
}
wxString dir = filename.GetPath();
return dir;
}
// Move the object to dest
void TREEPROJECT_ITEM::Move( TREEPROJECT_ITEM* dest )
{
// function not safe.
return;
const wxString sep = wxFileName().GetPathSeparator();
if( m_Type == TREE_DIRECTORY )
return;
if( !dest )
return;
if( m_parent != dest->m_parent )
return; // Can not cross move!
if( dest == this )
return; // Can not move to ourself...
wxTreeItemId parent = m_parent->GetItemParent( GetId() );
if( dest == dynamic_cast<TREEPROJECT_ITEM*>( m_parent->GetItemData( parent ) ) )
return; // same parent ?
// We need to create a new item from us, and move
// data to there ...
// First move file on the disk
wxFileName fname( m_FileName );
wxString destName;
if( !dest->GetDir().IsEmpty() )
destName = dest->GetDir() + sep;
destName += fname.GetFullName();
if( destName == GetFileName() )
return; // Same place ??
// Move the file on the disk:
if( !wxRenameFile( GetFileName(), destName, false ) )
{
wxMessageDialog( m_parent, _( "Unable to move file ... " ),
_( "Permission error ?" ), wxICON_ERROR | wxOK );
return;
}
SetFileName( destName );
if( TREE_DIRECTORY != GetType() )
{
// Move the tree item itself now:
wxTreeItemId oldId = GetId();
int i = m_parent->GetItemImage( oldId );
wxString text = m_parent->GetItemText( oldId );
// Bye bye old Id :'(
wxTreeItemId newId = m_parent->AppendItem( dest->GetId(), text, i );
m_parent->SetItemData( newId, this );
m_parent->SetItemData( oldId, NULL );
m_parent->Delete( oldId );
}
else
{
// We should move recursively all files, but that's quite boring
// let's just refresh that's all ... TODO (change this to a better code ...)
wxCommandEvent dummy;
dynamic_cast<TREEPROJECTFILES*>( m_parent )->GetParent()->m_Parent->OnRefresh( dummy );
}
}
/* rename the file checking if extension change occurs */
bool TREEPROJECT_ITEM::Rename( const wxString& name, bool check )
{
......@@ -218,7 +135,9 @@ type.\n Do you want to continue ?"
return false;
}
#ifndef KICAD_USE_FILES_WATCHER
SetFileName( newFile );
#endif
return true;
}
......@@ -263,7 +182,7 @@ bool TREEPROJECT_ITEM::Delete( bool check )
}
/* Called under item activation */
// Called under item activation
void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
{
wxString sep = wxFileName().GetPathSeparator();
......
......@@ -15,7 +15,6 @@ public:
bool m_WasPopulated; // True the name is a directory, and its content was read
private:
wxTreeCtrl* m_parent;
wxMenu m_fileMenu;
int m_state;
public:
......@@ -50,17 +49,15 @@ public:
m_FileName = name;
}
/**
* @return the path of an item.
* if this item is a directory, returns the stored filename
* if this is a file, returns its path
*/
wxString GetDir() const;
bool Rename( const wxString& name, bool check = true );
bool Delete( bool check = true );
void Move( TREEPROJECT_ITEM* dest );
void Activate( TREE_PROJECT_FRAME* prjframe );
const wxMenu* GetMenu()
{
return &m_fileMenu;
}
void SetState( int state );
};
This diff is collapsed.
......@@ -46,13 +46,10 @@ class TREE_PROJECT_FRAME : public wxSashLayoutWindow
public:
KICAD_MANAGER_FRAME* m_Parent;
TREEPROJECTFILES* m_TreeProject;
wxTreeItemId m_root;
private:
std::vector<wxMenu*> m_ContextMenus;
wxTreeItemId m_root;
std::vector<wxString> m_filters;
wxMenu* m_PopupMenu;
wxCursor m_DragCursor;
wxCursor m_Default;
#ifdef KICAD_USE_FILES_WATCHER
wxFileSystemWatcher* m_watcher; // file system watcher (since wxWidgets 2.9.2)
......@@ -73,7 +70,6 @@ public:
#endif
protected:
wxMenu* GetContextMenu( int type );
static wxString GetFileExt( TreeFileType type );
static wxString GetFileWildcard( TreeFileType type );
......@@ -94,10 +90,19 @@ protected:
TREEPROJECT_ITEM* GetItemIdData( wxTreeItemId aId );
private:
/**
* Called on a double click on an item
*/
void OnSelect( wxTreeEvent& Event );
/**
* Called on a click on the + or - button of an item with children
*/
void OnExpand( wxTreeEvent& Event );
void OnDragStart( wxTreeEvent& event );
void OnDragEnd( wxTreeEvent& event );
/**
* Called on a right click on an item
*/
void OnRight( wxTreeEvent& Event );
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment