Incoming chat messages : Display avatar and author name if not grouped.

Fix author name on call events.
This commit is contained in:
Julien Wadel 2023-06-09 15:41:26 +02:00
parent c7e1720871
commit dcddaed4a7
4 changed files with 17 additions and 17 deletions

View file

@ -22,6 +22,7 @@
#include "app/App.hpp"
#include "components/core/CoreManager.hpp"
#include "utils/Utils.hpp"
#include "ChatCallModel.hpp"
@ -58,6 +59,16 @@ QSharedPointer<ChatCallModel> ChatCallModel::create(std::shared_ptr<linphone::Ca
std::shared_ptr<linphone::CallLog> ChatCallModel::getCallLog(){
return mCallLog;
}
QString ChatCallModel::getFromDisplayName(){
if(!mFromDisplayNameCache.isEmpty())
return mFromDisplayNameCache;
if(!mCallLog)
return "";
mFromDisplayNameCache = Utils::getDisplayName(mCallLog->getFromAddress());
return mFromDisplayNameCache;
}
//--------------------------------------------------------------------------------------------------------------------------
void ChatCallModel::setIsStart(const bool& data){
if(data != mIsStart) {

View file

@ -38,12 +38,14 @@ public:
Q_PROPERTY(ChatRoomModel::EntryType type MEMBER mType CONSTANT)
Q_PROPERTY(QDateTime timestamp MEMBER mTimestamp CONSTANT)
Q_PROPERTY(QDateTime receivedTimestamp MEMBER mReceivedTimestamp CONSTANT)
Q_PROPERTY(QString fromDisplayName READ getFromDisplayName CONSTANT)
Q_PROPERTY(bool isStart MEMBER mIsStart WRITE setIsStart NOTIFY isStartChanged)
Q_PROPERTY(LinphoneEnums::CallStatus status MEMBER mStatus WRITE setStatus NOTIFY statusChanged)
Q_PROPERTY(bool isOutgoing MEMBER mIsOutgoing WRITE setIsOutgoing NOTIFY isOutgoingChanged)
std::shared_ptr<linphone::CallLog> getCallLog();
QString getFromDisplayName();
void setIsStart(const bool& isStart);
void setStatus(const LinphoneEnums::CallStatus& status);
@ -63,6 +65,7 @@ signals:
private:
std::shared_ptr<linphone::CallLog> mCallLog;
QString mFromDisplayNameCache;
};
Q_DECLARE_METATYPE(QSharedPointer<ChatCallModel>)
Q_DECLARE_METATYPE(ChatCallModel*)

View file

@ -195,7 +195,7 @@ Rectangle {
Layout.rightMargin: ChatStyle.entry.message.outgoing.areaSize
spacing:0
// Display time.
visible: !entry.isTopGrouped
visible: !entry.isTopGrouped// && !entry.isNotice
Text {
id:timeDisplay
@ -216,7 +216,6 @@ Rectangle {
TooltipArea {
text: entry.chatEntry ? UtilsCpp.toDateTimeString(entry.chatEntry.timestamp) : ''
}
visible:!entry.isNotice
}
Text{
id:authorName
@ -226,14 +225,7 @@ Rectangle {
color: ChatStyle.entry.event.text.colorModel.color
font.pointSize: ChatStyle.entry.event.text.pointSize
visible: entry.isMessage
&& entry.chatEntry
&& !entry.chatEntry.isOutgoing // Only outgoing
&& (!entry.previousItem //No previous entry
|| entry.previousItem.type != ChatRoomModel.MessageEntry // Previous entry is a message
|| entry.previousItem.fromSipAddress != entry.chatEntry.fromSipAddress // Different user
|| (new Date(entry.previousItem.timestamp)).setHours(0, 0, 0, 0) != (new Date(entry.chatEntry.timestamp)).setHours(0, 0, 0, 0) // Same day == section
)
visible: entry.chatEntry && !entry.chatEntry.isOutgoing && text != ''
}
}
// Display content.

View file

@ -47,13 +47,7 @@ RowLayout {
if (index <= 0) {
return true // 1. First message, so visible.
}
var previousEntry = proxyModel.getAt(index - 1)
return !$chatEntry.isOutgoing && (// Only outgoing
!previousEntry //No previous entry
|| previousEntry.type != ChatRoomModel.MessageEntry // Previous entry is a message
|| previousEntry.fromSipAddress != $chatEntry.fromSipAddress // Different user
|| (new Date(previousEntry.timestamp)).setHours(0, 0, 0, 0) != (new Date($chatEntry.timestamp)).setHours(0, 0, 0, 0) // Same day == section
)
return !$chatEntry.isOutgoing && !mainRow.isTopGrouped
}
TooltipArea{
delay:0