mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 16:39:29 -05:00
Fix ImHistoryBrowser Send Action
This commit is contained in:
parent
67d1265eb2
commit
7f13505c54
@ -392,7 +392,7 @@ void ImHistoryBrowser::customContextMenuRequested(QPoint /*pos*/)
|
||||
|
||||
QAction *sendItem = NULL;
|
||||
if (textEdit) {
|
||||
sendItem = new QAction(tr("Send"), &contextMnu);
|
||||
sendItem = new QAction(tr("Quote"), &contextMnu);
|
||||
if (currentItem) {
|
||||
connect(sendItem, SIGNAL(triggered()), this, SLOT(sendMessage()));
|
||||
} else {
|
||||
@ -427,23 +427,7 @@ 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)) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
QApplication::clipboard()->setText(getCurrentItemsQuotedText());
|
||||
}
|
||||
|
||||
void ImHistoryBrowser::removeMessages()
|
||||
@ -461,20 +445,37 @@ void ImHistoryBrowser::clearHistory()
|
||||
|
||||
void ImHistoryBrowser::sendMessage()
|
||||
{
|
||||
if (textEdit) {
|
||||
QListWidgetItem *currentItem = ui.listWidget->currentItem();
|
||||
if (currentItem) {
|
||||
uint32_t msgId = currentItem->data(ROLE_MSGID).toString().toInt();
|
||||
HistoryMsg msg;
|
||||
if (rsHistory->getMessage(msgId, msg)) {
|
||||
textEdit->clear();
|
||||
textEdit->setText(QString::fromUtf8(msg.message.c_str()));
|
||||
textEdit->setFocus();
|
||||
QTextCursor cursor = textEdit->textCursor();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
textEdit->setTextCursor(cursor);
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (textEdit) {
|
||||
QString msg =getCurrentItemsQuotedText();
|
||||
QTextCursor cursor = textEdit->textCursor();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
if (cursor.columnNumber()>0)
|
||||
cursor.insertText("\n");
|
||||
cursor.insertText(msg);
|
||||
textEdit->setFocus();
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
QString ImHistoryBrowser::getCurrentItemsQuotedText()
|
||||
{
|
||||
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()));
|
||||
|
||||
return "> " + date.toString() + " " + name + ":" + doc.toPlainText().replace("\n","\n> ");
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ private:
|
||||
void filterItems(const QString &text, QListWidgetItem *item = NULL);
|
||||
|
||||
void getSelectedItems(std::list<uint32_t> &items);
|
||||
QString getCurrentItemsQuotedText();
|
||||
|
||||
ImHistoryBrowserCreateItemsThread *m_createThread;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user