From c6ff50113425a20c2bbdb64d55a13acc718aefcf Mon Sep 17 00:00:00 2001 From: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com> Date: Mon, 24 Apr 2017 11:17:43 -0400 Subject: [PATCH] use user selected account when CM is not specified When currentDefaultAccount() was being called with no CM as input (eg: from ther UserActionModel), then the scheme type was being set to NONE, and thus Ring accounts were not passing the check in validAccountForScheme(). This is because we can always detect the scheme for a Ring URI, so Ring accounts don't support the scheme of type NONE. However, in this situation we want the user selected account to be chosen, since there is no other information available. Change-Id: Ia2d9b02fb3bb0476f044541d276dba768468feb8 --- src/availableaccountmodel.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/availableaccountmodel.cpp b/src/availableaccountmodel.cpp index c8d43749..bcf7814f 100644 --- a/src/availableaccountmodel.cpp +++ b/src/availableaccountmodel.cpp @@ -97,6 +97,12 @@ bool AvailableAccountModel::filterAcceptsRow(int source_row, const QModelIndex& ///Return the current account Account* AvailableAccountModel::currentDefaultAccount(ContactMethod* method) { + // if no CM is give, we use the user chosen account, since no other parameters are available + const auto idx = AvailableAccountModel::instance().selectionModel()->currentIndex(); + if (!method && idx.isValid()) { + return idx.data(static_cast<int>(Account::Role::Object)).value<Account*>(); + } + // Start by validating the scheme used by the ContactMethod URI::SchemeType type = (!method) ? URI::SchemeType::NONE : method->uri().schemeType(); -- GitLab