From 205bb29f4a52c9ce662838bceceb94aaef61fd70 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Wed, 29 Apr 2020 01:24:38 +0200 Subject: [PATCH] show only memos from selcted contact - work in progress --- src/chatmodel.cpp | 13 +++++++++++++ src/chatmodel.h | 1 + src/mainwindow.cpp | 7 +------ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index 64a781b..c037fa5 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -62,6 +62,8 @@ void ChatModel::showMessages() } } + + void ChatModel::renderChatBox(QListWidget &view) { /*for(auto &c : this->chatItems) @@ -82,8 +84,15 @@ void ChatModel::renderChatBox(QListWidget *view) view->takeItem(0); } + //QModelIndex index = parent->listContactWidget->currentIndex(); + // QString itemText = index.data(Qt::DisplayRole).toString(); + + for(auto &c : this->chatItems) + { + + // if ("" == QString(c.second.getAddress())){ ////// ToDo: render only memos from selected contact QDateTime myDateTime; myDateTime.setTime_t(c.second.getTimestamp()); @@ -93,6 +102,10 @@ void ChatModel::renderChatBox(QListWidget *view) line += QString(c.second.getMemo()) + QString("\n"); view->addItem(line); line =""; + // } + // else{ + + // } } } diff --git a/src/chatmodel.h b/src/chatmodel.h index 8472028..524ce61 100644 --- a/src/chatmodel.h +++ b/src/chatmodel.h @@ -102,6 +102,7 @@ class ChatModel { private: std::map chatItems; + QTableView* parent; public: ChatModel() {}; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cf063b1..21f922a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -992,15 +992,10 @@ void MainWindow::setupchatTab() { ///////// Set selected Zaddr for Chat with Doubleklick QObject::connect(ui->listContactWidget, &QTableView::doubleClicked, [=] () { - for (auto p : AddressBook::getInstance()->getAllAddressLabels()) { + QModelIndex index = ui->listContactWidget->currentIndex(); QString itemText = index.data(Qt::DisplayRole).toString(); ui->ContactZaddr->setText(itemText); - - - } - - /// ui->listContactWidget->setCurrentRow(1) }); }