diff --git a/linphone-app/src/app/proxyModel/ProxyAbstractListModel.hpp b/linphone-app/src/app/proxyModel/ProxyAbstractListModel.hpp index a959b1147..22254aea7 100644 --- a/linphone-app/src/app/proxyModel/ProxyAbstractListModel.hpp +++ b/linphone-app/src/app/proxyModel/ProxyAbstractListModel.hpp @@ -69,12 +69,14 @@ public: emit dataChanged(lastIndex,lastIndex ); } virtual void add(QList items){ - auto firstIndex = index(mList.size()-1,0); - beginInsertRows(QModelIndex(), mList.size(), mList.size() + items.size()-1); - mList << items; - endInsertRows(); - auto lastIndex = index(mList.size()-1,0); - emit dataChanged(firstIndex,lastIndex); + if(items.size() > 0) { + QModelIndex firstIndex = mList.size() > 0 ? index(mList.size()-1,0) : index(0,0); + beginInsertRows(QModelIndex(), mList.size(), mList.size() + items.size()-1); + mList << items; + endInsertRows(); + auto lastIndex = index(mList.size()-1,0); + emit dataChanged(firstIndex,lastIndex); + } } virtual void prepend(T item){ @@ -85,11 +87,13 @@ public: } virtual void prepend(QList items){ - beginInsertRows(QModelIndex(), 0, items.size()-1); - items << mList; - mList = items; - endInsertRows(); - emit dataChanged(index(0),index(items.size()-1)); + if(items.size() > 0){ + beginInsertRows(QModelIndex(), 0, items.size()-1); + items << mList; + mList = items; + endInsertRows(); + emit dataChanged(index(0),index(items.size()-1)); + } } // Remove functions diff --git a/linphone-app/src/app/proxyModel/ProxyListModel.hpp b/linphone-app/src/app/proxyModel/ProxyListModel.hpp index 608ee4fef..1cfd78f1e 100644 --- a/linphone-app/src/app/proxyModel/ProxyListModel.hpp +++ b/linphone-app/src/app/proxyModel/ProxyListModel.hpp @@ -65,13 +65,15 @@ public: template void add(QList> items){ - auto firstIndex = index(mList.size()-1,0); - beginInsertRows(QModelIndex(), mList.size(), mList.size() + items.size() - 1); - for(auto i : items) - mList << i.template objectCast(); - endInsertRows(); - auto lastIndex = index(mList.size()-1,0); - emit dataChanged(firstIndex,lastIndex); + if(items.size() > 0){ + QModelIndex firstIndex = mList.size() > 0 ? index(mList.size()-1,0) : index(0,0); + beginInsertRows(QModelIndex(), mList.size(), mList.size() + items.size() - 1); + for(auto i : items) + mList << i.template objectCast(); + endInsertRows(); + auto lastIndex = index(mList.size()-1,0); + emit dataChanged(firstIndex,lastIndex); + } } template @@ -81,11 +83,13 @@ public: template void prepend(QList> items){ - beginInsertRows(QModelIndex(), 0, items.size()-1); - items << mList; - mList = items; - endInsertRows(); - emit dataChanged(index(0),index(items.size()-1)); + if(items.size() > 0){ + beginInsertRows(QModelIndex(), 0, items.size()-1); + items << mList; + mList = items; + endInsertRows(); + emit dataChanged(index(0),index(items.size()-1)); + } } virtual bool remove(QObject *itemToRemove) override{ diff --git a/linphone-app/src/components/settings/AccountSettingsModel.cpp b/linphone-app/src/components/settings/AccountSettingsModel.cpp index 4c74d2bc6..c4b9bc53b 100644 --- a/linphone-app/src/components/settings/AccountSettingsModel.cpp +++ b/linphone-app/src/components/settings/AccountSettingsModel.cpp @@ -282,7 +282,7 @@ void AccountSettingsModel::removeAccount (const shared_ptr &a } // "message-expires" is used to keep contact for messages. Setting to 0 will remove the contact for messages too. // Check if a "message-expires" exists and set it to 0 - QStringList parameters = Utils::coreStringToAppString(account->getParams()->getContactParameters()).split(";"); + QStringList parameters = Utils::coreStringToAppString(account->getParams()->getContactParameters()).split(";", Qt::SkipEmptyParts); for(int i = 0 ; i < parameters.size() ; ++i){ QStringList fields = parameters[i].split("="); if( fields.size() > 1 && fields[0].simplified() == "message-expires"){ @@ -352,13 +352,38 @@ bool AccountSettingsModel::addOrUpdateAccount( txt = data["videoConferenceUri"].toString(); accountParams->setAudioVideoConferenceFactoryAddress(Utils::interpretUrl(txt)); accountParams->setLimeServerUrl(Utils::appStringToCoreString(data["limeServerUrl"].toString())); - + + QString contactParameters = Utils::coreStringToAppString(accountParams->getContactParameters()); if(data.contains("contactParams")) - accountParams->setContactParameters(Utils::appStringToCoreString(data["contactParams"].toString())); + contactParameters = data["contactParams"].toString(); if(data.contains("avpfInterval")) accountParams->setAvpfRrInterval(uint8_t(data["avpfInterval"].toInt())); - if(data.contains("registerEnabled")) - accountParams->enableRegister(data["registerEnabled"].toBool()); + if(data.contains("registerEnabled")){ + bool registerEnabled = data["registerEnabled"].toBool(); + + bool findMessageExpires = false; + QStringList parameters = contactParameters.split(";", Qt::SkipEmptyParts); + for(int i = 0 ; i < parameters.size() ; ++i){ + QStringList fields = parameters[i].split("="); + if( fields.size() > 1 && fields[0].simplified() == "message-expires"){ + findMessageExpires = true; + if(!registerEnabled)// replace message-expires by 0 in order to not get new incoming messages. + parameters[i] = Constants::DefaultContactParametersOnRemove; + else if(!accountParams->registerEnabled() && fields[1].toInt() == 0) + parameters[i] = Constants::DefaultContactParameters; + } + } + if(!findMessageExpires){ + if(!registerEnabled)// message-expires was not found we need to disable the account. + parameters.push_back(Constants::DefaultContactParametersOnRemove); + else if(!accountParams->registerEnabled())// Switch on + parameters.push_back(Constants::DefaultContactParameters); + } + accountParams->setContactParameters(Utils::appStringToCoreString(parameters.join(";"))); + accountParams->enableRegister(registerEnabled); + }else{ + accountParams->setContactParameters(Utils::appStringToCoreString(contactParameters)); + } if(data.contains("publishPresence")) { newPublishPresence = accountParams->publishEnabled() != data["publishPresence"].toBool(); accountParams->enablePublish(data["publishPresence"].toBool()); diff --git a/linphone-app/src/components/timeline/TimelineListModel.cpp b/linphone-app/src/components/timeline/TimelineListModel.cpp index 375d46269..0680b6ff2 100644 --- a/linphone-app/src/components/timeline/TimelineListModel.cpp +++ b/linphone-app/src/components/timeline/TimelineListModel.cpp @@ -45,7 +45,6 @@ TimelineListModel::TimelineListModel (QObject *parent) : ProxyListModel(parent) connect(coreHandlers, &CoreHandlers::chatRoomRead, this, &TimelineListModel::onChatRoomRead); connect(coreHandlers, &CoreHandlers::chatRoomStateChanged, this, &TimelineListModel::onChatRoomStateChanged); connect(coreHandlers, &CoreHandlers::messagesReceived, this, &TimelineListModel::update); - connect(coreHandlers, &CoreHandlers::messagesReceived, this, &TimelineListModel::updated); QObject::connect(coreHandlers, &CoreHandlers::callStateChanged, this, &TimelineListModel::onCallStateChanged); QObject::connect(coreHandlers, &CoreHandlers::callCreated, this, &TimelineListModel::onCallCreated); @@ -61,7 +60,6 @@ TimelineListModel::TimelineListModel(const TimelineListModel* model){ connect(coreHandlers, &CoreHandlers::chatRoomRead, this, &TimelineListModel::onChatRoomRead); connect(coreHandlers, &CoreHandlers::chatRoomStateChanged, this, &TimelineListModel::onChatRoomStateChanged); connect(coreHandlers, &CoreHandlers::messagesReceived, this, &TimelineListModel::update); - connect(coreHandlers, &CoreHandlers::messagesReceived, this, &TimelineListModel::updated); QObject::connect(coreHandlers, &CoreHandlers::callStateChanged, this, &TimelineListModel::onCallStateChanged); QObject::connect(coreHandlers, &CoreHandlers::callCreated, this, &TimelineListModel::onCallCreated); @@ -71,7 +69,8 @@ TimelineListModel::TimelineListModel(const TimelineListModel* model){ for(auto item : model->mList) { auto newItem = qobject_cast(item)->clone(); connect(newItem.get(), SIGNAL(selectedChanged(bool)), this, SLOT(onSelectedHasChanged(bool))); - connect(newItem.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onChatRoomDeleted); + connect(newItem.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onTimelineDeleted); + connect(newItem.get(), &TimelineModel::dataChanged, this, &TimelineListModel::onTimelineDataChanged); mList << newItem; } } @@ -325,7 +324,7 @@ void TimelineListModel::updateTimelines () { } } } - qInfo() << "Timelines adding :" << stepsTimer.restart() << "ms."; + qInfo() << "Timelines adding :" << stepsTimer.restart() << "ms for " << models.size() << " new timelines"; add(models); qInfo() << "Timelines adding GUI :" << stepsTimer.restart() << "ms."; CoreManager::getInstance()->updateUnreadMessageCount(); @@ -335,8 +334,9 @@ void TimelineListModel::updateTimelines () { void TimelineListModel::add (QSharedPointer timeline){ auto chatRoomModel = timeline->getChatRoomModel(); auto chatRoom = chatRoomModel->getChatRoom(); - connect(timeline.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onChatRoomDeleted); - connect(chatRoomModel, &ChatRoomModel::lastUpdateTimeChanged, this, &TimelineListModel::updated); + connect(timeline.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onTimelineDeleted); + connect(timeline.get(), &TimelineModel::dataChanged, this, &TimelineListModel::onTimelineDataChanged); + ProxyListModel::add(timeline); emit countChanged(); } @@ -345,11 +345,13 @@ void TimelineListModel::add (QList> timelines){ for(auto timeline : timelines){ auto chatRoomModel = timeline->getChatRoomModel(); auto chatRoom = chatRoomModel->getChatRoom(); - connect(timeline.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onChatRoomDeleted); - connect(chatRoomModel, &ChatRoomModel::lastUpdateTimeChanged, this, &TimelineListModel::updated); + connect(timeline.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onTimelineDeleted); + connect(timeline.get(), &TimelineModel::dataChanged, this, &TimelineListModel::onTimelineDataChanged); + } + if(timelines.size() > 0) { + ProxyListModel::add(timelines); + emit countChanged(); } - ProxyListModel::add(timelines); - emit countChanged(); } void TimelineListModel::removeChatRoomModel(QSharedPointer model){ @@ -467,6 +469,14 @@ void TimelineListModel::onCallCreated(const std::shared_ptr &cal } } -void TimelineListModel::onChatRoomDeleted(){ +void TimelineListModel::onTimelineDeleted(){ remove(sender());// This will call removeRows() } + +void TimelineListModel::onTimelineDataChanged(){ + int row = -1; + get(sender(), &row); + if(row >= 0){ + emit dataChanged(index(row),index(row)); + } +} \ No newline at end of file diff --git a/linphone-app/src/components/timeline/TimelineListModel.hpp b/linphone-app/src/components/timeline/TimelineListModel.hpp index 0fa8b490e..6a84005cd 100644 --- a/linphone-app/src/components/timeline/TimelineListModel.hpp +++ b/linphone-app/src/components/timeline/TimelineListModel.hpp @@ -67,13 +67,13 @@ public slots: void onChatRoomStateChanged(const std::shared_ptr &chatRoom,linphone::ChatRoom::State state); void onCallStateChanged (const std::shared_ptr &call, linphone::Call::State state) ; void onCallCreated(const std::shared_ptr &call); - void onChatRoomDeleted(); + void onTimelineDeleted(); + void onTimelineDataChanged(); signals: void countChanged(); void selectedCountChanged(int selectedCount); void selectedChanged(TimelineModel * timelineModel); - void updated(); private: virtual bool removeRows (int row, int count, const QModelIndex &parent) override; diff --git a/linphone-app/src/components/timeline/TimelineModel.cpp b/linphone-app/src/components/timeline/TimelineModel.cpp index 15ad1230a..e03d2b1e8 100644 --- a/linphone-app/src/components/timeline/TimelineModel.cpp +++ b/linphone-app/src/components/timeline/TimelineModel.cpp @@ -88,6 +88,7 @@ TimelineModel::TimelineModel (std::shared_ptr chatRoom, cons QObject::connect(CoreManager::getInstance()->getAccountSettingsModel(), &AccountSettingsModel::defaultAccountChanged, this, &TimelineModel::onDefaultAccountChanged); QObject::connect(mChatRoomModel.get(), &ChatRoomModel::chatRoomDeleted, this, &TimelineModel::onChatRoomDeleted); QObject::connect(mChatRoomModel.get(), &ChatRoomModel::updatingChanged, this, &TimelineModel::updatingChanged); + QObject::connect(mChatRoomModel.get(), &ChatRoomModel::lastUpdateTimeChanged, this, &TimelineModel::onChatRoomLastUpdateTimeChanged); QObject::connect(mChatRoomModel.get(), &ChatRoomModel::stateChanged, this, &TimelineModel::onChatRoomStateChanged); } if(chatRoom){ @@ -107,6 +108,7 @@ TimelineModel::TimelineModel(const TimelineModel * model){ QObject::connect(mChatRoomModel.get(), &ChatRoomModel::chatRoomDeleted, this, &TimelineModel::onChatRoomDeleted); QObject::connect(mChatRoomModel.get(), &ChatRoomModel::updatingChanged, this, &TimelineModel::updatingChanged); QObject::connect(mChatRoomModel.get(), &ChatRoomModel::stateChanged, this, &TimelineModel::onChatRoomStateChanged); + QObject::connect(mChatRoomModel.get(), &ChatRoomModel::lastUpdateTimeChanged, this, &TimelineModel::onChatRoomLastUpdateTimeChanged); } if(mChatRoomModel->getChatRoom()){ mChatRoomListener = model->mChatRoomListener; @@ -201,6 +203,10 @@ void TimelineModel::disconnectChatRoomListener(){ } } +void TimelineModel::onChatRoomLastUpdateTimeChanged(){ + emit dataChanged(); +} + //---------------------------------------------------------- //------ CHAT ROOM HANDLERS //---------------------------------------------------------- diff --git a/linphone-app/src/components/timeline/TimelineModel.hpp b/linphone-app/src/components/timeline/TimelineModel.hpp index 551c91792..5999ceeb4 100644 --- a/linphone-app/src/components/timeline/TimelineModel.hpp +++ b/linphone-app/src/components/timeline/TimelineModel.hpp @@ -108,6 +108,7 @@ public slots: void onDefaultAccountChanged(); void onChatRoomDeleted(); void onChatRoomStateChanged(); + void onChatRoomLastUpdateTimeChanged(); signals: void fullPeerAddressChanged(); @@ -118,8 +119,10 @@ signals: void selectedChanged(bool selected); void conferenceLeft(); void chatRoomDeleted(); + void dataChanged(); void updatingChanged(); + private: bool mDelaySelection = false; diff --git a/linphone-app/src/components/timeline/TimelineProxyModel.cpp b/linphone-app/src/components/timeline/TimelineProxyModel.cpp index d1fb22373..bc64484b2 100644 --- a/linphone-app/src/components/timeline/TimelineProxyModel.cpp +++ b/linphone-app/src/components/timeline/TimelineProxyModel.cpp @@ -75,7 +75,6 @@ void TimelineProxyModel::setListSource(const TimelineListSource& source){ model = source == Main ? CoreManager::getInstance()->getTimelineListModel() : CoreManager::getInstance()->getTimelineListModel()->clone(); connect(model, SIGNAL(selectedCountChanged(int)), this, SIGNAL(selectedCountChanged(int))); - connect(model, &TimelineListModel::updated, this, &TimelineProxyModel::invalidate); connect(model, &TimelineListModel::selectedChanged, this, &TimelineProxyModel::selectedChanged); connect(model, &TimelineListModel::countChanged, this, &TimelineProxyModel::countChanged); diff --git a/linphone-app/ui/modules/Linphone/Chat/ChatContent.qml b/linphone-app/ui/modules/Linphone/Chat/ChatContent.qml index 711d4b5ed..e5eec45e0 100644 --- a/linphone-app/ui/modules/Linphone/Chat/ChatContent.qml +++ b/linphone-app/ui/modules/Linphone/Chat/ChatContent.qml @@ -53,7 +53,7 @@ Loader{// Use of Loader because of Repeater (items cannot be loaded dynamically) sourceComponent: Component{ Column{ id: mainComponent - spacing: 0 + spacing: 5 padding: 10 function updateFilesBestWidth(){ var newBestWidth = 0 @@ -164,12 +164,14 @@ Loader{// Use of Loader because of Repeater (items cannot be loaded dynamically) chatMessageModel: mainItem.chatMessageModel } ChatFileMessage{ + id: fileMessage Layout.fillHeight: true Layout.fillWidth: true Layout.preferredHeight: fitHeight Layout.preferredWidth: fitWidth Layout.maximumWidth: fitWidth Layout.maximumHeight: fitHeight + Layout.alignment: Qt.AlignHCenter contentModel: $modelData onIsHoveringChanged: mainItem.isFileHoveringChanged(isHovering) borderWidth: mainItem.fileBorderWidth diff --git a/linphone-app/ui/views/App/Main/MainWindow.qml b/linphone-app/ui/views/App/Main/MainWindow.qml index e1af52017..9775b017f 100644 --- a/linphone-app/ui/views/App/Main/MainWindow.qml +++ b/linphone-app/ui/views/App/Main/MainWindow.qml @@ -366,6 +366,7 @@ ApplicationWindow { Layout.fillWidth: true model: TimelineProxyModel{ listSource: TimelineProxyModel.Main + onListSourceChanged: console.log("listSourceChanged") } onEntrySelected:{