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 <hblabel.h> |
|
24 #include "cpprofileactivatorentryitem.h" |
|
25 #include <QGraphicsLinearLayout> |
|
26 #include <QGraphicsWidget> |
|
27 |
|
28 CpProfileActivatorDialog::CpProfileActivatorDialog(CpSettingFormItemData *profileActivator, |
|
29 CpProfileModel &profileModel, |
|
30 QGraphicsItem *parent):HbDialog(parent), |
|
31 mProfileModel(profileModel), |
|
32 mProfileList(0), |
|
33 mProfileActivator(profileActivator) |
|
34 { |
|
35 mTitleLabel = new HbLabel(this); |
|
36 mTitleLabel->setPlainText(hbTrId("txt_cp_title_profile")); |
|
37 mContentWidget = new QGraphicsWidget(this); |
|
38 setContentWidget(mContentWidget); |
|
39 mLayout = new QGraphicsLinearLayout(); |
|
40 mLayout->setOrientation( Qt::Vertical ); |
|
41 mProfileIds << EProfileWrapperGeneralId |
|
42 << EProfileWrapperMeetingId; |
|
43 mProfileList = new HbRadioButtonList(); |
|
44 mProfileList->setItems(profileModel.profileNames()); |
|
45 mLayout->addItem(mTitleLabel); |
|
46 mLayout->addItem(mProfileList); |
|
47 |
|
48 int currentId = mProfileModel.activeProfileId(); |
|
49 mProfileList->setSelected(mProfileIds.indexOf(static_cast<ProfileWrapperProfileId>(currentId))); |
|
50 |
|
51 |
|
52 |
|
53 mConfirmProfile = new HbAction(hbTrId("txt_common_button_ok")); |
|
54 mCancelProfile = new HbAction(hbTrId("txt_common_button_cancel")); |
|
55 |
|
56 connect(mConfirmProfile, SIGNAL(triggered(bool)), this, SLOT(confirmProfileSelection())); |
|
57 connect(mCancelProfile, SIGNAL(triggered(bool)), this, SLOT(cancelProfileSelection())); |
|
58 |
|
59 |
|
60 this->addAction(mConfirmProfile); |
|
61 this->addAction(mCancelProfile); |
|
62 this->setModal(true); |
|
63 this->setDismissPolicy(HbPopup::NoDismiss); |
|
64 this->setTimeout(HbPopup::NoTimeout); |
|
65 mContentWidget->setLayout( mLayout ); |
|
66 } |
|
67 |
|
68 CpProfileActivatorDialog::~CpProfileActivatorDialog() |
|
69 { |
|
70 |
|
71 } |
|
72 void CpProfileActivatorDialog::confirmProfileSelection() |
|
73 { |
|
74 int currentIndex = mProfileList->selected(); |
|
75 if (currentIndex == -1) { |
|
76 return; |
|
77 } |
|
78 |
|
79 // the best choice is no need to convert the index to id |
|
80 mProfileModel.activateProfile(mProfileIds.at(currentIndex)); |
|
81 } |
|
82 void CpProfileActivatorDialog::cancelProfileSelection() |
|
83 { |
|
84 |
|
85 } |
|