Merge pull request #3 from strider-paff-shell/chat
added Chatmessages with Timestamp
This commit is contained in:
@@ -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 ="";
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -71,6 +71,7 @@ public:
|
||||
void refreshGBPCAP();
|
||||
void refreshAUDCAP();
|
||||
|
||||
void refreshChat(QListWidget *listWidget);
|
||||
|
||||
void executeStandardUITransaction(Tx tx);
|
||||
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -85,6 +85,7 @@ private:
|
||||
|
||||
void setupSendTab();
|
||||
void setupTransactionsTab();
|
||||
void updateChat();
|
||||
void setupReceiveTab();
|
||||
void setupBalancesTab();
|
||||
void setuphushdTab();
|
||||
|
||||
@@ -1432,7 +1432,7 @@
|
||||
<string><html><head/><body><p align="center">Messages</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListWidget" name="listChatWidget">
|
||||
<widget class="QListWidget" name="listChatMemo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
|
||||
Reference in New Issue
Block a user