* @brief Selects an example by index and triggers README/screenshot fetching. */
| 159 | * @brief Selects an example by index and triggers README/screenshot fetching. |
| 160 | */ |
| 161 | void Misc::Examples::setSelectedIndex(int index) |
| 162 | { |
| 163 | if (m_selectedIndex == index) |
| 164 | return; |
| 165 | |
| 166 | m_selectedIndex = index; |
| 167 | Q_EMIT selectedIndexChanged(); |
| 168 | |
| 169 | m_selectedReadme.clear(); |
| 170 | m_selectedScreenshot.clear(); |
| 171 | Q_EMIT selectedReadmeChanged(); |
| 172 | Q_EMIT selectedScreenshotChanged(); |
| 173 | |
| 174 | if (index >= 0 && index < m_filteredExamples.count()) { |
| 175 | const auto example = m_filteredExamples.at(index).toMap(); |
| 176 | const auto id = example.value("id").toString(); |
| 177 | fetchReadme(id); |
| 178 | if (example.value("hasScreenshot").toBool()) { |
| 179 | const auto ssFile = example.value("screenshotFileName", "screenshot.png").toString(); |
| 180 | fetchScreenshot(id, ssFile); |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * @brief Sets the search filter and re-applies filtering to the examples list. |
no test coverage detected