Merge pull request #1889 from PhenomRetroShare/Add_DateAndNameInCopyFromHistory

Add Date and Name in copied text from Chat History Browser.
This commit is contained in:
defnax 2020-05-07 23:30:49 +02:00 committed by GitHub
commit 0a2f2a1466
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -423,9 +423,16 @@ void ImHistoryBrowser::copyMessage()
uint32_t msgId = currentItem->data(ROLE_MSGID).toString().toInt(); uint32_t msgId = currentItem->data(ROLE_MSGID).toString().toInt();
HistoryMsg msg; HistoryMsg msg;
if (rsHistory->getMessage(msgId, 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; QTextDocument doc;
doc.setHtml(QString::fromUtf8(msg.message.c_str())); doc.setHtml(QString::fromUtf8(msg.message.c_str()));
QApplication::clipboard()->setText(doc.toPlainText()); QApplication::clipboard()->setText("> " + date.toString() + " " + name + ":" + doc.toPlainText());
} }
} }
} }