From 3da9eab318243145f0e3bb364c2b483601ac1407 Mon Sep 17 00:00:00 2001 From: xxxcucus Date: Sat, 10 Aug 2024 09:08:43 +0200 Subject: [PATCH] Bug fixes chat --- .../rightpane/chat/playerslistwidget.cpp | 6 +++++- .../communicationobjects/receivechatmessagescommobj.cpp | 3 +++ .../multiround/viewmodels/userwithlastloginviewmodel.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/c_plus_plus/PlanesGraphicsScene/rightpane/chat/playerslistwidget.cpp b/c_plus_plus/PlanesGraphicsScene/rightpane/chat/playerslistwidget.cpp index 31f8f739..b19c4b5e 100644 --- a/c_plus_plus/PlanesGraphicsScene/rightpane/chat/playerslistwidget.cpp +++ b/c_plus_plus/PlanesGraphicsScene/rightpane/chat/playerslistwidget.cpp @@ -87,7 +87,10 @@ void PlayersListWidget::requestChatMessages() { } void PlayersListWidget::itemDoubleClicked(QListWidgetItem* item) { - emit playerDoubleClicked(item->text()); + QString playerAndStatus = item->text(); + QStringList playerAndStatusParts = playerAndStatus.split(" ", Qt::SkipEmptyParts); + if (!playerAndStatus.isEmpty()) + emit playerDoubleClicked(playerAndStatusParts[0]); } /*void PlayersListWidget::updatePlayersList(const QStringList& players) { @@ -163,5 +166,6 @@ long int PlayersListWidget::getPlayerId(const QString& player) { return p.m_UserId; } + qDebug() << "GetPlayerId " << player << "id 0"; return 0L; } diff --git a/c_plus_plus/multiround/communicationobjects/receivechatmessagescommobj.cpp b/c_plus_plus/multiround/communicationobjects/receivechatmessagescommobj.cpp index 91788248..9fbaef23 100644 --- a/c_plus_plus/multiround/communicationobjects/receivechatmessagescommobj.cpp +++ b/c_plus_plus/multiround/communicationobjects/receivechatmessagescommobj.cpp @@ -64,8 +64,11 @@ void ReceiveChatMessagesCommObj::processResponse(const QJsonObject& retJson) { receivedMessage.m_ReceiverName = messageObject.value("receiverName").toString(); receivedMessage.m_Message = messageObject.value("message").toString(); receivedMessage.m_CreatedAt = CommunicationTools::parseDateFromString(messageObject.value("createdAt").toString()); + receivedMessages.push_back(receivedMessage); } } + + emit chatMessagesReceived(receivedMessages); } diff --git a/c_plus_plus/multiround/viewmodels/userwithlastloginviewmodel.h b/c_plus_plus/multiround/viewmodels/userwithlastloginviewmodel.h index 1ea41a77..898a9739 100644 --- a/c_plus_plus/multiround/viewmodels/userwithlastloginviewmodel.h +++ b/c_plus_plus/multiround/viewmodels/userwithlastloginviewmodel.h @@ -15,6 +15,7 @@ struct UserWithLastLoginViewModel { m_UserId = jsonObject.value("userid").toString().toLong(); QString lastLoginString = jsonObject.value("lastLogin").toString(); m_LastLogin = CommunicationTools::parseDateFromString(lastLoginString); + qDebug() << "UserwithLastLogin created " << m_UserName << " " << m_UserId; } UserWithLastLoginViewModel(const QString& username, long int userid) {