From 79137f71c3c708b6c3f3ae5c64de0479ae69db84 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Thu, 18 Nov 2021 10:56:20 +0100 Subject: [PATCH] Fix hidden IMDN status in menu by first loading all imdn, and optimize by loading GUI list on request. --- .../ParticipantImdnStateProxyModel.cpp | 5 +- .../ParticipantImdnStateProxyModel.hpp | 1 + .../modules/Linphone/Chat/ChatDeliveries.qml | 78 ++++++++++--------- .../ui/modules/Linphone/Chat/FileMessage.qml | 2 +- .../ui/modules/Linphone/Chat/Message.qml | 2 +- 5 files changed, 47 insertions(+), 41 deletions(-) diff --git a/linphone-app/src/components/participant-imdn/ParticipantImdnStateProxyModel.cpp b/linphone-app/src/components/participant-imdn/ParticipantImdnStateProxyModel.cpp index f6112ad84..91f17744d 100644 --- a/linphone-app/src/components/participant-imdn/ParticipantImdnStateProxyModel.cpp +++ b/linphone-app/src/components/participant-imdn/ParticipantImdnStateProxyModel.cpp @@ -57,10 +57,11 @@ int ParticipantImdnStateProxyModel::getCount(){ } ChatMessageModel * ParticipantImdnStateProxyModel::getChatMessageModel(){ - return nullptr; + return mChatMessageModel; } void ParticipantImdnStateProxyModel::setChatMessageModel(ChatMessageModel * message){ + mChatMessageModel = message; if(message){ ParticipantImdnStateListModel *model = static_cast(sourceModel()); ParticipantImdnStateListModel *messageModel = message->getParticipantImdnStates().get(); @@ -68,7 +69,7 @@ void ParticipantImdnStateProxyModel::setChatMessageModel(ChatMessageModel * mess setSourceModel(messageModel); connect(messageModel, &ParticipantImdnStateListModel::countChanged, this, &ParticipantImdnStateProxyModel::countChanged); sort(0); - emit chatMessageModelChanged(); } } + emit chatMessageModelChanged(); } \ No newline at end of file diff --git a/linphone-app/src/components/participant-imdn/ParticipantImdnStateProxyModel.hpp b/linphone-app/src/components/participant-imdn/ParticipantImdnStateProxyModel.hpp index c06820965..c21e5b10b 100644 --- a/linphone-app/src/components/participant-imdn/ParticipantImdnStateProxyModel.hpp +++ b/linphone-app/src/components/participant-imdn/ParticipantImdnStateProxyModel.hpp @@ -53,6 +53,7 @@ protected: virtual bool lessThan (const QModelIndex &left, const QModelIndex &right) const override; std::shared_ptr mImdns; + ChatMessageModel * mChatMessageModel = nullptr; }; #endif diff --git a/linphone-app/ui/modules/Linphone/Chat/ChatDeliveries.qml b/linphone-app/ui/modules/Linphone/Chat/ChatDeliveries.qml index 30328ff01..48e384554 100644 --- a/linphone-app/ui/modules/Linphone/Chat/ChatDeliveries.qml +++ b/linphone-app/ui/modules/Linphone/Chat/ChatDeliveries.qml @@ -18,44 +18,48 @@ import 'Message.js' as Logic // ============================================================================= -GridView{ - id: deliveryLayout - +Loader{ + id: loader property ChatMessageModel chatMessageModel - - //height: visible ? ChatStyle.composingText.height*container.proxyModel.composers.length : 0 - height: visible ? (ChatStyle.composingText.height-5)*deliveryLayout.model.count : 0 - cellWidth: parent.width; cellHeight: ChatStyle.composingText.height-5 + property ParticipantImdnStateProxyModel imdnStatesModel: ParticipantImdnStateProxyModel { + chatMessageModel: loader.chatMessageModel + } + height: visible ? (ChatStyle.composingText.height-5)*loader.imdnStatesModel.count : 0 visible:false - model: ParticipantImdnStateProxyModel{ - id: imdnStatesModel - chatMessageModel: deliveryLayout.visible ? deliveryLayout.chatMessageModel: null - } - function getText(state, displayName, stateChangeTime){ - if(state == LinphoneEnums.ChatMessageStateDelivered) - //: 'Send to %1 - %2' Little message to indicate the state of a message - //~ Context %1 is someone, %2 is a date/time. The state is that the message has been sent but not received. - return qsTr('deliveryDelivered').arg(displayName).arg(stateChangeTime) - else if(state == LinphoneEnums.ChatMessageStateDeliveredToUser) - //: 'Retrieved by %1 - %2' Little message to indicate the state of a message - //~ Context %1 is someone, %2 is a date/time. The state is that the message has been retrieved - return qsTr('deliveryDeliveredToUser').arg(displayName).arg(stateChangeTime) - else if(state == LinphoneEnums.ChatMessageStateDisplayed) - //: 'Read by %1 - %2' Little message to indicate the state of a message - //~ Context %1 is someone, %2 is a date/time. The state that the message has been read. - return qsTr('deliveryDisplayed').arg(displayName).arg(stateChangeTime) - else if(state == LinphoneEnums.ChatMessageStateNotDelivered) - //: "%1 have nothing received" Little message to indicate the state of a message - //~ Context %1 is someone. The state is that the message hasn't been delivered. - return qsTr('deliveryNotDelivered').arg(displayName) - else return '' - } - delegate:Text{ - height: ChatStyle.composingText.height-5 - width: GridView.width - text: deliveryLayout.getText(modelData.state, modelData.displayName, UtilsCpp.toDateTimeString(modelData.stateChangeTime)) - color: ChatStyle.entry.event.text.color - font.pointSize: Units.dp * 8 - elide: Text.ElideMiddle + active: visible + sourceComponent: + GridView{ + id: deliveryLayout + + cellWidth: parent.width; cellHeight: ChatStyle.composingText.height-5 + + model: loader.imdnStatesModel + function getText(state, displayName, stateChangeTime){ + if(state == LinphoneEnums.ChatMessageStateDelivered) + //: 'Send to %1 - %2' Little message to indicate the state of a message + //~ Context %1 is someone, %2 is a date/time. The state is that the message has been sent but not received. + return qsTr('deliveryDelivered').arg(displayName).arg(stateChangeTime) + else if(state == LinphoneEnums.ChatMessageStateDeliveredToUser) + //: 'Retrieved by %1 - %2' Little message to indicate the state of a message + //~ Context %1 is someone, %2 is a date/time. The state is that the message has been retrieved + return qsTr('deliveryDeliveredToUser').arg(displayName).arg(stateChangeTime) + else if(state == LinphoneEnums.ChatMessageStateDisplayed) + //: 'Read by %1 - %2' Little message to indicate the state of a message + //~ Context %1 is someone, %2 is a date/time. The state that the message has been read. + return qsTr('deliveryDisplayed').arg(displayName).arg(stateChangeTime) + else if(state == LinphoneEnums.ChatMessageStateNotDelivered) + //: "%1 have nothing received" Little message to indicate the state of a message + //~ Context %1 is someone. The state is that the message hasn't been delivered. + return qsTr('deliveryNotDelivered').arg(displayName) + else return '' + } + delegate:Text{ + height: ChatStyle.composingText.height-5 + width: GridView.width + text: deliveryLayout.getText(modelData.state, modelData.displayName, UtilsCpp.toDateTimeString(modelData.stateChangeTime)) + color: ChatStyle.entry.event.text.color + font.pointSize: Units.dp * 8 + elide: Text.ElideMiddle + } } } diff --git a/linphone-app/ui/modules/Linphone/Chat/FileMessage.qml b/linphone-app/ui/modules/Linphone/Chat/FileMessage.qml index 4ece81ab3..3c6115495 100644 --- a/linphone-app/ui/modules/Linphone/Chat/FileMessage.qml +++ b/linphone-app/ui/modules/Linphone/Chat/FileMessage.qml @@ -269,7 +269,7 @@ Row { //height: parent.height //width: parent.width - deliveryCount: deliveryLayout.model.count + deliveryCount: deliveryLayout.imdnStatesModel.count onDeliveryStatusClicked: deliveryLayout.visible = !deliveryLayout.visible onRemoveEntryRequested: removeEntry() deliveryVisible: deliveryLayout.visible diff --git a/linphone-app/ui/modules/Linphone/Chat/Message.qml b/linphone-app/ui/modules/Linphone/Chat/Message.qml index f6ba959fd..b4d6d730b 100644 --- a/linphone-app/ui/modules/Linphone/Chat/Message.qml +++ b/linphone-app/ui/modules/Linphone/Chat/Message.qml @@ -141,7 +141,7 @@ Item { lastTextSelected: message.lastTextSelected content: $chatEntry.content - deliveryCount: deliveryLayout.model.count + deliveryCount: deliveryLayout.imdnStatesModel.count onDeliveryStatusClicked: deliveryLayout.visible = !deliveryLayout.visible onRemoveEntryRequested: removeEntry() deliveryVisible: deliveryLayout.visible