From 36ea99da0313898ce89b05883279bf4e085a5970 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 16 Jul 2013 21:14:48 +0000 Subject: [PATCH] add date to chat msg if it is mroe than 1 day old git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6510 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/chat/ChatWidget.cpp | 10 +++++++++- retroshare-gui/src/gui/chat/ChatWidget.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index eb852ee63..8e1995b89 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -71,6 +71,7 @@ ChatWidget::ChatWidget(QWidget *parent) : firstShow = true; inChatCharFormatChanged = false; completer = NULL; + lastMsgDate = QDate::currentDate(); lastStatusSendTime = 0 ; @@ -512,6 +513,13 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime unsigned int formatTextFlag = RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_OPTIMIZE; unsigned int formatFlag = 0; + bool addDate = false; + if (QDate::currentDate()>lastMsgDate) + { + lastMsgDate=QDate::currentDate(); + addDate=true; + } + // embed smileys ? if (Settings->valueFromGroup(QString("Chat"), QString::fromUtf8("Emoteicons_PrivatChat"), true).toBool()) { formatTextFlag |= RSHTML_FORMATTEXT_EMBED_SMILEYS; @@ -541,7 +549,7 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime type = ChatStyle::FORMATMSG_OOUTGOING; } else if (chatType == TYPE_SYSTEM) { type = ChatStyle::FORMATMSG_SYSTEM; - } else if (chatType == TYPE_HISTORY) { + } else if (chatType == TYPE_HISTORY || addDate) { type = incoming ? ChatStyle::FORMATMSG_HINCOMING : ChatStyle::FORMATMSG_HOUTGOING; } else { type = incoming ? ChatStyle::FORMATMSG_INCOMING : ChatStyle::FORMATMSG_OUTGOING; diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index a0b4543e8..973cbc4eb 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -164,6 +164,7 @@ private: bool inChatCharFormatChanged; TransferRequestFlags mDefaultExtraFileFlags ; // flags for extra files shared in this chat. Will be 0 by default, but might be ANONYMOUS for chat lobbies. + QDate lastMsgDate ; QCompleter *completer;