diff --git a/src/api/newaccountmodel.h b/src/api/newaccountmodel.h index ea4b644a432afd966ffb7d438b474c8729ee5d77..a51cafea292f7048c6e06c1db64b04963fc45105 100644 --- a/src/api/newaccountmodel.h +++ b/src/api/newaccountmodel.h @@ -84,6 +84,11 @@ Q_SIGNALS: * @param accountID */ void accountRemoved(const std::string& accountID); + /** + * Connect this signal to know when an account was updated. + * @param accountID + */ + void profileUpdated(const std::string& accountID); private: std::unique_ptr<NewAccountModelPimpl> pimpl_; diff --git a/src/localprofilecollection.cpp b/src/localprofilecollection.cpp index 6023a684d6f4373e41fe8fd75b11ed234eadce32..98a8d6294125b3d12153102bd7b33552bc7b5e82 100644 --- a/src/localprofilecollection.cpp +++ b/src/localprofilecollection.cpp @@ -32,6 +32,7 @@ #include "account.h" #include "accountmodel.h" #include "person.h" +#include "profilemodel.h" class LocalProfileEditor final : public CollectionEditor<Profile> { @@ -86,6 +87,10 @@ bool LocalProfileEditor::save(const Profile* pro) file.write(result); file.close(); + + // we need to bind the legacy lrc to the new one. We doing that by using profileUpdated + emit ProfileModel::instance().profileUpdated(pro); + return true; } diff --git a/src/newaccountmodel.cpp b/src/newaccountmodel.cpp index b713f2453e14611b115544afbf5d1954fd237a9a..b215be38b13a28a913caeeffa3066ec4749e6eaf 100644 --- a/src/newaccountmodel.cpp +++ b/src/newaccountmodel.cpp @@ -30,6 +30,8 @@ #include "database.h" #include "accountmodel.h" +#include "profilemodel.h" +#include "profile.h" // Dbus #include "dbus/configurationmanager.h" @@ -74,6 +76,8 @@ public Q_SLOTS: * @param account */ void slotAccountRemoved(Account* account); + + void slotProfileUpdated(const Profile* profile); }; NewAccountModel::NewAccountModel(Database& database, @@ -127,6 +131,7 @@ NewAccountModelPimpl::NewAccountModelPimpl(NewAccountModel& linked, // NOTE: because we still use the legacy LRC for configuration, we are still using old signals connect(&AccountModel::instance(), &AccountModel::accountRemoved, this, &NewAccountModelPimpl::slotAccountRemoved); + connect(&ProfileModel::instance(), &ProfileModel::profileUpdated, this, &NewAccountModelPimpl::slotProfileUpdated); } NewAccountModelPimpl::~NewAccountModelPimpl() @@ -197,6 +202,13 @@ NewAccountModelPimpl::slotAccountRemoved(Account* account) emit linked.accountRemoved(accountId); } + +void +NewAccountModelPimpl::slotProfileUpdated(const Profile* profile) +{ + emit linked.profileUpdated(profile->accounts().first()->id().toStdString()); +} + } // namespace lrc #include "api/moc_newaccountmodel.cpp" diff --git a/src/profilemodel.h b/src/profilemodel.h index 3b56aa57907400bc6f066560332313338a3231ba..593f59ae1784e1b2e830cab3945e45f2c7443387 100644 --- a/src/profilemodel.h +++ b/src/profilemodel.h @@ -80,6 +80,9 @@ private: virtual bool addItemCallback(const Profile* item) override; virtual bool removeItemCallback(const Profile* item) override; +Q_SIGNALS: + bool profileUpdated(const Profile* item); + public Q_SLOTS: bool remove(const QModelIndex& idx); bool add(Person* person = nullptr);