Browse Source

some changes

pull/130/head
DenioD 4 years ago
parent
commit
492ebbf1c5
  1. 2
      src/addressbook.cpp
  2. 54
      src/chatmodel.cpp
  3. 1
      src/contactmodel.cpp
  4. 41
      src/controller.cpp
  5. 1
      src/mainwindow.cpp

2
src/addressbook.cpp

@ -8,7 +8,7 @@
AddressBookModel::AddressBookModel(QTableView *parent) : QAbstractTableModel(parent)
{
headers << tr("Avatar")<< tr("Label") << tr("Address") << tr("HushChatAddress") << tr("CID");
headers << tr("Label") << tr("Address") << tr("HushChatAddress") << tr("CID");
this->parent = parent;
loadData();
}

54
src/chatmodel.cpp

@ -10,13 +10,10 @@
#include "ui_memodialog.h"
#include "ui_contactrequest.h"
#include "addressbook.h"
#include <QUuid>
#include <bits/stdc++.h>
#include <boost/algorithm/string.hpp>
#include <QtWidgets>
#include <QUuid>
using namespace std;
using namespace boost;
ChatModel::ChatModel(std::map<QString, ChatItem> chatItems)
{
@ -108,52 +105,40 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
for (auto &c : this->chatItems)
for (auto &p : AddressBook::getInstance()->getAllAddressLabels())
{
//////Render only Memos for selected contacts. Do not render empty Memos //// Render only memos where cid=cid
if (
(ui->contactNameMemo->text().trimmed() == c.second.getContact()) &&
(c.second.getMemo().startsWith("{") == false) &&
(c.second.getMemo().isEmpty() == false) &&
(p.getPartnerAddress() == c.second.getAddress())
)
{
if ((c.second.getContact() == ui->contactNameMemo->text().trimmed()) && (p.getPartnerAddress() == c.second.getAddress()) && (c.second.getMemo().startsWith("{") == false) && (c.second.getMemo().isEmpty() == false) && (c.second.isOutgoing() == true))
{
QStandardItem* Items = new QStandardItem(c.second.toChatLine());
Items->setData("Outgoing", Qt::UserRole +1);
chat->appendRow(Items);
ui->listChat->setModel(chat);
ui->listChat->setItemDelegate(new ListViewDelegate());
}
ui->listChat->setModel(chat);
if (
(ui->contactNameMemo->text().trimmed() == c.second.getContact()) &&
(c.second.getMemo().startsWith("{") == false) &&
(c.second.getMemo().isEmpty() == false) &&
(p.getMyAddress() == c.second.getAddress())
}
else{
ui->listChat->setModel(chat);
)
}
if ((c.second.getContact() == ui->contactNameMemo->text().trimmed()) && ((p.getMyAddress() == c.second.getAddress()) && c.second.getMemo().startsWith("{") == false) && (c.second.getMemo().isEmpty() == false) && (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);
ui->listChat->setItemDelegate(new ListViewDelegate());
ui->listChat->setModel(chat);
}
}
}
}
void ChatModel::addCid(QString tx, QString cid)
{
@ -231,8 +216,9 @@ Tx MainWindow::createTxFromChatPage() {
// ui->memoSizeChat->setLenDisplayLabel();// Todo -> activate lendisplay for chat
tx.toAddrs.push_back(ToFields{addr, amt, memo});
tx.toAddrs.push_back(ToFields{addr, amt, hmemo});
tx.toAddrs.push_back(ToFields{addr, amt, memo});

1
src/contactmodel.cpp

@ -20,6 +20,7 @@ void ContactModel::renderContactList(QListView* view)
view->setIconSize(QSize(60,70));
view->setUniformItemSizes(true);
view->setDragDropMode(QAbstractItemView::DropOnly);
view->show();
}

41
src/controller.cpp

@ -149,10 +149,6 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
allRecepients.push_back(rec) ;
}
int decider = qrand() % ((100 + 1)-1)+ 1;// random int between 1 and 100
//50% chance of adding another zdust, shuffle.
if(decider % 4 == 3)
allRecepients.insert(std::begin(allRecepients), {
dust.at(0),
dust.at(1),
@ -164,21 +160,6 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
dust.at(7),
dust.at(8)
}) ;
// std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device());
else
allRecepients.insert(std::begin(allRecepients), {
dust.at(0),
dust.at(1),
dust.at(2),
dust.at(3),
dust.at(4),
dust.at(5),
dust.at(6),
dust.at(7),
dust.at(8),
dust.at(9)
});
// std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device());
}
void Controller::noConnection()
@ -879,22 +860,17 @@ void Controller::refreshTransactions() {
QString memo;
if (!o["memo"].is_null()) {
memo = QString::fromStdString(o["memo"]);
}
QString cid;
QString contact;
for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
{
if (ui->contactNameMemo->text().trimmed() == c.getName()) {
cid = c.getCid();
}else {cid = "";}
if (address == c.getPartnerAddress()){
if (address == c.getPartnerAddress()){
contact = c.getName();
}else{ contact = "";}
}else{ contact = "";}
}
ChatItem item = ChatItem(
datetime,
address,
@ -906,10 +882,7 @@ void Controller::refreshTransactions() {
);
chatModel->addMessage(item);
}
}
items.push_back(TransactionItemDetail{address, amount, memo});
total_amount = total_amount + amount;
@ -922,7 +895,7 @@ void Controller::refreshTransactions() {
addresses.push_back(item.address);
address = addresses.join(",");
}
}

1
src/mainwindow.cpp

@ -914,6 +914,7 @@ void MainWindow::setupTransactionsTab() {
ui->listChat->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->listChat->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->listChat->setMinimumSize(200,350);
ui->listChat->setItemDelegate(new ListViewDelegate());
ui->listChat->show();
ui->transactionsTable->setContextMenuPolicy(Qt::CustomContextMenu);
// Table right click

Loading…
Cancel
Save