Commit b943d423 authored by Ronan's avatar Ronan

feat(ui/views/App/Calls/ConferenceManager): in progress

parent f4d2ca9d
......@@ -193,7 +193,7 @@ void CallModel::stopRecording () {
// -----------------------------------------------------------------------------
void CallModel::handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state) {
void CallModel::handleCallStateChanged (const shared_ptr<linphone::Call> &call, linphone::CallState state) {
if (call != mCall)
return;
......
......@@ -33,7 +33,14 @@ ConferenceHelperModel::ConferenceAddModel::ConferenceAddModel (QObject *parent)
mConferenceHelperModel = qobject_cast<ConferenceHelperModel *>(parent);
Q_ASSERT(mConferenceHelperModel != nullptr);
for (auto &participant : CoreManager::getInstance()->getCore()->getConference()->getParticipants())
CoreManager *coreManager = CoreManager::getInstance();
QObject::connect(
coreManager->getSipAddressesModel(), &SipAddressesModel::dataChanged,
this, &ConferenceAddModel::handleDataChanged
);
for (auto &participant : coreManager->getCore()->getConference()->getParticipants())
addToConference(participant);
}
......@@ -118,9 +125,9 @@ void ConferenceHelperModel::ConferenceAddModel::update () {
// -----------------------------------------------------------------------------
void ConferenceHelperModel::ConferenceAddModel::addToConference (const std::shared_ptr<linphone::Address> &linphoneAddress) {
void ConferenceHelperModel::ConferenceAddModel::addToConference (const shared_ptr<linphone::Address> &linphoneAddress) {
QString sipAddress = ::Utils::linphoneStringToQString(linphoneAddress->asStringUriOnly());
QVariantMap map;
QVariantMap map = CoreManager::getInstance()->getSipAddressesModel()->find(sipAddress);
map["sipAddress"] = sipAddress;
map["__linphoneAddress"] = QVariant::fromValue(linphoneAddress);
......@@ -128,3 +135,27 @@ void ConferenceHelperModel::ConferenceAddModel::addToConference (const std::shar
mSipAddresses[sipAddress] = map;
mRefs << &mSipAddresses[sipAddress];
}
// -----------------------------------------------------------------------------
void ConferenceHelperModel::ConferenceAddModel::handleDataChanged (
const QModelIndex &topLeft,
const QModelIndex &bottomRight,
const QVector<int> &
) {
SipAddressesModel *sipAddressesModel = CoreManager::getInstance()->getSipAddressesModel();
int limit = bottomRight.row();
for (int row = topLeft.row(); row <= limit; ++row) {
const QVariantMap &map = sipAddressesModel->data(sipAddressesModel->index(row, 0)).toMap();
auto it = mSipAddresses.find(map["sipAddress"].toString());
if (it != mSipAddresses.end()) {
(*it)["contact"] = map.value("contact");
int row = mRefs.indexOf(&(*it));
Q_ASSERT(row != -1);
emit dataChanged(index(row, 0), index(row, 0));
}
}
}
......@@ -57,6 +57,12 @@ public:
private:
void addToConference (const std::shared_ptr<linphone::Address> &linphoneAddress);
void handleDataChanged (
const QModelIndex &topLeft,
const QModelIndex &bottomRight,
const QVector<int> &roles = QVector<int>()
);
QHash<QString, QVariantMap> mSipAddresses;
QList<const QVariantMap *> mRefs;
......
......@@ -39,7 +39,7 @@ namespace linphone {
class ConferenceHelperModel : public QSortFilterProxyModel {
Q_OBJECT;
Q_PROPERTY(ConferenceAddModel * toAdd READ getConferenceAddModel CONSTANT);
Q_PROPERTY(ConferenceHelperModel::ConferenceAddModel * toAdd READ getConferenceAddModel CONSTANT);
public:
class ConferenceAddModel;
......
......@@ -93,6 +93,13 @@ void SipAddressesModel::connectToChatModel (ChatModel *chatModel) {
// -----------------------------------------------------------------------------
QVariantMap SipAddressesModel::find (const QString &sipAddress) const {
auto it = mSipAddresses.find(sipAddress);
return it == mSipAddresses.end() ? QVariantMap() : *it;
}
// -----------------------------------------------------------------------------
ContactModel *SipAddressesModel::mapSipAddressToContact (const QString &sipAddress) const {
auto it = mSipAddresses.find(sipAddress);
if (it == mSipAddresses.end())
......
......@@ -47,6 +47,7 @@ public:
void connectToChatModel (ChatModel *chatModel);
Q_INVOKABLE QVariantMap find (const QString &sipAddress) const;
Q_INVOKABLE ContactModel *mapSipAddressToContact (const QString &sipAddress) const;
Q_INVOKABLE SipAddressObserver *getSipAddressObserver (const QString &sipAddress);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment