update// reformated datastore and changed storage chatmodel to store with datastore
This commit is contained in:
@@ -71,7 +71,10 @@ SOURCES += \
|
|||||||
src/chatbubbleme.cpp \
|
src/chatbubbleme.cpp \
|
||||||
src/chatbubblepartner.cpp \
|
src/chatbubblepartner.cpp \
|
||||||
src/chatmodel.cpp \
|
src/chatmodel.cpp \
|
||||||
src/contactmodel.cpp
|
src/contactmodel.cpp \
|
||||||
|
src/DataStore/DataStore.cpp \
|
||||||
|
src/DataStore/ChatDataStore.cpp \
|
||||||
|
src/DataStore/SietchDataStore.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/firsttimewizard.h \
|
src/firsttimewizard.h \
|
||||||
|
|||||||
42
src/DataStore/ChatDataStore.cpp
Normal file
42
src/DataStore/ChatDataStore.cpp
Normal 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;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#ifndef CHATDATASTORE_H
|
#ifndef CHATDATASTORE_H
|
||||||
#define CHATDATASTORE_H
|
#define CHATDATASTORE_H
|
||||||
|
#include "../chatmodel.h"
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
class ChatDataStore
|
class ChatDataStore
|
||||||
@@ -15,20 +15,11 @@ class ChatDataStore
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ChatDataStore* getInstance()
|
static ChatDataStore* getInstance();
|
||||||
{
|
|
||||||
if(!ChatDataStore::instanced)
|
|
||||||
{
|
|
||||||
ChatDataStore::instanced = true;
|
|
||||||
ChatDataStore::instance = new ChatDataStore();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ChatDataStore::instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void setData(QString key, ChatItem value);
|
void setData(QString key, ChatItem value);
|
||||||
ChatItem getData(QString key);
|
ChatItem getData(QString key);
|
||||||
|
std::map<QString, ChatItem> getAllRawChatItems();
|
||||||
QString dump();
|
QString dump();
|
||||||
|
|
||||||
~ChatDataStore()
|
~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
|
#endif
|
||||||
11
src/DataStore/DataStore.cpp
Normal file
11
src/DataStore/DataStore.cpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include "DataStore.h"
|
||||||
|
|
||||||
|
SietchDataStore* DataStore::getSietchDataStore()
|
||||||
|
{
|
||||||
|
return SietchDataStore::getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatDataStore* DataStore::getChatDataStore()
|
||||||
|
{
|
||||||
|
return ChatDataStore::getInstance();
|
||||||
|
}
|
||||||
@@ -11,14 +11,4 @@ class DataStore
|
|||||||
static ChatDataStore* getChatDataStore();
|
static ChatDataStore* getChatDataStore();
|
||||||
};
|
};
|
||||||
|
|
||||||
SietchDataStore* DataStore::getSietchDataStore()
|
|
||||||
{
|
|
||||||
return SietchDataStore::getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatDataStore* DataStore::getChatDataStore()
|
|
||||||
{
|
|
||||||
return ChatDataStore::getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
35
src/DataStore/SietchDataStore.cpp
Normal file
35
src/DataStore/SietchDataStore.cpp
Normal 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;
|
||||||
@@ -15,17 +15,7 @@ class SietchDataStore
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static SietchDataStore* getInstance()
|
static SietchDataStore* getInstance();
|
||||||
{
|
|
||||||
if(!SietchDataStore::instanced)
|
|
||||||
{
|
|
||||||
SietchDataStore::instanced = true;
|
|
||||||
SietchDataStore::instance = new SietchDataStore();
|
|
||||||
}
|
|
||||||
|
|
||||||
return SietchDataStore::instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void setData(QString key, QString value);
|
void setData(QString key, QString value);
|
||||||
QString getData(QString key);
|
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
|
#endif
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "addressbook.h"
|
#include "addressbook.h"
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
#include "DataStore/DataStore.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -109,7 +110,7 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
|
|||||||
// ui->lcdNumber->setPalette(Qt::red);
|
// ui->lcdNumber->setPalette(Qt::red);
|
||||||
// ui->lcdNumber->display("1");
|
// ui->lcdNumber->display("1");
|
||||||
|
|
||||||
for (auto &c : this->chatItems)
|
for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems())//this->chatItems)
|
||||||
for (auto &p : AddressBook::getInstance()->getAllAddressLabels())
|
for (auto &p : AddressBook::getInstance()->getAllAddressLabels())
|
||||||
{
|
{
|
||||||
//////Render only Memos for selected contacts. Do not render empty Memos //// Render only memos where cid=cid
|
//////Render only Memos for selected contacts. Do not render empty Memos //// Render only memos where cid=cid
|
||||||
@@ -159,7 +160,7 @@ void ChatModel::renderContactRequest(){
|
|||||||
QStandardItemModel* contactRequest = new QStandardItemModel();
|
QStandardItemModel* contactRequest = new QStandardItemModel();
|
||||||
|
|
||||||
|
|
||||||
for (auto &c : this->chatItems)
|
for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems())//this->chatItems)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((c.second.getType() == "cont") && (c.second.isOutgoing() == false) && (c.second.getMemo().startsWith("{"))) {
|
if ((c.second.getType() == "cont") && (c.second.isOutgoing() == false) && (c.second.getMemo().startsWith("{"))) {
|
||||||
@@ -187,7 +188,7 @@ void ChatModel::renderContactRequest(){
|
|||||||
|
|
||||||
QObject::connect(requestContact.requestContact, &QTableView::clicked, [&] () {
|
QObject::connect(requestContact.requestContact, &QTableView::clicked, [&] () {
|
||||||
|
|
||||||
for (auto &c : this->chatItems){
|
for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){//this->chatItems){
|
||||||
QModelIndex index = requestContact.requestContact->currentIndex();
|
QModelIndex index = requestContact.requestContact->currentIndex();
|
||||||
QString label_contact = index.data(Qt::DisplayRole).toString();
|
QString label_contact = index.data(Qt::DisplayRole).toString();
|
||||||
QStandardItemModel* contactMemo = new QStandardItemModel();
|
QStandardItemModel* contactMemo = new QStandardItemModel();
|
||||||
|
|||||||
@@ -13,8 +13,6 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "camount.h"
|
#include "camount.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ListViewDelegate : public QAbstractItemDelegate
|
class ListViewDelegate : public QAbstractItemDelegate
|
||||||
{
|
{
|
||||||
int d_radius;
|
int d_radius;
|
||||||
|
|||||||
@@ -887,7 +887,8 @@ void Controller::refreshTransactions() {
|
|||||||
txid,
|
txid,
|
||||||
true // is an outgoing message
|
true // is an outgoing message
|
||||||
);
|
);
|
||||||
chatModel->addMessage(item);
|
DataStore::getChatDataStore()->setData(chatModel->generateChatItemID(item), item);
|
||||||
|
//chatModel->addMessage(item);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -992,8 +993,8 @@ void Controller::refreshTransactions() {
|
|||||||
txid,
|
txid,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
DataStore::getChatDataStore()->setData(chatModel->generateChatItemID(item), item);
|
||||||
chatModel->addMessage(item);
|
//chatModel->addMessage(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "chatmodel.h"
|
#include "chatmodel.h"
|
||||||
#include "contactmodel.h"
|
#include "contactmodel.h"
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
struct WatchedTx {
|
struct WatchedTx {
|
||||||
|
|||||||
Reference in New Issue
Block a user