PCM: Auto select on download/install if there is only one version

This commit is contained in:
Mikolaj Wielgus 2021-11-12 14:06:06 +01:00 committed by Jeff Young
parent a87c68eaf7
commit aa0a00dee7
2 changed files with 13 additions and 7 deletions

View File

@ -393,15 +393,18 @@ void PANEL_PACKAGES_VIEW::OnVersionsCellClicked( wxGridEvent& event )
void PANEL_PACKAGES_VIEW::OnDownloadVersionClicked( wxCommandEvent& event )
{
const wxArrayInt rows = m_gridVersions->GetSelectedRows();
if( m_gridVersions->GetNumberRows() == 1 )
m_gridVersions->SelectRow( 0 );
if( !m_currentSelected || rows.size() != 1 )
const wxArrayInt selectedRows = m_gridVersions->GetSelectedRows();
if( !m_currentSelected || selectedRows.size() != 1 )
{
wxBell();
return;
}
wxString version = m_gridVersions->GetCellValue( rows[0], COL_VERSION );
wxString version = m_gridVersions->GetCellValue( selectedRows[0], COL_VERSION );
const PCM_PACKAGE& package = m_currentSelected->GetPackageData().package;
auto ver_it = std::find_if( package.versions.begin(), package.versions.end(),
@ -471,15 +474,18 @@ void PANEL_PACKAGES_VIEW::OnDownloadVersionClicked( wxCommandEvent& event )
void PANEL_PACKAGES_VIEW::OnInstallVersionClicked( wxCommandEvent& event )
{
const wxArrayInt rows = m_gridVersions->GetSelectedRows();
if( m_gridVersions->GetNumberRows() == 1 )
m_gridVersions->SelectRow( 0 );
if( !m_currentSelected || rows.size() != 1 )
const wxArrayInt selectedRows = m_gridVersions->GetSelectedRows();
if( !m_currentSelected || selectedRows.size() != 1 )
{
wxBell();
return;
}
wxString version = m_gridVersions->GetCellValue( rows[0], COL_VERSION );
wxString version = m_gridVersions->GetCellValue( selectedRows[0], COL_VERSION );
const PCM_PACKAGE& package = m_currentSelected->GetPackageData().package;
auto ver_it = std::find_if( package.versions.begin(), package.versions.end(),

View File

@ -39,7 +39,7 @@ public:
~PANEL_PACKAGES_VIEW();
/**
* @brief Recreates package panels and displays daya
* @brief Recreates package panels and displays data
*
* @param aPackageData list of package view data
* @param aCallback (un)install button callback