KiCad PCB EDA Suite
project_tree_pane.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 1992-2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #ifndef TREEPRJ_FRAME_H
31 #define TREEPRJ_FRAME_H
32 
33 #include <vector>
34 #include <wx/fswatcher.h>
35 #include <wx/laywin.h>
36 #include <wx/treebase.h>
37 
38 #include "tree_file_type.h"
39 
40 
42 class PROJECT_TREE_ITEM;
43 class PROJECT_TREE;
44 
48 class PROJECT_TREE_PANE : public wxSashLayoutWindow
49 {
50  friend class PROJECT_TREE_ITEM;
51 
52 public:
55 
59  void ReCreateTreePrj();
60 
67  void FileWatcherReset();
68 
72  void EmptyTreePrj();
73 
74 protected:
75  static wxString GetFileExt( TREE_FILE_TYPE type );
76 
83  std::vector<PROJECT_TREE_ITEM*> GetSelectedData();
84 
91  PROJECT_TREE_ITEM* GetItemIdData( wxTreeItemId aId );
92 
93 private:
97  void onSelect( wxTreeEvent& Event );
98 
102  void onExpand( wxTreeEvent& Event );
103 
107  void onRight( wxTreeEvent& Event );
108 
113  void onOpenSelectedFileWithTextEditor( wxCommandEvent& event );
114 
119  void onDeleteFile( wxCommandEvent& event );
120 
125  void onPrintFile( wxCommandEvent& event );
126 
131  void onRenameFile( wxCommandEvent& event );
132 
137  void onOpenDirectory( wxCommandEvent& event );
138 
144  void onCreateNewDirectory( wxCommandEvent& event );
145 
150  void onSwitchToSelectedProject( wxCommandEvent& event );
151 
156  void onIdle( wxIdleEvent &aEvent );
157 
167  wxTreeItemId addItemToProjectTree( const wxString& aName, const wxTreeItemId& aParent,
168  std::vector<wxString>* aProjectNames, bool aRecurse );
169 
177  wxTreeItemId findSubdirTreeItem( const wxString& aSubDir );
178 
184  void onFileSystemEvent( wxFileSystemWatcherEvent& event );
185 
186 public:
189 
190 private:
191  bool m_isRenaming; // Are we in the process of renaming a file
192  wxTreeItemId m_root;
193  std::vector<wxString> m_filters;
194  wxFileSystemWatcher* m_watcher; // file system watcher
196  bool m_watcherNeedReset; // true if FileWatcherReset() must be called
197  // (during an idle time for instance) after
198  // the main loop event handler is started
199 
200  DECLARE_EVENT_TABLE()
201 };
202 
203 #endif // TREEPRJ_FRAME_H
void onRight(wxTreeEvent &Event)
Called on a right click on an item.
void onCreateNewDirectory(wxCommandEvent &event)
Function onCreateNewDirectory Creates a new subdirectory inside the current kicad project directory t...
PROJECT_TREE_PANE(KICAD_MANAGER_FRAME *parent)
class PROJECT_TREE_PANE is the frame that shows the tree list of files and subdirs inside the working...
void onRenameFile(wxCommandEvent &event)
Function onRenameFile Rename the selected file or directory in the tree project.
wxTreeItemId findSubdirTreeItem(const wxString &aSubDir)
Function findSubdirTreeItem searches for the item in tree project which is the node of the subdirecto...
std::vector< wxString > m_filters
TREE_FILE_TYPE
void onDeleteFile(wxCommandEvent &event)
Function onDeleteFile Delete the selected file or directory in the tree project.
void ReCreateTreePrj()
Create or modify the tree showing project file names.
void onOpenSelectedFileWithTextEditor(wxCommandEvent &event)
Function onOpenSelectedFileWithTextEditor Call the text editor to open the selected file in the tree ...
PROJECT_TREE_ITEM * m_selectedItem
void onSwitchToSelectedProject(wxCommandEvent &event)
Switch to a other project selected from the tree project (by selecting an other .pro file inside the ...
void onExpand(wxTreeEvent &Event)
Called on a click on the + or - button of an item with children.
PROJECT_TREE_PANE Window to display the tree files.
PROJECT_TREE * m_TreeProject
void onIdle(wxIdleEvent &aEvent)
Idle event handler, used process the selected items at a point in time when all other events have bee...
void FileWatcherReset()
Reinit the watched paths Should be called after opening a new project to rebuild the list of watched ...
void onOpenDirectory(wxCommandEvent &event)
Function onOpenDirectory Handles the right-click menu for opening a directory in the current system f...
std::vector< PROJECT_TREE_ITEM * > GetSelectedData()
Function GetSelectedData return the item data from item currently selected (highlighted) Note this is...
void EmptyTreePrj()
Delete all m_TreeProject entries.
static wxString GetFileExt(TREE_FILE_TYPE type)
wxFileSystemWatcher * m_watcher
PROJECT_TREE_ITEM handles one item (a file or a directory name) for the tree file.
void onFileSystemEvent(wxFileSystemWatcherEvent &event)
called when a file or directory is modified/created/deleted The tree project is modified when a file ...
wxTreeItemId addItemToProjectTree(const wxString &aName, const wxTreeItemId &aParent, std::vector< wxString > *aProjectNames, bool aRecurse)
Function addItemToProjectTree.
KICAD_MANAGER_FRAME * m_Parent
void onSelect(wxTreeEvent &Event)
Called on a double click on an item.
The main KiCad project manager frame.
PROJECT_TREE_ITEM * GetItemIdData(wxTreeItemId aId)
Function GetItemIdData return the item data corresponding to a wxTreeItemId identifier.
PROJECT_TREE This is the class to show (as a tree) the files in the project directory.
Definition: project_tree.h:38
void onPrintFile(wxCommandEvent &event)
Function onDeleteFile Print the selected file or directory in the tree project.