From f0658b14013f3fbca7202bf37215b59b0b3014bf Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> Date: Fri, 27 Feb 2015 18:10:22 -0500 Subject: [PATCH] Fix the "Refuse" UserAction Refs #66613 --- src/call.cpp | 1 - src/private/useractions.h | 37 +++++++++++++++++++------------------ src/useractionmodel.cpp | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/call.cpp b/src/call.cpp index c4c97439..1ef09c03 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -478,7 +478,6 @@ Call* Call::operator<<( Call::Action& c) return this; } - Call* operator<<(Call* c, Call::Action action) { return (!c) ? nullptr : (*c) << action; diff --git a/src/private/useractions.h b/src/private/useractions.h index fe9a0b89..46f81d68 100644 --- a/src/private/useractions.h +++ b/src/private/useractions.h @@ -37,29 +37,30 @@ bool record(const QList<Call*> calls); bool accept(const QList<Call*> calls) { bool ret = true; + + //Add a new call if none is there + if (!calls.size()) { + Call* call = CallModel::instance()->dialingCall(); + CallModel::instance()->selectionModel()->setCurrentIndex(CallModel::instance()->getIndex(call), QItemSelectionModel::ClearAndSelect); + return true; + } + for (Call* call : calls) { - if(!call) { - qDebug() << "Calling when no item is selected. Opening an item."; - CallModel::instance()->dialingCall(); - CallModel::instance()->selectionModel()->setCurrentIndex(CallModel::instance()->getIndex(call), QItemSelectionModel::ClearAndSelect); + const Call::State state = call->state(); + //TODO port to lifeCycle code + if (state == Call::State::RINGING || state == Call::State::CURRENT || state == Call::State::HOLD + || state == Call::State::BUSY || state == Call::State::FAILURE || state == Call::State::ERROR) { + qDebug() << "Calling when item currently ringing, current, hold or busy. Opening an item."; + Call* c2 = CallModel::instance()->dialingCall(); + CallModel::instance()->selectionModel()->setCurrentIndex(CallModel::instance()->getIndex(c2), QItemSelectionModel::ClearAndSelect); } else { - const Call::State state = call->state(); - //TODO port to lifeCycle code - if (state == Call::State::RINGING || state == Call::State::CURRENT || state == Call::State::HOLD - || state == Call::State::BUSY || state == Call::State::FAILURE || state == Call::State::ERROR) { - qDebug() << "Calling when item currently ringing, current, hold or busy. Opening an item."; - Call* c2 = CallModel::instance()->dialingCall(); - CallModel::instance()->selectionModel()->setCurrentIndex(CallModel::instance()->getIndex(c2), QItemSelectionModel::ClearAndSelect); + try { + call->performAction(Call::Action::ACCEPT); } - else { - try { - call->performAction(Call::Action::ACCEPT); - } - catch(const char * msg) { + catch(const char * msg) { // KMessageBox::error(Ring::app(),i18n(msg)); - ret = false; - } + ret = false; } } } diff --git a/src/useractionmodel.cpp b/src/useractionmodel.cpp index 2864e932..37e4b2fe 100644 --- a/src/useractionmodel.cpp +++ b/src/useractionmodel.cpp @@ -479,7 +479,7 @@ bool UserActionModel::execute(const UserActionModel::Action action) const d_ptr->updateActions(); break; case UserActionModel::Action::HANGUP : - if (UserActions::accept(selected)) + if (UserActions::hangup(selected)) d_ptr->updateActions(); break; case UserActionModel::Action::JOIN : -- GitLab