fix a problem with two chatrender functions due to refractor

This commit is contained in:
DenioD
2020-05-14 12:50:05 +02:00
parent 7e491b3a25
commit b9526c1f35
4 changed files with 13 additions and 83 deletions

View File

@@ -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(){
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());