* @brief Loads each provider's previously-selected model from QSettings. */
| 733 | * @brief Loads each provider's previously-selected model from QSettings. |
| 734 | */ |
| 735 | void AI::Assistant::restoreModelSelections() |
| 736 | { |
| 737 | m_settings.beginGroup(QStringLiteral("ai/model")); |
| 738 | for (int i = 0; i < kProviderCount; ++i) { |
| 739 | const auto stored = m_settings.value(modelSettingsKey(i)).toString(); |
| 740 | if (stored.isEmpty()) |
| 741 | continue; |
| 742 | |
| 743 | auto* p = providerAt(i); |
| 744 | if (!p) |
| 745 | continue; |
| 746 | |
| 747 | if (i == static_cast<int>(ProviderId::Local)) { |
| 748 | p->setCurrentModel(stored); |
| 749 | continue; |
| 750 | } |
| 751 | |
| 752 | if (!p->availableModels().contains(stored)) { |
| 753 | qCInfo(serialStudioAI) << "Discarding stale model id" << stored << "for provider" << i |
| 754 | << "-- not in availableModels"; |
| 755 | m_settings.remove(modelSettingsKey(i)); |
| 756 | continue; |
| 757 | } |
| 758 | |
| 759 | p->setCurrentModel(stored); |
| 760 | } |
| 761 | m_settings.endGroup(); |
| 762 | } |
| 763 | |
| 764 | /** |
| 765 | * @brief Returns the QSettings sub-key name for the provider's model. |
nothing calls this directly
no test coverage detected