From 707d858601f6538d4ce4a77073dc6e6edca883f5 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 13 Feb 2020 09:31:11 -0500 Subject: [PATCH] Find the current HushContact when sendMemo is clicked Current (row,col) index: 0 , 0 Current HushContact: "Alice" --- src/mainwindow.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8837f6f..987d07f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -199,8 +199,15 @@ void MainWindow::sendMemo() { QString memo = ui->textEdit->toPlainText(); QString addr = contact.getZaddr(); - QModelIndex qmil = ui->contactsView->currentIndex(); - qDebug() << "Current index: " << qmil; + QModelIndex qmi = ui->contactsView->currentIndex(); + if (qmi.isValid()) { + qDebug() << "Current (row,col) index: " << qmi.row() << "," << qmi.column(); + // we seem to get duplicates due to QT internals shenanigans, just pick the first + QMap currentContacts = ui->contactsView->model()->itemData(qmi); + qDebug() << "Current HushContact: " << currentContacts[0].toString(); + } else { + qDebug() << "Invalid current index, no contacts selected"; + } // we send a header memo plus actual memo tx.toAddrs.push_back( ToFields{addr, amount, hmemo, hmemo.toUtf8().toHex()} ); @@ -720,11 +727,11 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event) { QMouseEvent *ev = static_cast(event); if (ev->buttons() & Qt::RightButton) { - qDebug()<< "RightButton clicked"; + //qDebug()<< "RightButton clicked"; } if (ev->buttons() & Qt::LeftButton) { - qDebug()<< "LeftButton clicked"; + //qDebug()<< "LeftButton clicked"; //TODO: if this was a HushContact object in chatView, update MainWindow::contact } //return false;