update// reformated datastore and changed storage chatmodel to store with datastore

This commit is contained in:
Strider
2020-05-08 21:16:40 +02:00
parent d0562d2c65
commit 30ddc479ba
11 changed files with 104 additions and 88 deletions

View File

@@ -0,0 +1,42 @@
#include "ChatDataStore.h"
ChatDataStore* ChatDataStore::getInstance()
{
if(!ChatDataStore::instanced)
{
ChatDataStore::instanced = true;
ChatDataStore::instance = new ChatDataStore();
}
return ChatDataStore::instance;
}
void ChatDataStore::clear()
{
this->data.clear();
}
void ChatDataStore::setData(QString key, ChatItem value)
{
this->data[key] = value;
}
ChatItem ChatDataStore::getData(QString key)
{
return this->data[key];
}
QString ChatDataStore::dump()
{
return "";
}
std::map<QString, ChatItem> ChatDataStore::getAllRawChatItems()
{
return this->data;
}
ChatDataStore* ChatDataStore::instance = nullptr;
bool ChatDataStore::instanced = false;

View File

@@ -1,6 +1,6 @@
#ifndef CHATDATASTORE_H
#define CHATDATASTORE_H
#include "../chatmodel.h"
using json = nlohmann::json;
class ChatDataStore
@@ -15,20 +15,11 @@ class ChatDataStore
}
public:
static ChatDataStore* getInstance()
{
if(!ChatDataStore::instanced)
{
ChatDataStore::instanced = true;
ChatDataStore::instance = new ChatDataStore();
}
return ChatDataStore::instance;
}
static ChatDataStore* getInstance();
void clear();
void setData(QString key, ChatItem value);
ChatItem getData(QString key);
std::map<QString, ChatItem> getAllRawChatItems();
QString dump();
~ChatDataStore()
@@ -38,28 +29,6 @@ class ChatDataStore
}
};
void ChatDataStore::clear()
{
this->data.clear();
}
void ChatDataStore::setData(QString key, ChatItem value)
{
this->data[key] = value;
}
ChatItem ChatDataStore::getData(QString key)
{
return this->data[key];
}
QString ChatDataStore::dump()
{
return "";
}
ChatDataStore* ChatDataStore::instance = nullptr;
bool ChatDataStore::instanced = false;
#endif

View File

@@ -0,0 +1,11 @@
#include "DataStore.h"
SietchDataStore* DataStore::getSietchDataStore()
{
return SietchDataStore::getInstance();
}
ChatDataStore* DataStore::getChatDataStore()
{
return ChatDataStore::getInstance();
}

View File

@@ -11,14 +11,4 @@ class DataStore
static ChatDataStore* getChatDataStore();
};
SietchDataStore* DataStore::getSietchDataStore()
{
return SietchDataStore::getInstance();
}
ChatDataStore* DataStore::getChatDataStore()
{
return ChatDataStore::getInstance();
}
#endif

View File

@@ -0,0 +1,35 @@
#include "SietchDataStore.h"
SietchDataStore* SietchDataStore::getInstance()
{
if(!SietchDataStore::instanced)
{
SietchDataStore::instanced = true;
SietchDataStore::instance = new SietchDataStore();
}
return SietchDataStore::instance;
}
void SietchDataStore::clear()
{
this->data.clear();
}
void SietchDataStore::setData(QString key, QString value)
{
this->data[key] = value;
}
QString SietchDataStore::getData(QString key)
{
return this->data[key];
}
QString SietchDataStore::dump()
{
return "";
}
SietchDataStore* SietchDataStore::instance = nullptr;
bool SietchDataStore::instanced = false;

View File

@@ -15,17 +15,7 @@ class SietchDataStore
}
public:
static SietchDataStore* getInstance()
{
if(!SietchDataStore::instanced)
{
SietchDataStore::instanced = true;
SietchDataStore::instance = new SietchDataStore();
}
return SietchDataStore::instance;
}
static SietchDataStore* getInstance();
void clear();
void setData(QString key, QString value);
QString getData(QString key);
@@ -38,27 +28,4 @@ class SietchDataStore
}
};
void SietchDataStore::clear()
{
this->data.clear();
}
void SietchDataStore::setData(QString key, QString value)
{
this->data[key] = value;
}
QString SietchDataStore::getData(QString key)
{
return this->data[key];
}
QString SietchDataStore::dump()
{
return "";
}
SietchDataStore* SietchDataStore::instance = nullptr;
bool SietchDataStore::instanced = false;
#endif