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 (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{
37public:
39 DIALOG_PCM( wxWindow* parent, std::shared_ptr<PLUGIN_CONTENT_MANAGER> pcm );
41
43 void OnCloseClicked( wxCommandEvent& event ) override;
44 void OnCloseWindow( wxCloseEvent& aEvent );
45
47 void OnManageRepositoriesClicked( wxCommandEvent& event ) override;
48
50 void OnRefreshClicked( wxCommandEvent& event ) override;
51
53 void OnInstallFromFileClicked( wxCommandEvent& event ) override;
54
56 void OnOpenPackageDirClicked( wxCommandEvent& event ) override;
57
59 void OnApplyChangesClicked( wxCommandEvent& event ) override;
60
62 void OnDiscardChangesClicked( wxCommandEvent& event ) override;
63
65 void OnRepositoryChoice( wxCommandEvent& event ) override;
66
68 void OnPendingActionsCellClicked( wxGridEvent& event ) override;
69
71 void OnDiscardActionClicked( wxCommandEvent& event ) override;
72
74 void OnUpdateEventButtons( wxUpdateUIEvent& event );
75
77 const std::unordered_set<PCM_PACKAGE_TYPE>& GetChangedPackageTypes() const
78 {
80 };
81
82private:
88 void setRepositoryData( const wxString& aRepositoryId );
89
92
95
98
100 void updatePackageState( const wxString& aPackageId, const PCM_PACKAGE_STATE aState );
101
103 void discardAction( int aIndex );
104
105 std::shared_ptr<PLUGIN_CONTENT_MANAGER> m_pcm;
109 std::unordered_map<PCM_PACKAGE_TYPE, PANEL_PACKAGES_VIEW*> m_repositoryContentPanels;
111 std::unordered_map<wxString, wxBitmap> m_packageBitmaps;
112 std::unordered_map<wxString, wxBitmap> m_installedBitmaps;
114 std::unordered_set<PCM_PACKAGE_TYPE> m_changed_package_types;
115
117 {
121 wxString version;
122 PENDING_ACTION( const PCM_PACKAGE_ACTION& aAction, const wxString& aRepositoryId,
123 const PCM_PACKAGE& aPackage, const wxString& aVersion ) :
124 action( aAction ),
125 repository_id( aRepositoryId ), package( aPackage ), version( aVersion )
126 {
127 }
128 };
129
130 std::vector<PENDING_ACTION> m_pendingActions;
131
133 {
138 };
139};
140
141
142#endif // DIALOG_PCM_H_
Class DIALOG_PCM_BASE.
Implementing pcm main dialog.
Definition: dialog_pcm.h:36
ActionCallback m_actionCallback
Definition: dialog_pcm.h:106
void OnDiscardChangesClicked(wxCommandEvent &event) override
Switches to another repository.
Definition: dialog_pcm.cpp:492
std::unordered_map< wxString, wxBitmap > m_installedBitmaps
Definition: dialog_pcm.h:112
std::unordered_map< wxString, wxBitmap > m_packageBitmaps
Definition: dialog_pcm.h:111
void OnManageRepositoriesClicked(wxCommandEvent &event) override
Discards current repo cache, fetches it anew and displays.
Definition: dialog_pcm.cpp:229
void updatePackageState(const wxString &aPackageId, const PCM_PACKAGE_STATE aState)
Discards specified pending action.
Definition: dialog_pcm.cpp:539
void OnApplyChangesClicked(wxCommandEvent &event) override
Discards all pending changes.
Definition: dialog_pcm.cpp:450
void OnDiscardActionClicked(wxCommandEvent &event) override
Handles modification of the buttons' status.
Definition: dialog_pcm.cpp:504
void OnUpdateEventButtons(wxUpdateUIEvent &event)
Returns types of packages that were installed/uninstalled.
Definition: dialog_pcm.cpp:202
std::unordered_map< PCM_PACKAGE_TYPE, PANEL_PACKAGES_VIEW * > m_repositoryContentPanels
Definition: dialog_pcm.h:109
void OnOpenPackageDirClicked(wxCommandEvent &event) override
Enqueues current pending actions in PCM_TASK_MANAGER and runs the queue.
Definition: dialog_pcm.cpp:550
PinCallback m_pinCallback
Definition: dialog_pcm.h:107
std::unordered_set< PCM_PACKAGE_TYPE > m_changed_package_types
Definition: dialog_pcm.h:114
void updatePendingActionsTab()
Gets installed packages list from PCM and displays it on installed tab.
Definition: dialog_pcm.cpp:403
std::vector< PENDING_ACTION > m_pendingActions
Definition: dialog_pcm.h:130
void setRepositoryListFromPcm()
Updates pending actions tab caption and content-fits the grid.
Definition: dialog_pcm.cpp:258
void OnInstallFromFileClicked(wxCommandEvent &event) override
Opens local directory where packages are installed in file manager.
Definition: dialog_pcm.cpp:290
PendingActionsGridColumns
Definition: dialog_pcm.h:133
@ PENDING_COL_NAME
Definition: dialog_pcm.h:135
@ PENDING_COL_REPOSITORY
Definition: dialog_pcm.h:137
@ PENDING_COL_VERSION
Definition: dialog_pcm.h:136
@ PENDING_COL_ACTION
Definition: dialog_pcm.h:134
void OnCloseWindow(wxCloseEvent &aEvent)
Opens repository management dialog, saves changes to PCM.
Definition: dialog_pcm.cpp:221
std::shared_ptr< PLUGIN_CONTENT_MANAGER > m_pcm
Definition: dialog_pcm.h:105
void OnRepositoryChoice(wxCommandEvent &event) override
Selects the whole row in the grid if a cell is clicked.
Definition: dialog_pcm.cpp:311
wxString m_selectedRepositoryId
Definition: dialog_pcm.h:110
PANEL_PACKAGES_VIEW * m_installedPanel
Definition: dialog_pcm.h:108
~DIALOG_PCM()
Closes the window, asks user confirmation if there are pending actions.
Definition: dialog_pcm.cpp:188
void setInstalledPackages()
Reflects new state of the package in all panels where it is displayed.
Definition: dialog_pcm.cpp:416
void OnPendingActionsCellClicked(wxGridEvent &event) override
Discards selected pending actions.
Definition: dialog_pcm.cpp:396
void setRepositoryData(const wxString &aRepositoryId)
Gets package data from PCM and displays it on repository tab.
Definition: dialog_pcm.cpp:322
void discardAction(int aIndex)
Definition: dialog_pcm.cpp:524
wxBitmap m_defaultBitmap
Definition: dialog_pcm.h:113
void OnRefreshClicked(wxCommandEvent &event) override
Opens file selection dialog and installs selected package archive.
Definition: dialog_pcm.cpp:283
void OnCloseClicked(wxCommandEvent &event) override
Definition: dialog_pcm.cpp:208
const std::unordered_set< PCM_PACKAGE_TYPE > & GetChangedPackageTypes() const
Definition: dialog_pcm.h:77
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:118
PENDING_ACTION(const PCM_PACKAGE_ACTION &aAction, const wxString &aRepositoryId, const PCM_PACKAGE &aPackage, const wxString &aVersion)
Definition: dialog_pcm.h:122
Repository reference to a resource.
Definition: pcm_data.h:96