fix #LINQT-1505 edit meeting start/end time

This commit is contained in:
Gaelle Braud 2024-12-26 17:58:52 +01:00
parent d425a3dfe8
commit cae5372e97
5 changed files with 39 additions and 12 deletions

View file

@ -568,6 +568,9 @@ void ConferenceInfoCore::save() {
thisCopy->writeIntoModel(mConferenceInfoModel); thisCopy->writeIntoModel(mConferenceInfoModel);
thisCopy->deleteLater(); thisCopy->deleteLater();
mConferenceInfoModel->updateConferenceInfo(); mConferenceInfoModel->updateConferenceInfo();
mConfInfoModelConnection->invokeToCore([this] {
undo(); // Reset new values because some values can be invalid and not changed.
});
}); });
} else { } else {
mCoreModelConnection->invokeToModel([this, thisCopy]() { mCoreModelConnection->invokeToModel([this, thisCopy]() {

View file

@ -218,11 +218,28 @@ ConferenceInfoList::build(const std::shared_ptr<linphone::ConferenceInfo> &confe
} }
void ConferenceInfoList::connectItem(QSharedPointer<ConferenceInfoCore> confInfoCore) { void ConferenceInfoList::connectItem(QSharedPointer<ConferenceInfoCore> confInfoCore) {
if (confInfoCore) if (confInfoCore) {
connect(confInfoCore.get(), &ConferenceInfoCore::removed, this, [this](ConferenceInfoCore *confInfo) { connect(confInfoCore.get(), &ConferenceInfoCore::removed, this, [this](ConferenceInfoCore *confInfo) {
remove(confInfo); remove(confInfo);
updateHaveCurrentDate(); 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<int, QByteArray> ConferenceInfoList::roleNames() const { QHash<int, QByteArray> ConferenceInfoList::roleNames() const {

View file

@ -31,13 +31,14 @@ ListProxy::~ListProxy() {
} }
QSharedPointer<QObject> ListProxy::get(QObject *itemToGet, int *index) const { QSharedPointer<QObject> ListProxy::get(QObject *itemToGet, int *index) const {
int row = 0; auto it = std::find(mList.begin(), mList.end(), itemToGet);
for (auto item : mList) if (it != mList.end()) {
if (item.get() == itemToGet) { if (index != nullptr) *index = std::distance(mList.begin(), it);
if (index) *index = row; return *it;
return item; } else {
} else ++row; if (index != nullptr) *index = -1;
return nullptr; return nullptr;
}
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View file

@ -160,13 +160,15 @@ FocusScope {
contentText.font.weight: (isCreation ? 700 : 400) * DefaultStyle.dp contentText.font.weight: (isCreation ? 700 : 400) * DefaultStyle.dp
KeyNavigation.up: startDate KeyNavigation.up: startDate
KeyNavigation.down: timeZoneCbox KeyNavigation.down: timeZoneCbox
KeyNavigation.left: startDate KeyNavigation.left: endHour
KeyNavigation.right: endHour KeyNavigation.right: endHour
onSelectedDateTimeChanged: { onSelectedDateTimeChanged: {
mainItem.conferenceInfoGui.core.dateTime = selectedDateTime
endHour.minTime = selectedDateTime endHour.minTime = selectedDateTime
endHour.maxTime = UtilsCpp.createDateTime(selectedDateTime, 23, 59) endHour.maxTime = UtilsCpp.createDateTime(selectedDateTime, 23, 59)
mainItem.conferenceInfoGui.core.dateTime = selectedDateTime if (mainItem.isCreation) {
endHour.selectedDateTime = UtilsCpp.addSecs(selectedDateTime, 3600) endHour.selectedDateTime = UtilsCpp.addSecs(selectedDateTime, 3600)
}
} }
} }
TimeComboBox { TimeComboBox {
@ -177,6 +179,10 @@ FocusScope {
background.visible: mainItem.isCreation background.visible: mainItem.isCreation
contentText.font.weight: (isCreation ? 700 : 400) * DefaultStyle.dp contentText.font.weight: (isCreation ? 700 : 400) * DefaultStyle.dp
onSelectedDateTimeChanged: mainItem.conferenceInfoGui.core.endDateTime = selectedDateTime onSelectedDateTimeChanged: mainItem.conferenceInfoGui.core.endDateTime = selectedDateTime
KeyNavigation.up: startDate
KeyNavigation.down: timeZoneCbox
KeyNavigation.left: startHour
KeyNavigation.right: startHour
} }
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true

View file

@ -401,7 +401,7 @@ AbstractMainPage {
leftPadding: 12 * DefaultStyle.dp leftPadding: 12 * DefaultStyle.dp
rightPadding: 12 * DefaultStyle.dp rightPadding: 12 * DefaultStyle.dp
focus: true focus: true
text: qsTr("Save") text: qsTr("Enregistrer")
textSize: 13 * DefaultStyle.dp textSize: 13 * DefaultStyle.dp
KeyNavigation.left: titleText KeyNavigation.left: titleText
KeyNavigation.right: backButton KeyNavigation.right: backButton