From cae5372e978ced5ebc46eb252735a253924d6673 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Thu, 26 Dec 2024 17:58:52 +0100 Subject: [PATCH] fix #LINQT-1505 edit meeting start/end time --- .../core/conference/ConferenceInfoCore.cpp | 3 +++ .../core/conference/ConferenceInfoList.cpp | 19 ++++++++++++++++++- Linphone/core/proxy/ListProxy.cpp | 15 ++++++++------- .../view/Page/Form/Meeting/MeetingForm.qml | 12 +++++++++--- .../view/Page/Main/Meeting/MeetingPage.qml | 2 +- 5 files changed, 39 insertions(+), 12 deletions(-) diff --git a/Linphone/core/conference/ConferenceInfoCore.cpp b/Linphone/core/conference/ConferenceInfoCore.cpp index a3a57b4e1..cec0b7fc0 100644 --- a/Linphone/core/conference/ConferenceInfoCore.cpp +++ b/Linphone/core/conference/ConferenceInfoCore.cpp @@ -568,6 +568,9 @@ void ConferenceInfoCore::save() { thisCopy->writeIntoModel(mConferenceInfoModel); thisCopy->deleteLater(); mConferenceInfoModel->updateConferenceInfo(); + mConfInfoModelConnection->invokeToCore([this] { + undo(); // Reset new values because some values can be invalid and not changed. + }); }); } else { mCoreModelConnection->invokeToModel([this, thisCopy]() { diff --git a/Linphone/core/conference/ConferenceInfoList.cpp b/Linphone/core/conference/ConferenceInfoList.cpp index 2d717c6b1..b3535e164 100644 --- a/Linphone/core/conference/ConferenceInfoList.cpp +++ b/Linphone/core/conference/ConferenceInfoList.cpp @@ -218,11 +218,28 @@ ConferenceInfoList::build(const std::shared_ptr &confe } void ConferenceInfoList::connectItem(QSharedPointer confInfoCore) { - if (confInfoCore) + if (confInfoCore) { connect(confInfoCore.get(), &ConferenceInfoCore::removed, this, [this](ConferenceInfoCore *confInfo) { remove(confInfo); updateHaveCurrentDate(); }); + connect(confInfoCore.get(), &ConferenceInfoCore::dateTimeChanged, this, [this, confInfoCore]() { + int i = -1; + get(confInfoCore.get(), &i); + if (i != -1) { + auto modelIndex = index(i); + emit dataChanged(modelIndex, modelIndex); + } + }); + connect(confInfoCore.get(), &ConferenceInfoCore::endDateTimeChanged, this, [this, confInfoCore]() { + int i = -1; + get(confInfoCore.get(), &i); + if (i != -1) { + auto modelIndex = index(i); + emit dataChanged(modelIndex, modelIndex); + } + }); + } } QHash ConferenceInfoList::roleNames() const { diff --git a/Linphone/core/proxy/ListProxy.cpp b/Linphone/core/proxy/ListProxy.cpp index 311459ccf..c4acad1a7 100644 --- a/Linphone/core/proxy/ListProxy.cpp +++ b/Linphone/core/proxy/ListProxy.cpp @@ -31,13 +31,14 @@ ListProxy::~ListProxy() { } QSharedPointer ListProxy::get(QObject *itemToGet, int *index) const { - int row = 0; - for (auto item : mList) - if (item.get() == itemToGet) { - if (index) *index = row; - return item; - } else ++row; - return nullptr; + auto it = std::find(mList.begin(), mList.end(), itemToGet); + if (it != mList.end()) { + if (index != nullptr) *index = std::distance(mList.begin(), it); + return *it; + } else { + if (index != nullptr) *index = -1; + return nullptr; + } } // ----------------------------------------------------------------------------- diff --git a/Linphone/view/Page/Form/Meeting/MeetingForm.qml b/Linphone/view/Page/Form/Meeting/MeetingForm.qml index 86750eb6b..02179ac19 100644 --- a/Linphone/view/Page/Form/Meeting/MeetingForm.qml +++ b/Linphone/view/Page/Form/Meeting/MeetingForm.qml @@ -160,13 +160,15 @@ FocusScope { contentText.font.weight: (isCreation ? 700 : 400) * DefaultStyle.dp KeyNavigation.up: startDate KeyNavigation.down: timeZoneCbox - KeyNavigation.left: startDate + KeyNavigation.left: endHour KeyNavigation.right: endHour onSelectedDateTimeChanged: { + mainItem.conferenceInfoGui.core.dateTime = selectedDateTime endHour.minTime = selectedDateTime endHour.maxTime = UtilsCpp.createDateTime(selectedDateTime, 23, 59) - mainItem.conferenceInfoGui.core.dateTime = selectedDateTime - endHour.selectedDateTime = UtilsCpp.addSecs(selectedDateTime, 3600) + if (mainItem.isCreation) { + endHour.selectedDateTime = UtilsCpp.addSecs(selectedDateTime, 3600) + } } } TimeComboBox { @@ -177,6 +179,10 @@ FocusScope { background.visible: mainItem.isCreation contentText.font.weight: (isCreation ? 700 : 400) * DefaultStyle.dp onSelectedDateTimeChanged: mainItem.conferenceInfoGui.core.endDateTime = selectedDateTime + KeyNavigation.up: startDate + KeyNavigation.down: timeZoneCbox + KeyNavigation.left: startHour + KeyNavigation.right: startHour } Item { Layout.fillWidth: true diff --git a/Linphone/view/Page/Main/Meeting/MeetingPage.qml b/Linphone/view/Page/Main/Meeting/MeetingPage.qml index b6698441d..22318eec2 100644 --- a/Linphone/view/Page/Main/Meeting/MeetingPage.qml +++ b/Linphone/view/Page/Main/Meeting/MeetingPage.qml @@ -401,7 +401,7 @@ AbstractMainPage { leftPadding: 12 * DefaultStyle.dp rightPadding: 12 * DefaultStyle.dp focus: true - text: qsTr("Save") + text: qsTr("Enregistrer") textSize: 13 * DefaultStyle.dp KeyNavigation.left: titleText KeyNavigation.right: backButton