|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include "cpprofileactivatordialog.h" |
|
18 |
|
19 #include <hbradiobuttonlist.h> |
|
20 #include <hbaction.h> |
|
21 #include <hbdataformmodelitem.h> |
|
22 #include <hbpopup.h> |
|
23 #include "cpprofileactivatorentryitem.h" |
|
24 CpProfileActivatorDialog::CpProfileActivatorDialog(CpSettingFormItemData *profileActivator, |
|
25 CpProfileModel &profileModel, |
|
26 QGraphicsItem *parent):HbDialog(parent), |
|
27 mProfileModel(profileModel), |
|
28 mProfileList(0), |
|
29 mProfileActivator(profileActivator), |
|
30 mConfirmProfile(0), |
|
31 mCancelProfile(0) |
|
32 { |
|
33 mProfileIds << EProfileWrapperGeneralId |
|
34 << EProfileWrapperMeetingId; |
|
35 mProfileList = new HbRadioButtonList(); |
|
36 mProfileList->setItems(profileModel.profileNames()); |
|
37 |
|
38 int currentId = mProfileModel.activeProfileId(); |
|
39 mProfileList->setSelected(mProfileIds.indexOf(static_cast<ProfileWrapperProfileId>(currentId))); |
|
40 |
|
41 |
|
42 |
|
43 mConfirmProfile = new HbAction(hbTrId("txt_common_button_ok")); |
|
44 mCancelProfile = new HbAction(hbTrId("txt_common_button_cancel")); |
|
45 |
|
46 connect(mConfirmProfile, SIGNAL(triggered(bool)), this, SLOT(confirmProfileSelection())); |
|
47 connect(mCancelProfile, SIGNAL(triggered(bool)), this, SLOT(cancelProfileSelection())); |
|
48 |
|
49 |
|
50 this->setPrimaryAction(mConfirmProfile); |
|
51 this->setSecondaryAction(mCancelProfile); |
|
52 |
|
53 this->setContentWidget(mProfileList); |
|
54 this->setModal(true); |
|
55 this->setDismissPolicy(HbPopup::NoDismiss); |
|
56 this->setTimeout(HbPopup::NoTimeout); |
|
57 } |
|
58 |
|
59 CpProfileActivatorDialog::~CpProfileActivatorDialog() |
|
60 { |
|
61 delete mConfirmProfile; |
|
62 delete mCancelProfile; |
|
63 } |
|
64 void CpProfileActivatorDialog::confirmProfileSelection() |
|
65 { |
|
66 int currentIndex = mProfileList->selected(); |
|
67 |
|
68 // the best choice is no need to convert the index to id |
|
69 mProfileModel.activateProfile(mProfileIds.at(currentIndex)); |
|
70 // ret should be remove from here |
|
71 // no invalid profile exsit |
|
72 QString profileName = mProfileModel.profileName(mProfileModel.activeProfileId()); |
|
73 //change the descripton of entry item |
|
74 if (CpSettingFormEntryItemData *entryItem = qobject_cast<CpSettingFormEntryItemData*>(mProfileActivator)) { |
|
75 entryItem->setDescription(profileName); |
|
76 } |
|
77 } |
|
78 void CpProfileActivatorDialog::cancelProfileSelection() |
|
79 { |
|
80 |
|
81 } |