Optimizations:

- Caching of displayname computation.
- Optimize call logs access when building timelines.
- Avoid building QTextSpeech if not needed.
- Avoid loading emojis of picker on chat creation. Load them only on demand.
This commit is contained in:
Julien Wadel 2023-06-09 11:53:49 +02:00
parent 058d56ab29
commit eafb33e6b8
16 changed files with 159 additions and 92 deletions

View file

@ -116,14 +116,24 @@ QSharedPointer<ContentModel> ChatMessageModel::getContentModel(std::shared_ptr<l
//-----------------------------------------------------------------------------------------------------------------------
QString ChatMessageModel::getFromDisplayName() const{
return mChatMessage ? Utils::getDisplayName(mChatMessage->getFromAddress()) : "";
QString ChatMessageModel::getFromDisplayName(){
if(!mFromDisplayNameCache.isEmpty())
return mFromDisplayNameCache;
if(!mChatMessage)
return "";
mFromDisplayNameCache = Utils::getDisplayName(mChatMessage->getFromAddress());
return mFromDisplayNameCache;
}
QString ChatMessageModel::getFromDisplayNameReplyMessage() const{
if( isReply())
return Utils::getDisplayName(mChatMessage->getReplyMessageSenderAddress());
else
QString ChatMessageModel::getFromDisplayNameReplyMessage(){
if( isReply()){
if(!fromDisplayNameReplyMessage.isEmpty())
return fromDisplayNameReplyMessage;
if(!mChatMessage)
return "";
fromDisplayNameReplyMessage = Utils::getDisplayName(mChatMessage->getReplyMessageSenderAddress());
return fromDisplayNameReplyMessage;
}else
return "";
}

View file

@ -79,8 +79,8 @@ public:
//----------------------------------------------------------------------------
QString getFromDisplayName() const;
QString getFromDisplayNameReplyMessage() const;
QString getFromDisplayName();
QString getFromDisplayNameReplyMessage();
QString getFromSipAddress() const;
QString getToDisplayName() const;
QString getToSipAddress() const;
@ -152,6 +152,9 @@ private:
QSharedPointer<ContentModel> mFileTransfertContent;
QSharedPointer<ParticipantImdnStateListModel> mParticipantImdnStateListModel;
QSharedPointer<ChatMessageModel> mReplyChatMessageModel;
QString mFromDisplayNameCache;
QString fromDisplayNameReplyMessage;
};
Q_DECLARE_METATYPE(ChatMessageModel*)
Q_DECLARE_METATYPE(QSharedPointer<ChatMessageModel>)

View file

@ -103,8 +103,8 @@ void ChatRoomModel::connectTo(ChatRoomListener * listener){
}
// -----------------------------------------------------------------------------
QSharedPointer<ChatRoomModel> ChatRoomModel::create(const std::shared_ptr<linphone::ChatRoom>& chatRoom, const std::list<std::shared_ptr<linphone::CallLog>>& callLogs){
QSharedPointer<ChatRoomModel> model = QSharedPointer<ChatRoomModel>::create(chatRoom, callLogs);
QSharedPointer<ChatRoomModel> ChatRoomModel::create(const std::shared_ptr<linphone::ChatRoom>& chatRoom, const QMap<QString,QMap<QString, std::shared_ptr<linphone::CallLog>>>& lastCalls){
QSharedPointer<ChatRoomModel> model = QSharedPointer<ChatRoomModel>::create(chatRoom, lastCalls);
if(model){
model->mSelf = model;
//chatRoom->addListener(model);
@ -113,7 +113,7 @@ QSharedPointer<ChatRoomModel> ChatRoomModel::create(const std::shared_ptr<linpho
return nullptr;
}
ChatRoomModel::ChatRoomModel (const std::shared_ptr<linphone::ChatRoom>& chatRoom, const std::list<std::shared_ptr<linphone::CallLog>>& callLogs, QObject * parent) : ProxyListModel(parent){
ChatRoomModel::ChatRoomModel (const std::shared_ptr<linphone::ChatRoom>& chatRoom, const QMap<QString,QMap<QString, std::shared_ptr<linphone::CallLog>>>& lastCalls, QObject * parent) : ProxyListModel(parent){
App::getInstance()->getEngine()->setObjectOwnership(this, QQmlEngine::CppOwnership);// Avoid QML to destroy it when passing by Q_INVOKABLE
CoreManager *coreManager = CoreManager::getInstance();
mCoreHandlers = coreManager->getHandlers();
@ -157,34 +157,23 @@ ChatRoomModel::ChatRoomModel (const std::shared_ptr<linphone::ChatRoom>& chatRoo
connect(contact.get(), &ContactModel::contactUpdated, this, &ChatRoomModel::fullPeerAddressChanged);
}
}
std::shared_ptr<linphone::CallLog> lastCall = nullptr;
QString peerAddress = getParticipantAddress();
std::shared_ptr<const linphone::Address> lLocalAddress = mChatRoom->getLocalAddress();
QString localAddress = Utils::coreStringToAppString(lLocalAddress->asStringUriOnly());
if(callLogs.size() == 0) {
auto callHistory = CallsListModel::getCallHistory(peerAddress, localAddress);
if(callHistory.size() > 0)
lastCall = callHistory.front();
}else{// Find the last call in list
std::shared_ptr<linphone::Address> lPeerAddress = Utils::interpretUrl(peerAddress);
if( lPeerAddress && lLocalAddress){
auto itCallLog = std::find_if(callLogs.begin(), callLogs.end(), [lPeerAddress, lLocalAddress](std::shared_ptr<linphone::CallLog> c){
return c->getLocalAddress()->weakEqual(lLocalAddress) && c->getRemoteAddress()->weakEqual(lPeerAddress);
});
if( itCallLog != callLogs.end())
lastCall = *itCallLog;
time_t callDate = 0;
if(lastCalls.size() > 0){
QString peerAddress = getParticipantAddress();
QString localAddress = Utils::coreStringToAppString(mChatRoom->getLocalAddress()->asStringUriOnly());
auto itLocal = lastCalls.find(localAddress);
if(itLocal != lastCalls.end()){
auto itPeer = itLocal->find(peerAddress);
if(itPeer != itLocal->end()) {
callDate = itPeer.value()->getStartDate();
if( itPeer.value()->getStatus() == linphone::Call::Status::Success )
callDate += itPeer.value()->getDuration();
}
}
}
if(lastCall){
auto callDate = lastCall->getStartDate();
if( lastCall->getStatus() == linphone::Call::Status::Success )
callDate += lastCall->getDuration();
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(std::max(mChatRoom->getLastUpdateTime(), callDate )*1000));
}else
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(mChatRoom->getLastUpdateTime()*1000));
setLastUpdateTime(QDateTime::fromMSecsSinceEpoch(std::max(mChatRoom->getLastUpdateTime(), callDate )*1000));
}else
mParticipantListModel = nullptr;
}
@ -986,7 +975,7 @@ void ChatRoomModel::initEntries(){
if( e->mType == ChatRoomModel::EntryType::MessageEntry){
connect(e.objectCast<ChatMessageModel>().get(), &ChatMessageModel::remove, this, &ChatRoomModel::removeEntry);
auto model = e.objectCast<ChatMessageModel>().get();
qDebug() << "Adding" << model->getReceivedTimestamp().toString("yyyy/MM/dd hh:mm:ss.zzz") << model->getTimestamp().toString("yyyy/MM/dd hh:mm:ss.zzz") << QString(model->getChatMessage()->getUtf8Text().c_str()).left(5);
qDebug() << "Adding" << model->getReceivedTimestamp().toString("yyyy/MM/dd hh:mm:ss.zzz") << model->getTimestamp().toString("yyyy/MM/dd hh:mm:ss.zzz") << (CoreManager::getInstance()->getSettingsModel()->isDeveloperSettingsAvailable() ? QString(model->getChatMessage()->getUtf8Text().c_str()).left(5) : "");
}
mList.push_back(e);
}

View file

@ -98,8 +98,8 @@ public:
Q_PROPERTY(bool entriesLoading READ isEntriesLoading WRITE setEntriesLoading NOTIFY entriesLoadingChanged)
static QSharedPointer<ChatRoomModel> create(const std::shared_ptr<linphone::ChatRoom>& chatRoom, const std::list<std::shared_ptr<linphone::CallLog>>& callLogs = std::list<std::shared_ptr<linphone::CallLog>>());
ChatRoomModel (const std::shared_ptr<linphone::ChatRoom>& chatRoom, const std::list<std::shared_ptr<linphone::CallLog>>& callLogs = std::list<std::shared_ptr<linphone::CallLog>>(), QObject * parent = nullptr);
static QSharedPointer<ChatRoomModel> create(const std::shared_ptr<linphone::ChatRoom>& chatRoom, const QMap<QString,QMap<QString, std::shared_ptr<linphone::CallLog>>>& lastCalls = QMap<QString,QMap<QString, std::shared_ptr<linphone::CallLog>>>());
ChatRoomModel (const std::shared_ptr<linphone::ChatRoom>& chatRoom, const QMap<QString,QMap<QString, std::shared_ptr<linphone::CallLog>>>& lastCalls = QMap<QString,QMap<QString, std::shared_ptr<linphone::CallLog>>>(), QObject * parent = nullptr);
~ChatRoomModel ();

View file

@ -25,6 +25,7 @@
#include "components/contact/VcardModel.hpp"
#include "components/core/CoreManager.hpp"
#include "components/friend/FriendListListener.hpp"
#include "utils/Utils.hpp"
#include "ContactsListModel.hpp"
@ -69,7 +70,9 @@ bool ContactsListModel::removeRows (int row, int count, const QModelIndex &paren
for (int i = 0; i < count; ++i) {
QSharedPointer<ContactModel> contact = mList.takeAt(row).objectCast<ContactModel>();
for(auto address : contact->getVcardModel()->getSipAddresses()){
mOptimizedSearch.remove(address.toString());
auto addressStr = address.toString();
mOptimizedSearch.remove(addressStr);
mDisplayNameCache.remove(addressStr);
}
for(auto l : friendsList)
@ -86,8 +89,9 @@ bool ContactsListModel::removeRows (int row, int count, const QModelIndex &paren
// -----------------------------------------------------------------------------
QSharedPointer<ContactModel> ContactsListModel::findContactModelFromSipAddress (const QString &sipAddress) const {
if(mOptimizedSearch.contains(sipAddress))
return mOptimizedSearch[sipAddress];
auto result = mOptimizedSearch.find(sipAddress);
if(result != mOptimizedSearch.end())
return result.value();
else
return nullptr;
}
@ -170,17 +174,32 @@ void ContactsListModel::addContact (QSharedPointer<ContactModel> contact) {
});
QObject::connect(contact.get(), &ContactModel::sipAddressAdded, this, [this, contact](const QString &sipAddress) {
mOptimizedSearch[sipAddress] = contact;
mDisplayNameCache.remove(sipAddress);
emit sipAddressAdded(contact, sipAddress);
});
QObject::connect(contact.get(), &ContactModel::sipAddressRemoved, this, [this, contact](const QString &sipAddress) {
mOptimizedSearch.remove(sipAddress);
mDisplayNameCache.remove(sipAddress);
emit sipAddressRemoved(contact, sipAddress);
});
add<ContactModel>(contact);
for(auto address : contact->getVcardModel()->getSipAddresses()){
mOptimizedSearch[address.toString()] = contact;
auto addressStr = address.toString();
mOptimizedSearch[addressStr] = contact;
mDisplayNameCache.remove(addressStr);
}
}
QString ContactsListModel::findDisplayNameFromCache(const QString& address) const{
auto cached = mDisplayNameCache.find(address);
if(cached != mDisplayNameCache.end())
return cached.value();
else
return "";
}
void ContactsListModel::addDisplayNameToCache(const QString& address, const QString& displayName){
mDisplayNameCache[address] = displayName;
}
void ContactsListModel::update(){
beginResetModel();

View file

@ -48,11 +48,14 @@ public:
QSharedPointer<ContactModel> findContactModelFromSipAddress (const QString &sipAddress) const;
QSharedPointer<ContactModel> findContactModelFromUsername (const QString &username) const;
QString findDisplayNameFromCache(const QString& address)const;
Q_INVOKABLE ContactModel *getContactModelFromAddress (const QString& address) const;
Q_INVOKABLE ContactModel *addContact (VcardModel *vcardModel);
Q_INVOKABLE void removeContact (ContactModel *contact);
void addDisplayNameToCache(const QString& address, const QString& displayName);
Q_INVOKABLE void cleanAvatars ();
Q_INVOKABLE void update ();
@ -79,6 +82,8 @@ private:
QMap<QString, QSharedPointer<ContactModel>> mOptimizedSearch;
std::list<std::shared_ptr<linphone::FriendList>> mLinphoneFriends;
std::shared_ptr<FriendListListener> mFriendListListener;
QMap<QString, QString> mDisplayNameCache;
};
#endif // CONTACTS_LIST_MODEL_H_

View file

@ -31,14 +31,19 @@
#ifdef TEXTTOSPEECH_ENABLED
TextToSpeech::TextToSpeech (QObject *parent) : QObject(parent) {
mQtTextToSpeech = new QTextToSpeech(this);
connect(mQtTextToSpeech, &QTextToSpeech::stateChanged, this, &TextToSpeech::onStateChanged);
}
TextToSpeech::~TextToSpeech(){
mQtTextToSpeech->deleteLater();
if(mQtTextToSpeech)
mQtTextToSpeech->deleteLater();
}
void TextToSpeech::say (const QString &text) {
if(!mQtTextToSpeech){
mQtTextToSpeech = new QTextToSpeech(this);
connect(mQtTextToSpeech, &QTextToSpeech::stateChanged, this, &TextToSpeech::onStateChanged);
}
if(mQtTextToSpeech->volume() == 0.0)
mQtTextToSpeech->setVolume(1.0);
QStringList names;

View file

@ -137,7 +137,7 @@ QSharedPointer<TimelineModel> TimelineListModel::getTimeline(std::shared_ptr<lin
return timeline;
}
}
if(create){
if(create){
QSharedPointer<TimelineModel> model = TimelineModel::create(this, chatRoom);
if(model){
connect(model.get(), SIGNAL(selectedChanged(bool)), this, SLOT(onSelectedHasChanged(bool)));
@ -294,18 +294,32 @@ void TimelineListModel::updateTimelines () {
// Add new.
// Call logs optimization : store all the list and check on it for each chat room instead of loading call logs on each chat room. See TimelineModel()
std::list<std::shared_ptr<linphone::CallLog>> callLogs = coreManager->getCore()->getCallLogs();
//
QList<QSharedPointer<TimelineModel>> models;
QMap<QString,QMap<QString, std::shared_ptr<linphone::CallLog>>> optimizedCallLogs;
for(auto callLog : callLogs){
QString localAddress = Utils::coreStringToAppString(callLog->getLocalAddress()->asStringUriOnly());
QString peerAddress = Utils::coreStringToAppString(callLog->getRemoteAddress()->asStringUriOnly());
auto itLocal = optimizedCallLogs.find(localAddress);
if(itLocal == optimizedCallLogs.end()){
optimizedCallLogs[localAddress][peerAddress] = callLog;
}else{
auto itPeer = itLocal->find(peerAddress);
if(itPeer == itLocal->end())
optimizedCallLogs[localAddress][peerAddress] = callLog;
}
}
for(auto dbChatRoom : allChatRooms){
auto haveTimeline = getTimeline(dbChatRoom, false);
if(!haveTimeline && dbChatRoom){// Create a new Timeline if needed
QSharedPointer<TimelineModel> model = TimelineModel::create(this, dbChatRoom, callLogs);
QSharedPointer<TimelineModel> model = TimelineModel::create(this, dbChatRoom, optimizedCallLogs);
if( model){
connect(model.get(), SIGNAL(selectedChanged(bool)), this, SLOT(onSelectedHasChanged(bool)));
add(model);
models << model;
}
}
}
add(models);
CoreManager::getInstance()->updateUnreadMessageCount();
}
@ -318,6 +332,17 @@ void TimelineListModel::add (QSharedPointer<TimelineModel> timeline){
emit countChanged();
}
void TimelineListModel::add (QList<QSharedPointer<TimelineModel>> timelines){
for(auto timeline : timelines){
auto chatRoomModel = timeline->getChatRoomModel();
auto chatRoom = chatRoomModel->getChatRoom();
connect(timeline.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onChatRoomDeleted);
connect(chatRoomModel, &ChatRoomModel::lastUpdateTimeChanged, this, &TimelineListModel::updated);
}
ProxyListModel::add(timelines);
emit countChanged();
}
void TimelineListModel::removeChatRoomModel(QSharedPointer<ChatRoomModel> model){
if(!model || (model->getChatRoom()->isEmpty() && (model->isReadOnly() || !model->isGroupEnabled()))){
auto itTimeline = mList.begin();

View file

@ -51,6 +51,7 @@ public:
QSharedPointer<ChatRoomModel> getChatRoomModel(ChatRoomModel * chatRoom);
void add (QSharedPointer<TimelineModel> timeline); // Use to add a timeline that is not in Linphone list (like empty chat rooms that were hide by configuration)
void add (QList<QSharedPointer<TimelineModel>> timelines);
Q_INVOKABLE void select(ChatRoomModel * chatRoomModel);
void setSelectedCount(int selectedCount);

View file

@ -66,9 +66,9 @@ void TimelineModel::connectTo(ChatRoomListener * listener){
}
// =============================================================================
QSharedPointer<TimelineModel> TimelineModel::create(TimelineListModel * mainList, std::shared_ptr<linphone::ChatRoom> chatRoom, const std::list<std::shared_ptr<linphone::CallLog>>& callLogs, QObject *parent){
QSharedPointer<TimelineModel> TimelineModel::create(TimelineListModel * mainList, std::shared_ptr<linphone::ChatRoom> chatRoom, const QMap<QString,QMap<QString, std::shared_ptr<linphone::CallLog>>>& lastCalls, QObject *parent){
if((!chatRoom || chatRoom->getState() != linphone::ChatRoom::State::Deleted) && (!mainList || !mainList->getTimeline(chatRoom, false)) ) {
QSharedPointer<TimelineModel> model = QSharedPointer<TimelineModel>::create(chatRoom,callLogs, parent);
QSharedPointer<TimelineModel> model = QSharedPointer<TimelineModel>::create(chatRoom,lastCalls, parent);
if(model && model->getChatRoomModel()){
return model;
}
@ -77,11 +77,11 @@ QSharedPointer<TimelineModel> TimelineModel::create(TimelineListModel * mainList
}
TimelineModel::TimelineModel (std::shared_ptr<linphone::ChatRoom> chatRoom, QObject *parent) : QObject(parent) {
TimelineModel(chatRoom, std::list<std::shared_ptr<linphone::CallLog>>(), parent);
TimelineModel(chatRoom, QMap<QString,QMap<QString, std::shared_ptr<linphone::CallLog>>>(), parent);
}
TimelineModel::TimelineModel (std::shared_ptr<linphone::ChatRoom> chatRoom, const std::list<std::shared_ptr<linphone::CallLog>>& callLogs, QObject *parent) : QObject(parent) {
TimelineModel::TimelineModel (std::shared_ptr<linphone::ChatRoom> chatRoom, const QMap<QString,QMap<QString, std::shared_ptr<linphone::CallLog>>>& lastCalls, QObject *parent) : QObject(parent) {
App::getInstance()->getEngine()->setObjectOwnership(this, QQmlEngine::CppOwnership);// Avoid QML to destroy it when passing by Q_INVOKABLE
mChatRoomModel = ChatRoomModel::create(chatRoom, callLogs);
mChatRoomModel = ChatRoomModel::create(chatRoom, lastCalls);
if( mChatRoomModel ){
CoreManager::getInstance()->handleChatRoomCreated(mChatRoomModel);
QObject::connect(this, &TimelineModel::selectedChanged, this, &TimelineModel::updateUnreadCount);
@ -168,6 +168,8 @@ void TimelineModel::setSelected(const bool& selected){
<< ", canHandleParticipants:"<< mChatRoomModel->canHandleParticipants()
<< ", isReadOnly:" << mChatRoomModel->isReadOnly()
<< ", state:" << mChatRoomModel->getState();
}else{
qInfo() << "Unselect "<< mChatRoomModel->getSubject();
}
emit selectedChanged(mSelected);
}
@ -254,4 +256,4 @@ void TimelineModel::onChatRoomStateChanged(){
mDelaySelection = false;
setSelected(true);
}
}
}

View file

@ -26,6 +26,7 @@
#include <QObject>
#include <QDateTime>
#include <QSharedPointer>
#include <QMap>
#include <linphone++/chat_room.hh>
@ -39,9 +40,9 @@ class TimelineModel : public QObject {
Q_OBJECT
public:
static QSharedPointer<TimelineModel> create(TimelineListModel * mainList, std::shared_ptr<linphone::ChatRoom> chatRoom, const std::list<std::shared_ptr<linphone::CallLog>>& callLogs = std::list<std::shared_ptr<linphone::CallLog>>(), QObject *parent = Q_NULLPTR);
static QSharedPointer<TimelineModel> create(TimelineListModel * mainList, std::shared_ptr<linphone::ChatRoom> chatRoom, const QMap<QString,QMap<QString, std::shared_ptr<linphone::CallLog>>>& lastCalls = QMap<QString,QMap<QString, std::shared_ptr<linphone::CallLog>>>(), QObject *parent = Q_NULLPTR);
TimelineModel (std::shared_ptr<linphone::ChatRoom> chatRoom, QObject *parent = Q_NULLPTR);
TimelineModel (std::shared_ptr<linphone::ChatRoom> chatRoom, const std::list<std::shared_ptr<linphone::CallLog>>& callLogs, QObject *parent = Q_NULLPTR);
TimelineModel (std::shared_ptr<linphone::ChatRoom> chatRoom, const QMap<QString,QMap<QString, std::shared_ptr<linphone::CallLog>>>& lastCalls, QObject *parent = Q_NULLPTR);
TimelineModel(const TimelineModel * model);
virtual ~TimelineModel();

View file

@ -545,37 +545,42 @@ QString Utils::getDisplayName(const std::shared_ptr<const linphone::Address>& ad
std::shared_ptr<linphone::Address> cleanAddress = address->clone();
cleanAddress->clean();
QString qtAddress = Utils::coreStringToAppString(cleanAddress->asStringUriOnly());
auto model = CoreManager::getInstance()->getContactsListModel()->findContactModelFromSipAddress(qtAddress);
if(model && model->getVcardModel())
displayName = model->getVcardModel()->getUsername();
else{
// Try to get display from full address
displayName = QString::fromStdString(address->getDisplayName());
if( displayName == ""){
// Try to get display name from proxies
auto accounts = CoreManager::getInstance()->getCore()->getAccountList();
for(auto accountIt = accounts.begin() ; displayName=="" && accountIt != accounts.end() ; ++accountIt){
auto params = accountIt->get()->getParams();
if(params){
auto accountAddress = params->getIdentityAddress();
if(accountAddress && accountAddress->weakEqual(address)){
displayName = Utils::coreStringToAppString(accountAddress->getDisplayName());
displayName = CoreManager::getInstance()->getContactsListModel()->findDisplayNameFromCache(qtAddress);
if(displayName.isEmpty()){
auto model = CoreManager::getInstance()->getContactsListModel()->findContactModelFromSipAddress(qtAddress);
if(model && model->getVcardModel())
displayName = model->getVcardModel()->getUsername();
else{
// Try to get display from full address
displayName = QString::fromStdString(address->getDisplayName());
if( displayName == ""){
// Try to get display name from proxies
auto accounts = CoreManager::getInstance()->getCore()->getAccountList();
for(auto accountIt = accounts.begin() ; displayName=="" && accountIt != accounts.end() ; ++accountIt){
auto params = accountIt->get()->getParams();
if(params){
auto accountAddress = params->getIdentityAddress();
if(accountAddress && accountAddress->weakEqual(address)){
displayName = Utils::coreStringToAppString(accountAddress->getDisplayName());
}
}
}
if(displayName == ""){
// Try to get display name from logs
auto callHistory = CoreManager::getInstance()->getCore()->getCallLogs();
auto callLog = std::find_if(callHistory.begin(), callHistory.end(), [address](std::shared_ptr<linphone::CallLog>& cl){
return cl->getRemoteAddress()->weakEqual(address);
});
if(callLog != callHistory.end())
displayName = QString::fromStdString((*callLog)->getRemoteAddress()->getDisplayName());
if(displayName == "")
displayName = QString::fromStdString(address->getDisplayName());
if(displayName == "")
displayName = Utils::coreStringToAppString(address->getUsername());
}
}
if(displayName == ""){
// Try to get display name from logs
auto callHistory = CoreManager::getInstance()->getCore()->getCallLogs();
auto callLog = std::find_if(callHistory.begin(), callHistory.end(), [address](std::shared_ptr<linphone::CallLog>& cl){
return cl->getRemoteAddress()->weakEqual(address);
});
if(callLog != callHistory.end())
displayName = QString::fromStdString((*callLog)->getRemoteAddress()->getDisplayName());
if(displayName == "")
displayName = QString::fromStdString(address->getDisplayName());
if(displayName == "")
displayName = Utils::coreStringToAppString(address->getUsername());
}
CoreManager::getInstance()->getContactsListModel()->addDisplayNameToCache(qtAddress, displayName);
}
}
}
@ -872,4 +877,4 @@ QPixmap Utils::getMaskedPixmap(const QString& name, const QColor& color){
pxr.fill( color );
pxr.setMask( img.createMaskFromColor( Qt::transparent ) );
return pxr;
}
}

View file

@ -62,6 +62,7 @@ public:
Q_INVOKABLE static QString toDateTimeString(QDateTime date);
Q_INVOKABLE static QString toTimeString(QDateTime date, const QString& format = "hh:mm:ss");
Q_INVOKABLE static QString toDateString(QDateTime date, const QString& format = "");
static void cleanDisplayNameCache(const QString& address = "");// if "", clean all cache
Q_INVOKABLE static QString getDisplayName(const QString& address);
Q_INVOKABLE static QString getInitials(const QString& username); // Support UTF32
Q_INVOKABLE static QString toString(const LinphoneEnums::TunnelMode& mode);

View file

@ -103,7 +103,7 @@ Rectangle {
if(!chat.isMoving && chat.atYBeginning && !chat.loadingEntries){// Moving has stopped. Check if we are at beginning
chat.displaying = true
console.log("Trying to load more entries")
Qt.callLater(container.proxyModel.loadMoreEntriesAsync())
Qt.callLater(container.proxyModel.loadMoreEntriesAsync)
}
}
// -----------------------------------------------------------------------

View file

@ -27,7 +27,7 @@ Item{
id: loader
property bool toLoad : false
anchors.fill: parent
active: true
active: false
asynchronous: true
//visible: status == Loader.Ready
sourceComponent:
@ -49,4 +49,4 @@ Item{
}
}
}
}
}

View file

@ -584,6 +584,7 @@ ColumnLayout {
anchors.verticalCenter: parent.verticalCenter
color: BusyIndicatorStyle.alternateColor.color
running: chatArea.tryingToLoadMoreEntries
onRunningChanged: console.log("Chat is busy: " +running)
}
// -------------------------------------------------------------------------