diff -r cfea66083b62 -r baacf668fe89 phoneapp/phoneuiqtviewadapter/src/phoneuicommandcontroller.cpp --- a/phoneapp/phoneuiqtviewadapter/src/phoneuicommandcontroller.cpp Mon Oct 04 16:06:10 2010 +0300 +++ b/phoneapp/phoneuiqtviewadapter/src/phoneuicommandcontroller.cpp Fri Oct 15 12:58:46 2010 +0300 @@ -79,13 +79,11 @@ { PHONE_DEBUG("PhoneMenuController::setDialpadMenuActions"); releaseMenu(); - QList values; + QList values; m_view.setMenuActions(values); - qDeleteAll(values); } -QMap - PhoneUiCommandController::pushButtonActionsForCall( +QList PhoneUiCommandController::pushButtonActionsForCall( int callState, bool emergencyCall, QMap callStates, @@ -94,7 +92,7 @@ int callId) { PHONE_TRACE - QMap translatedActions; + QList translatedActions; QList commands = buttonCommandList( callState, emergencyCall, callStates.values()); @@ -110,25 +108,25 @@ } if (1 == commands.count()) { - PhoneAction *action = mapCommandToAction(commands.at(0)); + HbAction *action = createAction(commands.at(0)); if (action) { - translatedActions[PhoneAction::LeftButton] = action; + translatedActions.append(action); } } else if (1 < commands.count()){ - PhoneAction *action = mapCommandToAction(commands.at(0)); - PhoneAction *action2 = mapCommandToAction(commands.at(1)); + HbAction *action = createAction(commands.at(0)); + HbAction *action2 = createAction(commands.at(1)); if (action) { - translatedActions[PhoneAction::LeftButton] = action; + translatedActions.append(action); } if (action2) { - translatedActions[PhoneAction::RightButton] = action2; + translatedActions.append(action2); } } return translatedActions; } -QList PhoneUiCommandController::toolBarActions( +QList PhoneUiCommandController::toolBarActions( int resourceId, QMap callStates, QMap serviceIds, @@ -136,7 +134,6 @@ int callId) { PHONE_TRACE - QList actions; //Set tool bar button flags setJoinFlag(callStates, serviceIds); @@ -146,8 +143,8 @@ setOutgoingFlag(callStates.values()); //Get tool bar item list by resource id. - QList commands = PhoneResourceAdapter::Instance()-> - convertToToolBarCommandList(resourceId); + QList toolBarCmdList = + PhoneResourceAdapter::Instance()->convertToToolBarCommandList(resourceId); if (serviceId != -1) { PhoneCommandExtensionWrapper *extension = commandExtension(serviceId); @@ -156,20 +153,18 @@ QList callInfo; extension->getCallInfoList( callInfo,callStates,serviceIds,callId); - - QList toolBarCmdList; - - mapToExtensionToolBarItems(commands,toolBarCmdList); + //Modify tool bar command list by extension extension->modifyToolBarCommandList(callInfo,toolBarCmdList); - // Map tool bar item list back to the phone action tool bar item list. - mapToPhoneActionToolBarItems(toolBarCmdList,commands); + } } - for ( int i=0; i < commands.count(); ++i) { - PhoneAction *action = mapCommandToAction( - commands.at(i).mCommandId, !commands.at(i).mEnabled); + QList actions; + for ( int i=0; i < toolBarCmdList.count(); ++i) { + HbAction *action = createAction( + toolBarCmdList[i].mCommandId, + toolBarCmdList[i].mIsEnabled); if (action) { actions.append(action); } @@ -230,30 +225,29 @@ void PhoneUiCommandController::addMenuItems(QList menuCmdList) { - QList values; + QList values; for (int i=0;isetCommand(command); - phoneAction->setText( + QScopedPointer action(new HbAction()); + action->setProperty("command", command); + action->setText( PhoneResourceAdapter::Instance()-> convertCommandToString(command)); - values.append(phoneAction); + values.append(action.take()); } } m_view.setMenuActions(values); - qDeleteAll(values); } -int PhoneUiCommandController::mapCommand(int command) const +int PhoneUiCommandController::mapCommand(int extensionCommand) const { int ret(-1); - switch(command) { + switch(extensionCommand) { case PhoneInCallCmdEndAllCalls: ret = EPhoneInCallCmdEndAllCalls; break; @@ -429,34 +423,6 @@ setButtonFlags(PhoneUIQtButtonsController::MultiCall, multicall); } -void PhoneUiCommandController::mapToExtensionToolBarItems( - const QList &sourceList, - QList &toolBarCmdList) const -{ - toolBarCmdList.clear(); - - for (int i=0;i &sourceList, - QList &commandList) const -{ - commandList.clear(); - - for (int i=0;i PhoneUiCommandController::buttonCommandList( int callState, bool emergencyCall, @@ -564,171 +530,136 @@ return ret; } -PhoneAction *PhoneUiCommandController::mapCommandToAction( - int command, bool disabled) const + + +HbAction *PhoneUiCommandController::createAction( + int extensionCommand, bool enabled) const { - PhoneAction *action=0; + QScopedPointer action(new HbAction); + action->setEnabled(enabled); - switch( command ) { + switch (extensionCommand) { case PhoneInCallCmdJoinToConference: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_join_call")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdJoin); + action->setProperty("command", EPhoneInCallCmdJoin); } break; case PhoneInCallCmdCreateConference: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_join_call")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdCreateConference); + action->setProperty("command", EPhoneInCallCmdCreateConference); } break; case PhoneInCallCmdAnswer: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_call")); - action->setDisabled(disabled); - action->setCommand (EPhoneCallComingCmdAnswer); - action->setActionRole(PhoneAction::Accept); + action->setProperty("command", EPhoneCallComingCmdAnswer); + action->setSoftKeyRole(QAction::PositiveSoftKey); } break; case PhoneInCallCmdReject: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_reject_call")); - action->setDisabled(disabled); - action->setCommand (EPhoneCallComingCmdReject); - action->setActionRole(PhoneAction::Decline); + action->setProperty("command", EPhoneCallComingCmdReject); + action->setSoftKeyRole(QAction::NegativeSoftKey); } break; case PhoneInCallCmdHold: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_hold_call")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdHold); + action->setProperty("command", EPhoneInCallCmdHold); } break; case PhoneInCallCmdUnhold: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_call")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdUnhold); + action->setProperty("command", EPhoneInCallCmdUnhold); } break; case PhoneInCallCmdEndActive: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_end_call")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdEndThisActiveCall); - action->setActionRole(PhoneAction::Decline); + action->setProperty("command", EPhoneInCallCmdEndThisActiveCall); + action->setSoftKeyRole(QAction::NegativeSoftKey); } break; case PhoneInCallCmdEndOutgoingCall: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_end_call")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdEndThisOutgoingCall); - action->setActionRole(PhoneAction::Decline); + action->setProperty("command", EPhoneInCallCmdEndThisOutgoingCall); + action->setSoftKeyRole(QAction::NegativeSoftKey); } break; case PhoneInCallCmdReplace: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_replace_call")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdReplace); - action->setActionRole(PhoneAction::Accept); + action->setProperty("command", EPhoneInCallCmdReplace); + action->setSoftKeyRole(QAction::PositiveSoftKey); } break; case PhoneInCallCmdSwap: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_swap_call")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdSwap); + action->setProperty("command", EPhoneInCallCmdSwap); } break; case PhoneCallComingCmdSoftReject: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_send")); - action->setDisabled(disabled); - action->setCommand(EPhoneCallComingCmdSoftReject); + action->setProperty("command", EPhoneCallComingCmdSoftReject); } break; case PhoneCallComingCmdSilent: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_speaker_off")); - action->setDisabled(disabled); - action->setCommand(EPhoneCallComingCmdSilent); + action->setProperty("command", EPhoneCallComingCmdSilent); } break; case PhoneInCallCmdOpenDialer: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_dialer")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdDialer); + action->setProperty("command", EPhoneInCallCmdDialer); } break; case PhoneInCallCmdMute: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_mic_mute")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdMute); + action->setProperty("command", EPhoneInCallCmdMute); } break; case PhoneInCallCmdUnmute: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_mic_unmute")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdUnmute); + action->setProperty("command", EPhoneInCallCmdUnmute); } break; case PhoneInCallCmdActivateIhf: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_speaker")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdActivateIhf); + action->setProperty("command", EPhoneInCallCmdActivateIhf); } break; case PhoneInCallCmdDeactivateIhf: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_mobile")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdDeactivateIhf); + action->setProperty("command", EPhoneInCallCmdDeactivateIhf); } break; case PhoneInCallCmdOpenContacts: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_contacts")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdContacts); + action->setProperty("command", EPhoneInCallCmdContacts); } break; case PhoneInCallCmdBtHandsfree: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_bluetooth_headset")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdBtHandsfree); + action->setProperty("command", EPhoneInCallCmdBtHandsfree); } break; case PhoneInCallCmdHandset: { - action = new PhoneAction; action->setIcon(HbIcon("qtg_mono_mobile")); - action->setDisabled(disabled); - action->setCommand(EPhoneInCallCmdHandset); + action->setProperty("command", EPhoneInCallCmdHandset); } break; - default: + default: { + delete action.take(); + } break; } - return action; + return action.take(); } bool PhoneUiCommandController::emergencyCall(QMap callStates) const