|
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 "cpvolumegroupitemdata.h" |
|
18 #include <cplogger.h> |
|
19 #include <QStringList> |
|
20 #include <cpsettingformentryitemdataimpl.h> |
|
21 #include <cpbasesettingview.h> |
|
22 #include <cpitemdatahelper.h> |
|
23 #include <hbmessagebox.h> |
|
24 #include <cpprofilemodel.h> |
|
25 //#include "cpmastervolumevaluecontroller.h" |
|
26 #include "cpvolumecontroller.h" |
|
27 #include "cppersonalizationcustomviewitem.h" |
|
28 #include <hbslider.h> |
|
29 |
|
30 CpVolumeGroupItemData::CpVolumeGroupItemData(CpItemDataHelper &itemDataHelper) |
|
31 : CpSettingFormItemData(HbDataFormModelItem::GroupItem,tr("txt_cp_subhead_volume")),//mSilenceIndicator(0), |
|
32 //mMasterVolume(0), |
|
33 //mMasterVibra(0), |
|
34 mVolumeController(0), |
|
35 mProfileModel(0) |
|
36 { |
|
37 initItems(itemDataHelper); |
|
38 } |
|
39 |
|
40 CpVolumeGroupItemData::~CpVolumeGroupItemData() |
|
41 { |
|
42 delete mProfileModel; |
|
43 } |
|
44 |
|
45 void CpVolumeGroupItemData::initItems(CpItemDataHelper &itemDataHelper) |
|
46 { |
|
47 mProfileModel = new CpProfileModel(); |
|
48 |
|
49 itemDataHelper.addItemPrototype(new CpPersonalizationCustomViewItem); |
|
50 CPFW_LOG("CpVolumeGroupItemData::initItems(), get active profile id"); |
|
51 CPFW_LOG("CpVolumeGroupItemData::initItems(), succeed in getting id"); |
|
52 |
|
53 HbDataFormModelItem *silenceIndicator = new HbDataFormModelItem(static_cast<HbDataFormModelItem::DataItemType>(SilenceIndicatorItem)); |
|
54 mItemList.insert(CpVolumeGroupItemData::EVolumeSilenceItem, silenceIndicator); |
|
55 silenceIndicator->setContentWidgetData("text",hbTrId("txt_cp_button_silence")); |
|
56 this->appendChild(silenceIndicator); |
|
57 |
|
58 HbDataFormModelItem *masterVolume = new HbDataFormModelItem(HbDataFormModelItem::SliderItem, |
|
59 hbTrId("txt_cp_setlabel_volume")); |
|
60 mItemList.insert(CpVolumeGroupItemData::EVolumeMasterVolumeItem, masterVolume); |
|
61 QList<QVariant> elements; |
|
62 elements << QVariant(HbSlider::IncreaseElement) << QVariant(HbSlider::TrackElement) |
|
63 << QVariant(HbSlider::DecreaseElement) << QVariant(HbSlider::IconElement) |
|
64 << QVariant(HbSlider::TextElement); |
|
65 masterVolume->setContentWidgetData("sliderElements",elements); |
|
66 |
|
67 QMap<QString, QVariant> iconMaps; |
|
68 iconMaps.insert(QString("DecreaseElement"), QVariant(":/icon/hb_vol_slider_decrement.svg")); |
|
69 iconMaps.insert(QString("IncreaseElement"), QVariant(":/icon/hb_vol_slider_increment.svg")); |
|
70 //iconMaps.insert(QString("IconElement"), QVariant(":/icon/hb_vol_slider_muted.svg")); |
|
71 |
|
72 masterVolume->setContentWidgetData("elementIcons", iconMaps); |
|
73 masterVolume->setContentWidgetData("minimum", 1); |
|
74 masterVolume->setContentWidgetData("maximum", 3); |
|
75 masterVolume->setContentWidgetData("majorTickInterval",1); |
|
76 |
|
77 QStringList tickLabels; |
|
78 tickLabels<<hbTrId("Soft") |
|
79 <<hbTrId("Med") |
|
80 <<hbTrId("Loud"); |
|
81 masterVolume->setContentWidgetData("majorTickLabels",tickLabels); |
|
82 |
|
83 this->appendChild(masterVolume); |
|
84 |
|
85 HbDataFormModelItem *masterVibra = new HbDataFormModelItem(HbDataFormModelItem::CheckBoxItem); |
|
86 mItemList.insert(CpVolumeGroupItemData::EVolumeMasterVibraItem, masterVibra); |
|
87 masterVibra->setContentWidgetData("text",hbTrId("txt_cp_list_vibrate")); |
|
88 |
|
89 this->appendChild(masterVibra); |
|
90 |
|
91 mVolumeController = new CpVolumeController(mProfileModel, mItemList, itemDataHelper); |
|
92 } |
|
93 //void CpVolumeGroupItemData::activateProfile(int profileIndex) |
|
94 //{ |
|
95 // switch (profileIndex) { |
|
96 // case 0: // general |
|
97 // { |
|
98 // mProfileModel->activateProfile(EProfileWrapperGeneralId); |
|
99 // int volumeValue = mProfileModel->ringVolume(); |
|
100 // // update the master volume when profile changed |
|
101 // // should be used profileChangedObserver in the future; |
|
102 // mMasterVolume->setContentWidgetData(/*"visible"*/"enabled",true); |
|
103 // mMasterVolume->setContentWidgetData("value", volumeValue); |
|
104 // break; |
|
105 // } |
|
106 // case 1: // meeting |
|
107 // { |
|
108 // mProfileModel->activateProfile(EProfileWrapperMeetingId); |
|
109 // int volumeValue = mProfileModel->ringVolume(); |
|
110 // mMasterVolume->setContentWidgetData(/*"visible"*/"enabled",true); |
|
111 // mMasterVolume->setContentWidgetData("value", volumeValue); |
|
112 // break; |
|
113 // } |
|
114 // case 2: // silent |
|
115 // { |
|
116 // mProfileModel->activateProfile(EProfileWrapperSilentId); |
|
117 // mMasterVolume->setContentWidgetData("value", 0); |
|
118 // mMasterVolume->setContentWidgetData(/*"visible"*/"enabled",false); |
|
119 // break; |
|
120 // } |
|
121 // default: |
|
122 // break; |
|
123 // |
|
124 // } |
|
125 //} |