Skip to content
Snippets Groups Projects
Commit 2417a376 authored by Nicolas Jager's avatar Nicolas Jager Committed by Anthony Léonard
Browse files

NewAccountModel : add profileUpdated signal


- Emitted when LocalProfileEditor::save() is called. Help clients
  to get warn when a profile was edited trough the legacy code.

- Use this signal the same way when the profile is edited trough
  the new lrc api.

Change-Id: I19d43cc10c7b42ea21a419a05e6ae8ba73ee24fa
Reviewed-by: default avatarAnthony Léonard <anthony.leonard@savoirfairelinux.com>
parent 9dd39e5a
Branches
Tags
No related merge requests found
......@@ -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_;
......
......@@ -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;
}
......
......@@ -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"
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment