mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-28 01:09:19 +00:00
Fix clearing chat while being in call (when switching chats in timeline)
This commit is contained in:
parent
bf9c76a02c
commit
ecd6e2abf7
5 changed files with 59 additions and 5 deletions
|
|
@ -859,6 +859,19 @@ bool ChatRoomModel::isTerminated(const std::shared_ptr<linphone::ChatRoom>& chat
|
|||
return chatRoom->getState() == linphone::ChatRoom::State::Terminated || chatRoom->getState() == linphone::ChatRoom::State::Deleted;
|
||||
}
|
||||
|
||||
void ChatRoomModel::addBindingCall(){ // If a call is binding to this chat room, we avoid cleaning data (Add=+1, remove=-1)
|
||||
++mBindingCalls;
|
||||
}
|
||||
|
||||
void ChatRoomModel::removeBindingCall(){
|
||||
--mBindingCalls;
|
||||
}
|
||||
|
||||
void ChatRoomModel::resetData(){
|
||||
if( mBindingCalls == 0)
|
||||
ProxyListModel::resetData();
|
||||
}
|
||||
|
||||
void ChatRoomModel::initEntries(){
|
||||
if( mList.size() > mLastEntriesStep)
|
||||
resetData();
|
||||
|
|
|
|||
|
|
@ -176,6 +176,10 @@ public:
|
|||
Q_INVOKABLE int loadTillMessage(ChatMessageModel * message);// Load all entries till message and return its index. -1 if not found.
|
||||
static bool isTerminated(const std::shared_ptr<linphone::ChatRoom>& chatRoom);
|
||||
|
||||
void addBindingCall(); // If a call is binding to this chat room, we avoid cleaning data (Add=+1, remove=-1)
|
||||
void removeBindingCall();
|
||||
virtual void resetData() override;
|
||||
|
||||
QDateTime mLastUpdateTime;
|
||||
int mUnreadMessagesCount = 0;
|
||||
int mMissedCallsCount = 0;
|
||||
|
|
@ -195,7 +199,6 @@ public:
|
|||
void insertNotice (const std::shared_ptr<linphone::EventLog> &enventLog);
|
||||
void insertNotices (const QList<std::shared_ptr<linphone::EventLog>> &eventLogs);
|
||||
|
||||
|
||||
//-------------------- CHAT ROOM HANDLER
|
||||
|
||||
public slots:
|
||||
|
|
@ -299,6 +302,7 @@ private:
|
|||
QSharedPointer<ParticipantListModel> mParticipantListModel;
|
||||
QSharedPointer<ChatMessageModel> mReplyModel;
|
||||
QSharedPointer<ChatNoticeModel> mUnreadMessageNotice;
|
||||
int mBindingCalls = 0;
|
||||
|
||||
QWeakPointer<ChatRoomModel> mSelf;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -56,6 +56,10 @@ ChatRoomProxyModel::ChatRoomProxyModel (QObject *parent) : QSortFilterProxyModel
|
|||
sort(0);
|
||||
}
|
||||
|
||||
ChatRoomProxyModel::~ChatRoomProxyModel(){
|
||||
setChatRoomModel(nullptr); // Do remove process like setting haveCall if is Call.
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define GET_CHAT_MODEL() \
|
||||
|
|
@ -242,6 +246,19 @@ QString ChatRoomProxyModel::getCachedText() const{
|
|||
return gCachedText;
|
||||
}
|
||||
|
||||
void ChatRoomProxyModel::setIsCall(const bool& isCall){
|
||||
if(mIsCall != isCall) {
|
||||
if(mChatRoomModel){
|
||||
if(isCall){
|
||||
mChatRoomModel->addBindingCall();
|
||||
}else
|
||||
mChatRoomModel->removeBindingCall();
|
||||
}
|
||||
mIsCall = isCall;
|
||||
emit isCallChanged();
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ChatRoomProxyModel::reload (ChatRoomModel *chatRoomModel) {
|
||||
|
|
@ -252,8 +269,14 @@ void ChatRoomProxyModel::reload (ChatRoomModel *chatRoomModel) {
|
|||
QObject::disconnect(ChatRoomModel, &ChatRoomModel::messageReceived, this, &ChatRoomProxyModel::handleMessageReceived);
|
||||
QObject::disconnect(ChatRoomModel, &ChatRoomModel::messageSent, this, &ChatRoomProxyModel::handleMessageSent);
|
||||
QObject::disconnect(ChatRoomModel, &ChatRoomModel::markAsReadEnabledChanged, this, &ChatRoomProxyModel::markAsReadEnabledChanged);
|
||||
QObject::disconnect(ChatRoomModel, &ChatRoomModel::moreEntriesLoaded, this, &ChatRoomProxyModel::onMoreEntriesLoaded);
|
||||
QObject::disconnect(ChatRoomModel, &ChatRoomModel::moreEntriesLoaded, this, &ChatRoomProxyModel::onMoreEntriesLoaded);
|
||||
if(mIsCall)
|
||||
mChatRoomModel->removeBindingCall();
|
||||
}
|
||||
if( mIsCall && chatRoomModel){
|
||||
chatRoomModel->addBindingCall();
|
||||
}
|
||||
|
||||
mChatRoomModel = CoreManager::getInstance()->getTimelineListModel()->getChatRoomModel(chatRoomModel);
|
||||
setSourceModel(mChatRoomModel.get());
|
||||
if (mChatRoomModel) {
|
||||
|
|
@ -303,9 +326,15 @@ ChatRoomModel *ChatRoomProxyModel::getChatRoomModel () const{
|
|||
}
|
||||
|
||||
void ChatRoomProxyModel::setChatRoomModel (ChatRoomModel *chatRoomModel){
|
||||
reload(chatRoomModel);
|
||||
emit chatRoomModelChanged();
|
||||
emit isRemoteComposingChanged();
|
||||
if(chatRoomModel){
|
||||
reload(chatRoomModel);
|
||||
emit chatRoomModelChanged();
|
||||
emit isRemoteComposingChanged();
|
||||
}else{
|
||||
if(mIsCall && mChatRoomModel)
|
||||
mChatRoomModel->removeBindingCall();
|
||||
mChatRoomModel = nullptr;
|
||||
}
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,11 @@ class ChatRoomProxyModel : public QSortFilterProxyModel {
|
|||
Q_PROPERTY(QString filterText MEMBER mFilterText WRITE setFilterText NOTIFY filterTextChanged)
|
||||
Q_PROPERTY(bool markAsReadEnabled READ markAsReadEnabled WRITE enableMarkAsRead NOTIFY markAsReadEnabledChanged)// Focus is at end of the list. Used to reset message count if not at end
|
||||
|
||||
Q_PROPERTY(bool isCall MEMBER mIsCall WRITE setIsCall NOTIFY isCallChanged)
|
||||
|
||||
public:
|
||||
ChatRoomProxyModel (QObject *parent = Q_NULLPTR);
|
||||
~ChatRoomProxyModel();
|
||||
|
||||
int getEntryTypeFilter ();
|
||||
Q_INVOKABLE void setEntryTypeFilter (int type);
|
||||
|
|
@ -55,6 +58,8 @@ public:
|
|||
Q_INVOKABLE QString getDisplayNameComposers()const;
|
||||
Q_INVOKABLE QVariant getAt(int row);
|
||||
|
||||
void setIsCall(const bool& isCall);
|
||||
|
||||
|
||||
Q_INVOKABLE void loadMoreEntriesAsync ();
|
||||
Q_INVOKABLE void loadMoreEntries ();
|
||||
|
|
@ -88,6 +93,7 @@ signals:
|
|||
|
||||
void entryTypeFilterChanged (int type);
|
||||
void filterTextChanged();
|
||||
void isCallChanged();
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
|
|
@ -133,6 +139,7 @@ private:
|
|||
QString mFullLocalAddress;
|
||||
static QString gCachedText;
|
||||
bool mMarkAsReadEnabled;
|
||||
bool mIsCall = false;
|
||||
|
||||
QString mFilterText;
|
||||
|
||||
|
|
|
|||
|
|
@ -218,6 +218,7 @@ Window {
|
|||
fullPeerAddress: window.call.fullPeerAddress
|
||||
fullLocalAddress: window.call.fullLocalAddress
|
||||
localAddress: window.call.localAddress
|
||||
isCall: true // Used for cleaning data if there are no call associated to this chat room.
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue