From 90f30b3b6dc0292915fc1f7db98f5dfbe5d2695e Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Sat, 17 Sep 2022 14:17:16 +0200 Subject: [PATCH] Hide chat deliveries idle display and adapt size from displayed deliveries. --- .../ParticipantImdnStateListModel.cpp | 7 ++++++- .../ParticipantImdnStateListModel.hpp | 1 + .../ParticipantImdnStateProxyModel.cpp | 12 ++++++++---- .../participant/ParticipantDeviceProxyModel.cpp | 2 -- .../ui/modules/Linphone/Chat/ChatDeliveries.qml | 2 ++ 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/linphone-app/src/components/participant-imdn/ParticipantImdnStateListModel.cpp b/linphone-app/src/components/participant-imdn/ParticipantImdnStateListModel.cpp index 1a3009be3..c67950efd 100644 --- a/linphone-app/src/components/participant-imdn/ParticipantImdnStateListModel.cpp +++ b/linphone-app/src/components/participant-imdn/ParticipantImdnStateListModel.cpp @@ -76,8 +76,13 @@ QSharedPointer ParticipantImdnStateListModel::getImdn //-------------------------------------------------------------------------------- void ParticipantImdnStateListModel::updateState(const std::shared_ptr & state){ - if(state->getParticipant()) + if(state->getParticipant()) { + auto imdn = getImdnState(state); + auto oldState = imdn->getState(); getImdnState(state)->update(state); + if( oldState == LinphoneEnums::ChatMessageState::ChatMessageStateIdle && oldState != imdn->getState()) + emit stateChangedFromIdle(); + } } //-------------------------------------------------------------------------------- diff --git a/linphone-app/src/components/participant-imdn/ParticipantImdnStateListModel.hpp b/linphone-app/src/components/participant-imdn/ParticipantImdnStateListModel.hpp index a6e858a13..5bcf16d2f 100644 --- a/linphone-app/src/components/participant-imdn/ParticipantImdnStateListModel.hpp +++ b/linphone-app/src/components/participant-imdn/ParticipantImdnStateListModel.hpp @@ -47,6 +47,7 @@ public slots: signals: void imdnStateChanged(); + void stateChangedFromIdle(); }; Q_DECLARE_METATYPE(QSharedPointer) diff --git a/linphone-app/src/components/participant-imdn/ParticipantImdnStateProxyModel.cpp b/linphone-app/src/components/participant-imdn/ParticipantImdnStateProxyModel.cpp index bc1e204a2..f7d009f4e 100644 --- a/linphone-app/src/components/participant-imdn/ParticipantImdnStateProxyModel.cpp +++ b/linphone-app/src/components/participant-imdn/ParticipantImdnStateProxyModel.cpp @@ -37,9 +37,10 @@ bool ParticipantImdnStateProxyModel::filterAcceptsRow ( int sourceRow, const QModelIndex &sourceParent ) const { - Q_UNUSED(sourceRow) - Q_UNUSED(sourceParent) - return true; + auto listModel = qobject_cast(sourceModel()); + const QModelIndex index = listModel->index(sourceRow, 0, sourceParent); + const ParticipantImdnStateModel *imdn = index.data().value(); + return imdn->getState() != LinphoneEnums::ChatMessageState::ChatMessageStateIdle; } bool ParticipantImdnStateProxyModel::lessThan (const QModelIndex &left, const QModelIndex &right) const { @@ -51,7 +52,8 @@ bool ParticipantImdnStateProxyModel::lessThan (const QModelIndex &left, const QM } //--------------------------------------------------------------------------------- int ParticipantImdnStateProxyModel::getCount(){ - return sourceModel() ? sourceModel()->rowCount() : 0; + //return sourceModel() ? sourceModel()->rowCount() : 0; + return rowCount(); } ChatMessageModel * ParticipantImdnStateProxyModel::getChatMessageModel(){ @@ -68,6 +70,8 @@ void ParticipantImdnStateProxyModel::setChatMessageModel(ChatMessageModel * mess disconnect(model, &ParticipantImdnStateListModel::countChanged, this, &ParticipantImdnStateProxyModel::countChanged); setSourceModel(messageModel); connect(messageModel, &ParticipantImdnStateListModel::countChanged, this, &ParticipantImdnStateProxyModel::countChanged); + connect(messageModel, &ParticipantImdnStateListModel::stateChangedFromIdle, this, &ParticipantImdnStateProxyModel::invalidate); + connect(messageModel, &ParticipantImdnStateListModel::stateChangedFromIdle, this, &ParticipantImdnStateProxyModel::countChanged); sort(0); emit countChanged(); } diff --git a/linphone-app/src/components/participant/ParticipantDeviceProxyModel.cpp b/linphone-app/src/components/participant/ParticipantDeviceProxyModel.cpp index 3fff536b1..b05c9129d 100644 --- a/linphone-app/src/components/participant/ParticipantDeviceProxyModel.cpp +++ b/linphone-app/src/components/participant/ParticipantDeviceProxyModel.cpp @@ -37,8 +37,6 @@ bool ParticipantDeviceProxyModel::filterAcceptsRow ( int sourceRow, const QModelIndex &sourceParent ) const { - Q_UNUSED(sourceRow) - Q_UNUSED(sourceParent) auto listModel = qobject_cast(sourceModel()); const QModelIndex index = listModel->index(sourceRow, 0, sourceParent); const ParticipantDeviceModel *device = index.data().value(); diff --git a/linphone-app/ui/modules/Linphone/Chat/ChatDeliveries.qml b/linphone-app/ui/modules/Linphone/Chat/ChatDeliveries.qml index bed63246c..c37e82192 100644 --- a/linphone-app/ui/modules/Linphone/Chat/ChatDeliveries.qml +++ b/linphone-app/ui/modules/Linphone/Chat/ChatDeliveries.qml @@ -51,6 +51,8 @@ Loader{ //: "%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 if(state == LinphoneEnums.ChatMessageStateIdle) + return '' else //: "Error while sending to %1" Little message to indicate the state of a message //~ Context %1 is someone. The state is that the message hasn't been delivered because of an error.