From 89579022ef98f162c48abda1fa60777f4215d6bf Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Thu, 10 Sep 2020 19:17:17 +0200 Subject: [PATCH] show timestamp of incoming contact request #194 --- src/chatmodel.cpp | 73 ++- src/requestContactDialog.ui | 952 ++++++++++++++++++++---------------- 2 files changed, 574 insertions(+), 451 deletions(-) diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index eb113cf..33cf8dc 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -91,7 +91,7 @@ QString ChatModel::Addressbylabel(QString address) return QString("0xdeadbeef"); } - + void MainWindow::renderContactRequest(){ Ui_requestDialog requestContact; @@ -109,58 +109,63 @@ void MainWindow::renderContactRequest(){ QPixmap unknownWhite(icon); QIcon addnewAddrIcon(unknownWhite); - - - - - QStandardItemModel* contactRequest = new QStandardItemModel(); + + + ///////// Tableview for incoming contact request + int requestsize = DataStore::getChatDataStore()->getAllNewContactRequests().size(); + requestContact.requestContact->setRowCount(requestsize); + requestContact.requestContact->setColumnCount(2); + QStringList request_TableHeader; + request_TableHeader<<"Address"<<"Date"; + requestContact.requestContact->setHorizontalHeaderLabels(request_TableHeader); + requestContact.requestContact->setShowGrid(false); + requestContact.requestContact->setEditTriggers(QAbstractItemView::NoEditTriggers); + requestContact.requestContact->setSelectionBehavior(QAbstractItemView::SelectRows); + requestContact.requestContact->setSelectionMode(QAbstractItemView::SingleSelection); + requestContact.requestContact->setColumnWidth(0,205); - for (auto &c : DataStore::getChatDataStore()->getAllNewContactRequests()) + int i=0; + + for (auto &c : DataStore::getChatDataStore()->getAllNewContactRequests()) + + { - { + int timestamp = c.second.getTimestamp(); + QDateTime myDateTime; + myDateTime.setTime_t(timestamp); + QString timestamphtml = myDateTime.toString("yyyy-MM-dd"); - QStandardItem* Items = new QStandardItem(QString(c.second.getRequestZaddr())); - contactRequest->appendRow(Items); - requestContact.requestContact->setModel(contactRequest); - Items->setData(QIcon(addnewAddrIcon),Qt::DecorationRole); - requestContact.requestContact->setIconSize(QSize(40,50)); - requestContact.requestContact->setUniformItemSizes(true); - requestContact.requestContact->show(); - requestContact.zaddrnew->setVisible(false); - requestContact.zaddrnew->setText(c.second.getRequestZaddr()); + requestContact.requestContact->setItem(i, 0, new QTableWidgetItem(c.second.getRequestZaddr())); + requestContact.requestContact->setItem(i, 1, new QTableWidgetItem(timestamphtml)); + requestContact.zaddrnew->setVisible(false); + requestContact.zaddrnew->setText(c.second.getRequestZaddr()); + requestContact.requestContact->sortByColumn(1, Qt::DescendingOrder); - - - } + i++; + + } - QStandardItemModel* contactRequestOld = new QStandardItemModel(); + QStandardItemModel* contactRequestOld = new QStandardItemModel(); - for (auto &c : DataStore::getChatDataStore()->getAllOldContactRequests()) + for (auto &c : DataStore::getChatDataStore()->getAllOldContactRequests()) { QStandardItem* Items = new QStandardItem(c.second.getContact()); contactRequestOld->appendRow(Items); requestContact.requestContactOld->setModel(contactRequestOld); requestContact.zaddrold->setVisible(false); requestContact.zaddrold->setText(c.second.getRequestZaddr()); - - + } - - QObject::connect(requestContact.requestContact, &QTableView::clicked, [&] () { for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){ QModelIndex index = requestContact.requestContact->currentIndex(); QString label_contact = index.data(Qt::DisplayRole).toString(); QStandardItemModel* contactMemo = new QStandardItemModel(); - - - - if ((c.second.isOutgoing() == false) && (label_contact == c.second.getRequestZaddr() && (c.second.getMemo().startsWith("{") == false))) @@ -184,8 +189,6 @@ void MainWindow::renderContactRequest(){ }); - - QObject::connect(requestContact.requestContactOld, &QTableView::clicked, [&] () { for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){ @@ -210,9 +213,7 @@ void MainWindow::renderContactRequest(){ }else{ } - } - - + } }); @@ -247,8 +248,6 @@ void MainWindow::renderContactRequest(){ ); return; } - - AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar); rpc->refreshContacts( ui->listContactWidget); diff --git a/src/requestContactDialog.ui b/src/requestContactDialog.ui index 76e904a..b41713c 100644 --- a/src/requestContactDialog.ui +++ b/src/requestContactDialog.ui @@ -6,7 +6,7 @@ 0 0 - 850 + 764 495 @@ -18,438 +18,562 @@ - 850 + 600 + 495 + + + + + 764 495 Incoming Contact Request - - - - - <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Memo of the request</span></p></body></html> - - - - - - - - 500 - 231 - - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - QAbstractScrollArea::AdjustToContents - - - QAbstractItemView::NoEditTriggers - - - QListView::Adjust - - - 0 - - - false - - - true - - - - - - - <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Open requests</span></p></body></html> - - - - - - - - 0 - 0 - - - - - 225 - 190 - - - - true - - - QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked - - - false - - - QAbstractItemView::SingleSelection - - - - - - - - 351 - 25 - - - - - 351 - 25 - - - - - - - - - 0 - 0 - - - - Request from: - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - 25 - - - - - - - - - + + + + 360 + 10 + 151 + 17 + + + + <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Memo of the request</span></p></body></html> + + + + + + 355 + 32 + 400 + 231 + + + + + 400 + 231 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustToContents + + + QAbstractItemView::NoEditTriggers + + + QListView::Adjust + + + 0 + + + false + + + true + + + + + + 9 + 9 + 161 + 17 + + + + <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Open requests from:</span></p></body></html> + + + + + + 9 + 294 + 162 + 192 + + + + + 0 + 0 + + + + + 150 + 190 + + + + true + + + QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + false + + + QAbstractItemView::SingleSelection + + + + + + 299 + 328 + 450 + 25 + + + + + 450 + 25 + + + + + 351 + 25 + + + + + + + 177 + 343 + 97 + 17 + + + + + 0 + 0 + + + + Request from: + + + + + + 299 + 399 + 142 + 25 + + + + + 0 + 0 + + + + + 0 + 25 + + + + 25 + + + + + + 480 + 461 + 16 + 17 + + + + + + + + + + 628 + 461 + 127 + 25 + + + + Add New Contact + + + false + + + + + + 417 + 461 + 16 + 17 + + + + + + + + + + 177 + 430 + 233 + 17 + + + + + 0 + 0 + + + + <html><head/><body><p>Choose an avatar for your contact:</p></body></html> + + + + + + 177 + 368 + 68 + 17 + + + + + 0 + 0 + + + + My Zaddr: + + + + + + 340 + 461 + 16 + 17 + + + + + + + + + + 542 + 461 + 80 + 25 + + + + + 0 + 0 + + + + + 100 + 0 + + + + Cancel + + + false + + + false + + + + + + 417 + 430 + 106 + 25 + + + + + 106 + 25 + + + + + 106 + 25 + + + + + SDLogo + + + + :/icons/res/SDLogo.png + + - - - - Add New Contact - - - false - - + + + Duke + + + + :/icons/res/Duke.png + + - - - - - - + + + Denio + + + + :/icons/res/Denio.png + + - - - - - 0 - 0 - - - - <html><head/><body><p>Choose an avatar for your contact:</p></body></html> - - + + + Berg + + + + :/icons/res/Berg.png + + - - - - - 0 - 0 - - - - My Zaddr: - - + + + Sharpee + + + + :/icons/res/Sharpee.png + + - - - - - - + + + Elsa + + + + :/icons/res/Elsa.png + + - - - - - 0 - 0 - - - - - 100 - 0 - - - - Cancel - - - false - - - false - - + + + Yoda + + + + :/icons/res/Yoda.png + + - - - - - 106 - 25 - - - - - 106 - 25 - - - - - SDLogo - - - - :/icons/res/SDLogo.png - - - - - - Duke - - - - :/icons/res/Duke.png - - - - - - Denio - - - - :/icons/res/Denio.png - - - - - - Berg - - - - :/icons/res/Berg.png - - - - - - Sharpee - - - - :/icons/res/Sharpee.png - - - - - - Elsa - - - - :/icons/res/Elsa.png - - - - - - Yoda - - - - :/icons/res/Yoda.png - - - - - - Garfield - - - - :/icons/res/Garfield.png - - - - - - Snoopy - - - - :/icons/res/Snoopy.png - - - - - - Popey - - - - :/icons/res/Popey.png - - - - - - Pinguin - - - - :/icons/res/Pinguin.png - - - - - - Mickey - - - - :/icons/res/Mickey.png - - - - - - Stag - - - - :/icons/res/Stag.png - - - - + + + Garfield + + + + :/icons/res/Garfield.png + + - - - - - 225 - 231 - - - - true - - - QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked - - - false - - - QAbstractItemView::SingleSelection - - + + + Snoopy + + + + :/icons/res/Snoopy.png + + - - - - <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Recently closed requests</span></p></body></html> - - + + + Popey + + + + :/icons/res/Popey.png + + - - - - - 0 - 0 - - - - <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Details of the request</span></p></body></html> - - + + + Pinguin + + + + :/icons/res/Pinguin.png + + - - - - - 0 - 0 - - - - Give a Nickname: - - + + + Mickey + + + + :/icons/res/Mickey.png + + - - - - - 351 - 25 - - - - - 351 - 25 - - - + + + Stag + + + + :/icons/res/Stag.png + + - + + + + + 9 + 271 + 179 + 17 + + + + <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Recently closed requests</span></p></body></html> + + + + + + 177 + 294 + 157 + 17 + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Details of the request</span></p></body></html> + + + + + + 177 + 399 + 116 + 17 + + + + + 0 + 0 + + + + Give a Nickname: + + + + + + 299 + 368 + 450 + 25 + + + + + 450 + 25 + + + + + 351 + 25 + + + + + + + 9 + 32 + 321 + 231 + + + + + 150 + 231 + + + + true + + + QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + false + + + QAbstractItemView::SingleSelection + +