From a4b7951b223421ff2078741d6b7d832b4d8e5df1 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Thu, 16 Jan 2025 10:59:26 +0100 Subject: [PATCH] fix meeting creation fix wrong thread conference info write from model fix #LINQT-1563 update dummy item on conf info date modif fix variant object ownership fix initaldisplayitems --- .../core/conference/ConferenceInfoCore.cpp | 34 +++++++++++-------- .../core/conference/ConferenceInfoList.cpp | 1 + .../Display/Meeting/MeetingListView.qml | 2 +- .../view/Page/Form/Meeting/MeetingForm.qml | 5 ++- .../view/Page/Main/Meeting/MeetingPage.qml | 18 +++++----- 5 files changed, 33 insertions(+), 27 deletions(-) diff --git a/Linphone/core/conference/ConferenceInfoCore.cpp b/Linphone/core/conference/ConferenceInfoCore.cpp index a3fa4eb6..e725b923 100644 --- a/Linphone/core/conference/ConferenceInfoCore.cpp +++ b/Linphone/core/conference/ConferenceInfoCore.cpp @@ -86,7 +86,6 @@ ConferenceInfoCore::ConferenceInfoCore(std::shared_ptr for (auto item : conferenceInfo->getParticipantInfos()) { QVariantMap participant; auto address = item->getAddress(); - participant["displayName"] = ToolModel::getDisplayName(address); participant["address"] = Utils::coreStringToAppString(address->asStringUriOnly()); participant["role"] = (int)LinphoneEnums::fromLinphone(item->getRole()); mParticipants.append(participant); @@ -221,6 +220,7 @@ void ConferenceInfoCore::setSelf(QSharedPointer me) { mConfInfoModelConnection->makeConnectToModel( &ConferenceInfoModel::invitationsSent, [this](const std::list> &failedInvitations) {}); + } else { // Create mCoreModelConnection = QSharedPointer>( new SafeConnection(me, CoreModel::getInstance()), &QObject::deleteLater); @@ -382,13 +382,12 @@ int ConferenceInfoCore::getParticipantCount() const { } void ConferenceInfoCore::addParticipant(const QString &address) { + mustBeInMainThread(log().arg(Q_FUNC_INFO)); for (auto &participant : mParticipants) { auto map = participant.toMap(); if (map["address"].toString() == address) return; } QVariantMap participant; - auto displayNameObj = Utils::getDisplayName(address); - participant["displayNameObj"] = QVariant::fromValue(displayNameObj); participant["address"] = address; participant["role"] = (int)LinphoneEnums::ParticipantRole::Listener; mParticipants.append(participant); @@ -396,6 +395,7 @@ void ConferenceInfoCore::addParticipant(const QString &address) { } void ConferenceInfoCore::addParticipants(const QStringList &addresses) { + mustBeInMainThread(log().arg(Q_FUNC_INFO)); bool addressAdded = false; for (auto &address : addresses) { auto found = std::find_if(mParticipants.begin(), mParticipants.end(), [address](QVariant participant) { @@ -403,8 +403,6 @@ void ConferenceInfoCore::addParticipants(const QStringList &addresses) { }); if (found == mParticipants.end()) { QVariantMap participant; - auto displayNameObj = Utils::getDisplayName(address); - participant["displayNameObj"] = QVariant::fromValue(displayNameObj); participant["address"] = address; participant["role"] = (int)LinphoneEnums::ParticipantRole::Listener; mParticipants.append(participant); @@ -446,12 +444,10 @@ void ConferenceInfoCore::resetParticipants(QVariantList participants) { } void ConferenceInfoCore::resetParticipants(const QStringList &adresses) { + mustBeInMainThread(log().arg(Q_FUNC_INFO)); mParticipants.clear(); for (auto &address : adresses) { QVariantMap participant; - QString name; - auto displayNameObj = Utils::getDisplayName(address); - participant["displayNameObj"] = QVariant::fromValue(displayNameObj); participant["address"] = address; participant["role"] = (int)LinphoneEnums::ParticipantRole::Listener; mParticipants.append(participant); @@ -522,17 +518,25 @@ void ConferenceInfoCore::setConferenceSchedulerState(LinphoneEnums::ConferenceSc void ConferenceInfoCore::writeFromModel(const std::shared_ptr &model) { mustBeInLinphoneThread(getClassName() + "::writeFromModel()"); - setDateTime(model->getDateTime()); - setDuration(model->getDuration()); - setSubject(model->getSubject()); - setOrganizerName(model->getOrganizerName()); - setOrganizerAddress(model->getOrganizerAddress()); - setDescription(model->getDescription()); + mDateTime = model->getDateTime(); + mDuration = model->getDuration(); + mSubject = model->getSubject(); + mOrganizerName = model->getOrganizerName(); + mOrganizerAddress = model->getOrganizerAddress(); + mDescription = model->getDescription(); + mParticipants.clear(); QStringList participantAddresses; for (auto &infos : model->getParticipantInfos()) { participantAddresses.append(Utils::coreStringToAppString(infos->getAddress()->asStringUriOnly())); } - resetParticipants(participantAddresses); + mConfInfoModelConnection->invokeToModel([this, participantAddresses]() { // Copy values to avoid concurrency + for (auto &address : participantAddresses) { + QVariantMap participant; + participant["address"] = address; + participant["role"] = (int)LinphoneEnums::ParticipantRole::Listener; + mParticipants.append(participant); + } + }); } void ConferenceInfoCore::writeIntoModel(std::shared_ptr model) { diff --git a/Linphone/core/conference/ConferenceInfoList.cpp b/Linphone/core/conference/ConferenceInfoList.cpp index 457be092..37d93a74 100644 --- a/Linphone/core/conference/ConferenceInfoList.cpp +++ b/Linphone/core/conference/ConferenceInfoList.cpp @@ -227,6 +227,7 @@ void ConferenceInfoList::connectItem(QSharedPointer confInfo int i = -1; get(confInfoCore.get(), &i); if (i != -1) { + updateHaveCurrentDate(); auto modelIndex = index(i); emit confInfoUpdated(confInfoCore); emit dataChanged(modelIndex, modelIndex); diff --git a/Linphone/view/Control/Display/Meeting/MeetingListView.qml b/Linphone/view/Control/Display/Meeting/MeetingListView.qml index 45a149a3..8fab89df 100644 --- a/Linphone/view/Control/Display/Meeting/MeetingListView.qml +++ b/Linphone/view/Control/Display/Meeting/MeetingListView.qml @@ -103,7 +103,7 @@ ListView { id: confInfoProxy filterText: searchBarText filterType: ConferenceInfoProxy.None - initialDisplayItems: 2 * mainItem.height / (63 * DefaultStyle.dp) + initialDisplayItems: Math.max(20, 2 * mainItem.height / (63 * DefaultStyle.dp)) displayItemsStep: initialDisplayItems/2 function selectData(confInfoGui){ mainItem.currentIndex = loadUntil(confInfoGui) diff --git a/Linphone/view/Page/Form/Meeting/MeetingForm.qml b/Linphone/view/Page/Form/Meeting/MeetingForm.qml index 59d60068..31c3d064 100644 --- a/Linphone/view/Page/Form/Meeting/MeetingForm.qml +++ b/Linphone/view/Page/Form/Meeting/MeetingForm.qml @@ -12,8 +12,6 @@ FocusScope { property bool isCreation property ConferenceInfoGui conferenceInfoGui signal addParticipantsRequested() - signal returnRequested() - signal saveSucceed(bool isCreation) ColumnLayout { id: formLayout @@ -287,7 +285,8 @@ FocusScope { _address: modelData.address } Text { - text: modelData.displayName || modelData.displayNameObj?.value || "" + property var displayNameObj: UtilsCpp.getDisplayName(modelData.address) + text: displayNameObj?.value || "" font.pixelSize: 14 * DefaultStyle.dp font.capitalization: Font.Capitalize } diff --git a/Linphone/view/Page/Main/Meeting/MeetingPage.qml b/Linphone/view/Page/Main/Meeting/MeetingPage.qml index 444d6312..f4ee4d39 100644 --- a/Linphone/view/Page/Main/Meeting/MeetingPage.qml +++ b/Linphone/view/Page/Main/Meeting/MeetingPage.qml @@ -48,7 +48,7 @@ AbstractMainPage { onSelectedConferenceChanged: { // While a conference is being edited, we need to stay on the edit page - if (overridenRightPanelStackView.currentItem && overridenRightPanelStackView.currentItem.objectName === "editConf") return + if (overridenRightPanelStackView.currentItem && (overridenRightPanelStackView.currentItem.objectName === "editConf" || overridenRightPanelStackView.currentItem.objectName === "createConf")) return overridenRightPanelStackView.clear() if (selectedConference && selectedConference.core && selectedConference.core.haveModel) { if (!overridenRightPanelStackView.currentItem || overridenRightPanelStackView.currentItem != meetingDetail) overridenRightPanelStackView.replace(meetingDetail, Control.StackView.Immediate) @@ -212,6 +212,7 @@ AbstractMainPage { id: createConf FocusScope{ id: createConfLayout + objectName: "createConf" property ConferenceInfoGui conferenceInfoGui property bool isCreation ColumnLayout { @@ -278,7 +279,12 @@ AbstractMainPage { target: meetingSetup.conferenceInfoGui ? meetingSetup.conferenceInfoGui.core : null function onConferenceSchedulerStateChanged() { var mainWin = UtilsCpp.getMainWindow() - if (meetingSetup.conferenceInfoGui.core.schedulerState == LinphoneEnums.ConferenceSchedulerState.AllocationPending + if (meetingSetup.conferenceInfoGui.core.schedulerState == LinphoneEnums.ConferenceSchedulerState.Ready) { + leftPanelStackView.pop() + UtilsCpp.showInformationPopup(qsTr("Nouvelle réunion"), qsTr("Réunion planifiée avec succès"), true) + mainWindow.closeLoadingPopup() + } + else if (meetingSetup.conferenceInfoGui.core.schedulerState == LinphoneEnums.ConferenceSchedulerState.AllocationPending || meetingSetup.conferenceInfoGui.core.schedulerState == LinphoneEnums.ConferenceSchedulerState.Updating) { mainWin.showLoadingPopup(qsTr("Création de la réunion en cours..."), true, function () { leftPanelStackView.pop() @@ -296,11 +302,6 @@ AbstractMainPage { mainWin.closeLoadingPopup() } } - onSaveSucceed: { - leftPanelStackView.pop() - UtilsCpp.showInformationPopup(qsTr("Nouvelle réunion"), qsTr("Réunion planifiée avec succès"), true) - mainWindow.closeLoadingPopup() - } onAddParticipantsRequested: { leftPanelStackView.push(addParticipants, {"conferenceInfoGui": conferenceInfoGui, "container": leftPanelStackView}) } @@ -763,7 +764,8 @@ AbstractMainPage { _address: modelData.address } Text { - text: modelData.displayName || modelData.displayNameObj?.value || "" + property var displayNameObj: UtilsCpp.getDisplayName(modelData.address) + text: displayNameObj?.value || "" maximumLineCount: 1 Layout.fillWidth: true font {