Qtification "lite" - first round

This commit is contained in:
miodragpop
2020-06-15 13:11:39 +02:00
parent efa216a131
commit e20efde2ed
29 changed files with 859 additions and 19772 deletions

View File

@@ -59,15 +59,16 @@ void ChatDataStore::setPassword(QString password)
QString ChatDataStore::dump()
{
json chats;
chats["count"] = this->data.size();
json j = {};
QJsonObject chats;
chats["count"] = (qint64)this->data.size();
QJsonArray j;
for (auto &c: this->data)
{
j.push_back(c.second.toJson());
}
chats["chatitems"] = j;
return QString::fromStdString(chats.dump());
QJsonDocument jd_chats = QJsonDocument(chats);
return QLatin1String(jd_chats.toJson(QJsonDocument::Compact));
}
std::map<QString, ChatItem> ChatDataStore::getAllRawChatItems()
@@ -136,4 +137,4 @@ std::map<QString, ChatItem> ChatDataStore::getAllMemos()
ChatDataStore* ChatDataStore::instance = nullptr;
bool ChatDataStore::instanced = false;
bool ChatDataStore::instanced = false;

View File

@@ -1,7 +1,6 @@
#ifndef CHATDATASTORE_H
#define CHATDATASTORE_H
#include "../chatmodel.h"
using json = nlohmann::json;
class ChatDataStore
{
@@ -45,4 +44,4 @@ class ChatDataStore
#endif
#endif

View File

@@ -33,9 +33,9 @@ ContactItem ContactDataStore::getData(QString key)
QString ContactDataStore::dump()
{
json contacts;
contacts["count"] = this->data.size();
json j = {};
QJsonObject contacts;
contacts["count"] = (qint64)this->data.size();
QJsonArray j = {};
for (auto &c: this->data)
{
qDebug() << c.second.toQTString();
@@ -43,8 +43,11 @@ QString ContactDataStore::dump()
j.push_back(c.second.toJson());
}
contacts["contacts"] = j;
return QString::fromStdString(contacts.dump(4));
QJsonDocument jd_contacts = QJsonDocument(contacts);
return QLatin1String(jd_contacts.toJson(QJsonDocument::Compact));
// return QString::fromStdString(contacts.dump(4));
}
ContactDataStore* ContactDataStore::instance = nullptr;
bool ContactDataStore::instanced = false;
bool ContactDataStore::instanced = false;

View File

@@ -2,7 +2,6 @@
#define CONTACTDATASTORE_H
#include "../Model/ContactItem.h"
#include <string>
using json = nlohmann::json;
class ContactDataStore
{
@@ -31,4 +30,4 @@ class ContactDataStore
#endif
#endif

View File

@@ -1,8 +1,6 @@
#ifndef SIETCHDATASTORE_H
#define SIETCHDATASTORE_H
using json = nlohmann::json;
class SietchDataStore
{
private:
@@ -28,4 +26,4 @@ class SietchDataStore
}
};
#endif
#endif