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 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
87
88private:
94 void setRepositoryData( const wxString& aRepositoryId );
95
98
101
104
106 void updatePackageState( const wxString& aPackageId, const PCM_PACKAGE_STATE aState );
107
109 void discardAction( int aIndex );
110
111private:
113 std::shared_ptr<PLUGIN_CONTENT_MANAGER> m_pcm;
117 std::unordered_map<PCM_PACKAGE_TYPE, PANEL_PACKAGES_VIEW*> m_repositoryContentPanels;
119 std::unordered_map<wxString, wxBitmap> m_packageBitmaps;
120 std::unordered_map<wxString, wxBitmap> m_installedBitmaps;
122 std::unordered_set<PCM_PACKAGE_TYPE> m_changed_package_types;
123
125 {
129 wxString version;
130 PENDING_ACTION( const PCM_PACKAGE_ACTION& aAction, const wxString& aRepositoryId,
131 const PCM_PACKAGE& aPackage, const wxString& aVersion ) :
132 action( aAction ),
133 repository_id( aRepositoryId ), package( aPackage ), version( aVersion )
134 {
135 }
136 };
137
138 std::vector<PENDING_ACTION> m_pendingActions;
139
147};
148
149
150#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:114
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:44
std::unordered_map< wxString, wxBitmap > m_installedBitmaps
Definition dialog_pcm.h:120
std::unordered_map< wxString, wxBitmap > m_packageBitmaps
Definition dialog_pcm.h:119
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:117
void OnOpenPackageDirClicked(wxCommandEvent &event) override
Enqueues current pending actions in PCM_TASK_MANAGER and runs the queue.
PinCallback m_pinCallback
Definition dialog_pcm.h:115
std::unordered_set< PCM_PACKAGE_TYPE > m_changed_package_types
Definition dialog_pcm.h:122
void SetActivePackageType(PCM_PACKAGE_TYPE aType)
EDA_BASE_FRAME * m_parentFrame
Definition dialog_pcm.h:112
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:138
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:141
@ PENDING_COL_REPOSITORY
Definition dialog_pcm.h:145
@ PENDING_COL_VERSION
Definition dialog_pcm.h:144
@ PENDING_COL_ACTION
Definition dialog_pcm.h:142
void OnCloseWindow(wxCloseEvent &aEvent)
Opens repository management dialog, saves changes to PCM.
std::shared_ptr< PLUGIN_CONTENT_MANAGER > m_pcm
Definition dialog_pcm.h:113
void OnRepositoryChoice(wxCommandEvent &event) override
Selects the whole row in the grid if a cell is clicked.
wxString m_selectedRepositoryId
Definition dialog_pcm.h:118
PANEL_PACKAGES_VIEW * m_installedPanel
Definition dialog_pcm.h:116
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:121
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: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
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:126
PENDING_ACTION(const PCM_PACKAGE_ACTION &aAction, const wxString &aRepositoryId, const PCM_PACKAGE &aPackage, const wxString &aVersion)
Definition dialog_pcm.h:130
Repository reference to a resource.
Definition pcm_data.h:114