Browse Source

update// added chatmessages to chatwindow

pull/130/head
Strider 4 years ago
parent
commit
b79334a497
  1. 27
      src/chatmodel.cpp
  2. 6
      src/chatmodel.h
  3. 10
      src/controller.cpp
  4. 1
      src/controller.h
  5. 7
      src/mainwindow.cpp
  6. 1
      src/mainwindow.h
  7. 2
      src/mainwindow.ui

27
src/chatmodel.cpp

@ -51,7 +51,7 @@ void ChatModel::showMessages()
}
}
void ChatModel::renderChatBox(QListView &view)
void ChatModel::renderChatBox(QListWidget &view)
{
/*for(auto &c : this->chatItems)
{
@ -61,12 +61,25 @@ void ChatModel::renderChatBox(QListView &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 ...."));
}*/
qDebug() << "not implemented yet blyat";
//todo render items to view
view->takeItem(0);
}
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 ="";
}
}

6
src/chatmodel.h

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

10
src/controller.cpp

@ -982,11 +982,17 @@ void Controller::refreshTransactions()
// Update model data, which updates the table view
transactionsTableModel->replaceData(txdata);
//chatModel->renderChatBox();
chatModel->showMessages();
chatModel->renderChatBox(ui->listChatMemo);
//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
void Controller::unlockIfEncrypted(std::function<void(void)> cb, std::function<void(void)> error)
{

1
src/controller.h

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

7
src/mainwindow.cpp

@ -900,7 +900,6 @@ void MainWindow::setupTransactionsTab() {
// Set up context menu on transactions tab
ui->transactionsTable->setContextMenuPolicy(Qt::CustomContextMenu);
// Table right click
QObject::connect(ui->transactionsTable, &QTableView::customContextMenuRequested, [=] (QPoint 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) {
rpc->createNewZaddr(sapling, [=] (json reply) {
QString addr = QString::fromStdString(reply.get<json::array_t>()[0]);

1
src/mainwindow.h

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

2
src/mainwindow.ui

@ -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>
</property>
</widget>
<widget class="QListWidget" name="listChatWidget">
<widget class="QListWidget" name="listChatMemo">
<property name="geometry">
<rect>
<x>340</x>

Loading…
Cancel
Save