Hide chat deliveries idle display and adapt size from displayed deliveries.

This commit is contained in:
Julien Wadel 2022-09-17 14:17:16 +02:00
parent 8fa1c028fc
commit 90f30b3b6d
5 changed files with 17 additions and 7 deletions

View file

@ -76,8 +76,13 @@ QSharedPointer<ParticipantImdnStateModel> ParticipantImdnStateListModel::getImdn
//--------------------------------------------------------------------------------
void ParticipantImdnStateListModel::updateState(const std::shared_ptr<const linphone::ParticipantImdnState> & 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();
}
}
//--------------------------------------------------------------------------------

View file

@ -47,6 +47,7 @@ public slots:
signals:
void imdnStateChanged();
void stateChangedFromIdle();
};
Q_DECLARE_METATYPE(QSharedPointer<ParticipantImdnStateListModel>)

View file

@ -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<ParticipantImdnStateListModel*>(sourceModel());
const QModelIndex index = listModel->index(sourceRow, 0, sourceParent);
const ParticipantImdnStateModel *imdn = index.data().value<ParticipantImdnStateModel *>();
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();
}

View file

@ -37,8 +37,6 @@ bool ParticipantDeviceProxyModel::filterAcceptsRow (
int sourceRow,
const QModelIndex &sourceParent
) const {
Q_UNUSED(sourceRow)
Q_UNUSED(sourceParent)
auto listModel = qobject_cast<ParticipantDeviceListModel*>(sourceModel());
const QModelIndex index = listModel->index(sourceRow, 0, sourceParent);
const ParticipantDeviceModel *device = index.data().value<ParticipantDeviceModel *>();

View file

@ -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.