From bbeefda932c08bc46b1c96f728bd4d41f2588e5f Mon Sep 17 00:00:00 2001 From: Phenom Date: Wed, 29 Apr 2020 14:48:39 +0200 Subject: [PATCH] Add Date and Name in copied text from Chat History Browser. --- .../src/gui/im_history/ImHistoryBrowser.cpp | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp index 4615c06e4..9adcd3d22 100644 --- a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp +++ b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp @@ -418,16 +418,23 @@ void ImHistoryBrowser::customContextMenuRequested(QPoint /*pos*/) void ImHistoryBrowser::copyMessage() { - QListWidgetItem *currentItem = ui.listWidget->currentItem(); - if (currentItem) { - uint32_t msgId = currentItem->data(ROLE_MSGID).toString().toInt(); - HistoryMsg msg; - if (rsHistory->getMessage(msgId, msg)) { - QTextDocument doc; - doc.setHtml(QString::fromUtf8(msg.message.c_str())); - QApplication::clipboard()->setText(doc.toPlainText()); - } - } + QListWidgetItem *currentItem = ui.listWidget->currentItem(); + if (currentItem) { + uint32_t msgId = currentItem->data(ROLE_MSGID).toString().toInt(); + HistoryMsg msg; + if (rsHistory->getMessage(msgId, msg)) { + RsIdentityDetails details; + QString name = (rsIdentity->getIdDetails(RsGxsId(msg.peerName), details)) + ? QString::fromUtf8(details.mNickname.c_str()) + : QString::fromUtf8(msg.peerName.c_str()); + QDateTime date = msg.incoming + ? QDateTime::fromTime_t(msg.sendTime) + : QDateTime::fromTime_t(msg.recvTime); + QTextDocument doc; + doc.setHtml(QString::fromUtf8(msg.message.c_str())); + QApplication::clipboard()->setText("> " + date.toString() + " " + name + ":" + doc.toPlainText()); + } + } } void ImHistoryBrowser::removeMessages()