Added NOTIFY to readOnly property on friendcode + default value

This commit is contained in:
Christophe Deschamps 2024-09-27 17:50:14 +02:00
parent 36d63098a7
commit 46a42456ab
2 changed files with 6 additions and 2 deletions

View file

@ -100,6 +100,7 @@ FriendCore::FriendCore(const std::shared_ptr<linphone::Friend> &contact) : QObje
mStarred = false; mStarred = false;
} }
mIsLdap = false;
connect(this, &FriendCore::addressChanged, &FriendCore::allAddressesChanged); connect(this, &FriendCore::addressChanged, &FriendCore::allAddressesChanged);
connect(this, &FriendCore::phoneNumberChanged, &FriendCore::allAddressesChanged); connect(this, &FriendCore::phoneNumberChanged, &FriendCore::allAddressesChanged);
} }
@ -116,6 +117,7 @@ FriendCore::FriendCore(const FriendCore &friendCore) {
mJob = friendCore.mJob; mJob = friendCore.mJob;
mPictureUri = friendCore.mPictureUri; mPictureUri = friendCore.mPictureUri;
mIsSaved = friendCore.mIsSaved; mIsSaved = friendCore.mIsSaved;
mIsLdap = friendCore.mIsLdap;
} }
FriendCore::~FriendCore() { FriendCore::~FriendCore() {
@ -622,7 +624,7 @@ void FriendCore::save() { // Save Values to model
(core->getDefaultFriendList()->addFriend(contact) == linphone::FriendList::Status::OK); (core->getDefaultFriendList()->addFriend(contact) == linphone::FriendList::Status::OK);
if (created) { if (created) {
core->getDefaultFriendList()->updateSubscriptions(); core->getDefaultFriendList()->updateSubscriptions();
emit CoreModel::getInstance() -> friendCreated(contact); emit CoreModel::getInstance()->friendCreated(contact);
} }
mCoreModelConnection->invokeToCore([this, created]() { mCoreModelConnection->invokeToCore([this, created]() {
if (created) setSelf(mCoreModelConnection->mCore); if (created) setSelf(mCoreModelConnection->mCore);
@ -655,6 +657,7 @@ bool FriendCore::getIsLdap() const {
void FriendCore::setIsLdap(bool data) { void FriendCore::setIsLdap(bool data) {
if (mIsLdap != data) { if (mIsLdap != data) {
mIsLdap = data; mIsLdap = data;
emit readOnlyChanged();
} }
} }

View file

@ -67,7 +67,7 @@ class FriendCore : public QObject, public AbstractObject {
Q_PROPERTY(bool isSaved READ getIsSaved NOTIFY isSavedChanged) Q_PROPERTY(bool isSaved READ getIsSaved NOTIFY isSavedChanged)
Q_PROPERTY(QString pictureUri READ getPictureUri WRITE setPictureUri NOTIFY pictureUriChanged) Q_PROPERTY(QString pictureUri READ getPictureUri WRITE setPictureUri NOTIFY pictureUriChanged)
Q_PROPERTY(bool starred READ getStarred WRITE lSetStarred NOTIFY starredChanged) Q_PROPERTY(bool starred READ getStarred WRITE lSetStarred NOTIFY starredChanged)
Q_PROPERTY(bool readOnly READ getReadOnly CONSTANT) Q_PROPERTY(bool readOnly READ getReadOnly NOTIFY readOnlyChanged)
public: public:
// Should be call from model Thread. Will be automatically in App thread after initialization // Should be call from model Thread. Will be automatically in App thread after initialization
@ -168,6 +168,7 @@ signals:
void devicesChanged(); void devicesChanged();
void verifiedDevicesChanged(); void verifiedDevicesChanged();
void lSetStarred(bool starred); void lSetStarred(bool starred);
void readOnlyChanged();
protected: protected:
void writeIntoModel(std::shared_ptr<FriendModel> model) const; void writeIntoModel(std::shared_ptr<FriendModel> model) const;