From b9dab96b870f70c998fcee723a95ddb482b098e8 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Fri, 1 May 2020 12:27:21 +0200 Subject: [PATCH 1/3] add txid and cid to chatmodel --- src/chatmodel.cpp | 8 ++++++-- src/chatmodel.h | 29 +++++++++++++++++++++++++++-- src/controller.cpp | 8 ++++++-- src/mainwindow.cpp | 1 + src/mainwindow.ui | 13 +++++++++++++ 5 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index e95aff7..eaa1b88 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -8,8 +8,11 @@ #include "ui_memodialog.h" #include "addressbook.h" #include +#include +#include - +using namespace std; +using namespace boost; ChatModel::ChatModel(std::map chatItems) { @@ -89,8 +92,9 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListWidget *view) myDateTime.setTime_t(c.second.getTimestamp()); - //////Render only Memos for selected contacts. Do not render empty Memos + //////Render only Memos for selected contacts. Do not render empty Memos //// Render only memos where cid=cid if ((ui->ContactZaddr->text().trimmed() == c.second.getAddress()) && (c.second.getMemo().startsWith("{") == false) && (c.second.getMemo().isEmpty() == false)) { + // if (c.second.getMemo.find()) line += QString("[") + myDateTime.toString("dd.MM.yyyy hh:mm:ss ") + QString("] "); line += QString("<") + QString("Outgoing") + QString("> :\n"); line += QString(c.second.getMemo()) + QString("\n"); diff --git a/src/chatmodel.h b/src/chatmodel.h index 43a0e88..4e822c1 100644 --- a/src/chatmodel.h +++ b/src/chatmodel.h @@ -17,27 +17,33 @@ class ChatItem QString _address; QString _contact; QString _memo; + QString _cid; + QString _txid; bool _outgoing = false; public: ChatItem() {} - ChatItem(long timestamp, QString address, QString contact, QString memo) + ChatItem(long timestamp, QString address, QString contact, QString memo, QString cid, QString txid) { _timestamp = timestamp; _address = address; _contact = contact; _memo = memo; + _cid = cid; + _txid = txid; _outgoing = false; } - ChatItem(long timestamp, QString address, QString contact, QString memo, bool outgoing) + ChatItem(long timestamp, QString address, QString contact, QString memo, QString cid, QString txid, bool outgoing) { _timestamp = timestamp; _address = address; _contact = contact; _memo = memo; + _cid = cid; + _txid = txid; _outgoing = outgoing; } @@ -62,6 +68,16 @@ class ChatItem return _memo; } + QString getCid() + { + return _cid; + } + + QString getTxid() + { + return _cid; + } + bool isOutgoing() { return _outgoing; @@ -87,6 +103,15 @@ class ChatItem _memo = memo; } + void setCid(QString cid) + { + _cid = cid; + } + void setTxid(QString txid) + { + _txid = txid; + } + void toggleOutgo() { _outgoing = true; diff --git a/src/controller.cpp b/src/controller.cpp index e6b6b37..cf73946 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -884,7 +884,9 @@ void Controller::refreshTransactions() { datetime, address, QString(""), - memo + memo, + "", // we have to set the cid here, + txid // true // is an outgoing message ); chatModel->addMessage(item); @@ -933,7 +935,9 @@ void Controller::refreshTransactions() { datetime, address, QString(""), - memo + memo, + "", // we have to set the cid here + txid ); chatModel->addMessage(item); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 76cd090..2b252e4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1001,6 +1001,7 @@ void MainWindow::setupchatTab() { ui->ContactZaddr->setText(p.getPartnerAddress()); ui->MyZaddr->setText(p.getMyAddress()); ui->contactNameMemo->setText(p.getName()); + ui->contactCid->setText(p.getCid()); rpc->refresh(true); } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index e5eb12e..913907f 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1524,6 +1524,19 @@ + + + + 870 + 90 + 331 + 20 + + + + <html><head/><body><p align="center"><br/></p></body></html> + + From 4afd49d0a7cb79eeff2c6066548a8c74efc70257 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Fri, 1 May 2020 13:15:05 +0200 Subject: [PATCH 2/3] read the cid from headermemo into qstring --- src/controller.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index cf73946..0871d6b 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -885,7 +885,7 @@ void Controller::refreshTransactions() { address, QString(""), memo, - "", // we have to set the cid here, + "", // we have to set the cid here, its included in our Addressbook for this contact txid // true // is an outgoing message ); @@ -924,21 +924,30 @@ void Controller::refreshTransactions() { if (!it["memo"].is_null()) { memo = QString::fromStdString(it["memo"]); } - + TransactionItem tx{ "Receive", datetime, address, txid,confirmations, items }; txdata.push_back(tx); + QString cid; + if (memo.startsWith("{")) { + + cid = memo.mid(14,36); + + }else{ cid = "";} + ChatItem item = ChatItem( datetime, address, QString(""), memo, - "", // we have to set the cid here + cid, // we have to set the cid here, its included in the headermemo txid ); + qDebug()<addMessage(item); items.push_back(TransactionItemDetail{ From 4f4ec7cd317bd21114c4cf5ebc2d79c3135b029e Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Fri, 1 May 2020 13:42:25 +0200 Subject: [PATCH 3/3] fix typo --- src/chatmodel.cpp | 4 ++++ src/chatmodel.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index eaa1b88..558ea6f 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -100,6 +100,10 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListWidget *view) line += QString(c.second.getMemo()) + QString("\n"); view->addItem(line); line =""; + + ////////////////////////////////// Todo : Render green checkmark for contacts if cid = cid - We have to search for cid in txid/cid list + QString cid = c.second.getCid(); + }else{} if ((ui->MyZaddr->text().trimmed() == c.second.getAddress()) && (c.second.getMemo().startsWith("{") == false) && (c.second.getMemo().isEmpty() == false)){ diff --git a/src/chatmodel.h b/src/chatmodel.h index 4e822c1..9f06d3a 100644 --- a/src/chatmodel.h +++ b/src/chatmodel.h @@ -75,7 +75,7 @@ class ChatItem QString getTxid() { - return _cid; + return _txid; } bool isOutgoing()