diff --git a/linphone-app/src/app/proxyModel/ProxyAbstractListModel.hpp b/linphone-app/src/app/proxyModel/ProxyAbstractListModel.hpp index ee4162041..52363b6aa 100644 --- a/linphone-app/src/app/proxyModel/ProxyAbstractListModel.hpp +++ b/linphone-app/src/app/proxyModel/ProxyAbstractListModel.hpp @@ -62,14 +62,18 @@ public: // Add functions virtual void add(T item){ int row = mList.count(); + emit layoutAboutToBeChanged(); beginInsertRows(QModelIndex(), row, row); mList << item; endInsertRows(); + emit layoutChanged(); } virtual void add(QList items){ + emit layoutAboutToBeChanged(); beginInsertRows(QModelIndex(), mList.size(), mList.size() + items.size()-1); mList << items; endInsertRows(); + emit layoutChanged(); } virtual void prepend(T item){ @@ -93,10 +97,12 @@ public: int limit = row + count - 1; if (row < 0 || count < 0 || limit >= mList.count()) return false; + emit layoutAboutToBeChanged(); beginRemoveRows(parent, row, limit); for (int i = 0; i < count; ++i) mList.takeAt(row); endRemoveRows(); + emit layoutChanged(); return true; } diff --git a/linphone-app/src/app/proxyModel/ProxyListModel.hpp b/linphone-app/src/app/proxyModel/ProxyListModel.hpp index 22ba8a5f0..45781dc79 100644 --- a/linphone-app/src/app/proxyModel/ProxyListModel.hpp +++ b/linphone-app/src/app/proxyModel/ProxyListModel.hpp @@ -65,10 +65,12 @@ public: template void add(QList> items){ + emit layoutAboutToBeChanged(); beginInsertRows(QModelIndex(), mList.size(), mList.size() + items.size() - 1); for(auto i : items) mList << i.template objectCast(); endInsertRows(); + emit layoutChanged(); } template @@ -78,10 +80,12 @@ public: template void prepend(QList> items){ + emit layoutAboutToBeChanged(); beginInsertRows(QModelIndex(), 0, items.size()-1); items << mList; mList = items; endInsertRows(); + emit layoutChanged(); } virtual bool remove(QObject *itemToRemove) override{ diff --git a/linphone-app/src/components/calls/CallsListModel.cpp b/linphone-app/src/components/calls/CallsListModel.cpp index 0b446080d..5e8e22042 100644 --- a/linphone-app/src/components/calls/CallsListModel.cpp +++ b/linphone-app/src/components/calls/CallsListModel.cpp @@ -581,7 +581,6 @@ void CallsListModel::addCall (const shared_ptr &call) { connect(callModel.get(), &CallModel::statusChanged, this, &CallsListModel::handleCallStatusChanged); add(callModel); - emit layoutChanged(); if (call->getDir() == linphone::Call::Dir::Outgoing) { QQuickWindow *callsWindow = App::getInstance()->getCallsWindow(); @@ -616,7 +615,6 @@ void CallsListModel::addDummyCall () { connect(callModel.get(), &CallModel::statusChanged, this, &CallsListModel::handleCallStatusChanged); add(callModel); - emit layoutChanged(); } void CallsListModel::removeCall (const shared_ptr &call) { diff --git a/linphone-app/src/components/chat-room/ChatRoomModel.cpp b/linphone-app/src/components/chat-room/ChatRoomModel.cpp index 5ffc722e2..ac1bd86a7 100644 --- a/linphone-app/src/components/chat-room/ChatRoomModel.cpp +++ b/linphone-app/src/components/chat-room/ChatRoomModel.cpp @@ -238,7 +238,7 @@ bool ChatRoomModel::removeRows (int row, int count, const QModelIndex &parent) { if (row < 0 || count < 0 || limit >= mList.count()) return false; - + emit layoutAboutToBeChanged(); beginRemoveRows(parent, row, limit); for (int i = 0; i < count; ++i) { @@ -253,6 +253,7 @@ bool ChatRoomModel::removeRows (int row, int count, const QModelIndex &parent) { else if (limit == mList.count()) emit lastEntryRemoved(); emit focused();// Removing rows is like having focus. Don't wait asynchronous events. + emit layoutChanged(); return true; } @@ -870,9 +871,6 @@ void ChatRoomModel::updateNewMessageNotice(const int& count){ prepend(mUnreadMessageNotice); qDebug() << "New message notice timestamp to :" << lastUnreadMessage.toString() << " recv at " << lastReceivedMessage.toString(); } -// Seems to be a Qt bug : If layoutChanged() is not send, some delegates after notice will be wrong (their $chatEntry will be updated with undefined while not being really updated on next check) -// Reproduce case with a ChatMessage after a Notice: On Notice deletion, this chatMessage will update its text with an undefined $chatEntry. But when checking the value of its $chatEntry after this event(make a MouseArea with a click event), it will be the correct one (and not the undefined). - emit layoutChanged(); } } @@ -981,6 +979,7 @@ void ChatRoomModel::initEntries(){ EntrySorterHelper::getLimitedSelection(&entries, prepareEntries, mFirstLastEntriesStep, this); qDebug() << "Internal Entries : Built"; if(entries.size() >0){ + emit layoutAboutToBeChanged(); beginInsertRows(QModelIndex(),0, entries.size()-1); for(auto e : entries) { if( e->mType == ChatRoomModel::EntryType::MessageEntry){ @@ -991,6 +990,7 @@ void ChatRoomModel::initEntries(){ mList.push_back(e); } endInsertRows(); + emit layoutChanged(); updateNewMessageNotice(mChatRoom->getUnreadMessagesCount()); } qDebug() << "Internal Entries : End"; @@ -1073,13 +1073,16 @@ int ChatRoomModel::loadMoreEntries(){ EntrySorterHelper::getLimitedSelection(&entries, prepareEntries, mLastEntriesStep, this); if(entries.size() >0){ - if(mPostModelChangedEvents) + if(mPostModelChangedEvents){ + emit layoutAboutToBeChanged(); beginInsertRows(QModelIndex(), 0, entries.size()-1); + } for(auto entry : entries) mList.prepend(entry); - if(mPostModelChangedEvents) + if(mPostModelChangedEvents){ endInsertRows(); - //emit layoutChanged(); + emit layoutChanged(); + } updateLastUpdateTime(); } newEntries = entries.size(); @@ -1111,9 +1114,11 @@ void ChatRoomModel::insertCall (const std::shared_ptr &callLo QSharedPointer model = ChatCallModel::create(callLog, true); if(model){ int row = mList.count(); + emit layoutAboutToBeChanged(); beginInsertRows(QModelIndex(), row, row); mList << model; endInsertRows(); + emit layoutChanged(); if (callLog->getStatus() == linphone::Call::Status::Success) { model = ChatCallModel::create(callLog, false); if(model) @@ -1141,7 +1146,6 @@ void ChatRoomModel::insertCalls (const QList } if(entries.size() > 0){ prepend(entries); - emit layoutChanged(); } } } @@ -1173,7 +1177,6 @@ void ChatRoomModel::insertMessages (const QList 0){ prepend(entries); setUnreadMessagesCount(mChatRoom->getUnreadMessagesCount()); - emit layoutChanged(); } } } @@ -1197,7 +1200,6 @@ void ChatRoomModel::insertNotices (const QList 0){ prepend(entries); - emit layoutChanged(); } } } diff --git a/linphone-app/src/components/conference/ConferenceAddModel.cpp b/linphone-app/src/components/conference/ConferenceAddModel.cpp index e691e50bd..92c131854 100644 --- a/linphone-app/src/components/conference/ConferenceAddModel.cpp +++ b/linphone-app/src/components/conference/ConferenceAddModel.cpp @@ -79,7 +79,7 @@ bool ConferenceHelperModel::ConferenceAddModel::addToConference (const shared_pt return false; int row = rowCount(); - + emit layoutAboutToBeChanged(); beginInsertRows(QModelIndex(), row, row); addToConferencePrivate(linphoneAddress->clone()); endInsertRows(); @@ -99,6 +99,7 @@ bool ConferenceHelperModel::ConferenceAddModel::addToConference (const QString & return false; int row = rowCount(); + emit layoutAboutToBeChanged(); beginInsertRows(QModelIndex(), row, row); qInfo() << QStringLiteral("Add sip address to conference: `%1`.").arg(sipAddress); @@ -127,7 +128,7 @@ bool ConferenceHelperModel::ConferenceAddModel::removeFromConference (const QStr return false; int row = mRefs.indexOf(&(*it)); - + emit layoutAboutToBeChanged(); beginRemoveRows(QModelIndex(), row, row); qInfo() << QStringLiteral("Remove sip address from conference: `%1`.").arg(sipAddress); @@ -136,7 +137,7 @@ bool ConferenceHelperModel::ConferenceAddModel::removeFromConference (const QStr mSipAddresses.remove(sipAddress); endRemoveRows(); - + emit layoutChanged(); mConferenceHelperModel->invalidate(); return true; diff --git a/linphone-app/src/components/contacts/ContactsImporterListModel.cpp b/linphone-app/src/components/contacts/ContactsImporterListModel.cpp index 647c14e80..4380627f9 100644 --- a/linphone-app/src/components/contacts/ContactsImporterListModel.cpp +++ b/linphone-app/src/components/contacts/ContactsImporterListModel.cpp @@ -74,7 +74,7 @@ bool ContactsImporterListModel::removeRows (int row, int count, const QModelInde if (row < 0 || count < 0 || limit >= mList.count()) return false; - + emit layoutAboutToBeChanged(); beginRemoveRows(parent, row, limit); for (int i = 0; i < count; ++i) { @@ -82,7 +82,7 @@ bool ContactsImporterListModel::removeRows (int row, int count, const QModelInde } endRemoveRows(); - + emit layoutChanged(); return true; } @@ -115,8 +115,6 @@ ContactsImporterModel *ContactsImporterListModel::createContactsImporter(QVarian contactsImporter->setFields(newData); addContactsImporter(contactsImporter); - emit layoutChanged(); - emit contactsImporterAdded(contactsImporter); } } diff --git a/linphone-app/src/components/contacts/ContactsListModel.cpp b/linphone-app/src/components/contacts/ContactsListModel.cpp index ff3835a90..101e3934d 100644 --- a/linphone-app/src/components/contacts/ContactsListModel.cpp +++ b/linphone-app/src/components/contacts/ContactsListModel.cpp @@ -63,7 +63,7 @@ bool ContactsListModel::removeRows (int row, int count, const QModelIndex &paren return false; auto friendsList = CoreManager::getInstance()->getCore()->getFriendsLists(); - + emit layoutAboutToBeChanged(); beginRemoveRows(parent, row, limit); for (int i = 0; i < count; ++i) { @@ -79,7 +79,7 @@ bool ContactsListModel::removeRows (int row, int count, const QModelIndex &paren } endRemoveRows(); - + emit layoutChanged(); return true; } @@ -140,8 +140,6 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcardModel) { // Make sure new subscribe is issued. friendsList->updateSubscriptions(); - emit layoutChanged(); - emit contactAdded(contact); return contact.get(); diff --git a/linphone-app/src/components/history/HistoryModel.cpp b/linphone-app/src/components/history/HistoryModel.cpp index a2b90ddf3..15b5d6264 100644 --- a/linphone-app/src/components/history/HistoryModel.cpp +++ b/linphone-app/src/components/history/HistoryModel.cpp @@ -127,7 +127,7 @@ bool HistoryModel::removeRows (int row, int count, const QModelIndex &parent) { if (row < 0 || count < 0 || limit >= mEntries.count()) return false; - + emit layoutAboutToBeChanged(); beginRemoveRows(parent, row, limit); for (int i = 0; i < count; ++i) { @@ -143,6 +143,7 @@ bool HistoryModel::removeRows (int row, int count, const QModelIndex &parent) { emit lastEntryRemoved(); emit CoreManager::getInstance()->callLogsCountChanged(); emit focused();// Removing rows is like having focus. Don't wait asynchronous events. + emit layoutChanged(); return true; } @@ -235,7 +236,7 @@ void HistoryModel::insertCall (const shared_ptr &callLog) { }); int row = int(distance(mEntries.begin(), it)); - + emit layoutAboutToBeChanged(); beginInsertRows(QModelIndex(), row, row); it = mEntries.insert(it, entry); endInsertRows(); diff --git a/linphone-app/src/components/ldap/LdapListModel.cpp b/linphone-app/src/components/ldap/LdapListModel.cpp index 161e7382a..c11497d83 100644 --- a/linphone-app/src/components/ldap/LdapListModel.cpp +++ b/linphone-app/src/components/ldap/LdapListModel.cpp @@ -72,7 +72,6 @@ void LdapListModel::add(){ connect(ldap.get(), &LdapModel::indexChanged, this, &LdapListModel::indexChanged); ldap->init(); ProxyListModel::add(ldap); - emit layoutChanged(); } void LdapListModel::remove (LdapModel *ldap) { diff --git a/linphone-app/src/components/other/colors/ColorListModel.cpp b/linphone-app/src/components/other/colors/ColorListModel.cpp index a281b60fd..5fe0acee1 100644 --- a/linphone-app/src/components/other/colors/ColorListModel.cpp +++ b/linphone-app/src/components/other/colors/ColorListModel.cpp @@ -93,7 +93,6 @@ void ColorListModel::add(QSharedPointer color){ mData.insert(color->getName(), QVariant::fromValue(color.get())); ProxyListModel::add(color); - emit layoutChanged(); } QString ColorListModel::buildDescription(QString description){ diff --git a/linphone-app/src/components/other/images/ImageListModel.cpp b/linphone-app/src/components/other/images/ImageListModel.cpp index 944052752..86c959ad7 100644 --- a/linphone-app/src/components/other/images/ImageListModel.cpp +++ b/linphone-app/src/components/other/images/ImageListModel.cpp @@ -62,8 +62,6 @@ void ImageListModel::add(QSharedPointer image){ mData.insert(image->getId(), QVariant::fromValue(image.get())); ProxyListModel::add(image); - - emit layoutChanged(); } void ImageListModel::useConfig (const std::shared_ptr &config) { diff --git a/linphone-app/src/components/participant/ParticipantListModel.cpp b/linphone-app/src/components/participant/ParticipantListModel.cpp index 9a9389275..c06bb26f3 100644 --- a/linphone-app/src/components/participant/ParticipantListModel.cpp +++ b/linphone-app/src/components/participant/ParticipantListModel.cpp @@ -153,6 +153,8 @@ void ParticipantListModel::updateParticipants () { } if( itDbParticipant == dbParticipants.end()){ int row = itParticipant - mList.begin(); + if(!changed) + emit layoutAboutToBeChanged(); beginRemoveRows(QModelIndex(), row, row); itParticipant = mList.erase(itParticipant); endRemoveRows(); @@ -196,7 +198,6 @@ void ParticipantListModel::add (QSharedPointer participant){ connect(this, &ParticipantListModel::securityLevelChanged, participant.get(), &ParticipantModel::onSecurityLevelChanged); connect(participant.get(),&ParticipantModel::updateAdminStatus, this, &ParticipantListModel::setAdminStatus); ProxyListModel::add(participant); - emit layoutChanged(); emit participantsChanged(); } diff --git a/linphone-app/src/components/sip-addresses/SipAddressesModel.cpp b/linphone-app/src/components/sip-addresses/SipAddressesModel.cpp index c2fad8035..0d8c106b0 100644 --- a/linphone-app/src/components/sip-addresses/SipAddressesModel.cpp +++ b/linphone-app/src/components/sip-addresses/SipAddressesModel.cpp @@ -256,14 +256,14 @@ bool SipAddressesModel::removeRows (int row, int count, const QModelIndex &paren if (row < 0 || count < 0 || limit >= mRefs.count()) return false; - + emit layoutAboutToBeChanged(); beginRemoveRows(parent, row, limit); for (int i = 0; i < count; ++i) mPeerAddressToSipAddressEntry.remove(mRefs.takeAt(row)->sipAddress); endRemoveRows(); - + emit layoutChanged(); return true; } @@ -545,7 +545,7 @@ void SipAddressesModel::addOrUpdateSipAddress (const QString &sipAddress, T data addOrUpdateSipAddress(sipAddressEntry, data); int row = mRefs.count(); - + emit layoutAboutToBeChanged(); beginInsertRows(QModelIndex(), row, row); mPeerAddressToSipAddressEntry[sipAddress] = move(sipAddressEntry); diff --git a/linphone-app/src/components/timeline/TimelineListModel.cpp b/linphone-app/src/components/timeline/TimelineListModel.cpp index c181d7452..f68823ec9 100644 --- a/linphone-app/src/components/timeline/TimelineListModel.cpp +++ b/linphone-app/src/components/timeline/TimelineListModel.cpp @@ -105,7 +105,7 @@ bool TimelineListModel::removeRows (int row, int count, const QModelIndex &paren if (row < 0 || count < 0 || limit >= mList.count()) return false; - + emit layoutAboutToBeChanged(); beginRemoveRows(parent, row, limit); for (int i = 0; i < count; ++i){ @@ -122,6 +122,7 @@ bool TimelineListModel::removeRows (int row, int count, const QModelIndex &paren } emit countChanged(); + emit layoutChanged(); return true; } @@ -314,7 +315,6 @@ void TimelineListModel::add (QSharedPointer timeline){ connect(timeline.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onChatRoomDeleted); connect(chatRoomModel, &ChatRoomModel::lastUpdateTimeChanged, this, &TimelineListModel::updated); ProxyListModel::add(timeline); - emit layoutChanged(); emit countChanged(); } diff --git a/linphone-app/src/components/tunnel/TunnelConfigListModel.cpp b/linphone-app/src/components/tunnel/TunnelConfigListModel.cpp index d1e2cbffb..fc03f35aa 100644 --- a/linphone-app/src/components/tunnel/TunnelConfigListModel.cpp +++ b/linphone-app/src/components/tunnel/TunnelConfigListModel.cpp @@ -48,7 +48,6 @@ void TunnelConfigListModel::updateTunnelConfigs(std::shared_ptr::create(config); } endResetModel(); - emit layoutChanged(); } bool TunnelConfigListModel::apply(std::shared_ptr tunnel){ @@ -62,9 +61,11 @@ bool TunnelConfigListModel::apply(std::shared_ptr tunnel){ void TunnelConfigListModel::addTunnelConfig(){ int row = rowCount(); + emit layoutAboutToBeChanged(); beginInsertRows(QModelIndex(),row,row); mList << QSharedPointer::create(linphone::Factory::get()->createTunnelConfig()); endInsertRows(); + emit layoutChanged(); } void TunnelConfigListModel::removeTunnelConfig(std::shared_ptr tunnel, TunnelConfigModel * model){