From 9857f5b60b60d64214921885f6c449b31e7d54c0 Mon Sep 17 00:00:00 2001 From: PKEv Date: Thu, 26 Mar 2015 00:31:39 +0300 Subject: [PATCH] #1402 duplicate of the sender's name set if interval more 5 minuts, sender name repet not tested for group chats!!! --- src/chatlog/chatlog.h | 4 ++++ src/widget/form/chatform.cpp | 3 ++- src/widget/form/genericchatform.cpp | 8 ++++++-- src/widget/form/genericchatform.h | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/chatlog/chatlog.h b/src/chatlog/chatlog.h index ec7cf5ecd..fdc4a8436 100644 --- a/src/chatlog/chatlog.h +++ b/src/chatlog/chatlog.h @@ -58,6 +58,8 @@ public: ChatLine::Ptr getTypingNotification() const; QVector getLines(); + // repetition interval sender name (sec) + const uint repNameAfter = 5*60; signals: void selectionChanged(); @@ -142,6 +144,8 @@ private: QMargins margins = QMargins(10,10,10,10); qreal lineSpacing = 5.0f; + + }; #endif // CHATLOG_H diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 14388f735..5626e27c9 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -843,10 +843,11 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered) authorId.isMine(), QDateTime()); - if(!isAction && prevId == authorId) + if(!isAction && (prevId == authorId) && (prevMsgDateTime.secsTo(msgDateTime) < getChatLog()->repNameAfter) ) msg->hideSender(); prevId = authorId; + prevMsgDateTime = msgDateTime; if (it.isSent || !authorId.isMine()) { diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index 760c028e4..d594f1462 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -233,10 +233,11 @@ ChatMessage::Ptr GenericChatForm::addMessage(const ToxID& author, const QString else { msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::NORMAL, author.isMine()); - if(author == previousId) + if ( (author == previousId) && (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < getChatLog()->repNameAfter) ) msg->hideSender(); previousId = author; + prevMsgDateTime = QDateTime::currentDateTime(); } insertChatMessage(msg); @@ -258,10 +259,11 @@ void GenericChatForm::addAlertMessage(const ToxID &author, QString message, QDat ChatMessage::Ptr msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::ALERT, author.isMine(), datetime); insertChatMessage(msg); - if(author == previousId) + if( (author == previousId) && (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < getChatLog()->repNameAfter) ) msg->hideSender(); previousId = author; + prevMsgDateTime = QDateTime::currentDateTime(); } void GenericChatForm::onEmoteButtonClicked() @@ -382,3 +384,5 @@ void GenericChatForm::insertChatMessage(ChatMessage::Ptr msg) { chatWidget->insertChatlineAtBottom(std::dynamic_pointer_cast(msg)); } + + diff --git a/src/widget/form/genericchatform.h b/src/widget/form/genericchatform.h index 499daee3b..f5a0a17da 100644 --- a/src/widget/form/genericchatform.h +++ b/src/widget/form/genericchatform.h @@ -84,6 +84,7 @@ protected: void insertChatMessage(ChatMessage::Ptr msg); ToxID previousId; + QDateTime prevMsgDateTime; Widget *parent; QMenu menu; int curRow;