diff --git a/src/chatmodel.h b/src/chatmodel.h index 5a35db9..d44a35f 100644 --- a/src/chatmodel.h +++ b/src/chatmodel.h @@ -1,3 +1,5 @@ +#ifndef CHATMODEL_H +#define CHATMODEL_H #include #include #include @@ -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); -}; \ No newline at end of file +}; +#endif \ No newline at end of file diff --git a/src/controller.cpp b/src/controller.cpp index 0661b06..b7c5dba 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -10,6 +10,7 @@ template<> DataStore* DataStore::instance = nullptr; template<> bool DataStore::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{ diff --git a/src/controller.h b/src/controller.h index 5071dee..a5f0fee 100644 --- a/src/controller.h +++ b/src/controller.h @@ -15,8 +15,6 @@ using json = nlohmann::json; -ChatModel *chatModel = new ChatModel(); - struct WatchedTx { QString opid; Tx tx;