fix #LINQT-1439 select new conf on created

This commit is contained in:
Gaelle Braud 2024-11-22 18:36:27 +01:00
parent 733702b781
commit 3863365863
10 changed files with 35 additions and 48 deletions

View file

@ -205,9 +205,10 @@ void ConferenceInfoCore::setSelf(QSharedPointer<ConferenceInfoCore> me) {
setConferenceInfoState(infoState); setConferenceInfoState(infoState);
if (state == LinphoneEnums::ConferenceSchedulerState::Ready) { if (state == LinphoneEnums::ConferenceSchedulerState::Ready) {
setUri(uri); setUri(uri);
mConfInfoModelConnection->invokeToModel([this, uri] { mConfInfoModelConnection->invokeToModel([this, uri, infoState] {
CoreModel::getInstance()->conferenceInfoCreated( if (infoState == LinphoneEnums::ConferenceInfoState::New)
mConferenceInfoModel->getConferenceInfo()); emit CoreModel::getInstance()->conferenceInfoCreated(
mConferenceInfoModel->getConferenceInfo());
}); });
} }
setConferenceSchedulerState(state); setConferenceSchedulerState(state);

View file

@ -62,12 +62,12 @@ void ConferenceInfoList::setSelf(QSharedPointer<ConferenceInfoList> me) {
defaultAccount->getConferenceInformationList(); defaultAccount->getConferenceInformationList();
items->push_back(nullptr); // Add Dummy conference for today items->push_back(nullptr); // Add Dummy conference for today
for (auto conferenceInfo : conferenceInfos) { for (auto conferenceInfo : conferenceInfos) {
auto confInfoCore = build(conferenceInfo);
// Cancelled conference organized ourself me must be hidden
if (conferenceInfo->getState() == linphone::ConferenceInfo::State::Cancelled) { if (conferenceInfo->getState() == linphone::ConferenceInfo::State::Cancelled) {
auto myAddress = defaultAccount->getContactAddress(); auto myAddress = defaultAccount->getContactAddress();
if (!myAddress || myAddress->weakEqual(conferenceInfo->getOrganizer())) continue; if (!myAddress || myAddress->weakEqual(conferenceInfo->getOrganizer())) continue;
} }
auto confInfoCore = build(conferenceInfo);
// Cancelled conference organized ourself me must be hidden
if (confInfoCore) { if (confInfoCore) {
qDebug() << log().arg("Add conf") << confInfoCore->getSubject() << "with state" qDebug() << log().arg("Add conf") << confInfoCore->getSubject() << "with state"
<< confInfoCore->getConferenceInfoState(); << confInfoCore->getConferenceInfoState();
@ -85,8 +85,6 @@ void ConferenceInfoList::setSelf(QSharedPointer<ConferenceInfoList> me) {
// TODO : uncomment when linphone conference scheduler updated // TODO : uncomment when linphone conference scheduler updated
// and model returns the scheduler conferenceInfo uri // and model returns the scheduler conferenceInfo uri
index = findConfInfoIndexByUri(mLastConfInfoInserted->getUri()); index = findConfInfoIndexByUri(mLastConfInfoInserted->getUri());
// int index2;
// get(mLastConfInfoInserted.get(), &index2);
if (index != -1) setCurrentDateIndex(index); if (index != -1) setCurrentDateIndex(index);
else setCurrentDateIndex(mHaveCurrentDate ? currentDateIndex : currentDateIndex + 1); else setCurrentDateIndex(mHaveCurrentDate ? currentDateIndex : currentDateIndex + 1);
mLastConfInfoInserted = nullptr; mLastConfInfoInserted = nullptr;
@ -113,7 +111,6 @@ void ConferenceInfoList::setSelf(QSharedPointer<ConferenceInfoList> me) {
mCoreModelConnection->makeConnectToModel(&CoreModel::defaultAccountChanged, connectModel); mCoreModelConnection->makeConnectToModel(&CoreModel::defaultAccountChanged, connectModel);
connectModel(); connectModel();
mCoreModelConnection->makeConnectToModel(&CoreModel::conferenceInfoReceived, &ConferenceInfoList::lUpdate);
mCoreModelConnection->makeConnectToModel( mCoreModelConnection->makeConnectToModel(
&CoreModel::conferenceInfoCreated, [this](const std::shared_ptr<linphone::ConferenceInfo> &confInfo) { &CoreModel::conferenceInfoCreated, [this](const std::shared_ptr<linphone::ConferenceInfo> &confInfo) {
auto confInfoCore = ConferenceInfoCore::create(confInfo); auto confInfoCore = ConferenceInfoCore::create(confInfo);
@ -132,8 +129,8 @@ void ConferenceInfoList::setSelf(QSharedPointer<ConferenceInfoList> me) {
&CoreModel::conferenceInfoReceived, &CoreModel::conferenceInfoReceived,
[this](const std::shared_ptr<linphone::Core> &core, [this](const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<const linphone::ConferenceInfo> &conferenceInfo) { const std::shared_ptr<const linphone::ConferenceInfo> &conferenceInfo) {
lDebug() << log().arg("conference info received") << conferenceInfo->getOrganizer()->asStringUriOnly() lDebug() << log().arg("conference info received") << conferenceInfo->getSubject();
<< conferenceInfo->getSubject(); emit lUpdate();
}); });
emit lUpdate(); emit lUpdate();
} }
@ -171,19 +168,18 @@ int ConferenceInfoList::getCurrentDateIndex() const {
} }
void ConferenceInfoList::setCurrentDateIndex(int index) { void ConferenceInfoList::setCurrentDateIndex(int index) {
if (mCurrentDateIndex != index) { mCurrentDateIndex = index;
mCurrentDateIndex = index; emit currentDateIndexChanged(index);
emit currentDateIndexChanged();
}
} }
int ConferenceInfoList::findConfInfoIndexByUri(const QString &uri) { int ConferenceInfoList::findConfInfoIndexByUri(const QString &uri) {
auto items = getSharedList<ConferenceInfoCore>(); auto confInList = std::find_if(mList.begin(), mList.end(), [uri](const QSharedPointer<QObject> &item) {
for (int i = 0; i < items.size(); ++i) { auto isConfInfo = item.objectCast<ConferenceInfoCore>();
if (!items[i]) continue; if (!isConfInfo) return false;
if (items[i]->getUri() == uri) return i; return isConfInfo->getUri() == uri;
} });
return -1;
return (confInList == mList.end() ? -1 : std::distance(mList.begin(), confInList));
} }
QSharedPointer<ConferenceInfoCore> QSharedPointer<ConferenceInfoCore>

View file

@ -61,7 +61,7 @@ signals:
void lUpdate(); void lUpdate();
void addCurrentDateChanged(); void addCurrentDateChanged();
void haveCurrentDateChanged(); void haveCurrentDateChanged();
void currentDateIndexChanged(); void currentDateIndexChanged(int index);
private: private:
QSharedPointer<SafeConnection<ConferenceInfoList, CoreModel>> mCoreModelConnection; QSharedPointer<SafeConnection<ConferenceInfoList, CoreModel>> mCoreModelConnection;

View file

@ -57,10 +57,8 @@ int ConferenceInfoProxy::getCurrentDateIndex() const {
void ConferenceInfoProxy::updateCurrentDateIndex() { void ConferenceInfoProxy::updateCurrentDateIndex() {
int newIndex = mapFromSource(sourceModel()->index(mList->getCurrentDateIndex(), 0)).row(); int newIndex = mapFromSource(sourceModel()->index(mList->getCurrentDateIndex(), 0)).row();
if (mCurrentDateIndex != newIndex) { mCurrentDateIndex = newIndex;
mCurrentDateIndex = newIndex; emit currentDateIndexChanged(newIndex);
emit currentDateIndexChanged();
}
} }
bool ConferenceInfoProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { bool ConferenceInfoProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {

View file

@ -48,7 +48,7 @@ public:
signals: signals:
void haveCurrentDateChanged(); void haveCurrentDateChanged();
void currentDateIndexChanged(); void currentDateIndexChanged(int index);
private: private:
QSharedPointer<ConferenceInfoList> mList; QSharedPointer<ConferenceInfoList> mList;

View file

@ -41,10 +41,6 @@ ConferenceInfoModel::~ConferenceInfoModel() {
if (mConferenceSchedulerModel) mConferenceSchedulerModel->removeListener(); if (mConferenceSchedulerModel) mConferenceSchedulerModel->removeListener();
} }
void ConferenceInfoModel::createConferenceScheduler() {
mustBeInLinphoneThread(getClassName() + "::createConferenceScheduler()");
}
std::shared_ptr<linphone::ConferenceInfo> ConferenceInfoModel::getConferenceInfo() const { std::shared_ptr<linphone::ConferenceInfo> ConferenceInfoModel::getConferenceInfo() const {
return mConferenceInfo; return mConferenceInfo;
} }
@ -64,6 +60,8 @@ void ConferenceInfoModel::setConferenceScheduler(const std::shared_ptr<Conferenc
mConferenceSchedulerModel = model; mConferenceSchedulerModel = model;
connect(mConferenceSchedulerModel.get(), &ConferenceSchedulerModel::stateChanged, connect(mConferenceSchedulerModel.get(), &ConferenceSchedulerModel::stateChanged,
[this](linphone::ConferenceScheduler::State state) { [this](linphone::ConferenceScheduler::State state) {
if (mConferenceSchedulerModel->getConferenceInfo())
mConferenceInfo = mConferenceSchedulerModel->getConferenceInfo()->clone();
if (state == linphone::ConferenceScheduler::State::Ready && mInviteEnabled) { if (state == linphone::ConferenceScheduler::State::Ready && mInviteEnabled) {
auto params = CoreModel::getInstance()->getCore()->createDefaultChatRoomParams(); auto params = CoreModel::getInstance()->getCore()->createDefaultChatRoomParams();
// TODO : wait for new sdk api to send the invitations again // TODO : wait for new sdk api to send the invitations again

View file

@ -34,8 +34,6 @@ public:
ConferenceInfoModel(const std::shared_ptr<linphone::ConferenceInfo> &conferenceInfo, QObject *parent = nullptr); ConferenceInfoModel(const std::shared_ptr<linphone::ConferenceInfo> &conferenceInfo, QObject *parent = nullptr);
~ConferenceInfoModel(); ~ConferenceInfoModel();
void createConferenceScheduler();
std::shared_ptr<linphone::ConferenceInfo> getConferenceInfo() const; std::shared_ptr<linphone::ConferenceInfo> getConferenceInfo() const;
std::shared_ptr<ConferenceSchedulerModel> getConferenceScheduler() const; std::shared_ptr<ConferenceSchedulerModel> getConferenceScheduler() const;

View file

@ -52,6 +52,10 @@ linphone::ConferenceScheduler::State ConferenceSchedulerModel::getState() const
return mState; return mState;
} }
std::shared_ptr<const linphone::ConferenceInfo> ConferenceSchedulerModel::getConferenceInfo() const {
return mMonitor->getInfo();
}
void ConferenceSchedulerModel::setInfo(const std::shared_ptr<linphone::ConferenceInfo> &confInfo) { void ConferenceSchedulerModel::setInfo(const std::shared_ptr<linphone::ConferenceInfo> &confInfo) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
mMonitor->setInfo(confInfo); mMonitor->setInfo(confInfo);

View file

@ -40,6 +40,7 @@ public:
QString getUri(); QString getUri();
linphone::ConferenceScheduler::State getState() const; linphone::ConferenceScheduler::State getState() const;
std::shared_ptr<const linphone::ConferenceInfo> getConferenceInfo() const;
void setInfo(const std::shared_ptr<linphone::ConferenceInfo> &confInfo); void setInfo(const std::shared_ptr<linphone::ConferenceInfo> &confInfo);
void cancelConference(const std::shared_ptr<linphone::ConferenceInfo> &confInfo); void cancelConference(const std::shared_ptr<linphone::ConferenceInfo> &confInfo);

View file

@ -16,8 +16,6 @@ ListView {
property var delegateButtons property var delegateButtons
property ConferenceInfoGui selectedConference: model && currentIndex != -1 ? model.getAt(currentIndex) : null property ConferenceInfoGui selectedConference: model && currentIndex != -1 ? model.getAt(currentIndex) : null
signal conferenceSelected(var contact)
spacing: 8 * DefaultStyle.dp spacing: 8 * DefaultStyle.dp
currentIndex: confInfoProxy.currentDateIndex currentIndex: confInfoProxy.currentDateIndex
// using highlight doesn't center, take time before moving and don't work for not visible item (like not loaded) // using highlight doesn't center, take time before moving and don't work for not visible item (like not loaded)
@ -26,9 +24,15 @@ ListView {
onCountChanged: { onCountChanged: {
selectedConference = model && currentIndex != -1 && currentIndex < model.count ? model.getAt(currentIndex) : null selectedConference = model && currentIndex != -1 && currentIndex < model.count ? model.getAt(currentIndex) : null
} }
Connections {
target: confInfoProxy
function onCurrentDateIndexChanged(index) {
mainItem.currentIndex = index
}
}
onCurrentIndexChanged: { onCurrentIndexChanged: {
selectedConference = model.getAt(currentIndex) || null selectedConference = model.getAt(currentIndex) || null
positionViewAtIndex(currentIndex, ListView.Center) if (currentIndex != -1) positionViewAtIndex(currentIndex, ListView.Contain)
} }
onVisibleChanged: if( visible) { onVisibleChanged: if( visible) {
mainItem.positionViewAtIndex(currentIndex, ListView.Center)// First approximative move mainItem.positionViewAtIndex(currentIndex, ListView.Center)// First approximative move
@ -214,23 +218,10 @@ ListView {
visible: itemDelegate.haveModel visible: itemDelegate.haveModel
onClicked: { onClicked: {
mainItem.currentIndex = index mainItem.currentIndex = index
mainItem.conferenceSelected($modelData)
itemDelegate.forceActiveFocus() itemDelegate.forceActiveFocus()
} }
} }
} }
} }
// MouseArea {
// id: confArea
// hoverEnabled: mainItem.hoverEnabled
// visible: !dateDay.visible && itemDelegate.haveModel
// anchors.fill: parent
// cursorShape: Qt.PointingHandCursor
// onClicked: {
// mainItem.currentIndex = index
// mainItem.conferenceSelected($modelData)
// }
// }
} }
} }