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
This commit is contained in:
Gaelle Braud 2025-01-16 10:59:26 +01:00
parent 60182a8797
commit a4b7951b22
5 changed files with 33 additions and 27 deletions

View file

@ -86,7 +86,6 @@ ConferenceInfoCore::ConferenceInfoCore(std::shared_ptr<linphone::ConferenceInfo>
for (auto item : conferenceInfo->getParticipantInfos()) { for (auto item : conferenceInfo->getParticipantInfos()) {
QVariantMap participant; QVariantMap participant;
auto address = item->getAddress(); auto address = item->getAddress();
participant["displayName"] = ToolModel::getDisplayName(address);
participant["address"] = Utils::coreStringToAppString(address->asStringUriOnly()); participant["address"] = Utils::coreStringToAppString(address->asStringUriOnly());
participant["role"] = (int)LinphoneEnums::fromLinphone(item->getRole()); participant["role"] = (int)LinphoneEnums::fromLinphone(item->getRole());
mParticipants.append(participant); mParticipants.append(participant);
@ -221,6 +220,7 @@ void ConferenceInfoCore::setSelf(QSharedPointer<ConferenceInfoCore> me) {
mConfInfoModelConnection->makeConnectToModel( mConfInfoModelConnection->makeConnectToModel(
&ConferenceInfoModel::invitationsSent, &ConferenceInfoModel::invitationsSent,
[this](const std::list<std::shared_ptr<linphone::Address>> &failedInvitations) {}); [this](const std::list<std::shared_ptr<linphone::Address>> &failedInvitations) {});
} else { // Create } else { // Create
mCoreModelConnection = QSharedPointer<SafeConnection<ConferenceInfoCore, CoreModel>>( mCoreModelConnection = QSharedPointer<SafeConnection<ConferenceInfoCore, CoreModel>>(
new SafeConnection<ConferenceInfoCore, CoreModel>(me, CoreModel::getInstance()), &QObject::deleteLater); new SafeConnection<ConferenceInfoCore, CoreModel>(me, CoreModel::getInstance()), &QObject::deleteLater);
@ -382,13 +382,12 @@ int ConferenceInfoCore::getParticipantCount() const {
} }
void ConferenceInfoCore::addParticipant(const QString &address) { void ConferenceInfoCore::addParticipant(const QString &address) {
mustBeInMainThread(log().arg(Q_FUNC_INFO));
for (auto &participant : mParticipants) { for (auto &participant : mParticipants) {
auto map = participant.toMap(); auto map = participant.toMap();
if (map["address"].toString() == address) return; if (map["address"].toString() == address) return;
} }
QVariantMap participant; QVariantMap participant;
auto displayNameObj = Utils::getDisplayName(address);
participant["displayNameObj"] = QVariant::fromValue(displayNameObj);
participant["address"] = address; participant["address"] = address;
participant["role"] = (int)LinphoneEnums::ParticipantRole::Listener; participant["role"] = (int)LinphoneEnums::ParticipantRole::Listener;
mParticipants.append(participant); mParticipants.append(participant);
@ -396,6 +395,7 @@ void ConferenceInfoCore::addParticipant(const QString &address) {
} }
void ConferenceInfoCore::addParticipants(const QStringList &addresses) { void ConferenceInfoCore::addParticipants(const QStringList &addresses) {
mustBeInMainThread(log().arg(Q_FUNC_INFO));
bool addressAdded = false; bool addressAdded = false;
for (auto &address : addresses) { for (auto &address : addresses) {
auto found = std::find_if(mParticipants.begin(), mParticipants.end(), [address](QVariant participant) { 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()) { if (found == mParticipants.end()) {
QVariantMap participant; QVariantMap participant;
auto displayNameObj = Utils::getDisplayName(address);
participant["displayNameObj"] = QVariant::fromValue(displayNameObj);
participant["address"] = address; participant["address"] = address;
participant["role"] = (int)LinphoneEnums::ParticipantRole::Listener; participant["role"] = (int)LinphoneEnums::ParticipantRole::Listener;
mParticipants.append(participant); mParticipants.append(participant);
@ -446,12 +444,10 @@ void ConferenceInfoCore::resetParticipants(QVariantList participants) {
} }
void ConferenceInfoCore::resetParticipants(const QStringList &adresses) { void ConferenceInfoCore::resetParticipants(const QStringList &adresses) {
mustBeInMainThread(log().arg(Q_FUNC_INFO));
mParticipants.clear(); mParticipants.clear();
for (auto &address : adresses) { for (auto &address : adresses) {
QVariantMap participant; QVariantMap participant;
QString name;
auto displayNameObj = Utils::getDisplayName(address);
participant["displayNameObj"] = QVariant::fromValue(displayNameObj);
participant["address"] = address; participant["address"] = address;
participant["role"] = (int)LinphoneEnums::ParticipantRole::Listener; participant["role"] = (int)LinphoneEnums::ParticipantRole::Listener;
mParticipants.append(participant); mParticipants.append(participant);
@ -522,17 +518,25 @@ void ConferenceInfoCore::setConferenceSchedulerState(LinphoneEnums::ConferenceSc
void ConferenceInfoCore::writeFromModel(const std::shared_ptr<ConferenceInfoModel> &model) { void ConferenceInfoCore::writeFromModel(const std::shared_ptr<ConferenceInfoModel> &model) {
mustBeInLinphoneThread(getClassName() + "::writeFromModel()"); mustBeInLinphoneThread(getClassName() + "::writeFromModel()");
setDateTime(model->getDateTime()); mDateTime = model->getDateTime();
setDuration(model->getDuration()); mDuration = model->getDuration();
setSubject(model->getSubject()); mSubject = model->getSubject();
setOrganizerName(model->getOrganizerName()); mOrganizerName = model->getOrganizerName();
setOrganizerAddress(model->getOrganizerAddress()); mOrganizerAddress = model->getOrganizerAddress();
setDescription(model->getDescription()); mDescription = model->getDescription();
mParticipants.clear();
QStringList participantAddresses; QStringList participantAddresses;
for (auto &infos : model->getParticipantInfos()) { for (auto &infos : model->getParticipantInfos()) {
participantAddresses.append(Utils::coreStringToAppString(infos->getAddress()->asStringUriOnly())); 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<ConferenceInfoModel> model) { void ConferenceInfoCore::writeIntoModel(std::shared_ptr<ConferenceInfoModel> model) {

View file

@ -227,6 +227,7 @@ void ConferenceInfoList::connectItem(QSharedPointer<ConferenceInfoCore> confInfo
int i = -1; int i = -1;
get(confInfoCore.get(), &i); get(confInfoCore.get(), &i);
if (i != -1) { if (i != -1) {
updateHaveCurrentDate();
auto modelIndex = index(i); auto modelIndex = index(i);
emit confInfoUpdated(confInfoCore); emit confInfoUpdated(confInfoCore);
emit dataChanged(modelIndex, modelIndex); emit dataChanged(modelIndex, modelIndex);

View file

@ -103,7 +103,7 @@ ListView {
id: confInfoProxy id: confInfoProxy
filterText: searchBarText filterText: searchBarText
filterType: ConferenceInfoProxy.None filterType: ConferenceInfoProxy.None
initialDisplayItems: 2 * mainItem.height / (63 * DefaultStyle.dp) initialDisplayItems: Math.max(20, 2 * mainItem.height / (63 * DefaultStyle.dp))
displayItemsStep: initialDisplayItems/2 displayItemsStep: initialDisplayItems/2
function selectData(confInfoGui){ function selectData(confInfoGui){
mainItem.currentIndex = loadUntil(confInfoGui) mainItem.currentIndex = loadUntil(confInfoGui)

View file

@ -12,8 +12,6 @@ FocusScope {
property bool isCreation property bool isCreation
property ConferenceInfoGui conferenceInfoGui property ConferenceInfoGui conferenceInfoGui
signal addParticipantsRequested() signal addParticipantsRequested()
signal returnRequested()
signal saveSucceed(bool isCreation)
ColumnLayout { ColumnLayout {
id: formLayout id: formLayout
@ -287,7 +285,8 @@ FocusScope {
_address: modelData.address _address: modelData.address
} }
Text { Text {
text: modelData.displayName || modelData.displayNameObj?.value || "" property var displayNameObj: UtilsCpp.getDisplayName(modelData.address)
text: displayNameObj?.value || ""
font.pixelSize: 14 * DefaultStyle.dp font.pixelSize: 14 * DefaultStyle.dp
font.capitalization: Font.Capitalize font.capitalization: Font.Capitalize
} }

View file

@ -48,7 +48,7 @@ AbstractMainPage {
onSelectedConferenceChanged: { onSelectedConferenceChanged: {
// While a conference is being edited, we need to stay on the edit page // 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() overridenRightPanelStackView.clear()
if (selectedConference && selectedConference.core && selectedConference.core.haveModel) { if (selectedConference && selectedConference.core && selectedConference.core.haveModel) {
if (!overridenRightPanelStackView.currentItem || overridenRightPanelStackView.currentItem != meetingDetail) overridenRightPanelStackView.replace(meetingDetail, Control.StackView.Immediate) if (!overridenRightPanelStackView.currentItem || overridenRightPanelStackView.currentItem != meetingDetail) overridenRightPanelStackView.replace(meetingDetail, Control.StackView.Immediate)
@ -212,6 +212,7 @@ AbstractMainPage {
id: createConf id: createConf
FocusScope{ FocusScope{
id: createConfLayout id: createConfLayout
objectName: "createConf"
property ConferenceInfoGui conferenceInfoGui property ConferenceInfoGui conferenceInfoGui
property bool isCreation property bool isCreation
ColumnLayout { ColumnLayout {
@ -278,7 +279,12 @@ AbstractMainPage {
target: meetingSetup.conferenceInfoGui ? meetingSetup.conferenceInfoGui.core : null target: meetingSetup.conferenceInfoGui ? meetingSetup.conferenceInfoGui.core : null
function onConferenceSchedulerStateChanged() { function onConferenceSchedulerStateChanged() {
var mainWin = UtilsCpp.getMainWindow() 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) { || meetingSetup.conferenceInfoGui.core.schedulerState == LinphoneEnums.ConferenceSchedulerState.Updating) {
mainWin.showLoadingPopup(qsTr("Création de la réunion en cours..."), true, function () { mainWin.showLoadingPopup(qsTr("Création de la réunion en cours..."), true, function () {
leftPanelStackView.pop() leftPanelStackView.pop()
@ -296,11 +302,6 @@ AbstractMainPage {
mainWin.closeLoadingPopup() mainWin.closeLoadingPopup()
} }
} }
onSaveSucceed: {
leftPanelStackView.pop()
UtilsCpp.showInformationPopup(qsTr("Nouvelle réunion"), qsTr("Réunion planifiée avec succès"), true)
mainWindow.closeLoadingPopup()
}
onAddParticipantsRequested: { onAddParticipantsRequested: {
leftPanelStackView.push(addParticipants, {"conferenceInfoGui": conferenceInfoGui, "container": leftPanelStackView}) leftPanelStackView.push(addParticipants, {"conferenceInfoGui": conferenceInfoGui, "container": leftPanelStackView})
} }
@ -763,7 +764,8 @@ AbstractMainPage {
_address: modelData.address _address: modelData.address
} }
Text { Text {
text: modelData.displayName || modelData.displayNameObj?.value || "" property var displayNameObj: UtilsCpp.getDisplayName(modelData.address)
text: displayNameObj?.value || ""
maximumLineCount: 1 maximumLineCount: 1
Layout.fillWidth: true Layout.fillWidth: true
font { font {