| 721 | } |
| 722 | |
| 723 | void SourceFormatterSelectionEditPrivate::fillLanguageCombobox() |
| 724 | { |
| 725 | // Move the languages not supported by KDevelop to the bottom of the combobox. |
| 726 | // Use std::array to avoid extra memory allocations. |
| 727 | |
| 728 | constexpr std::array unsupportedLanguages{ |
| 729 | QLatin1String("C#", 2), |
| 730 | QLatin1String("Java", 4), |
| 731 | }; |
| 732 | Q_ASSERT(std::is_sorted(unsupportedLanguages.cbegin(), unsupportedLanguages.cend())); |
| 733 | std::array<QString, unsupportedLanguages.size()> skippedLanguages{}; |
| 734 | |
| 735 | for (const auto& lang : languages) { |
| 736 | const QString& name = lang.name(); |
| 737 | const auto unsupportedIt = std::find(unsupportedLanguages.cbegin(), unsupportedLanguages.cend(), name); |
| 738 | if (unsupportedIt == unsupportedLanguages.cend()) { |
| 739 | ui.cbLanguages->addItem(name); |
| 740 | } else { |
| 741 | skippedLanguages[unsupportedIt - unsupportedLanguages.cbegin()] = name; |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | for (const auto& name : skippedLanguages) { |
| 746 | if (!name.isEmpty()) { |
| 747 | ui.cbLanguages->addItem(name); |
| 748 | } |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | void SourceFormatterSelectionEditPrivate::addMimeTypes(const SourceFormatterStyle::MimeList& mimeTypes, |
| 753 | FormatterData& formatter) |