mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 03:18:07 +00:00
remove friend from friendsmanager maps when created, updated, removed
This commit is contained in:
parent
8463c3e5f9
commit
a2c0bfe558
3 changed files with 36 additions and 3 deletions
|
|
@ -678,12 +678,13 @@ void FriendCore::save() { // Save Values to model
|
|||
if (contact != nullptr) {
|
||||
auto friendModel = Utils::makeQObject_ptr<FriendModel>(contact);
|
||||
friendModel->setSelf(friendModel);
|
||||
mCoreModelConnection->invokeToCore([this, thisCopy, friendModel] {
|
||||
mCoreModelConnection->invokeToCore([this, thisCopy, friendModel, contact] {
|
||||
mFriendModel = friendModel;
|
||||
mCoreModelConnection->invokeToModel([this, thisCopy] {
|
||||
mCoreModelConnection->invokeToModel([this, thisCopy, contact] {
|
||||
thisCopy->writeIntoModel(mFriendModel);
|
||||
thisCopy->deleteLater();
|
||||
mVCardString = mFriendModel->getVCardAsString();
|
||||
emit CoreModel::getInstance()->friendUpdated(contact);
|
||||
mCoreModelConnection->invokeToCore([this] {
|
||||
setIsSaved(true);
|
||||
emit saved();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,39 @@ DEFINE_ABSTRACT_OBJECT(FriendsManager)
|
|||
std::shared_ptr<FriendsManager> FriendsManager::gFriendsManager;
|
||||
FriendsManager::FriendsManager(QObject *parent) : QObject(parent) {
|
||||
moveToThread(CoreModel::getInstance()->thread());
|
||||
|
||||
connect(CoreModel::getInstance().get(), &CoreModel::friendRemoved, this, [this] (const std::shared_ptr<linphone::Friend> &f) {
|
||||
auto key = mKnownFriends.key(QVariant::fromValue(f), nullptr);
|
||||
if (key != nullptr) {
|
||||
mKnownFriends.remove(key);
|
||||
}
|
||||
auto unknown = mUnknownFriends.key(QVariant::fromValue(f), nullptr);
|
||||
if (unknown != nullptr) {
|
||||
mUnknownFriends.remove(unknown);
|
||||
}
|
||||
auto address = QString::fromStdString(f->getAddress()->asStringUriOnly());
|
||||
mOtherAddresses.removeAll(address);
|
||||
});
|
||||
connect(CoreModel::getInstance().get(), &CoreModel::friendCreated, this, [this] (const std::shared_ptr<linphone::Friend> &f) {
|
||||
auto unknown = mUnknownFriends.key(QVariant::fromValue(f), nullptr);
|
||||
if (unknown != nullptr) {
|
||||
mUnknownFriends.remove(unknown);
|
||||
}
|
||||
auto address = QString::fromStdString(f->getAddress()->asStringUriOnly());
|
||||
mOtherAddresses.removeAll(address);
|
||||
});
|
||||
connect(CoreModel::getInstance().get(), &CoreModel::friendUpdated, this, [this] (const std::shared_ptr<linphone::Friend> &f) {
|
||||
auto key = mKnownFriends.key(QVariant::fromValue(f), nullptr);
|
||||
if (key != nullptr) {
|
||||
mKnownFriends.remove(key);
|
||||
}
|
||||
auto unknown = mUnknownFriends.key(QVariant::fromValue(f), nullptr);
|
||||
if (unknown != nullptr) {
|
||||
mUnknownFriends.remove(unknown);
|
||||
}
|
||||
auto address = QString::fromStdString(f->getAddress()->asStringUriOnly());
|
||||
mOtherAddresses.removeAll(address);
|
||||
});
|
||||
}
|
||||
|
||||
FriendsManager::~FriendsManager() {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ private:
|
|||
QVariantMap mKnownFriends;
|
||||
QVariantMap mUnknownFriends;
|
||||
QStringList mOtherAddresses;
|
||||
//core model connection + reset unknown et other quand friend ajouté, supprimé, updated
|
||||
DECLARE_ABSTRACT_OBJECT
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue