From 78ca3cf8caca719a43f8c3ac5df23ab019dc136d Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Tue, 26 May 2020 22:11:15 +0200 Subject: [PATCH] fix for double outgoing message --- src/Chat/Chat.cpp | 5 ++++- src/chatmodel.cpp | 9 ++++----- src/controller.cpp | 37 +++++++++++++++++++------------------ src/mainwindow.cpp | 1 + src/mainwindow.ui | 7 +++++-- 5 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/Chat/Chat.cpp b/src/Chat/Chat.cpp index f76222d..c0482b8 100644 --- a/src/Chat/Chat.cpp +++ b/src/Chat/Chat.cpp @@ -67,7 +67,8 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label) Items->setData(OUTGOING, Qt::UserRole + 1); chat->appendRow(Items); - ui->listChat->setModel(chat); + ui->listChat->setModel(chat); + } else @@ -86,6 +87,8 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label) Items1->setData(INCOMING, Qt::UserRole + 1); chat->appendRow(Items1); ui->listChat->setModel(chat); + + } else { diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index 97d46f9..e5864f8 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -53,7 +53,6 @@ void ChatModel::clear() void ChatModel::addMessage(ChatItem item) { QString key = ChatIDGenerator::getInstance()->generateID(item); //this->generateChatItemID(item); - // qDebug() << "inserting chatitem with id: " << key; this->chatItems[key] = item; } @@ -72,9 +71,7 @@ void ChatModel::showMessages() } } - - - + void MainWindow::renderContactRequest(){ Ui_requestDialog requestContact; @@ -336,7 +333,9 @@ void MainWindow::sendChat() { // Memos can only be used with zAddrs. So check that first // for(auto &c : AddressBook::getInstance()->getAllAddressLabels()) - + QString Name = ui->contactNameMemo->text(); + int sizename = Name.size(); + qDebug()<< sizename; if (ui->contactNameMemo->text().trimmed().isEmpty() || ui->memoTxtChat->toPlainText().trimmed().isEmpty()) { // auto addr = ""; diff --git a/src/controller.cpp b/src/controller.cpp index 2b4c982..cd6152b 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -237,18 +237,15 @@ void Controller::getInfoThenRefresh(bool force) zrpc->fetchInfo([=] (const json& reply) { prevCallSucceeded = true; int curBlock = reply["latest_block_height"].get(); + bool doUpdate = force || (model->getLatestBlock() != curBlock); + int difficulty = reply["difficulty"].get(); + int blocks_until_halving= 340000 - curBlock; + int halving_days = (blocks_until_halving * 150) / (60*60*24) ; int longestchain = reply["longestchain"].get(); int notarized = reply["notarized"].get(); - int lag = longestchain - notarized ; + - qDebug()<<"Lag :" << lag; - - - int difficulty = reply["difficulty"].get(); - int blocks_until_halving= 340000 - curBlock; - int halving_days = (blocks_until_halving * 150) / (60*60*24) ; - bool doUpdate = force || (model->getLatestBlock() != curBlock); model->setLatestBlock(curBlock); if ( Settings::getInstance()->get_currency_name() == "EUR" || @@ -267,7 +264,7 @@ void Controller::getInfoThenRefresh(bool force) ); - this->setLag(lag); + ui->difficulty->setText( QLocale(QLocale::German).toString(difficulty) @@ -295,8 +292,6 @@ void Controller::getInfoThenRefresh(bool force) (QLocale(QLocale::English).toString(blocks_until_halving)) + " Blocks or , " + (QLocale(QLocale::English).toString(halving_days) + " days" ) ); - - this->setLag(lag); } ui->Version->setText( @@ -305,7 +300,6 @@ void Controller::getInfoThenRefresh(bool force) ui->Vendor->setText( QString::fromStdString(reply["vendor"].get()) ); - this->setLag(lag); main->logger->write( QString("Refresh. curblock ") % QString::number(curBlock) % ", update=" % (doUpdate ? "true" : "false") ); @@ -553,8 +547,12 @@ void Controller::getInfoThenRefresh(bool force) refreshAddresses(); // This calls refreshZSentTransactions() and refreshReceivedZTrans() refreshTransactions(); } + + int lag = longestchain - notarized ; + this->setLag(lag); }, [=](QString err) { // hushd has probably disappeared. + this->noConnection(); // Prevent multiple dialog boxes, because these are called async @@ -914,6 +912,12 @@ void Controller::refreshTransactions() { isNotarized = false; } + if (confirmations == 1) { + DataStore::getChatDataStore()->clear(); + this->refresh(true); + } + qDebug()<<"Conf : " << confirmations; + ChatItem item = ChatItem( datetime, address, @@ -927,12 +931,10 @@ void Controller::refreshTransactions() { true, isNotarized ); - // qDebug()<<"Memo : " <setData(ChatIDGenerator::getInstance()->generateID(item), item); - - } + } + + items.push_back(TransactionItemDetail{address, amount, memo}); total_amount = total_amount + amount; @@ -1038,7 +1040,6 @@ void Controller::refreshTransactions() { isNotarized ); qDebug()<< "Notarized : " << isNotarized; - // qDebug()<<"Confirmation :" << confirmations; DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4f6c428..d71baad 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1208,6 +1208,7 @@ void MainWindow::setupTransactionsTab() { ui->listChat->setMinimumSize(200,350); ui->listChat->setItemDelegate(new ListViewDelegate()); ui->listChat->show(); + ui->transactionsTable->setContextMenuPolicy(Qt::CustomContextMenu); // Table right click QObject::connect(ui->transactionsTable, &QTableView::customContextMenuRequested, [=] (QPoint pos) { diff --git a/src/mainwindow.ui b/src/mainwindow.ui index c7d5481..a4a4e78 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1378,7 +1378,10 @@ true - QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + QAbstractItemView::NoEditTriggers + + + false false @@ -1518,7 +1521,7 @@ QAbstractScrollArea::AdjustToContents - QAbstractItemView::AllEditTriggers + QAbstractItemView::NoEditTriggers QListView::Adjust