From 7e491b3a2534bf88f9b80d71c994b9b0531e1b96 Mon Sep 17 00:00:00 2001 From: Strider <127.0.0.1@404.com> Date: Sun, 10 May 2020 19:15:04 +0200 Subject: [PATCH] update// addec chat.cpp --- src/Chat/Chat.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/Chat/Chat.cpp diff --git a/src/Chat/Chat.cpp b/src/Chat/Chat.cpp new file mode 100644 index 0000000..c2719ee --- /dev/null +++ b/src/Chat/Chat.cpp @@ -0,0 +1,53 @@ +#include "Chat.h" +#include "../addressbook.h" +#include "../DataStore/DataStore.h" +Chat::Chat() {} + +void Chat::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); + } + } + } +} \ No newline at end of file