@@ -17,7 +17,7 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view)
|
|||||||
//////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
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(c.second.getContact() == ui->contactNameMemo->text().trimmed()) &&
|
(p.getName() == ui->contactNameMemo->text().trimmed()) &&
|
||||||
(p.getPartnerAddress() == c.second.getAddress()) &&
|
(p.getPartnerAddress() == c.second.getAddress()) &&
|
||||||
(c.second.isOutgoing() == true))
|
(c.second.isOutgoing() == true))
|
||||||
{
|
{
|
||||||
@@ -33,7 +33,7 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(c.second.getContact() == ui->contactNameMemo->text().trimmed()) &&
|
(p.getName() == ui->contactNameMemo->text().trimmed()) &&
|
||||||
(p.getMyAddress() == c.second.getAddress()) &&
|
(p.getMyAddress() == c.second.getAddress()) &&
|
||||||
(c.second.isOutgoing() == false))
|
(c.second.isOutgoing() == false))
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
|
|||||||
ab.addr_chat->setText(myAddr);
|
ab.addr_chat->setText(myAddr);
|
||||||
});
|
});
|
||||||
model.updateUi(); //todo fix updating gui after adding
|
model.updateUi(); //todo fix updating gui after adding
|
||||||
rpc->refresh(true);
|
//rpc->refresh(true);
|
||||||
|
|
||||||
// If there is a target then make it the addr for the "Add to" button
|
// If there is a target then make it the addr for the "Add to" button
|
||||||
if (target != nullptr && Settings::isValidAddress(target->text()))
|
if (target != nullptr && Settings::isValidAddress(target->text()))
|
||||||
|
|||||||
@@ -86,77 +86,7 @@ void ChatModel::showMessages()
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView &view)
|
|
||||||
{
|
|
||||||
/*for(auto &c : this->chatItems)
|
|
||||||
{
|
|
||||||
//view.getItems().add(QString("[Timestamp] <Contactname|Me>: lorem ipsum ...."));
|
|
||||||
}*/
|
|
||||||
qDebug() << "not implemented yet";
|
|
||||||
//todo render items to view
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
QStandardItemModel* chat = new QStandardItemModel();
|
|
||||||
// ui->lcdNumber->setStyleSheet("background-color: red");
|
|
||||||
// ui->lcdNumber->setPalette(Qt::red);
|
|
||||||
// ui->lcdNumber->display("1");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (auto &p : AddressBook::getInstance()->getAllAddressLabels())
|
|
||||||
for (auto &c : DataStore::getChatDataStore()->getAllMemos())
|
|
||||||
{
|
|
||||||
//////Render only Memos for selected contacts. Do not render empty Memos //// Render only memos where cid=cid
|
|
||||||
|
|
||||||
|
|
||||||
if (
|
|
||||||
(c.second.getContact() == ui->contactNameMemo->text().trimmed()) &&
|
|
||||||
(p.getPartnerAddress() == c.second.getAddress()) &&
|
|
||||||
(c.second.isOutgoing() == true)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
|
|
||||||
QStandardItem* Items = new QStandardItem(c.second.toChatLine());
|
|
||||||
Items->setData("Outgoing", Qt::UserRole +1);
|
|
||||||
chat->appendRow(Items);
|
|
||||||
ui->listChat->setModel(chat);
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
ui->listChat->setModel(chat);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
(c.second.getContact() == ui->contactNameMemo->text().trimmed()) &&
|
|
||||||
(p.getMyAddress() == c.second.getAddress()) &&
|
|
||||||
(c.second.isOutgoing() == false)
|
|
||||||
)
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
QStandardItem* Items1 = new QStandardItem(c.second.toChatLine());
|
|
||||||
Items1->setData("Incoming", Qt::UserRole +1);
|
|
||||||
chat->appendRow(Items1);
|
|
||||||
ui->listChat->setModel(chat);
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
|
|
||||||
ui->listChat->setModel(chat);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::renderContactRequest(){
|
void MainWindow::renderContactRequest(){
|
||||||
|
|
||||||
Ui_requestDialog requestContact;
|
Ui_requestDialog requestContact;
|
||||||
|
|||||||
@@ -30,18 +30,13 @@ class ChatModel
|
|||||||
ChatModel() {};
|
ChatModel() {};
|
||||||
ChatModel(std::map<QString, ChatItem> chatItems);
|
ChatModel(std::map<QString, ChatItem> chatItems);
|
||||||
ChatModel(std::vector<ChatItem> chatItems);
|
ChatModel(std::vector<ChatItem> chatItems);
|
||||||
//QString generateChatItemID(ChatItem item);
|
|
||||||
std::map<QString, ChatItem> getItems();
|
std::map<QString, ChatItem> getItems();
|
||||||
void setItems(std::map<QString, ChatItem> items);
|
void setItems(std::map<QString, ChatItem> items);
|
||||||
QString zaddr();
|
QString zaddr();
|
||||||
void setItems(std::vector<ChatItem> items);
|
void setItems(std::vector<ChatItem> items);
|
||||||
void renderChatBox(Ui::MainWindow* ui, QListView &view);
|
|
||||||
void renderChatBox(Ui::MainWindow* ui, QListView *view);
|
|
||||||
// void renderContactRequest();
|
|
||||||
void triggerRequest();
|
void triggerRequest();
|
||||||
void showMessages();
|
void showMessages();
|
||||||
void clear();
|
void clear();
|
||||||
//void renderContactRequest(Ui::MainWindow* ui, QListView *view);
|
|
||||||
void addMessage(ChatItem item);
|
void addMessage(ChatItem item);
|
||||||
void addMessage(QString timestamp, ChatItem item);
|
void addMessage(QString timestamp, ChatItem item);
|
||||||
void addCid(QString tx, QString cid);
|
void addCid(QString tx, QString cid);
|
||||||
|
|||||||
@@ -855,8 +855,7 @@ void Controller::refreshTransactions() {
|
|||||||
for (auto o: it["outgoing_metadata"].get<json::array_t>()) {
|
for (auto o: it["outgoing_metadata"].get<json::array_t>()) {
|
||||||
|
|
||||||
QString address;
|
QString address;
|
||||||
|
|
||||||
|
|
||||||
address = QString::fromStdString(o["address"]);
|
address = QString::fromStdString(o["address"]);
|
||||||
|
|
||||||
// Sent items are -ve
|
// Sent items are -ve
|
||||||
@@ -867,22 +866,13 @@ void Controller::refreshTransactions() {
|
|||||||
QString memo;
|
QString memo;
|
||||||
if (!o["memo"].is_null()) {
|
if (!o["memo"].is_null()) {
|
||||||
memo = QString::fromStdString(o["memo"]);
|
memo = QString::fromStdString(o["memo"]);
|
||||||
}
|
|
||||||
|
|
||||||
QString cid;
|
QString cid;
|
||||||
QString contact;
|
|
||||||
|
|
||||||
for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
|
|
||||||
{
|
|
||||||
if (address == c.getPartnerAddress()){
|
|
||||||
contact = c.getName();
|
|
||||||
}else{ contact = "";}
|
|
||||||
|
|
||||||
|
|
||||||
ChatItem item = ChatItem(
|
ChatItem item = ChatItem(
|
||||||
datetime,
|
datetime,
|
||||||
address,
|
address,
|
||||||
contact,
|
QString(""),
|
||||||
memo,
|
memo,
|
||||||
QString(""),
|
QString(""),
|
||||||
QString(""),
|
QString(""),
|
||||||
@@ -890,6 +880,7 @@ void Controller::refreshTransactions() {
|
|||||||
txid,
|
txid,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
qDebug()<<"Memo : " <<memo;
|
||||||
|
|
||||||
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
|
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
|
||||||
|
|
||||||
@@ -898,7 +889,7 @@ void Controller::refreshTransactions() {
|
|||||||
items.push_back(TransactionItemDetail{address, amount, memo});
|
items.push_back(TransactionItemDetail{address, amount, memo});
|
||||||
total_amount = total_amount + amount;
|
total_amount = total_amount + amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
QList<QString> addresses;
|
QList<QString> addresses;
|
||||||
for (auto item : items) {
|
for (auto item : items) {
|
||||||
@@ -932,7 +923,6 @@ void Controller::refreshTransactions() {
|
|||||||
memo
|
memo
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
TransactionItem tx{
|
TransactionItem tx{
|
||||||
"Receive", datetime, address, txid,confirmations, items
|
"Receive", datetime, address, txid,confirmations, items
|
||||||
};
|
};
|
||||||
@@ -941,12 +931,14 @@ void Controller::refreshTransactions() {
|
|||||||
|
|
||||||
QString type;
|
QString type;
|
||||||
QString cid;
|
QString cid;
|
||||||
// int position;
|
int position;
|
||||||
QString requestZaddr;
|
QString requestZaddr;
|
||||||
|
|
||||||
|
if (!it["memo"].is_null()) {
|
||||||
|
|
||||||
if (memo.startsWith("{")) {
|
if (memo.startsWith("{")) {
|
||||||
|
|
||||||
QJsonDocument headermemo = QJsonDocument::fromJson(memo.toUtf8());
|
QJsonDocument headermemo = QJsonDocument::fromJson(memo.toUtf8());
|
||||||
|
|
||||||
cid = headermemo["cid"].toString();
|
cid = headermemo["cid"].toString();
|
||||||
type = headermemo["t"].toString();
|
type = headermemo["t"].toString();
|
||||||
@@ -955,43 +947,27 @@ void Controller::refreshTransactions() {
|
|||||||
chatModel->addCid(txid, cid);
|
chatModel->addCid(txid, cid);
|
||||||
chatModel->addrequestZaddr(txid, requestZaddr);
|
chatModel->addrequestZaddr(txid, requestZaddr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatModel->getCidByTx(txid) != QString("0xdeadbeef")){
|
if (chatModel->getCidByTx(txid) != QString("0xdeadbeef")){
|
||||||
|
|
||||||
cid = chatModel->getCidByTx(txid);
|
cid = chatModel->getCidByTx(txid);
|
||||||
|
|
||||||
}
|
}else{
|
||||||
else{
|
cid = "";
|
||||||
|
|
||||||
cid = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatModel->getrequestZaddrByTx(txid) != QString("0xdeadbeef")){
|
if (chatModel->getrequestZaddrByTx(txid) != QString("0xdeadbeef")){
|
||||||
|
|
||||||
requestZaddr = chatModel->getrequestZaddrByTx(txid);
|
requestZaddr = chatModel->getrequestZaddrByTx(txid);
|
||||||
|
}else{
|
||||||
}
|
|
||||||
|
|
||||||
else{
|
|
||||||
requestZaddr = "";
|
requestZaddr = "";
|
||||||
}
|
}
|
||||||
|
position = it["position"].get<json::number_integer_t>();
|
||||||
QString contact;
|
|
||||||
for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
|
|
||||||
{
|
|
||||||
|
|
||||||
if (address == c.getMyAddress()){
|
|
||||||
contact = c.getName();
|
|
||||||
|
|
||||||
}else{ contact = "";}
|
|
||||||
|
|
||||||
// position = it["position"].get<json::number_integer_t>();
|
|
||||||
|
|
||||||
ChatItem item = ChatItem(
|
ChatItem item = ChatItem(
|
||||||
datetime,
|
datetime,
|
||||||
address,
|
address,
|
||||||
contact,
|
QString(""),
|
||||||
memo,
|
memo,
|
||||||
requestZaddr,
|
requestZaddr,
|
||||||
type,
|
type,
|
||||||
@@ -999,6 +975,7 @@ void Controller::refreshTransactions() {
|
|||||||
txid,
|
txid,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
qDebug()<< "Position : " << position;
|
||||||
|
|
||||||
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
|
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user