Implemented "updateReply" function of "NotesApp"
This commit is contained in:
parent
f64df0ddf6
commit
a99e30aeea
3 changed files with 21 additions and 1 deletions
|
@ -44,6 +44,8 @@ public slots:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void updateCapabilities(QJsonObject* json) = 0;
|
||||
|
||||
bool updateApiReply(QNetworkReply* reply) {
|
||||
if (m_replies.contains(reply)) {
|
||||
emit replyReceived(reply);
|
||||
|
@ -51,6 +53,8 @@ public slots:
|
|||
return m_replies.removeOne(reply);
|
||||
}
|
||||
|
||||
virtual void updateReply(QNetworkReply* reply) = 0;
|
||||
|
||||
signals:
|
||||
void installedChanged(bool);
|
||||
void capabilitiesChanged(QJsonObject* json);
|
||||
|
|
|
@ -113,4 +113,19 @@ void NotesApp::updateReply(QNetworkReply* reply) {
|
|||
|
||||
QByteArray data = reply->readAll();
|
||||
QJsonDocument json = QJsonDocument::fromJson(data);
|
||||
if (json.isObject()) {
|
||||
QJsonObject obj = json.object();
|
||||
updateNote(obj.value("id").toInt(), obj, true);
|
||||
}
|
||||
else if (json.isArray()) {
|
||||
QJsonArray arr = json.array();
|
||||
QJsonArray::iterator i;
|
||||
for (i = arr.begin(); i != arr.end(); ++i) {
|
||||
QJsonObject obj = i->toObject();
|
||||
updateNote(obj.value("id").toInt(), obj, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug() << "Reply not valid!";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,8 @@ public slots:
|
|||
//Q_INVOKABLE bool changeSettings(const QJsonObject& settings);
|
||||
|
||||
protected slots:
|
||||
virtual void updateReply(QNetworkReply* reply);
|
||||
void updateCapabilities(QJsonObject* json) { }
|
||||
void updateReply(QNetworkReply* reply);
|
||||
|
||||
signals:
|
||||
void capabilitiesChanged(QJsonObject* json);
|
||||
|
|
Loading…
Reference in a new issue