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 "cpprofilesgroupitemdata.h" |
|
18 #include <QStringList> |
|
19 #include <cpsettingformentryitemdataimpl.h> |
|
20 #include <cpbasesettingview.h> |
|
21 #include <cpitemdatahelper.h> |
|
22 #include <hbmessagebox.h> |
|
23 #include "cpprofilesettingform.h" |
|
24 #include "cpmastervolumevaluecontroller.h" |
|
25 #include "cppersonalizationcustomviewitem.h" |
|
26 |
|
27 |
|
28 CpProfilesGroupItemData::CpProfilesGroupItemData(CpItemDataHelper &itemDataHelper) |
|
29 : CpSettingFormItemData(HbDataFormModelItem::GroupItem,tr("Profiles")),mProfileModel(0) |
|
30 { |
|
31 mProfileModel = new CpProfileModel(); |
|
32 initItems(itemDataHelper); |
|
33 } |
|
34 |
|
35 CpProfilesGroupItemData::~CpProfilesGroupItemData() |
|
36 { |
|
37 delete mProfileModel; |
|
38 if (mMasterVolumeValueController != 0) { |
|
39 delete mMasterVolumeValueController; |
|
40 } |
|
41 } |
|
42 |
|
43 namespace |
|
44 { |
|
45 class CpProfileSettingView : public CpBaseSettingView |
|
46 { |
|
47 public: |
|
48 CpProfileSettingView() : CpBaseSettingView(new CpProfileSettingForm()) |
|
49 { |
|
50 } |
|
51 }; |
|
52 } |
|
53 |
|
54 void CpProfilesGroupItemData::initItems(CpItemDataHelper &itemDataHelper) |
|
55 { |
|
56 itemDataHelper.addItemPrototype(new CpPersonalizationCustomViewItem); |
|
57 HbDataFormModelItem *activeProfileItem = new HbDataFormModelItem( |
|
58 HbDataFormModelItem::RadioButtonListItem,tr("Profiles")); |
|
59 //enable the profile activating |
|
60 // why come into slots twice when select a item? |
|
61 itemDataHelper.addConnection(activeProfileItem,SIGNAL(itemSelected(int)),this,SLOT(activateProfile(int))); |
|
62 |
|
63 mCurrentProfileId = static_cast<ProfileWrapperProfileId>(mProfileModel->activeProfileId()); |
|
64 // QString warnningNote = "Profile Id = "+ mCurrentProfileId; |
|
65 //HbMessageBox::information(warnningNote); |
|
66 QStringList items; |
|
67 items << tr("General") << tr("Meeting") << tr("Silent"); |
|
68 activeProfileItem->setContentWidgetData("items",items); |
|
69 switch (mCurrentProfileId) { |
|
70 case EProfileWrapperGeneralId: |
|
71 activeProfileItem->setContentWidgetData("selected",0); |
|
72 break; |
|
73 case EProfileWrapperSilentId: |
|
74 activeProfileItem->setContentWidgetData("selected",2); |
|
75 break; |
|
76 case EProfileWrapperMeetingId: |
|
77 activeProfileItem->setContentWidgetData("selected",1); |
|
78 break; |
|
79 default: |
|
80 // HbMessageBox::information("unknown id of profile"); |
|
81 break; |
|
82 }; |
|
83 |
|
84 appendChild(activeProfileItem); |
|
85 |
|
86 mMasterVolume = new HbDataFormModelItem(static_cast<HbDataFormModelItem::DataItemType>(MasterVolumeSliderItem)); |
|
87 |
|
88 mMasterVolumeValueController = new CpMasterVolumeValueController(mProfileModel, mMasterVolume, |
|
89 itemDataHelper, activeProfileItem); |
|
90 this->appendChild(mMasterVolume); |
|
91 |
|
92 HbDataFormModelItem *editProfileItem = new CpSettingFormEntryItemDataImpl<CpProfileSettingView>( |
|
93 itemDataHelper,tr("Edit profiles")); |
|
94 appendChild(editProfileItem); |
|
95 } |
|
96 void CpProfilesGroupItemData::activateProfile(int profileIndex) |
|
97 { |
|
98 switch (profileIndex) { |
|
99 case 0: // general |
|
100 { |
|
101 mProfileModel->activateProfile(EProfileWrapperGeneralId); |
|
102 int volumeValue = mProfileModel->ringVolume(); |
|
103 // update the master volume when profile changed |
|
104 // should be used profileChangedObserver in the future; |
|
105 mMasterVolume->setEnabled(true); |
|
106 mMasterVolume->setContentWidgetData("value", volumeValue); |
|
107 break; |
|
108 } |
|
109 case 1: // meeting |
|
110 { |
|
111 mProfileModel->activateProfile(EProfileWrapperMeetingId); |
|
112 int volumeValue = mProfileModel->ringVolume(); |
|
113 mMasterVolume->setEnabled(true); |
|
114 mMasterVolume->setContentWidgetData("value", volumeValue); |
|
115 break; |
|
116 } |
|
117 case 2: // silent |
|
118 { |
|
119 mProfileModel->activateProfile(EProfileWrapperSilentId); |
|
120 mMasterVolume->setContentWidgetData("value", 0); |
|
121 mMasterVolume->setEnabled(false); |
|
122 break; |
|
123 } |
|
124 default: |
|
125 break; |
|
126 |
|
127 } |
|
128 } |
|