Skip to content

Instantly share code, notes, and snippets.

@v-kolesnikov
Created May 16, 2015 15:06
Show Gist options
  • Save v-kolesnikov/5949826d4300642fb7f4 to your computer and use it in GitHub Desktop.
Save v-kolesnikov/5949826d4300642fb7f4 to your computer and use it in GitHub Desktop.
gistmanager.cpp
void GistManager::gistsReceive()
{
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
if (!reply) {
return;
}
QJsonParseError parser;
QJsonDocument jsonReply = QJsonDocument::fromJson(reply->readAll(), &parser);
if (parser.error != QJsonParseError::NoError) {
emit apiError(parser.errorString());
return;
}
for (auto it : jsonReply.array()) {
QJsonObject jsonGist = it.toObject();
m_gists << new GistItem(jsonGist);
}
emit gistsUpdated();
reply->deleteLater();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment