KiCad PCB EDA Suite
dialog_pcm.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) 2021 Andrew Lutsenko, anlutsenko at gmail dot com
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 modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef DIALOG_PCM_H_
22 #define DIALOG_PCM_H_
23 
24 #include "core/wx_stl_compat.h"
25 #include "dialog_pcm_base.h"
26 #include "panel_package.h"
27 #include "panel_packages_view.h"
28 #include "pcm.h"
29 #include "pcm_data.h"
30 
31 #include <vector>
32 
33 
36 {
37 public:
39  DIALOG_PCM( wxWindow* parent );
40  ~DIALOG_PCM();
41 
43  void OnCloseClicked( wxCommandEvent& event ) override;
44 
46  void OnManageRepositoriesClicked( wxCommandEvent& event ) override;
47 
49  void OnRefreshClicked( wxCommandEvent& event ) override;
50 
52  void OnInstallFromFileClicked( wxCommandEvent& event ) override;
53 
55  void OnApplyChangesClicked( wxCommandEvent& event ) override;
56 
58  void OnDiscardChangesClicked( wxCommandEvent& event ) override;
59 
61  void OnRepositoryChoice( wxCommandEvent& event ) override;
62 
64  void OnPendingActionsCellClicked( wxGridEvent& event ) override;
65 
67  void OnDiscardActionClicked( wxCommandEvent& event ) override;
68 
69 private:
75  void setRepositoryData( const wxString& aRepositoryId );
76 
79 
82 
84  void setInstalledPackages();
85 
87  void discardAction( int aIndex );
88 
89  std::shared_ptr<PLUGIN_CONTENT_MANAGER> m_pcm;
92  std::unordered_map<PCM_PACKAGE_TYPE, PANEL_PACKAGES_VIEW*> m_repositoryContentPanels;
94  std::unordered_map<wxString, wxBitmap> m_packageBitmaps;
95  std::unordered_map<wxString, wxBitmap> m_installedBitmaps;
96  wxBitmap m_defaultBitmap;
97 
99  {
101  wxString repository_id;
103  wxString version;
104  PENDING_ACTION( const PCM_PACKAGE_ACTION& aAction, const wxString& aRepositoryId,
105  const PCM_PACKAGE& aPackage, const wxString& aVersion ) :
106  action( aAction ),
107  repository_id( aRepositoryId ), package( aPackage ), version( aVersion )
108  {
109  }
110  };
111 
112  std::vector<PENDING_ACTION> m_pendingActions;
113 
115  {
120  };
121 };
122 
123 
124 #endif // DIALOG_PCM_H_
void setRepositoryData(const wxString &aRepositoryId)
Gets package data from PCM and displays it on repository tab.
Definition: dialog_pcm.cpp:262
void setRepositoryListFromPcm()
Updates pending actions tab caption and content-fits the grid.
Definition: dialog_pcm.cpp:201
std::vector< PENDING_ACTION > m_pendingActions
Definition: dialog_pcm.h:112
void updatePendingActionsTab()
Gets installed packages list from PCM and displays it on installed tab.
Definition: dialog_pcm.cpp:327
void setInstalledPackages()
Discards specified pending action.
Definition: dialog_pcm.cpp:341
void OnPendingActionsCellClicked(wxGridEvent &event) override
Discards selected pending actions.
Definition: dialog_pcm.cpp:320
std::unordered_map< wxString, wxBitmap > m_installedBitmaps
Definition: dialog_pcm.h:95
void OnInstallFromFileClicked(wxCommandEvent &event) override
Enqueues current pending actions in PCM_TASK_MANAGER and runs the queue.
Definition: dialog_pcm.cpp:233
void discardAction(int aIndex)
Definition: dialog_pcm.cpp:427
void OnDiscardActionClicked(wxCommandEvent &event) override
Definition: dialog_pcm.cpp:407
void OnManageRepositoriesClicked(wxCommandEvent &event) override
Discards current repo cache, fetches it anew and displays.
Definition: dialog_pcm.cpp:170
DIALOG_PCM(wxWindow *parent)
Constructor.
Definition: dialog_pcm.cpp:56
Implementing pcm main dialog.
Definition: dialog_pcm.h:35
Repository reference to a resource.
Definition: pcm_data.h:93
PANEL_PACKAGES_VIEW * m_installedPanel
Definition: dialog_pcm.h:91
PendingActionsGridColumns
Definition: dialog_pcm.h:114
~DIALOG_PCM()
Closes the window, asks user confirmation if there are pending actions.
Definition: dialog_pcm.cpp:151
std::unordered_map< wxString, wxBitmap > m_packageBitmaps
Definition: dialog_pcm.h:94
void OnRepositoryChoice(wxCommandEvent &event) override
Selects the whole row in the grid if a cell is clicked.
Definition: dialog_pcm.cpp:251
void OnRefreshClicked(wxCommandEvent &event) override
Opens file selection dialog and installs selected package archive.
Definition: dialog_pcm.cpp:226
ActionCallback m_callback
Definition: dialog_pcm.h:90
PENDING_ACTION(const PCM_PACKAGE_ACTION &aAction, const wxString &aRepositoryId, const PCM_PACKAGE &aPackage, const wxString &aVersion)
Definition: dialog_pcm.h:104
wxString m_selectedRepositoryId
Definition: dialog_pcm.h:93
void OnCloseClicked(wxCommandEvent &event) override
Opens repository management dialog, saves changes to PCM.
Definition: dialog_pcm.cpp:157
Class DIALOG_PCM_BASE.
std::unordered_map< PCM_PACKAGE_TYPE, PANEL_PACKAGES_VIEW * > m_repositoryContentPanels
Definition: dialog_pcm.h:92
std::function< void(const PACKAGE_VIEW_DATA &aData, PCM_PACKAGE_ACTION aAction, const wxString &aVersion)> ActionCallback
Definition: panel_package.h:52
void OnDiscardChangesClicked(wxCommandEvent &event) override
Switches to another repository.
Definition: dialog_pcm.cpp:395
std::shared_ptr< PLUGIN_CONTENT_MANAGER > m_pcm
Definition: dialog_pcm.h:89
void OnApplyChangesClicked(wxCommandEvent &event) override
Discards all pending changes.
Definition: dialog_pcm.cpp:369
PCM_PACKAGE_ACTION action
Definition: dialog_pcm.h:100
wxBitmap m_defaultBitmap
Definition: dialog_pcm.h:96
PCM_PACKAGE_ACTION
Definition: pcm.h:62