Merge pull request #3 from strider-paff-shell/chat

added Chatmessages with Timestamp
This commit is contained in:
Denio
2020-04-27 22:08:18 +02:00
committed by GitHub
7 changed files with 40 additions and 14 deletions

View File

@@ -51,7 +51,7 @@ void ChatModel::showMessages()
} }
} }
void ChatModel::renderChatBox(QListView &view) void ChatModel::renderChatBox(QListWidget &view)
{ {
/*for(auto &c : this->chatItems) /*for(auto &c : this->chatItems)
{ {
@@ -61,12 +61,25 @@ void ChatModel::renderChatBox(QListView &view)
//todo render items to view //todo render items to view
} }
void ChatModel::renderChatBox(QListView *view) void ChatModel::renderChatBox(QListWidget *view)
{ {
/*for(auto &c : this->chatItems) qDebug() << "called ChatModel::renderChatBox(QListWidget *view)";
QString line = "";
while(view->count() > 0)
{ {
//view->getItems().add(QString("[Timestamp] <Contactname|Me>: lorem ipsum ....")); view->takeItem(0);
}*/ }
qDebug() << "not implemented yet blyat";
//todo render items to view for(auto &c : this->chatItems)
{
QDateTime myDateTime;
myDateTime.setTime_t(c.second.getTimestamp());
qDebug() << "[" << myDateTime.toString("dd.MM.yyyy hh:mm:ss ") << "] " << "<" << c.second.getAddress() << "> :" << c.second.getMemo();
line += QString("[") + myDateTime.toString("dd.MM.yyyy hh:mm:ss ") + QString("] ");
line += QString("<") + QString(c.second.getAddress()) + QString("> :");
line += QString(c.second.getMemo());
view->addItem(line);
line ="";
}
} }

View File

@@ -3,7 +3,7 @@
#include <QString> #include <QString>
#include <map> #include <map>
#include <vector> #include <vector>
#include <QListView> #include <QListWidget>
class ChatItem class ChatItem
{ {
@@ -109,8 +109,8 @@ class ChatModel
std::map<long, ChatItem> getItems(); std::map<long, ChatItem> getItems();
void setItems(std::map<long, ChatItem> items); void setItems(std::map<long, ChatItem> items);
void setItems(std::vector<ChatItem> items); void setItems(std::vector<ChatItem> items);
void renderChatBox(QListView &view); void renderChatBox(QListWidget &view);
void renderChatBox(QListView *view); void renderChatBox(QListWidget *view);
void showMessages(); void showMessages();
void clear(); void clear();
void addMessage(ChatItem item); void addMessage(ChatItem item);

View File

@@ -982,11 +982,17 @@ 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(); chatModel->renderChatBox(ui->listChatMemo);
chatModel->showMessages(); //chatModel->showMessages();
}); });
} }
void Controller::refreshChat(QListWidget *listWidget)
{
qDebug() << "Called Controller::refreshChat(QListWidget *listWidget)";
chatModel->renderChatBox(listWidget);
}
// If the wallet is encrpyted and locked, we need to unlock it // If the wallet is encrpyted and locked, we need to unlock it
void Controller::unlockIfEncrypted(std::function<void(void)> cb, std::function<void(void)> error) void Controller::unlockIfEncrypted(std::function<void(void)> cb, std::function<void(void)> error)
{ {

View File

@@ -71,6 +71,7 @@ public:
void refreshGBPCAP(); void refreshGBPCAP();
void refreshAUDCAP(); void refreshAUDCAP();
void refreshChat(QListWidget *listWidget);
void executeStandardUITransaction(Tx tx); void executeStandardUITransaction(Tx tx);

View File

@@ -900,7 +900,6 @@ void MainWindow::setupTransactionsTab() {
// Set up context menu on transactions tab // Set up context menu on transactions tab
ui->transactionsTable->setContextMenuPolicy(Qt::CustomContextMenu); ui->transactionsTable->setContextMenuPolicy(Qt::CustomContextMenu);
// Table right click // Table right click
QObject::connect(ui->transactionsTable, &QTableView::customContextMenuRequested, [=] (QPoint pos) { QObject::connect(ui->transactionsTable, &QTableView::customContextMenuRequested, [=] (QPoint pos) {
QModelIndex index = ui->transactionsTable->indexAt(pos); QModelIndex index = ui->transactionsTable->indexAt(pos);
@@ -983,6 +982,12 @@ void MainWindow::setupTransactionsTab() {
}); });
} }
void MainWindow::updateChat()
{
qDebug() << "Called MainWindow::updateChat()";
rpc->refreshChat(ui->listChatMemo);
}
void MainWindow::addNewZaddr(bool sapling) { void MainWindow::addNewZaddr(bool sapling) {
rpc->createNewZaddr(sapling, [=] (json reply) { rpc->createNewZaddr(sapling, [=] (json reply) {
QString addr = QString::fromStdString(reply.get<json::array_t>()[0]); QString addr = QString::fromStdString(reply.get<json::array_t>()[0]);

View File

@@ -85,6 +85,7 @@ private:
void setupSendTab(); void setupSendTab();
void setupTransactionsTab(); void setupTransactionsTab();
void updateChat();
void setupReceiveTab(); void setupReceiveTab();
void setupBalancesTab(); void setupBalancesTab();
void setuphushdTab(); void setuphushdTab();

View File

@@ -1432,7 +1432,7 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;Messages&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;Messages&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
<widget class="QListWidget" name="listChatWidget"> <widget class="QListWidget" name="listChatMemo">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>340</x> <x>340</x>