MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setSelectedIndex

Method setSelectedIndex

app/src/Misc/Examples.cpp:161–183  ·  view source on GitHub ↗

* @brief Selects an example by index and triggers README/screenshot fetching. */

Source from the content-addressed store, hash-verified

159 * @brief Selects an example by index and triggers README/screenshot fetching.
160 */
161void 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.

Callers 2

installExtensionMethod · 0.45
uninstallExtensionMethod · 0.45

Calls 3

clearMethod · 0.45
countMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected