Repository: microsoft/PowerToys
File: src/modules/powerrename/PowerRenameUILib/MainWindow.xaml.cpp (C++)

Code before:
            {
                itemToUpdate.Original(*newOriginalName);
            }

            if (newName.has_value())
            {
                itemToUpdate.Renamed(*newName);
            }

            itemToUpdate.State(static_cast<int32_t>(itemStatus));
        }
    }

    PowerRenameUI::ExplorerItem MainWindow::FindById(int32_t id)
    {
        return m_explorerItemsMap.contains(id) ? m_explorerItemsMap[id] : NULL;
    }

    void MainWindow::SelectAll(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&)
    {
        if (checkBox_selectAll().IsChecked().GetBoolean() != m_allSelected)
        {
            ToggleAll();
            m_allSelected = !m_allSelected;
            m_explorerItems.Clear();
            PopulateExplorerItems();
        }
    }

    void MainWindow::ShowAll(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&)
    {
        button_showAll().IsChecked(true);
        button_showRenamed().IsChecked(false);

        DWORD filter = 0;
        m_prManager->GetFilter(&filter);
        if (filter != PowerRenameFilters::None)
        {
            m_explorerItems.Clear();
            m_explorerItemsMap.clear();
            m_prManager->SwitchFilter(0);
            PopulateExplorerItems();
            UpdateCounts();
        }
    }

    void MainWindow::ShowRenamed(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&)
    {
        button_showRenamed().IsChecked(true);
        button_showAll().IsChecked(false);


Review comment (suggestion):
this change doesn't make sense to me. On SelectAll/UnsellectAll items list remains the same, so re-population is not needed. Only the change in `ToggleAll()` should be enough here

Code after:
            {
                itemToUpdate.Original(*newOriginalName);
            }

            if (newName.has_value())
            {
                itemToUpdate.Renamed(*newName);
            }

            itemToUpdate.State(static_cast<int32_t>(itemStatus));
        }
    }

    PowerRenameUI::ExplorerItem MainWindow::FindById(int32_t id)
    {
        return m_explorerItemsMap.contains(id) ? m_explorerItemsMap[id] : NULL;
    }

    void MainWindow::SelectAll(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&)
    {
        if (checkBox_selectAll().IsChecked().GetBoolean() != m_allSelected)
        {
            ToggleAll();
            m_allSelected = !m_allSelected;
            if (button_showRenamed().IsChecked())
            {
                m_explorerItems.Clear();
                m_explorerItemsMap.clear();
                PopulateExplorerItems();
                UpdateCounts();
            }
        }
    }

    void MainWindow::ShowAll(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&)
    {
        button_showAll().IsChecked(true);
        button_showRenamed().IsChecked(false);

        DWORD filter = 0;
        m_prManager->GetFilter(&filter);
        if (filter != PowerRenameFilters::None)
        {
            m_explorerItems.Clear();
            m_explorerItemsMap.clear();
            m_prManager->SwitchFilter(0);
            PopulateExplorerItems();
            UpdateCounts();
        }
    }