KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_packages_view.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 PANEL_PACKAGES_VIEW_H_
22#define PANEL_PACKAGES_VIEW_H_
23
24#include "core/wx_stl_compat.h"
25#include "panel_package.h"
27#include "pcm.h"
28#include "pcm_data.h"
29
30#include <memory>
31#include <unordered_map>
32#include <vector>
33
34
36{
37public:
38 PANEL_PACKAGES_VIEW( wxWindow* parent, std::shared_ptr<PLUGIN_CONTENT_MANAGER> aPcm,
39 const ActionCallback& aCallback, const PinCallback& aPinCallback );
41
47 void SetData( const std::vector<PACKAGE_VIEW_DATA>& aPackageData );
48
56 void SetPackageState( const wxString& aPackageId, const PCM_PACKAGE_STATE aState,
57 const bool aPinned );
58
60 void ClearData();
61
63 void OnVersionsCellClicked( wxGridEvent& event ) override;
64
66 void OnDownloadVersionClicked( wxCommandEvent& event ) override;
67
69 void OnVersionActionClicked( wxCommandEvent& event ) override;
70
72 void OnShowAllVersionsClicked( wxCommandEvent& event ) override;
73
75 void OnSearchTextChanged( wxCommandEvent& event );
76
77 void OnSizeInfoBox( wxSizeEvent& aEvent ) override;
78
80 void OnURLClicked( wxHtmlLinkEvent& event ) override;
81
83 void OnInfoMouseWheel( wxMouseEvent& event ) override;
84
86 void SetSashOnIdle( wxIdleEvent& );
87
89 void OnUpdateAllClicked( wxCommandEvent& event ) override;
90
91private:
93 void updatePackageList();
94
97
99 void updateCommonState();
100
102 void setPackageDetails( const PACKAGE_VIEW_DATA& aPackageData );
103
105 void unsetPackageDetails();
106
108 wxString toHumanReadableSize( const std::optional<uint64_t> size ) const;
109
111 bool canDownload() const;
112
114 bool canRunAction() const;
115
118
119private:
122 std::unordered_map<wxString, PANEL_PACKAGE*> m_packagePanels;
123 std::vector<wxString> m_packageInitialOrder;
125 std::unordered_set<wxString> m_updateablePackages;
126 std::shared_ptr<PLUGIN_CONTENT_MANAGER> m_pcm;
127
129 {
135 };
136
137 static std::unordered_map<PCM_PACKAGE_VERSION_STATUS, wxString> STATUS_ENUM_TO_STR;
138};
139
140#endif // PANEL_PACKAGES_VIEW_H_
Class PANEL_PACKAGES_VIEW_BASE.
void OnInfoMouseWheel(wxMouseEvent &event) override
Replacement of wxFormBuilder's ill-advised m_splitter1OnIdle.
std::unordered_set< wxString > m_updateablePackages
void OnUpdateAllClicked(wxCommandEvent &event) override
void ClearData()
Selects full row of the clicked cell.
void updateDetailsButtons()
Called when package state changes, currently used to calculate Update All button state.
void OnVersionActionClicked(wxCommandEvent &event) override
Shows all versions including incompatible ones.
void OnSizeInfoBox(wxSizeEvent &aEvent) override
Respond to a URL in the info window.
bool canDownload() const
Returns true if the package action can be performed.
void OnDownloadVersionClicked(wxCommandEvent &event) override
Schedules relevant action for selected package version.
wxString toHumanReadableSize(const std::optional< uint64_t > size) const
Returns true if it the download operation can be performed.
void OnSearchTextChanged(wxCommandEvent &event)
void updateCommonState()
Updates details panel.
void updatePackageList()
< Updates package listing according to search term
const ActionCallback & m_actionCallback
std::unordered_map< wxString, PANEL_PACKAGE * > m_packagePanels
void setPackageDetails(const PACKAGE_VIEW_DATA &aPackageData)
Clears details panel.
const PinCallback & m_pinCallback
std::shared_ptr< PLUGIN_CONTENT_MANAGER > m_pcm
PCM_PACKAGE_ACTION getAction() const
bool canRunAction() const
Returns implied action for the action button.
PANEL_PACKAGE * m_currentSelected
void unsetPackageDetails()
Bytes to Kb/Mb/Gb string or "-" if absent.
void SetData(const std::vector< PACKAGE_VIEW_DATA > &aPackageData)
Recreates package panels and displays data.
void OnVersionsCellClicked(wxGridEvent &event) override
Opens file chooser dialog and downloads selected package version archive.
void OnURLClicked(wxHtmlLinkEvent &event) override
Respond to scrolling over the window.
void SetSashOnIdle(wxIdleEvent &)
Enqueues all available package updates.
static std::unordered_map< PCM_PACKAGE_VERSION_STATUS, wxString > STATUS_ENUM_TO_STR
void SetPackageState(const wxString &aPackageId, const PCM_PACKAGE_STATE aState, const bool aPinned)
Set the state of package.
std::vector< wxString > m_packageInitialOrder
void OnShowAllVersionsClicked(wxCommandEvent &event) override
Ranks packages for entered search term and rearranges/hides panels according to their rank.
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
< Collection of data relevant to the package display panel Callback for (un)install button
Definition: panel_package.h:31