KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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
18 * along with this program. If not, see <https://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 <unordered_map>
32#include <vector>
33
34class EDA_BASE_FRAME;
35
36
39{
40public:
42 DIALOG_PCM( EDA_BASE_FRAME* parent, std::shared_ptr<PLUGIN_CONTENT_MANAGER> pcm );
44
46
48 void OnCloseClicked( wxCommandEvent& event ) override;
49 void OnCloseWindow( wxCloseEvent& aEvent );
50
52 void OnManageRepositoriesClicked( wxCommandEvent& event ) override;
53
55 void OnRefreshClicked( wxCommandEvent& event ) override;
56
58 void OnInstallFromFileClicked( wxCommandEvent& event ) override;
59
61 void OnOpenPackageDirClicked( wxCommandEvent& event ) override;
62
64 void OnApplyChangesClicked( wxCommandEvent& event ) override;
65
67 void OnDiscardChangesClicked( wxCommandEvent& event ) override;
68
70 void OnRepositoryChoice( wxCommandEvent& event ) override;
71
73 void OnPendingActionsCellClicked( wxGridEvent& event ) override;
74
76 void OnDiscardActionClicked( wxCommandEvent& event ) override;
77
79 void OnUpdateEventButtons( wxUpdateUIEvent& event );
80
82 const std::unordered_set<PCM_PACKAGE_TYPE>& GetChangedPackageTypes() const
83 {
85 };
86
88
89private:
95 void setRepositoryData( const wxString& aRepositoryId );
96
101
109 void renderPackageGrids( const std::unordered_map<wxString, PCM_PACKAGE>& aPackages,
110 const std::unordered_map<wxString, wxString>& aPackageRepoIds,
111 const std::unordered_map<wxString, wxString>& aPackageRepoNames );
112
115
118
121
123 void updatePackageState( const wxString& aPackageId, const PCM_PACKAGE_STATE aState );
124
126 void discardAction( int aIndex );
127
128private:
130 std::shared_ptr<PLUGIN_CONTENT_MANAGER> m_pcm;
134 std::unordered_map<PCM_PACKAGE_TYPE, PANEL_PACKAGES_VIEW*> m_repositoryContentPanels;
136 std::unordered_map<wxString, wxBitmap> m_packageBitmaps;
137 std::unordered_map<wxString, wxBitmap> m_installedBitmaps;
139 std::unordered_set<PCM_PACKAGE_TYPE> m_changed_package_types;
140
142 {
146 wxString version;
147 PENDING_ACTION( const PCM_PACKAGE_ACTION& aAction, const wxString& aRepositoryId,
148 const PCM_PACKAGE& aPackage, const wxString& aVersion ) :
149 action( aAction ),
150 repository_id( aRepositoryId ), package( aPackage ), version( aVersion )
151 {
152 }
153 };
154
155 std::vector<PENDING_ACTION> m_pendingActions;
156
164};
165
166
167#endif // DIALOG_PCM_H_
DIALOG_PCM_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Plugin And Content Manager"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
ActionCallback m_actionCallback
Definition dialog_pcm.h:131
void OnDiscardChangesClicked(wxCommandEvent &event) override
Switches to another repository.
EDA_BASE_FRAME * ParentFrame() const
Closes the window, asks user confirmation if there are pending actions.
Definition dialog_pcm.h:45
std::unordered_map< wxString, wxBitmap > m_installedBitmaps
Definition dialog_pcm.h:137
std::unordered_map< wxString, wxBitmap > m_packageBitmaps
Definition dialog_pcm.h:136
void OnManageRepositoriesClicked(wxCommandEvent &event) override
Discards current repo cache, fetches it anew and displays.
void updatePackageState(const wxString &aPackageId, const PCM_PACKAGE_STATE aState)
Discards specified pending action.
void OnApplyChangesClicked(wxCommandEvent &event) override
Discards all pending changes.
void OnDiscardActionClicked(wxCommandEvent &event) override
Handles modification of the buttons' status.
void OnUpdateEventButtons(wxUpdateUIEvent &event)
Returns types of packages that were installed/uninstalled.
std::unordered_map< PCM_PACKAGE_TYPE, PANEL_PACKAGES_VIEW * > m_repositoryContentPanels
Definition dialog_pcm.h:134
void OnOpenPackageDirClicked(wxCommandEvent &event) override
Enqueues current pending actions in PCM_TASK_MANAGER and runs the queue.
PinCallback m_pinCallback
Definition dialog_pcm.h:132
void renderPackageGrids(const std::unordered_map< wxString, PCM_PACKAGE > &aPackages, const std::unordered_map< wxString, wxString > &aPackageRepoIds, const std::unordered_map< wxString, wxString > &aPackageRepoNames)
Shared logic to render a given set of packages to the UI notebooks.
std::unordered_set< PCM_PACKAGE_TYPE > m_changed_package_types
Definition dialog_pcm.h:139
void SetActivePackageType(PCM_PACKAGE_TYPE aType)
EDA_BASE_FRAME * m_parentFrame
Definition dialog_pcm.h:129
void setRepositoryDataMulti()
Aggregates and deduplicates packages from all configured repositories.
DIALOG_PCM(EDA_BASE_FRAME *parent, std::shared_ptr< PLUGIN_CONTENT_MANAGER > pcm)
Constructor.
void updatePendingActionsTab()
Gets installed packages list from PCM and displays it on installed tab.
std::vector< PENDING_ACTION > m_pendingActions
Definition dialog_pcm.h:155
void setRepositoryListFromPcm()
Updates pending actions tab caption and content-fits the grid.
void OnInstallFromFileClicked(wxCommandEvent &event) override
Opens local directory where packages are installed in file manager.
PendingActionsGridColumns
Definition dialog_pcm.h:158
@ PENDING_COL_REPOSITORY
Definition dialog_pcm.h:162
@ PENDING_COL_VERSION
Definition dialog_pcm.h:161
@ PENDING_COL_ACTION
Definition dialog_pcm.h:159
void OnCloseWindow(wxCloseEvent &aEvent)
Opens repository management dialog, saves changes to PCM.
std::shared_ptr< PLUGIN_CONTENT_MANAGER > m_pcm
Definition dialog_pcm.h:130
void OnRepositoryChoice(wxCommandEvent &event) override
Selects the whole row in the grid if a cell is clicked.
wxString m_selectedRepositoryId
Definition dialog_pcm.h:135
PANEL_PACKAGES_VIEW * m_installedPanel
Definition dialog_pcm.h:133
void setInstalledPackages()
Reflects new state of the package in all panels where it is displayed.
void OnPendingActionsCellClicked(wxGridEvent &event) override
Discards selected pending actions.
void setRepositoryData(const wxString &aRepositoryId)
Gets package data from PCM and displays it on repository tab.
void discardAction(int aIndex)
wxBitmap m_defaultBitmap
Definition dialog_pcm.h:138
void OnRefreshClicked(wxCommandEvent &event) override
Opens file selection dialog and installs selected package archive.
void OnCloseClicked(wxCommandEvent &event) override
const std::unordered_set< PCM_PACKAGE_TYPE > & GetChangedPackageTypes() const
Definition dialog_pcm.h:82
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
std::function< void(const PACKAGE_VIEW_DATA &aData, PCM_PACKAGE_ACTION aAction, const wxString &aVersion)> ActionCallback
PCM_PACKAGE_STATE
Definition pcm.h:58
PCM_PACKAGE_ACTION
Definition pcm.h:71
PCM_PACKAGE_TYPE
< Supported package types
Definition pcm_data.h:42
PCM_PACKAGE_ACTION action
Definition dialog_pcm.h:143
PENDING_ACTION(const PCM_PACKAGE_ACTION &aAction, const wxString &aRepositoryId, const PCM_PACKAGE &aPackage, const wxString &aVersion)
Definition dialog_pcm.h:147
Repository reference to a resource.
Definition pcm_data.h:114