16 */ |
16 */ |
17 #include "cpprofilesgroupitemdata.h" |
17 #include "cpprofilesgroupitemdata.h" |
18 #include <QStringList> |
18 #include <QStringList> |
19 #include <cpsettingformentryitemdataimpl.h> |
19 #include <cpsettingformentryitemdataimpl.h> |
20 #include <cpbasesettingview.h> |
20 #include <cpbasesettingview.h> |
|
21 #include <cpitemdatahelper.h> |
|
22 #include <hbmessagebox.h> |
21 #include "cpprofilesettingform.h" |
23 #include "cpprofilesettingform.h" |
|
24 #include "cpmastervolumevaluecontroller.h" |
|
25 #include "cppersonalizationcustomviewitem.h" |
|
26 |
22 |
27 |
23 CpProfilesGroupItemData::CpProfilesGroupItemData(CpItemDataHelper &itemDataHelper) |
28 CpProfilesGroupItemData::CpProfilesGroupItemData(CpItemDataHelper &itemDataHelper) |
24 : CpSettingFormItemData(HbDataFormModelItem::GroupItem,tr("Profiles")) |
29 : CpSettingFormItemData(HbDataFormModelItem::GroupItem,tr("Profiles")),mProfileModel(0) |
25 { |
30 { |
|
31 mProfileModel = new CpProfileModel(); |
26 initItems(itemDataHelper); |
32 initItems(itemDataHelper); |
27 } |
33 } |
28 |
34 |
29 CpProfilesGroupItemData::~CpProfilesGroupItemData() |
35 CpProfilesGroupItemData::~CpProfilesGroupItemData() |
30 { |
36 { |
|
37 delete mProfileModel; |
|
38 if (mMasterVolumeValueController != 0) { |
|
39 delete mMasterVolumeValueController; |
|
40 } |
31 } |
41 } |
32 |
42 |
33 namespace |
43 namespace |
34 { |
44 { |
35 class CpProfileSettingView : public CpBaseSettingView |
45 class CpProfileSettingView : public CpBaseSettingView |
37 public: |
47 public: |
38 CpProfileSettingView() : CpBaseSettingView(new CpProfileSettingForm()) |
48 CpProfileSettingView() : CpBaseSettingView(new CpProfileSettingForm()) |
39 { |
49 { |
40 } |
50 } |
41 }; |
51 }; |
42 }; |
52 } |
43 |
53 |
44 void CpProfilesGroupItemData::initItems(CpItemDataHelper &itemDataHelper) |
54 void CpProfilesGroupItemData::initItems(CpItemDataHelper &itemDataHelper) |
45 { |
55 { |
|
56 itemDataHelper.addItemPrototype(new CpPersonalizationCustomViewItem); |
46 HbDataFormModelItem *activeProfileItem = new HbDataFormModelItem( |
57 HbDataFormModelItem *activeProfileItem = new HbDataFormModelItem( |
47 HbDataFormModelItem::RadioButtonListItem,tr("Profiles")); |
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)); |
48 |
87 |
49 QStringList items; |
88 mMasterVolumeValueController = new CpMasterVolumeValueController(mProfileModel, mMasterVolume, |
50 items << tr("Normal") << tr("Meeting") << tr("Silent"); |
89 itemDataHelper, activeProfileItem); |
51 activeProfileItem->setContentWidgetData("items",items); |
90 this->appendChild(mMasterVolume); |
52 activeProfileItem->setContentWidgetData("selected",0); |
|
53 |
|
54 appendChild(activeProfileItem); |
|
55 |
91 |
56 HbDataFormModelItem *editProfileItem = new CpSettingFormEntryItemDataImpl<CpProfileSettingView>( |
92 HbDataFormModelItem *editProfileItem = new CpSettingFormEntryItemDataImpl<CpProfileSettingView>( |
57 itemDataHelper,tr("Edit profiles")); |
93 itemDataHelper,tr("Edit profiles")); |
58 appendChild(editProfileItem); |
94 appendChild(editProfileItem); |
59 } |
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 } |