add chatbubbles to render chat
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <bits/stdc++.h>
|
#include <bits/stdc++.h>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
@@ -80,11 +81,11 @@ void ChatModel::showMessages()
|
|||||||
{
|
{
|
||||||
for(auto &c : this->chatItems)
|
for(auto &c : this->chatItems)
|
||||||
{
|
{
|
||||||
qDebug() << "[" << c.second.getTimestamp() << "] " << "<" << c.second.getAddress() << "> :" << c.second.getMemo();
|
qDebug() << c.second.toChatLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatModel::renderChatBox(Ui::MainWindow* ui, QListWidget &view)
|
void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView &view)
|
||||||
{
|
{
|
||||||
/*for(auto &c : this->chatItems)
|
/*for(auto &c : this->chatItems)
|
||||||
{
|
{
|
||||||
@@ -94,65 +95,67 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListWidget &view)
|
|||||||
//todo render items to view
|
//todo render items to view
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatModel::renderChatBox(Ui::MainWindow* ui, QListWidget *view)
|
void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
|
||||||
{
|
{
|
||||||
|
// QStandardItemModel mymodel;
|
||||||
while(view->count() > 0)
|
// QStandardItem* Items = new QStandardItem(myString);
|
||||||
|
QStandardItemModel* myModel = new QStandardItemModel();
|
||||||
|
for(auto &c : this->chatItems)
|
||||||
{
|
{
|
||||||
view->takeItem(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString line = "";
|
|
||||||
|
|
||||||
for(auto &c : this->chatItems){
|
|
||||||
|
|
||||||
QDateTime myDateTime;
|
|
||||||
|
|
||||||
myDateTime.setTime_t(c.second.getTimestamp());
|
|
||||||
|
|
||||||
//////Render only Memos for selected contacts. Do not render empty Memos //// Render only memos where cid=cid
|
//////Render only Memos for selected contacts. Do not render empty Memos //// Render only memos where cid=cid
|
||||||
|
|
||||||
///
|
///
|
||||||
if ((ui->ContactZaddr->text().trimmed() == c.second.getAddress()) && (c.second.getMemo().startsWith("{") == false) && (c.second.getMemo().isEmpty() == false)) {
|
if (
|
||||||
// if (c.second.getMemo.find())
|
(ui->ContactZaddr->text().trimmed() == c.second.getAddress()) &&
|
||||||
line += QString("[") + myDateTime.toString("dd.MM.yyyy hh:mm:ss ") + QString("] ");
|
(c.second.getMemo().startsWith("{") == false) &&
|
||||||
line += QString("<") + QString("Outgoing") + QString("> :\n");
|
(c.second.getMemo().isEmpty() == false)
|
||||||
line += QString(c.second.getMemo()) + QString("\n");
|
)
|
||||||
view->addItem(line);
|
{
|
||||||
line ="";
|
|
||||||
|
|
||||||
|
QStandardItem* Items = new QStandardItem(c.second.toChatLine());
|
||||||
////////////////////////////////// Todo : Render green checkmark for contacts if cid = cid - We have to search for cid in txid/cid list
|
Items->setData("Incoming", Qt::UserRole +1);
|
||||||
// QString cid = c.second.getCid();
|
myModel->appendRow(Items);
|
||||||
|
qDebug()<<Items->text();
|
||||||
}
|
ui->listChat->setModel(myModel);
|
||||||
|
ui->listChat->setMinimumSize(200,350);
|
||||||
if ((ui->MyZaddr->text().trimmed() == c.second.getAddress()) && (c.second.getMemo().startsWith("{") == false) && (c.second.getMemo().isEmpty() == false)){
|
ui->listChat->setItemDelegate(new ListViewDelegate());
|
||||||
for(auto &p : AddressBook::getInstance()->getAllAddressLabels()){
|
ui->listChat->show();
|
||||||
|
|
||||||
if ((ui->checkBox->isChecked() == true) && (p.getCid() != c.second.getCid()))
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}else{
|
|
||||||
|
|
||||||
// line+= QString("[") + "Warning. Not verified!" + QString("]");
|
|
||||||
|
|
||||||
|
|
||||||
line += QString("[") + myDateTime.toString("dd.MM.yyyy hh:mm:ss ") + QString("] ");
|
|
||||||
line += QString("<") + QString("incoming") + QString("> :\n");
|
|
||||||
line += QString(c.second.getMemo()) + QString("\n");
|
|
||||||
view->addItem(line);
|
|
||||||
line ="";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (
|
||||||
|
(ui->MyZaddr->text().trimmed() == c.second.getAddress()) &&
|
||||||
|
(c.second.getMemo().startsWith("{") == false) &&
|
||||||
|
(c.second.getMemo().isEmpty() == false)
|
||||||
|
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
QStandardItem* Items1 = new QStandardItem(c.second.toChatLine());
|
||||||
|
Items1->setData("Outgoing", Qt::UserRole +1);
|
||||||
|
myModel->appendRow(Items1);
|
||||||
|
qDebug()<<Items1->text();
|
||||||
}
|
}
|
||||||
|
ui->listChat->setModel(myModel);
|
||||||
|
ui->listChat->setMinimumSize(200,350);
|
||||||
|
ui->listChat->setItemDelegate(new ListViewDelegate());
|
||||||
|
ui->listChat->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
/////////////////////////Render only when CID=CID?
|
||||||
|
|
||||||
|
// for(auto &p : AddressBook::getInstance()->getAllAddressLabels())
|
||||||
|
// {
|
||||||
|
|
||||||
|
// if ((ui->checkBox->isChecked() == true) && (p.getCid() != c.second.getCid()))
|
||||||
|
// {
|
||||||
|
|
||||||
|
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,6 +250,9 @@ Tx MainWindow::createTxFromChatPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::sendChatButton() {
|
void MainWindow::sendChatButton() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////Todo: Check if a Contact is selected//////////
|
////////////////////////////Todo: Check if a Contact is selected//////////
|
||||||
|
|
||||||
// Create a Tx from the values on the send tab. Note that this Tx object
|
// Create a Tx from the values on the send tab. Note that this Tx object
|
||||||
@@ -420,6 +426,9 @@ Tx MainWindow::createTxForSafeContactRequest() {
|
|||||||
//////////////////De-activated for now///////////////////
|
//////////////////De-activated for now///////////////////
|
||||||
void MainWindow::safeContactRequest() {
|
void MainWindow::safeContactRequest() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////Todo: Check if its a zaddr//////////
|
////////////////////////////Todo: Check if its a zaddr//////////
|
||||||
|
|
||||||
// Create a Tx from the values on the send tab. Note that this Tx object
|
// Create a Tx from the values on the send tab. Note that this Tx object
|
||||||
|
|||||||
161
src/chatmodel.h
161
src/chatmodel.h
@@ -1,15 +1,161 @@
|
|||||||
#ifndef CHATMODEL_H
|
#ifndef CHATMODEL_H
|
||||||
#define CHATMODEL_H
|
#define CHATMODEL_H
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
#include <QAbstractItemDelegate>
|
||||||
|
#include <QPainter>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <QListWidget>
|
#include <QListView>
|
||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "camount.h"
|
#include "camount.h"
|
||||||
|
|
||||||
|
class ListViewDelegate : public QAbstractItemDelegate
|
||||||
|
{
|
||||||
|
int d_radius;
|
||||||
|
int d_toppadding;
|
||||||
|
int d_bottompadding;
|
||||||
|
int d_leftpadding;
|
||||||
|
int d_rightpadding;
|
||||||
|
int d_verticalmargin;
|
||||||
|
int d_horizontalmargin;
|
||||||
|
int d_pointerwidth;
|
||||||
|
int d_pointerheight;
|
||||||
|
float d_widthfraction;
|
||||||
|
public:
|
||||||
|
inline ListViewDelegate(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
inline void paint(QPainter *painter, QStyleOptionViewItem const &option, QModelIndex const &index) const;
|
||||||
|
inline QSize sizeHint(QStyleOptionViewItem const &option, QModelIndex const &index) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ListViewDelegate::ListViewDelegate(QObject *parent): QAbstractItemDelegate(parent), d_radius(5), d_toppadding(5), d_bottompadding(3), d_leftpadding(5), d_rightpadding(5), d_verticalmargin(15), d_horizontalmargin(10), d_pointerwidth(10), d_pointerheight(17), d_widthfraction(.7)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ListViewDelegate::paint(QPainter *painter, QStyleOptionViewItem const &option, QModelIndex const &index) const
|
||||||
|
{
|
||||||
|
QTextDocument bodydoc;
|
||||||
|
QTextOption textOption(bodydoc.defaultTextOption());
|
||||||
|
textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
|
||||||
|
bodydoc.setDefaultTextOption(textOption);
|
||||||
|
bodydoc.setDefaultFont(QFont("Roboto", 12));
|
||||||
|
QString bodytext(index.data(Qt::DisplayRole).toString());
|
||||||
|
bodydoc.setHtml(bodytext);
|
||||||
|
qreal contentswidth = option.rect.width() * d_widthfraction - d_horizontalmargin - d_pointerwidth - d_leftpadding - d_rightpadding;
|
||||||
|
bodydoc.setTextWidth(contentswidth);
|
||||||
|
qreal bodyheight = bodydoc.size().height();
|
||||||
|
bool outgoing = index.data(Qt::UserRole + 1).toString() == "Outgoing";
|
||||||
|
painter->save();
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
|
// uncomment to see the area provided to paint this item
|
||||||
|
|
||||||
|
//painter->drawRect(option.rect);
|
||||||
|
|
||||||
|
painter->translate(option.rect.left() + d_horizontalmargin, option.rect.top() + ((index.row() == 0) ? d_verticalmargin : 0));
|
||||||
|
|
||||||
|
// background color for chat bubble
|
||||||
|
QColor bgcolor("fbffff");
|
||||||
|
if (outgoing)
|
||||||
|
bgcolor = "#fffcfb";
|
||||||
|
|
||||||
|
// create chat bubble
|
||||||
|
QPainterPath pointie;
|
||||||
|
|
||||||
|
// left bottom
|
||||||
|
pointie.moveTo(0, bodyheight + d_toppadding + d_bottompadding);
|
||||||
|
|
||||||
|
// right bottom
|
||||||
|
pointie.lineTo(0 + contentswidth + d_pointerwidth + d_leftpadding + d_rightpadding - d_radius,
|
||||||
|
bodyheight + d_toppadding + d_bottompadding);
|
||||||
|
pointie.arcTo(0 + contentswidth + d_pointerwidth + d_leftpadding + d_rightpadding - 2 * d_radius,
|
||||||
|
bodyheight + d_toppadding + d_bottompadding - 2 * d_radius,
|
||||||
|
2 * d_radius, 2 * d_radius, 270, 90);
|
||||||
|
|
||||||
|
// right top
|
||||||
|
pointie.lineTo(0 + contentswidth + d_pointerwidth + d_leftpadding + d_rightpadding, 0 + d_radius);
|
||||||
|
pointie.arcTo(0 + contentswidth + d_pointerwidth + d_leftpadding + d_rightpadding - 2 * d_radius, 0,
|
||||||
|
2 * d_radius, 2 * d_radius, 0, 90);
|
||||||
|
|
||||||
|
// left top
|
||||||
|
pointie.lineTo(0 + d_pointerwidth + d_radius, 0);
|
||||||
|
pointie.arcTo(0 + d_pointerwidth, 0, 2 * d_radius, 2 * d_radius, 90, 90);
|
||||||
|
|
||||||
|
// left bottom almost (here is the pointie)
|
||||||
|
pointie.lineTo(0 + d_pointerwidth, bodyheight + d_toppadding + d_bottompadding - d_pointerheight);
|
||||||
|
pointie.closeSubpath();
|
||||||
|
|
||||||
|
// rotate bubble for outgoing messages
|
||||||
|
if (outgoing)
|
||||||
|
{
|
||||||
|
painter->translate(option.rect.width() - pointie.boundingRect().width() - d_horizontalmargin - d_pointerwidth, 0);
|
||||||
|
painter->translate(pointie.boundingRect().center());
|
||||||
|
painter->rotate(180);
|
||||||
|
painter->translate(-pointie.boundingRect().center());
|
||||||
|
}
|
||||||
|
|
||||||
|
// now paint it!
|
||||||
|
painter->setPen(QPen(bgcolor));
|
||||||
|
painter->drawPath(pointie);
|
||||||
|
painter->fillPath(pointie, QBrush(bgcolor));
|
||||||
|
|
||||||
|
// rotate back or painter is going to paint the text rotated...
|
||||||
|
if (outgoing)
|
||||||
|
{
|
||||||
|
painter->translate(pointie.boundingRect().center());
|
||||||
|
painter->rotate(-180);
|
||||||
|
painter->translate(-pointie.boundingRect().center());
|
||||||
|
}
|
||||||
|
|
||||||
|
// set text color used to draw message body
|
||||||
|
QAbstractTextDocumentLayout::PaintContext ctx;
|
||||||
|
if (outgoing)
|
||||||
|
ctx.palette.setColor(QPalette::Text, QColor("black"));
|
||||||
|
else
|
||||||
|
ctx.palette.setColor(QPalette::Text, QColor("white"));
|
||||||
|
|
||||||
|
// draw body text
|
||||||
|
painter->translate((outgoing ? 0 : d_pointerwidth) + d_leftpadding, 0);
|
||||||
|
bodydoc.documentLayout()->draw(painter, ctx);
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QSize ListViewDelegate::sizeHint(QStyleOptionViewItem const &option, QModelIndex const &index) const
|
||||||
|
{
|
||||||
|
QTextDocument bodydoc;
|
||||||
|
QTextOption textOption(bodydoc.defaultTextOption());
|
||||||
|
textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
|
||||||
|
bodydoc.setDefaultTextOption(textOption);
|
||||||
|
bodydoc.setDefaultFont(QFont("Roboto", 12));
|
||||||
|
QString bodytext(index.data(Qt::DisplayRole).toString());
|
||||||
|
bodydoc.setHtml(bodytext);
|
||||||
|
|
||||||
|
// the width of the contents are the (a fraction of the window width) minus (margins + padding + width of the bubble's tail)
|
||||||
|
qreal contentswidth = option.rect.width() * d_widthfraction - d_horizontalmargin - d_pointerwidth - d_leftpadding - d_rightpadding;
|
||||||
|
|
||||||
|
// set this available width on the text document
|
||||||
|
bodydoc.setTextWidth(contentswidth);
|
||||||
|
|
||||||
|
QSize size(bodydoc.idealWidth() + d_horizontalmargin + d_pointerwidth + d_leftpadding + d_rightpadding,
|
||||||
|
bodydoc.size().height() + d_bottompadding + d_toppadding + d_verticalmargin + 1); // I dont remember why +1, haha, might not be necessary
|
||||||
|
|
||||||
|
if (index.row() == 0) // have extra margin at top of first item
|
||||||
|
size += QSize(0, d_verticalmargin);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ChatItem
|
class ChatItem
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -117,6 +263,15 @@ class ChatItem
|
|||||||
_outgoing = true;
|
_outgoing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString toChatLine()
|
||||||
|
{
|
||||||
|
QDateTime myDateTime;
|
||||||
|
myDateTime.setTime_t(_timestamp);
|
||||||
|
QString line = QString("[") + myDateTime.toString("dd.MM.yyyy hh:mm:ss ") + QString("] ");
|
||||||
|
line += QString(_memo) + QString("\n");
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
~ChatItem()
|
~ChatItem()
|
||||||
{
|
{
|
||||||
/*delete timestamp;
|
/*delete timestamp;
|
||||||
@@ -145,8 +300,8 @@ class ChatModel
|
|||||||
void setItems(std::map<QString, ChatItem> items);
|
void setItems(std::map<QString, ChatItem> items);
|
||||||
QString zaddr();
|
QString zaddr();
|
||||||
void setItems(std::vector<ChatItem> items);
|
void setItems(std::vector<ChatItem> items);
|
||||||
void renderChatBox(Ui::MainWindow* ui, QListWidget &view);
|
void renderChatBox(Ui::MainWindow* ui, QListView &view);
|
||||||
void renderChatBox(Ui::MainWindow* ui, QListWidget *view);
|
void renderChatBox(Ui::MainWindow* ui, QListView *view);
|
||||||
void showMessages();
|
void showMessages();
|
||||||
void clear();
|
void clear();
|
||||||
void addMessage(ChatItem item);
|
void addMessage(ChatItem item);
|
||||||
|
|||||||
@@ -893,8 +893,8 @@ void Controller::refreshTransactions() {
|
|||||||
QString(""),
|
QString(""),
|
||||||
memo,
|
memo,
|
||||||
cid, // we have to set the cid here, its included in our Addressbook for this contact
|
cid, // we have to set the cid here, its included in our Addressbook for this contact
|
||||||
txid
|
txid,
|
||||||
// true // is an outgoing message
|
true // is an outgoing message
|
||||||
);
|
);
|
||||||
chatModel->addMessage(item);
|
chatModel->addMessage(item);
|
||||||
}
|
}
|
||||||
@@ -964,7 +964,8 @@ void Controller::refreshTransactions() {
|
|||||||
QString(""),
|
QString(""),
|
||||||
memo,
|
memo,
|
||||||
cid, // we have to set the cid here, its included in the headermemo
|
cid, // we have to set the cid here, its included in the headermemo
|
||||||
txid
|
txid,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
// qDebug()<< "Message CID: " << cid;
|
// qDebug()<< "Message CID: " << cid;
|
||||||
chatModel->addMessage(item);
|
chatModel->addMessage(item);
|
||||||
@@ -990,7 +991,7 @@ void Controller::refreshTransactions() {
|
|||||||
|
|
||||||
// Update model data, which updates the table view
|
// Update model data, which updates the table view
|
||||||
transactionsTableModel->replaceData(txdata);
|
transactionsTableModel->replaceData(txdata);
|
||||||
chatModel->renderChatBox(ui, ui->listChatMemo);
|
chatModel->renderChatBox(ui, ui->listChat);
|
||||||
refreshContacts(
|
refreshContacts(
|
||||||
ui->listContactWidget
|
ui->listContactWidget
|
||||||
|
|
||||||
@@ -998,7 +999,7 @@ void Controller::refreshTransactions() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::refreshChat(QListWidget *listWidget)
|
void Controller::refreshChat(QListView *listWidget)
|
||||||
{
|
{
|
||||||
chatModel->renderChatBox(ui, listWidget);
|
chatModel->renderChatBox(ui, listWidget);
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public:
|
|||||||
void refreshGBPCAP();
|
void refreshGBPCAP();
|
||||||
void refreshAUDCAP();
|
void refreshAUDCAP();
|
||||||
|
|
||||||
void refreshChat(QListWidget *listWidget);
|
void refreshChat(QListView *listWidget);
|
||||||
void refreshContacts(QListWidget *listWidget);
|
void refreshContacts(QListWidget *listWidget);
|
||||||
|
|
||||||
void executeStandardUITransaction(Tx tx);
|
void executeStandardUITransaction(Tx tx);
|
||||||
|
|||||||
@@ -994,6 +994,92 @@ void MainWindow::setupchatTab() {
|
|||||||
|
|
||||||
QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () {
|
QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () {
|
||||||
|
|
||||||
|
QStandardItemModel mymodel;
|
||||||
|
|
||||||
|
// for(auto &c : this->chatItems)
|
||||||
|
//{
|
||||||
|
//////Render only Memos for selected contacts. Do not render empty Memos //// Render only memos where cid=cid
|
||||||
|
|
||||||
|
///
|
||||||
|
// if (
|
||||||
|
// (ui->ContactZaddr->text().trimmed() == c.second.getAddress()) &&
|
||||||
|
// (c.second.getMemo().startsWith("{") == false) &&
|
||||||
|
// (c.second.getMemo().isEmpty() == false)
|
||||||
|
// )
|
||||||
|
// {
|
||||||
|
// if (c.second.getMemo.find())
|
||||||
|
|
||||||
|
//view->addItem(line);
|
||||||
|
|
||||||
|
// QStandardItem *item1 = new QStandardItem(c.second.toChatLine());
|
||||||
|
// item1->setData("Incoming", Qt::UserRole + 1);
|
||||||
|
// model.appendRow(item1);
|
||||||
|
|
||||||
|
QStandardItem *item1 = new QStandardItem("Kacke Hier");
|
||||||
|
item1->setData("Incoming", Qt::UserRole +1);
|
||||||
|
mymodel.appendRow(item1);
|
||||||
|
qDebug()<<item1->text();
|
||||||
|
|
||||||
|
|
||||||
|
QStandardItem *item2 = new QStandardItem("This is item one");
|
||||||
|
item2->setData("Outgoing", Qt::UserRole +1);
|
||||||
|
mymodel.appendRow(item2);
|
||||||
|
qDebug()<<item2->text();
|
||||||
|
|
||||||
|
QStandardItem *item3 = new QStandardItem("This is item one");
|
||||||
|
item3->setData("Outgoing", Qt::UserRole +1);
|
||||||
|
mymodel.appendRow(item3);
|
||||||
|
qDebug()<<item3->text();
|
||||||
|
|
||||||
|
// QStandardItem *item2 = new QStandardItem("Hallo");
|
||||||
|
// item1->setData("Outgoing", Qt::UserRole + 1);
|
||||||
|
// mymodel.appendRow(item2);
|
||||||
|
// qDebug()<<item2->text();
|
||||||
|
|
||||||
|
////////////////////////////////// Todo : Render green checkmark for contacts if cid = cid - We have to search for cid in txid/cid list
|
||||||
|
// QString cid = c.second.getCid();
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (
|
||||||
|
// (ui->MyZaddr->text().trimmed() == c.second.getAddress()) &&
|
||||||
|
// (c.second.getMemo().startsWith("{") == false) &&
|
||||||
|
// (c.second.getMemo().isEmpty() == false)
|
||||||
|
// )
|
||||||
|
// {
|
||||||
|
|
||||||
|
|
||||||
|
// for(auto &p : AddressBook::getInstance()->getAllAddressLabels())
|
||||||
|
// {
|
||||||
|
|
||||||
|
// if ((ui->checkBox->isChecked() == true) && (p.getCid() != c.second.getCid()))
|
||||||
|
// {
|
||||||
|
|
||||||
|
|
||||||
|
//}
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// line+= QString("[") + "Warning. Not verified!" + QString("]");
|
||||||
|
// QStandardItem *item = new QStandardItem(c.second.toChatLine());
|
||||||
|
//view->addItem(line);
|
||||||
|
// model.appendRow(item);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ui->listChat->setModel(&mymodel);
|
||||||
|
ui->listChat->setItemDelegate(new ListViewDelegate());
|
||||||
|
ui->listChat->show();
|
||||||
|
//ui->listChat->update();
|
||||||
|
|
||||||
|
|
||||||
QModelIndex index = ui->listContactWidget->currentIndex();
|
QModelIndex index = ui->listContactWidget->currentIndex();
|
||||||
QString label_contact = index.data(Qt::DisplayRole).toString();
|
QString label_contact = index.data(Qt::DisplayRole).toString();
|
||||||
|
|
||||||
@@ -1005,8 +1091,12 @@ void MainWindow::setupchatTab() {
|
|||||||
ui->contactCid->setText(p.getCid());
|
ui->contactCid->setText(p.getCid());
|
||||||
|
|
||||||
rpc->refresh(true);
|
rpc->refresh(true);
|
||||||
|
updateChat();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatMemoEdit::ChatMemoEdit(QWidget* parent) : QPlainTextEdit(parent) {
|
ChatMemoEdit::ChatMemoEdit(QWidget* parent) : QPlainTextEdit(parent) {
|
||||||
@@ -1052,12 +1142,13 @@ void ChatMemoEdit::setSendChatButton(QPushButton* button) {
|
|||||||
|
|
||||||
void MainWindow::updateChat()
|
void MainWindow::updateChat()
|
||||||
{
|
{
|
||||||
rpc->refreshChat(ui->listChatMemo);
|
rpc->refreshChat(ui->listChat);
|
||||||
|
rpc->refresh(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateContacts()
|
void MainWindow::updateContacts()
|
||||||
{
|
{
|
||||||
qDebug() << "Called MainWindow::updateContacts()";
|
|
||||||
rpc->refreshContacts(ui->listContactWidget);
|
rpc->refreshContacts(ui->listContactWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public:
|
|||||||
void createWebsocket(QString wormholecode);
|
void createWebsocket(QString wormholecode);
|
||||||
void stopWebsocket();
|
void stopWebsocket();
|
||||||
|
|
||||||
|
|
||||||
void balancesReady();
|
void balancesReady();
|
||||||
void payhushURI(QString uri = "", QString myAddr = "");
|
void payhushURI(QString uri = "", QString myAddr = "");
|
||||||
|
|
||||||
@@ -92,8 +93,9 @@ private:
|
|||||||
void setupBalancesTab();
|
void setupBalancesTab();
|
||||||
void setuphushdTab();
|
void setuphushdTab();
|
||||||
void setupchatTab();
|
void setupchatTab();
|
||||||
void updateChat();
|
|
||||||
void updateContacts();
|
void updateContacts();
|
||||||
|
void updateChat();
|
||||||
|
|
||||||
void setupSettingsModal();
|
void setupSettingsModal();
|
||||||
void setupStatusBar();
|
void setupStatusBar();
|
||||||
|
|||||||
@@ -1390,31 +1390,6 @@
|
|||||||
<string><html><head/><body><p align="center"><br/></p></body></html></string>
|
<string><html><head/><body><p align="center"><br/></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QListWidget" name="listChatMemo">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>340</x>
|
|
||||||
<y>40</y>
|
|
||||||
<width>921</width>
|
|
||||||
<height>371</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="editTriggers">
|
|
||||||
<set>QAbstractItemView::NoEditTriggers</set>
|
|
||||||
</property>
|
|
||||||
<property name="showDropIndicator" stdset="0">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="defaultDropAction">
|
|
||||||
<enum>Qt::IgnoreAction</enum>
|
|
||||||
</property>
|
|
||||||
<property name="selectionMode">
|
|
||||||
<enum>QAbstractItemView::NoSelection</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QPushButton" name="sendChatButton">
|
<widget class="QPushButton" name="sendChatButton">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
@@ -1563,6 +1538,40 @@
|
|||||||
<string><html><head/><body><p align="center">Contact Name:</p></body></html></string>
|
<string><html><head/><body><p align="center">Contact Name:</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QListView" name="listChat">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>340</x>
|
||||||
|
<y>40</y>
|
||||||
|
<width>921</width>
|
||||||
|
<height>371</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeAdjustPolicy">
|
||||||
|
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||||
|
</property>
|
||||||
|
<property name="editTriggers">
|
||||||
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
|
</property>
|
||||||
|
<property name="resizeMode">
|
||||||
|
<enum>QListView::Adjust</enum>
|
||||||
|
</property>
|
||||||
|
<property name="modelColumn">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="uniformItemSizes">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user