update// moved class to a normal variable instace
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#ifndef CHATMODEL_H
|
||||
#define CHATMODEL_H
|
||||
#include <QString>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
@@ -6,65 +8,83 @@
|
||||
class ChatItem
|
||||
{
|
||||
private:
|
||||
long timestamp;
|
||||
QString address;
|
||||
QString contact;
|
||||
QString memo;
|
||||
bool outgoing = false;
|
||||
long _timestamp;
|
||||
QString _address;
|
||||
QString _contact;
|
||||
QString _memo;
|
||||
bool _outgoing = false;
|
||||
|
||||
public:
|
||||
ChatItem() {}
|
||||
ChatItem(long timestamp, QString address, QString contact, QString memo);
|
||||
ChatItem(long timestamp, QString address, QString contact, QString memo, bool outgoing = false);
|
||||
|
||||
ChatItem(long timestamp, QString address, QString contact, QString memo)
|
||||
{
|
||||
_timestamp = timestamp;
|
||||
_address = address;
|
||||
_contact = contact;
|
||||
_memo = memo;
|
||||
_outgoing = false;
|
||||
|
||||
}
|
||||
|
||||
ChatItem(long timestamp, QString address, QString contact, QString memo, bool outgoing)
|
||||
{
|
||||
_timestamp = timestamp;
|
||||
_address = address;
|
||||
_contact = contact;
|
||||
_memo = memo;
|
||||
_outgoing = outgoing;
|
||||
|
||||
}
|
||||
|
||||
long getTimestamp()
|
||||
{
|
||||
return this->timestamp;
|
||||
return _timestamp;
|
||||
}
|
||||
|
||||
QString getAddress()
|
||||
{
|
||||
return this->address;
|
||||
return _address;
|
||||
}
|
||||
|
||||
QString getContact()
|
||||
{
|
||||
return this->contact;
|
||||
return _contact;
|
||||
}
|
||||
|
||||
QString getMemo()
|
||||
{
|
||||
return this->memo;
|
||||
return _memo;
|
||||
}
|
||||
|
||||
bool isOutgoing()
|
||||
{
|
||||
return this->outgoing;
|
||||
return _outgoing;
|
||||
}
|
||||
|
||||
void setTimestamp(long timestamp)
|
||||
{
|
||||
this->timestamp = timestamp;
|
||||
_timestamp = timestamp;
|
||||
}
|
||||
|
||||
void setAddress(QString address)
|
||||
{
|
||||
this->address = address;
|
||||
_address = address;
|
||||
}
|
||||
|
||||
void setContact(QString contact)
|
||||
{
|
||||
this->contact = contact;
|
||||
_contact = contact;
|
||||
}
|
||||
|
||||
void setMemo(QString memo)
|
||||
{
|
||||
this->memo = memo;
|
||||
_memo = memo;
|
||||
}
|
||||
|
||||
void toggleOutgo()
|
||||
{
|
||||
this->outgoing = true;
|
||||
_outgoing = true;
|
||||
}
|
||||
|
||||
~ChatItem()
|
||||
@@ -95,4 +115,5 @@ class ChatModel
|
||||
void clear();
|
||||
void addMessage(ChatItem item);
|
||||
void addMessage(long timestamp, ChatItem item);
|
||||
};
|
||||
};
|
||||
#endif
|
||||
@@ -10,6 +10,7 @@ template<>
|
||||
DataStore<QString>* DataStore<QString>::instance = nullptr;
|
||||
template<>
|
||||
bool DataStore<QString>::instanced = false;
|
||||
ChatModel *chatModel = new ChatModel();
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -877,6 +878,7 @@ void Controller::refreshTransactions()
|
||||
QString memo;
|
||||
if (!o["memo"].is_null())
|
||||
{
|
||||
memo = QString::fromStdString(o["memo"]);
|
||||
ChatItem item = ChatItem(
|
||||
datetime,
|
||||
address,
|
||||
@@ -885,7 +887,7 @@ void Controller::refreshTransactions()
|
||||
true // is an outgoing message
|
||||
);
|
||||
chatModel->addMessage(item);
|
||||
memo = QString::fromStdString(o["memo"]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -925,6 +927,7 @@ void Controller::refreshTransactions()
|
||||
QString memo;
|
||||
if (!it["memo"].is_null())
|
||||
{
|
||||
memo = QString::fromStdString(it["memo"]);
|
||||
ChatItem item = ChatItem(
|
||||
datetime,
|
||||
address,
|
||||
@@ -933,7 +936,7 @@ void Controller::refreshTransactions()
|
||||
);
|
||||
chatModel->addMessage(item);
|
||||
}
|
||||
memo = QString::fromStdString(it["memo"]);
|
||||
|
||||
|
||||
items.push_back(
|
||||
TransactionItemDetail{
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
ChatModel *chatModel = new ChatModel();
|
||||
|
||||
struct WatchedTx {
|
||||
QString opid;
|
||||
Tx tx;
|
||||
|
||||
Reference in New Issue
Block a user