diff --git a/src/Chat/Chat.cpp b/src/Chat/Chat.cpp index c2719ee..7038fe1 100644 --- a/src/Chat/Chat.cpp +++ b/src/Chat/Chat.cpp @@ -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 if ( - (c.second.getContact() == ui->contactNameMemo->text().trimmed()) && + (p.getName() == ui->contactNameMemo->text().trimmed()) && (p.getPartnerAddress() == c.second.getAddress()) && (c.second.isOutgoing() == true)) { @@ -33,7 +33,7 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view) } if ( - (c.second.getContact() == ui->contactNameMemo->text().trimmed()) && + (p.getName() == ui->contactNameMemo->text().trimmed()) && (p.getMyAddress() == c.second.getAddress()) && (c.second.isOutgoing() == false)) diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index 67dd432..01aed54 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -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] : 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(){ Ui_requestDialog requestContact; @@ -167,7 +97,7 @@ void MainWindow::renderContactRequest(){ QStandardItemModel* contactRequest = new QStandardItemModel(); { - for (auto &c : DataStore::getChatDataStore()->getAllContactRequests()) + for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()) { QStandardItem* Items = new QStandardItem(c.second.getAddress()); diff --git a/src/chatmodel.h b/src/chatmodel.h index b54c5ae..04493b8 100644 --- a/src/chatmodel.h +++ b/src/chatmodel.h @@ -30,18 +30,13 @@ class ChatModel ChatModel() {}; ChatModel(std::map chatItems); ChatModel(std::vector chatItems); - //QString generateChatItemID(ChatItem item); std::map getItems(); void setItems(std::map items); QString zaddr(); void setItems(std::vector items); - void renderChatBox(Ui::MainWindow* ui, QListView &view); - void renderChatBox(Ui::MainWindow* ui, QListView *view); - // void renderContactRequest(); void triggerRequest(); void showMessages(); void clear(); - //void renderContactRequest(Ui::MainWindow* ui, QListView *view); void addMessage(ChatItem item); void addMessage(QString timestamp, ChatItem item); void addCid(QString tx, QString cid); diff --git a/src/controller.cpp b/src/controller.cpp index 730e906..35403c1 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -877,7 +877,7 @@ void Controller::refreshTransactions() { if (address == c.getPartnerAddress()){ contact = c.getName(); }else{ contact = "";} - + } ChatItem item = ChatItem( datetime, @@ -890,14 +890,17 @@ void Controller::refreshTransactions() { txid, true ); + qDebug()<<"Kontaktname : " <setData(ChatIDGenerator::getInstance()->generateID(item), item); - } + // } items.push_back(TransactionItemDetail{address, amount, memo}); total_amount = total_amount + amount; } + { QList addresses; @@ -986,6 +989,7 @@ void Controller::refreshTransactions() { }else{ contact = "";} + } // position = it["position"].get(); ChatItem item = ChatItem( @@ -999,9 +1003,10 @@ void Controller::refreshTransactions() { txid, false ); - + qDebug()<<"Kontaktname : " <setData(ChatIDGenerator::getInstance()->generateID(item), item); - } + // } } }