mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Add GXS Id in anchor in Chat.
This commit is contained in:
parent
eefc8d3393
commit
6df42a0b7d
@ -370,7 +370,7 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg)
|
|||||||
else
|
else
|
||||||
name = QString::fromUtf8(msg.peer_alternate_nickname.c_str()) + " (" + QString::fromStdString(gxs_id.toStdString()) + ")" ;
|
name = QString::fromUtf8(msg.peer_alternate_nickname.c_str()) + " (" + QString::fromStdString(gxs_id.toStdString()) + ")" ;
|
||||||
|
|
||||||
ui.chatWidget->addChatMsg(msg.incoming, name, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL);
|
ui.chatWidget->addChatMsg(msg.incoming, name, gxs_id, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL);
|
||||||
emit messageReceived(msg.incoming, id(), sendTime, name, message) ;
|
emit messageReceived(msg.incoming, id(), sendTime, name, message) ;
|
||||||
|
|
||||||
// This is a trick to translate HTML into text.
|
// This is a trick to translate HTML into text.
|
||||||
|
@ -351,9 +351,12 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co
|
|||||||
Q_UNUSED(flag);
|
Q_UNUSED(flag);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QString formatMsg = style.replace("%name%", RsHtml::plainText(name))
|
QString strName = RsHtml::plainText(name).prepend(QString("<a name=\"name\">")).append(QString("</a>"));
|
||||||
.replace("%date%", DateTime::formatDate(timestamp.date()))
|
QString strDate = DateTime::formatDate(timestamp.date()).prepend(QString("<a name=\"date\">")).append(QString("</a>"));
|
||||||
.replace("%time%", DateTime::formatTime(timestamp.time()))
|
QString strTime = DateTime::formatTime(timestamp.time()).prepend(QString("<a name=\"time\">")).append(QString("</a>"));
|
||||||
|
QString formatMsg = style.replace("%name%", strName)
|
||||||
|
.replace("%date%", strDate)
|
||||||
|
.replace("%time%", strTime)
|
||||||
#ifdef COLORED_NICKNAMES
|
#ifdef COLORED_NICKNAMES
|
||||||
.replace("%color%", color.name())
|
.replace("%color%", color.name())
|
||||||
#endif
|
#endif
|
||||||
|
@ -845,6 +845,13 @@ void ChatWidget::setWelcomeMessage(QString &text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType)
|
void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType)
|
||||||
|
{
|
||||||
|
addChatMsg(incoming, name, RsGxsId(), sendTime, recvTime, message, chatType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatWidget::addChatMsg(bool incoming, const QString &name, const RsGxsId gxsId
|
||||||
|
, const QDateTime &sendTime, const QDateTime &recvTime
|
||||||
|
, const QString &message, MsgType chatType)
|
||||||
{
|
{
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cout << "ChatWidget::addChatMsg message : " << message.toStdString() << std::endl;
|
std::cout << "ChatWidget::addChatMsg message : " << message.toStdString() << std::endl;
|
||||||
@ -905,8 +912,15 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime
|
|||||||
QString formatMsg = chatStyle.formatMessage(type, name, dtTimestamp, formattedMessage, formatFlag);
|
QString formatMsg = chatStyle.formatMessage(type, name, dtTimestamp, formattedMessage, formatFlag);
|
||||||
QString timeStamp = dtTimestamp.toString(Qt::ISODate);
|
QString timeStamp = dtTimestamp.toString(Qt::ISODate);
|
||||||
|
|
||||||
formatMsg.prepend(QString("<a name=\"%1\"/>").arg(timeStamp));
|
//replace Date and Time anchors
|
||||||
//To call this anchor do: ui->textBrowser->scrollToAnchor(QString("%1_%2").arg(timeStamp).arg(name));
|
formatMsg.replace(QString("<a name=\"date\">"),QString("<a name=\"%1\">").arg(timeStamp));
|
||||||
|
formatMsg.replace(QString("<a name=\"time\">"),QString("<a name=\"%1\">").arg(timeStamp));
|
||||||
|
//replace Name anchors with GXS Id
|
||||||
|
QString strGxsId = "";
|
||||||
|
if (!gxsId.isNull())
|
||||||
|
strGxsId = QString::fromStdString(gxsId.toStdString());
|
||||||
|
formatMsg.replace(QString("<a name=\"name\">"),QString("<a name=\"%1\">").arg(strGxsId));
|
||||||
|
|
||||||
QTextCursor textCursor = QTextCursor(ui->textBrowser->textCursor());
|
QTextCursor textCursor = QTextCursor(ui->textBrowser->textCursor());
|
||||||
textCursor.movePosition(QTextCursor::End);
|
textCursor.movePosition(QTextCursor::End);
|
||||||
textCursor.setBlockFormat(QTextBlockFormat ());
|
textCursor.setBlockFormat(QTextBlockFormat ());
|
||||||
|
@ -94,6 +94,7 @@ public:
|
|||||||
|
|
||||||
void setWelcomeMessage(QString &text);
|
void setWelcomeMessage(QString &text);
|
||||||
void addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType);
|
void addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType);
|
||||||
|
void addChatMsg(bool incoming, const QString &name, const RsGxsId gxsId, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType);
|
||||||
void updateStatusString(const QString &statusMask, const QString &statusString, bool permanent = false);
|
void updateStatusString(const QString &statusMask, const QString &statusString, bool permanent = false);
|
||||||
|
|
||||||
void addToolsAction(QAction *action);
|
void addToolsAction(QAction *action);
|
||||||
|
Loading…
Reference in New Issue
Block a user