Skip to content
Snippets Groups Projects
Commit b66eea03 authored by Sébastien Blin's avatar Sébastien Blin Committed by Andreas Traczyk
Browse files

newaccountmodel: use setAccountsOrder from daemon to save top account


Change-Id: I51a895fc495e5a6b841f7425df321fc3adb7bfde
Reviewed-by: default avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent 77b9268c
Branches
No related tags found
No related merge requests found
......@@ -163,6 +163,11 @@ public:
const std::string& password = "",
const std::string& pin = "");
/**
* Set an account to the first position
*/
void setTopAccount(const std::string& accountId);
Q_SIGNALS:
/**
* Connect this signal to know when an invalid account is here
......
......@@ -140,11 +140,13 @@ std::vector<std::string>
NewAccountModel::getAccountList() const
{
std::vector<std::string> accountsId;
const QStringList accountIds = ConfigurationManager::instance().getAccountList();
for(auto const& accountInfo: pimpl_->accounts) {
for (auto const& id : accountIds) {
auto accountInfo = pimpl_->accounts.find(id.toStdString());
// Do not include accounts flagged for removal
if (accountInfo.second.valid)
accountsId.emplace_back(accountInfo.first);
if (accountInfo != pimpl_->accounts.end() && accountInfo->second.valid)
accountsId.emplace_back(id.toStdString());
}
return accountsId;
......@@ -712,6 +714,27 @@ NewAccountModel::createNewAccount(profile::Type type,
return accountId.toStdString();
}
void
NewAccountModel::setTopAccount(const std::string& accountId)
{
bool found = false;
std::string order = {};
const QStringList accountIds = ConfigurationManager::instance().getAccountList();
for (auto& id : accountIds)
{
if (id.toStdString() == accountId) {
found = true;
} else {
order += id.toStdString() + "/";
}
}
if (found) {
order = accountId + "/" + order;
}
ConfigurationManager::instance().setAccountsOrder(order.c_str());
}
} // namespace lrc
#include "api/moc_newaccountmodel.cpp"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment