KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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/datetime.h>
35#include <wx/fswatcher.h>
36#include <wx/laywin.h>
37#include <wx/treebase.h>
38
39#include "tree_file_type.h"
40
41
44class PROJECT_TREE;
45
49class PROJECT_TREE_PANE : public wxSashLayoutWindow
50{
51 friend class PROJECT_TREE_ITEM;
52
53public:
56
60 void ReCreateTreePrj();
61
68 void FileWatcherReset();
69
73 void EmptyTreePrj();
74
75protected:
76 static wxString GetFileExt( TREE_FILE_TYPE type );
77
84 std::vector<PROJECT_TREE_ITEM*> GetSelectedData();
85
92 PROJECT_TREE_ITEM* GetItemIdData( wxTreeItemId aId );
93
94private:
98 void onSelect( wxTreeEvent& Event );
99
103 void onExpand( wxTreeEvent& Event );
104
108 void onRight( wxTreeEvent& Event );
109
114 void onOpenSelectedFileWithTextEditor( wxCommandEvent& event );
115
120 void onDeleteFile( wxCommandEvent& event );
121
126 void onRenameFile( wxCommandEvent& event );
127
132 void onOpenDirectory( wxCommandEvent& event );
133
139 void onCreateNewDirectory( wxCommandEvent& event );
140
145 void onSwitchToSelectedProject( wxCommandEvent& event );
146
151 void onIdle( wxIdleEvent& aEvent );
152
156 void onPaint( wxPaintEvent& aEvent );
157
161 void onGitInitializeProject( wxCommandEvent& event );
162
166 void onGitCommit( wxCommandEvent& event );
167
171 void onGitPullProject( wxCommandEvent& event );
172
176 void onGitPushProject( wxCommandEvent& event );
177
181 void onGitSwitchBranch( wxCommandEvent& event );
182
186 void onGitCompare( wxCommandEvent& event );
187
191 void onGitRemoveVCS( wxCommandEvent& event );
192
196 void onGitAddToIndex( wxCommandEvent& event );
197
201 void onGitRemoveFromIndex( wxCommandEvent& event );
202
206 void onGitSyncProject( wxCommandEvent& event );
207
211 void onGitFetch( wxCommandEvent& event );
212
216 void onGitResolveConflict( wxCommandEvent& event );
217
221 void onGitRevertLocal( wxCommandEvent& event );
222
227
231 bool hasChangedFiles();
232
238
243 void shutdownFileWatcher();
244
254 wxTreeItemId addItemToProjectTree( const wxString& aName, const wxTreeItemId& aParent,
255 std::vector<wxString>* aProjectNames, bool aRecurse );
256
264 wxTreeItemId findSubdirTreeItem( const wxString& aSubDir );
265
271 void onFileSystemEvent( wxFileSystemWatcherEvent& event );
272
273 void onThemeChanged( wxSysColourChangedEvent &aEvent );
274
279 bool canFileBeAddedToVCS( const wxString& aFilePath );
280
281public:
284
285private:
286 bool m_isRenaming; // Are we in the process of renaming a file
287 wxTreeItemId m_root;
288 std::vector<wxString> m_filters;
289 wxFileSystemWatcher* m_watcher; // file system watcher
291 bool m_watcherNeedReset; // true if FileWatcherReset() must be called
292 // (during an idle time for instance) after
293 // the main loop event handler is started
296
297 DECLARE_EVENT_TABLE()
298};
299
300#endif // TREEPRJ_FRAME_H
The main KiCad project manager frame.
Handle one item (a file or a directory name) for the tree file.
PROJECT_TREE_PANE Window to display the tree files.
PROJECT_TREE_ITEM * m_selectedItem
void onGitFetch(wxCommandEvent &event)
Fetch the latest changes from the git repository.
void onGitInitializeProject(wxCommandEvent &event)
Initialize a new git repository in the current project directory.
void onGitSyncProject(wxCommandEvent &event)
Sync the current project with the git repository.
void onDeleteFile(wxCommandEvent &event)
Function onDeleteFile Delete the selected file or directory in the tree project.
void onGitRemoveVCS(wxCommandEvent &event)
Remove the git repository from the current project directory.
void EmptyTreePrj()
Delete all m_TreeProject entries.
void FileWatcherReset()
Reinit the watched paths Should be called after opening a new project to rebuild the list of watched ...
std::vector< PROJECT_TREE_ITEM * > GetSelectedData()
Function GetSelectedData return the item data from item currently selected (highlighted) Note this is...
void onOpenDirectory(wxCommandEvent &event)
Function onOpenDirectory Handles the right-click menu for opening a directory in the current system f...
void onGitResolveConflict(wxCommandEvent &event)
Resolve conflicts in the git repository.
void onFileSystemEvent(wxFileSystemWatcherEvent &event)
called when a file or directory is modified/created/deleted The tree project is modified when a file ...
wxFileSystemWatcher * m_watcher
wxDateTime m_lastGitStatusUpdate
void onRight(wxTreeEvent &Event)
Called on a right click on an item.
void onGitCommit(wxCommandEvent &event)
Commit the current project saved changes to the git repository.
void onSelect(wxTreeEvent &Event)
Called on a double click on an item.
PROJECT_TREE * m_TreeProject
KICAD_MANAGER_FRAME * m_Parent
void onExpand(wxTreeEvent &Event)
Called on a click on the + or - button of an item with children.
void onIdle(wxIdleEvent &aEvent)
Idle event handler, used process the selected items at a point in time when all other events have bee...
bool hasLocalCommits()
Returns true if the current project has local commits that have not been pushed to the remote reposit...
void onGitRevertLocal(wxCommandEvent &event)
Revert the local repository to the last commit.
void onGitPullProject(wxCommandEvent &event)
Pull the latest changes from the git repository.
static wxString GetFileExt(TREE_FILE_TYPE type)
void onGitRemoveFromIndex(wxCommandEvent &event)
Remove a file from the git index.
wxTreeItemId findSubdirTreeItem(const wxString &aSubDir)
Function findSubdirTreeItem searches for the item in tree project which is the node of the subdirecto...
void ReCreateTreePrj()
Create or modify the tree showing project file names.
void onThemeChanged(wxSysColourChangedEvent &aEvent)
void onGitCompare(wxCommandEvent &event)
Compare the current project to a different branch in the git repository.
void shutdownFileWatcher()
Shutdown the file watcher.
wxTreeItemId addItemToProjectTree(const wxString &aName, const wxTreeItemId &aParent, std::vector< wxString > *aProjectNames, bool aRecurse)
Function addItemToProjectTree.
bool hasChangedFiles()
Returns true if the current project has any uncommitted changes.
void onOpenSelectedFileWithTextEditor(wxCommandEvent &event)
Function onOpenSelectedFileWithTextEditor Call the text editor to open the selected file in the tree ...
void onGitAddToIndex(wxCommandEvent &event)
Add a file to the git index.
void updateGitStatusIcons()
Updates the icons shown in the tree project to reflect the current git status.
PROJECT_TREE_ITEM * GetItemIdData(wxTreeItemId aId)
Function GetItemIdData return the item data corresponding to a wxTreeItemId identifier.
void onGitSwitchBranch(wxCommandEvent &event)
Switch to a different branch in the git repository.
void onCreateNewDirectory(wxCommandEvent &event)
Function onCreateNewDirectory Creates a new subdirectory inside the current kicad project directory t...
void onSwitchToSelectedProject(wxCommandEvent &event)
Switch to a other project selected from the tree project (by selecting an other .pro file inside the ...
void onPaint(wxPaintEvent &aEvent)
We don't have uniform borders so we have to draw them ourselves.
void onRenameFile(wxCommandEvent &event)
Function onRenameFile Rename the selected file or directory in the tree project.
void onGitPushProject(wxCommandEvent &event)
Push the current project changes to the git repository.
bool canFileBeAddedToVCS(const wxString &aFilePath)
Returns true if the file has already been added to the repository or false if it has not been added y...
std::vector< wxString > m_filters
PROJECT_TREE This is the class to show (as a tree) the files in the project directory.
Definition: project_tree.h:41
TREE_FILE_TYPE