KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 The 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
33class EDA_BASE_FRAME;
34
35
38{
39public:
41 DIALOG_PCM( EDA_BASE_FRAME* parent, std::shared_ptr<PLUGIN_CONTENT_MANAGER> pcm );
43
45
47 void OnCloseClicked( wxCommandEvent& event ) override;
48 void OnCloseWindow( wxCloseEvent& aEvent );
49
51 void OnManageRepositoriesClicked( wxCommandEvent& event ) override;
52
54 void OnRefreshClicked( wxCommandEvent& event ) override;
55
57 void OnInstallFromFileClicked( wxCommandEvent& event ) override;
58
60 void OnOpenPackageDirClicked( wxCommandEvent& event ) override;
61
63 void OnApplyChangesClicked( wxCommandEvent& event ) override;
64
66 void OnDiscardChangesClicked( wxCommandEvent& event ) override;
67
69 void OnRepositoryChoice( wxCommandEvent& event ) override;
70
72 void OnPendingActionsCellClicked( wxGridEvent& event ) override;
73
75 void OnDiscardActionClicked( wxCommandEvent& event ) override;
76
78 void OnUpdateEventButtons( wxUpdateUIEvent& event );
79
81 const std::unordered_set<PCM_PACKAGE_TYPE>& GetChangedPackageTypes() const
82 {
84 };
85
86private:
92 void setRepositoryData( const wxString& aRepositoryId );
93
96
99
102
104 void updatePackageState( const wxString& aPackageId, const PCM_PACKAGE_STATE aState );
105
107 void discardAction( int aIndex );
108
110 std::shared_ptr<PLUGIN_CONTENT_MANAGER> m_pcm;
114 std::unordered_map<PCM_PACKAGE_TYPE, PANEL_PACKAGES_VIEW*> m_repositoryContentPanels;
116 std::unordered_map<wxString, wxBitmap> m_packageBitmaps;
117 std::unordered_map<wxString, wxBitmap> m_installedBitmaps;
119 std::unordered_set<PCM_PACKAGE_TYPE> m_changed_package_types;
120
122 {
126 wxString version;
127 PENDING_ACTION( const PCM_PACKAGE_ACTION& aAction, const wxString& aRepositoryId,
128 const PCM_PACKAGE& aPackage, const wxString& aVersion ) :
129 action( aAction ),
130 repository_id( aRepositoryId ), package( aPackage ), version( aVersion )
131 {
132 }
133 };
134
135 std::vector<PENDING_ACTION> m_pendingActions;
136
138 {
143 };
144};
145
146
147#endif // DIALOG_PCM_H_
Class DIALOG_PCM_BASE.
Implementing pcm main dialog.
Definition: dialog_pcm.h:38
ActionCallback m_actionCallback
Definition: dialog_pcm.h:111
void OnDiscardChangesClicked(wxCommandEvent &event) override
Switches to another repository.
Definition: dialog_pcm.cpp:498
EDA_BASE_FRAME * ParentFrame() const
Closes the window, asks user confirmation if there are pending actions.
Definition: dialog_pcm.h:44
std::unordered_map< wxString, wxBitmap > m_installedBitmaps
Definition: dialog_pcm.h:117
std::unordered_map< wxString, wxBitmap > m_packageBitmaps
Definition: dialog_pcm.h:116
void OnManageRepositoriesClicked(wxCommandEvent &event) override
Discards current repo cache, fetches it anew and displays.
Definition: dialog_pcm.cpp:232
void updatePackageState(const wxString &aPackageId, const PCM_PACKAGE_STATE aState)
Discards specified pending action.
Definition: dialog_pcm.cpp:545
void OnApplyChangesClicked(wxCommandEvent &event) override
Discards all pending changes.
Definition: dialog_pcm.cpp:456
void OnDiscardActionClicked(wxCommandEvent &event) override
Handles modification of the buttons' status.
Definition: dialog_pcm.cpp:510
void OnUpdateEventButtons(wxUpdateUIEvent &event)
Returns types of packages that were installed/uninstalled.
Definition: dialog_pcm.cpp:205
std::unordered_map< PCM_PACKAGE_TYPE, PANEL_PACKAGES_VIEW * > m_repositoryContentPanels
Definition: dialog_pcm.h:114
void OnOpenPackageDirClicked(wxCommandEvent &event) override
Enqueues current pending actions in PCM_TASK_MANAGER and runs the queue.
Definition: dialog_pcm.cpp:556
PinCallback m_pinCallback
Definition: dialog_pcm.h:112
std::unordered_set< PCM_PACKAGE_TYPE > m_changed_package_types
Definition: dialog_pcm.h:119
EDA_BASE_FRAME * m_parentFrame
Definition: dialog_pcm.h:109
void updatePendingActionsTab()
Gets installed packages list from PCM and displays it on installed tab.
Definition: dialog_pcm.cpp:409
std::vector< PENDING_ACTION > m_pendingActions
Definition: dialog_pcm.h:135
void setRepositoryListFromPcm()
Updates pending actions tab caption and content-fits the grid.
Definition: dialog_pcm.cpp:261
void OnInstallFromFileClicked(wxCommandEvent &event) override
Opens local directory where packages are installed in file manager.
Definition: dialog_pcm.cpp:293
PendingActionsGridColumns
Definition: dialog_pcm.h:138
@ PENDING_COL_NAME
Definition: dialog_pcm.h:140
@ PENDING_COL_REPOSITORY
Definition: dialog_pcm.h:142
@ PENDING_COL_VERSION
Definition: dialog_pcm.h:141
@ PENDING_COL_ACTION
Definition: dialog_pcm.h:139
void OnCloseWindow(wxCloseEvent &aEvent)
Opens repository management dialog, saves changes to PCM.
Definition: dialog_pcm.cpp:224
std::shared_ptr< PLUGIN_CONTENT_MANAGER > m_pcm
Definition: dialog_pcm.h:110
void OnRepositoryChoice(wxCommandEvent &event) override
Selects the whole row in the grid if a cell is clicked.
Definition: dialog_pcm.cpp:314
wxString m_selectedRepositoryId
Definition: dialog_pcm.h:115
PANEL_PACKAGES_VIEW * m_installedPanel
Definition: dialog_pcm.h:113
void setInstalledPackages()
Reflects new state of the package in all panels where it is displayed.
Definition: dialog_pcm.cpp:422
void OnPendingActionsCellClicked(wxGridEvent &event) override
Discards selected pending actions.
Definition: dialog_pcm.cpp:402
void setRepositoryData(const wxString &aRepositoryId)
Gets package data from PCM and displays it on repository tab.
Definition: dialog_pcm.cpp:325
void discardAction(int aIndex)
Definition: dialog_pcm.cpp:530
wxBitmap m_defaultBitmap
Definition: dialog_pcm.h:118
void OnRefreshClicked(wxCommandEvent &event) override
Opens file selection dialog and installs selected package archive.
Definition: dialog_pcm.cpp:286
void OnCloseClicked(wxCommandEvent &event) override
Definition: dialog_pcm.cpp:211
const std::unordered_set< PCM_PACKAGE_TYPE > & GetChangedPackageTypes() const
Definition: dialog_pcm.h:81
The base frame for deriving all KiCad main window classes.
std::function< void(const wxString &aPackageId, const PCM_PACKAGE_STATE aState, const bool aPinned)> PinCallback
Definition: panel_package.h:60
std::function< void(const PACKAGE_VIEW_DATA &aData, PCM_PACKAGE_ACTION aAction, const wxString &aVersion)> ActionCallback
Definition: panel_package.h:57
PCM_PACKAGE_STATE
Definition: pcm.h:58
PCM_PACKAGE_ACTION
Definition: pcm.h:71
PCM_PACKAGE_ACTION action
Definition: dialog_pcm.h:123
PENDING_ACTION(const PCM_PACKAGE_ACTION &aAction, const wxString &aRepositoryId, const PCM_PACKAGE &aPackage, const wxString &aVersion)
Definition: dialog_pcm.h:127
Repository reference to a resource.
Definition: pcm_data.h:113