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

Method onReadmeReply

app/src/Misc/Examples.cpp:256–287  ·  view source on GitHub ↗

* @brief Handles the README.md fetch response and caches it. */

Source from the content-addressed store, hash-verified

254 * @brief Handles the README.md fetch response and caches it.
255 */
256void Misc::Examples::onReadmeReply()
257{
258 auto* reply = qobject_cast<QNetworkReply*>(sender());
259 if (!reply)
260 return;
261
262 reply->deleteLater();
263
264 if (reply->error() == QNetworkReply::NoError) {
265 const auto raw = QString::fromUtf8(reply->readAll());
266
267 const auto id = reply->property("exampleId").toString();
268 if (!id.isEmpty()) {
269 const auto path = exampleCachePath(id);
270 QDir().mkpath(path);
271 QFile file(path + "/README.md");
272 if (file.open(QIODevice::WriteOnly)) {
273 file.write(raw.toUtf8());
274 file.close();
275 }
276 }
277
278 m_selectedReadme = raw;
279 }
280
281 else
282 m_selectedReadme = tr("Failed to load README: %1").arg(reply->errorString());
283
284 m_loading = false;
285 Q_EMIT loadingChanged();
286 Q_EMIT selectedReadmeChanged();
287}
288
289/**
290 * @brief Handles the screenshot fetch response and caches it.

Callers

nothing calls this directly

Calls 7

senderFunction · 0.85
errorMethod · 0.80
isEmptyMethod · 0.80
errorStringMethod · 0.80
openMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected