mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -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;
|
QAction *sendItem = NULL;
|
||||||
if (textEdit) {
|
if (textEdit) {
|
||||||
sendItem = new QAction(tr("Send"), &contextMnu);
|
sendItem = new QAction(tr("Quote"), &contextMnu);
|
||||||
if (currentItem) {
|
if (currentItem) {
|
||||||
connect(sendItem, SIGNAL(triggered()), this, SLOT(sendMessage()));
|
connect(sendItem, SIGNAL(triggered()), this, SLOT(sendMessage()));
|
||||||
} else {
|
} else {
|
||||||
@ -427,23 +427,7 @@ void ImHistoryBrowser::customContextMenuRequested(QPoint /*pos*/)
|
|||||||
|
|
||||||
void ImHistoryBrowser::copyMessage()
|
void ImHistoryBrowser::copyMessage()
|
||||||
{
|
{
|
||||||
QListWidgetItem *currentItem = ui.listWidget->currentItem();
|
QApplication::clipboard()->setText(getCurrentItemsQuotedText());
|
||||||
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()
|
void ImHistoryBrowser::removeMessages()
|
||||||
@ -461,20 +445,37 @@ void ImHistoryBrowser::clearHistory()
|
|||||||
|
|
||||||
void ImHistoryBrowser::sendMessage()
|
void ImHistoryBrowser::sendMessage()
|
||||||
{
|
{
|
||||||
if (textEdit) {
|
if (textEdit) {
|
||||||
QListWidgetItem *currentItem = ui.listWidget->currentItem();
|
QString msg =getCurrentItemsQuotedText();
|
||||||
if (currentItem) {
|
QTextCursor cursor = textEdit->textCursor();
|
||||||
uint32_t msgId = currentItem->data(ROLE_MSGID).toString().toInt();
|
cursor.movePosition(QTextCursor::End);
|
||||||
HistoryMsg msg;
|
if (cursor.columnNumber()>0)
|
||||||
if (rsHistory->getMessage(msgId, msg)) {
|
cursor.insertText("\n");
|
||||||
textEdit->clear();
|
cursor.insertText(msg);
|
||||||
textEdit->setText(QString::fromUtf8(msg.message.c_str()));
|
textEdit->setFocus();
|
||||||
textEdit->setFocus();
|
close();
|
||||||
QTextCursor cursor = textEdit->textCursor();
|
}
|
||||||
cursor.movePosition(QTextCursor::End);
|
}
|
||||||
textEdit->setTextCursor(cursor);
|
|
||||||
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 filterItems(const QString &text, QListWidgetItem *item = NULL);
|
||||||
|
|
||||||
void getSelectedItems(std::list<uint32_t> &items);
|
void getSelectedItems(std::list<uint32_t> &items);
|
||||||
|
QString getCurrentItemsQuotedText();
|
||||||
|
|
||||||
ImHistoryBrowserCreateItemsThread *m_createThread;
|
ImHistoryBrowserCreateItemsThread *m_createThread;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user