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

Method fetchPage

app/src/Misc/HelpCenter.cpp:373–397  ·  view source on GitHub ↗

* @brief Fetches the content for the page at the given index. Uses preloaded * content or network fetch. */

Source from the content-addressed store, hash-verified

371 * content or network fetch.
372 */
373void Misc::HelpCenter::fetchPage(int index)
374{
375 if (index < 0 || index >= m_filteredPages.count())
376 return;
377
378 const auto page = m_filteredPages.at(index).toMap();
379 const auto id = page.value("id").toString();
380 const auto file = page.value("file").toString();
381
382 const auto it = m_pageContents.constFind(id);
383 if (it != m_pageContents.constEnd()) {
384 m_pageContent = *it;
385 Q_EMIT pageContentChanged();
386 return;
387 }
388
389 m_loading = true;
390 Q_EMIT loadingChanged();
391
392 auto encoded = QString::fromUtf8(QUrl::toPercentEncoding(file));
393 auto url = QUrl::fromEncoded((kBase + encoded).toUtf8());
394 auto* reply = m_nam.get(QNetworkRequest(url));
395 reply->setProperty("pageId", id);
396 connect(reply, &QNetworkReply::finished, this, &HelpCenter::onPageReply);
397}
398
399/**
400 * @brief Kicks off background preloading of all page contents for full-text

Callers

nothing calls this directly

Calls 3

countMethod · 0.45
valueMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected