27 |
27 |
28 #include "calensettings.h" |
28 #include "calensettings.h" |
29 #include "calenservices.h" |
29 #include "calenservices.h" |
30 #include "calendarprivatecrkeys.h" |
30 #include "calendarprivatecrkeys.h" |
31 |
31 |
|
32 // Constants |
|
33 const int KValueZero( 0 ); |
|
34 const int KValueOne( 1 ); |
|
35 |
|
36 |
32 CalenSettings::CalenSettings(MCalenServices& services, HbDataForm *form, QObject *parent) |
37 CalenSettings::CalenSettings(MCalenServices& services, HbDataForm *form, QObject *parent) |
33 :QObject(parent), |
38 :QObject(parent), |
34 mServices(services), |
39 mServices(services), |
35 mSettingsForm(form), |
40 mSettingsForm(form), |
36 mSettingsModel(0), |
41 mSettingsModel(NULL), |
|
42 mAlarmSnoozeTimeItem(NULL), |
|
43 mShowWeekNumberItem(NULL), |
37 mShowRegionalInfoItem(NULL), |
44 mShowRegionalInfoItem(NULL), |
38 mShowWeekStartOnInfoItem(NULL), |
45 mShowWeekStartOnInfoItem(NULL), |
|
46 mStartOfWeekItem(NULL), |
39 mWeekNumberItemAdded(false), |
47 mWeekNumberItemAdded(false), |
40 mRegionalpluginActive(false) |
48 mRegionalpluginActive(false) |
41 { |
49 { |
42 mSettingsManager = new XQSettingsManager(this); |
50 mSettingsManager = new XQSettingsManager(this); |
43 mAlarmSnoozeCenrepKey = new XQSettingsKey( |
51 mAlarmSnoozeCenrepKey = new XQSettingsKey( |
44 XQSettingsKey::TargetCentralRepository, |
52 XQSettingsKey::TargetCentralRepository, |
45 KCRUidCalendar, KCalendarSnoozeTime); |
53 KCRUidCalendar, KCalendarSnoozeTime); |
46 mWeekNumberCenrepKey = new XQSettingsKey( |
54 mWeekNumberCenrepKey = new XQSettingsKey( |
47 XQSettingsKey::TargetCentralRepository, |
55 XQSettingsKey::TargetCentralRepository, |
48 KCRUidCalendar, KCalendarShowWeekNum); |
56 KCRUidCalendar, KCalendarShowWeekNum); |
49 mShowRegionalInfoKey = new XQSettingsKey( |
57 mShowRegionalInfoKey = new XQSettingsKey( |
50 XQSettingsKey::TargetCentralRepository, |
58 XQSettingsKey::TargetCentralRepository, |
51 KCRUidCalendar, KCalendarShowRegionalInfo); |
59 KCRUidCalendar, KCalendarShowRegionalInfo); |
52 |
60 } |
53 // Read the initial values from the cenrep |
61 |
54 QVariant value = mSettingsManager->readItemValue(*mAlarmSnoozeCenrepKey); |
62 /*! |
55 mAlarmSnoozeTime = value.toUInt(); |
63 Destructor |
56 |
64 */ |
57 value = mSettingsManager->readItemValue(*mWeekNumberCenrepKey); |
|
58 mShowWeekNumber = value.toUInt(); |
|
59 |
|
60 value = mSettingsManager->readItemValue(*mShowRegionalInfoKey); |
|
61 mShowRegionalInfo = value.toUInt(); |
|
62 } |
|
63 |
|
64 CalenSettings::~CalenSettings() |
65 CalenSettings::~CalenSettings() |
65 { |
66 { |
66 // Nothing yet. |
67 if (mSettingsManager) { |
67 } |
68 delete mSettingsManager; |
68 |
69 } |
|
70 // Delete the cenrep keys |
|
71 delete mAlarmSnoozeCenrepKey; |
|
72 delete mWeekNumberCenrepKey; |
|
73 delete mShowRegionalInfoKey; |
|
74 |
|
75 if (mSettingsModel) { |
|
76 delete mSettingsModel; |
|
77 } |
|
78 if (mAlarmSnoozeTimeHash.count()) { |
|
79 // Clear the contents |
|
80 mAlarmSnoozeTimeHash.clear(); |
|
81 } |
|
82 } |
|
83 |
|
84 /*! |
|
85 Creates the settings model |
|
86 */ |
69 void CalenSettings::createModel() |
87 void CalenSettings::createModel() |
70 { |
88 { |
71 // Remove the model. |
89 // Remove the model. |
72 if (mSettingsForm->model()) { |
90 if (mSettingsForm->model()) { |
73 delete mSettingsForm->model(); |
91 delete mSettingsForm->model(); |
74 mSettingsForm->setModel(0); |
92 mSettingsForm->setModel(0); |
75 mSettingsModel = 0; |
93 mSettingsModel = 0; |
76 } |
94 } |
77 |
95 |
78 // Create a model and set it. |
96 // Create a model and set it. |
79 mSettingsModel = new HbDataFormModel(); |
97 mSettingsModel = new HbDataFormModel(mSettingsForm); |
80 |
98 |
81 // Create the alarm snooze choices |
99 // Create the alarm snooze choices |
82 QStringList alarmSnoozeChoices; |
100 QStringList alarmSnoozeChoices; |
83 alarmSnoozeChoices << hbTrId( |
101 alarmSnoozeChoices << hbTrId( |
84 "txt_calendar_setlabel_alarm_snooze_time_val_5_minu") |
102 "txt_calendar_setlabel_reminder_snooze_time_val_5_m") |
85 << hbTrId("txt_calendar_setlabel_alarm_snooze_time_val_10_min") |
103 << hbTrId("txt_calendar_setlabel_reminder_snooze_time_val_10") |
86 << hbTrId("txt_calendar_setlabel_alarm_snooze_time_val_15_min") |
104 << hbTrId("txt_calendar_setlabel_reminder_snooze_time_val_15") |
87 << hbTrId("txt_calendar_setlabel_alarm_snooze_time_val_30_min"); |
105 << hbTrId("txt_calendar_setlabel_reminder_snooze_time_val_30"); |
|
106 // Build the hash map for the alarm snooze time. |
|
107 // The values are five, ten, fifteen and thirty minutes |
|
108 mAlarmSnoozeTimeHash[0] = 5; |
|
109 mAlarmSnoozeTimeHash[1] = 10; |
|
110 mAlarmSnoozeTimeHash[2] = 15; |
|
111 mAlarmSnoozeTimeHash[3] = 30; |
88 |
112 |
89 // Append Alarm Snooze Time Setting item |
113 // Append Alarm Snooze Time Setting item |
90 mAlarmSnoozeTimeItem = new HbDataFormModelItem(); |
114 mAlarmSnoozeTimeItem = new HbDataFormModelItem(); |
91 mAlarmSnoozeTimeItem->setType(HbDataFormModelItem::ComboBoxItem); |
115 mAlarmSnoozeTimeItem->setType(HbDataFormModelItem::ComboBoxItem); |
92 mAlarmSnoozeTimeItem->setData(HbDataFormModelItem::LabelRole, |
116 mAlarmSnoozeTimeItem->setData(HbDataFormModelItem::LabelRole, |
93 QString(hbTrId("txt_calendar_setlabel_alarm_snooze_time"))); |
117 QString(hbTrId("txt_calendar_setlabel_reminder_snooze_time"))); |
94 |
118 |
95 mAlarmSnoozeTimeItem->setContentWidgetData(QString("items"), |
119 mAlarmSnoozeTimeItem->setContentWidgetData(QString("items"), |
96 alarmSnoozeChoices); |
120 alarmSnoozeChoices); |
97 mAlarmSnoozeTimeItem->setContentWidgetData(QString("currentIndex"), 0); |
121 mAlarmSnoozeTimeItem->setContentWidgetData(QString("currentIndex"), 0); |
98 mSettingsForm->addConnection(mAlarmSnoozeTimeItem, |
122 mSettingsForm->addConnection(mAlarmSnoozeTimeItem, |
99 SIGNAL(currentIndexChanged(int)), |
123 SIGNAL(currentIndexChanged(int)), |
100 this, SLOT(handleAlarmSnoozeTimeChange(int))); |
124 this, SLOT(handleAlarmSnoozeTimeChange(int))); |
101 mSettingsModel->appendDataFormItem(mAlarmSnoozeTimeItem); |
125 mSettingsModel->appendDataFormItem(mAlarmSnoozeTimeItem); |
102 |
126 |
103 // Create the weekday list based on start of week. |
127 // Create the weekday list based on start of week. |
104 QStringList weekdaysList; |
128 QStringList weekdaysList; |
105 weekdaysList |
129 weekdaysList |
106 << QString("Monday")//hbTrId("txt_clk_setlabel_val_monday")//@TODO set to proper localization strings once available |
130 << hbTrId("txt_calendar_setlabel_week_starts_on_val_monday") |
107 << QString("Tuesday")//hbTrId("txt_clk_setlabel_val_tuesday") |
131 << hbTrId("txt_calendar_setlabel_week_starts_on_val_tuesday") |
108 << QString("Wednesday")//hbTrId("txt_clk_setlabel_val_wednesday") |
132 << hbTrId("txt_calendar_setlabel_week_starts_on_val_wednesday") |
109 << QString("Thursday")//hbTrId("txt_clk_setlabel_val_thursday") |
133 << hbTrId("txt_calendar_setlabel_week_starts_on_val_thursday") |
110 << QString("Friday")//hbTrId("txt_clk_setlabel_val_friday") |
134 << hbTrId("txt_calendar_setlabel_week_starts_on_val_friday") |
111 << QString("Saturday")//hbTrId("txt_clk_setlabel_val_saturday") |
135 << hbTrId("txt_calendar_setlabel_week_starts_on_val_saturday") |
112 << QString("Sunday");//hbTrId("txt_clk_setlabel_val_sunday"); |
136 << hbTrId("txt_calendar_setlabel_week_starts_on_val_sunday"); |
113 // Start of week item. |
137 // Start of week item. |
114 mShowWeekStartOnInfoItem = mSettingsModel->appendDataFormItem(HbDataFormModelItem::ComboBoxItem,QString("Week Starts On")); |
138 mShowWeekStartOnInfoItem = mSettingsModel->appendDataFormItem( |
115 // hbTrId("txt_clock_setlabel_week_starts_on"));//@TODO set to proper localization strings once available |
139 HbDataFormModelItem::ComboBoxItem, |
|
140 hbTrId("txt_calendar_setlabel_week_starts_on")); |
|
141 |
116 // Get start of week from the locale. |
142 // Get start of week from the locale. |
117 HbExtendedLocale locale = HbExtendedLocale::system(); |
143 HbExtendedLocale locale = HbExtendedLocale::system(); |
118 mStartOfWeek = locale.startOfWeek(); |
144 mStartOfWeek = locale.startOfWeek(); |
119 mShowWeekStartOnInfoItem->setContentWidgetData("items", weekdaysList); |
145 mShowWeekStartOnInfoItem->setContentWidgetData("items", weekdaysList); |
120 mShowWeekStartOnInfoItem->setContentWidgetData("currentIndex", mStartOfWeek); |
146 mShowWeekStartOnInfoItem->setContentWidgetData("currentIndex", mStartOfWeek); |
121 mSettingsForm->addConnection(mShowWeekStartOnInfoItem, SIGNAL(currentIndexChanged(int)), |
147 mSettingsForm->addConnection(mShowWeekStartOnInfoItem, |
122 this, SLOT(setStartDayOfWeek(int))); |
148 SIGNAL(currentIndexChanged(int)), |
123 //add show week number item in the model |
149 this, SLOT(setStartDayOfWeek(int))); |
124 |
150 // Add the show week number item in the model |
125 addWeekNumberItem(); |
151 addWeekNumberItem(); |
126 mSettingsModel->appendDataFormItem(mShowWeekNumberItem); |
152 |
127 |
153 if (isPluginEnabled()) { |
128 if(isPluginEnabled()) { |
|
129 addRegionalInfoItem(); |
154 addRegionalInfoItem(); |
130 } |
155 } |
131 } |
156 } |
132 |
157 |
|
158 /*! |
|
159 Adds the regional info item to the model |
|
160 */ |
133 void CalenSettings::addRegionalInfoItem() |
161 void CalenSettings::addRegionalInfoItem() |
134 { |
162 { |
135 mRegionalpluginActive = true; |
163 mRegionalpluginActive = true; |
136 // Regional info is the second item in the model |
164 mShowRegionalInfoItem = new HbDataFormModelItem(); |
137 int index = mSettingsModel->indexFromItem(mAlarmSnoozeTimeItem).row() + 1; |
165 mShowRegionalInfoItem->setType(HbDataFormModelItem::ToggleValueItem); |
138 |
166 mShowRegionalInfoItem->setData(HbDataFormModelItem::LabelRole, |
139 mShowRegionalInfoItem = mSettingsModel->insertDataFormItem( |
167 QString(hbTrId("txt_calendar_setlabel_show_lunar_calendar"))); |
140 index , |
|
141 HbDataFormModelItem::ToggleValueItem, |
|
142 QString(hbTrId("txt_calendar_setlabel_show_lunar_calendar")), |
|
143 mSettingsModel->invisibleRootItem()); |
|
144 |
168 |
145 // For HbPushButton type properties -- to be used for toggle value item |
169 // For HbPushButton type properties -- to be used for toggle value item |
146 mShowRegionalInfoItem->setContentWidgetData(QString("text"), |
170 mShowRegionalInfoItem->setContentWidgetData(QString("text"), |
147 QString(hbTrId("txt_calendar_button_no"))); |
171 QString(hbTrId("txt_calendar_button_no"))); |
148 mShowRegionalInfoItem->setContentWidgetData(QString("additionalText"), |
172 mShowRegionalInfoItem->setContentWidgetData(QString("additionalText"), |
149 QString(hbTrId("txt_calendar_button_yes"))); |
173 QString(hbTrId("txt_calendar_button_yes"))); |
150 mSettingsForm->addConnection(mShowRegionalInfoItem, SIGNAL(clicked()), |
174 mSettingsForm->addConnection(mShowRegionalInfoItem, SIGNAL(clicked()), |
151 this, SLOT(handleRegionalInfoChange())); |
175 this, SLOT(handleRegionalInfoChange())); |
152 |
176 mSettingsModel->appendDataFormItem(mShowRegionalInfoItem); |
153 } |
177 } |
154 |
178 |
|
179 /*! |
|
180 Removes the regional info item from the model |
|
181 */ |
155 void CalenSettings::removeRegionalInfoItem() |
182 void CalenSettings::removeRegionalInfoItem() |
156 { |
183 { |
157 mSettingsForm->removeConnection(mShowRegionalInfoItem, SIGNAL(clicked()), |
184 mSettingsForm->removeConnection(mShowRegionalInfoItem, SIGNAL(clicked()), |
158 this, SLOT(handleRegionalInfoChange())); |
185 this, SLOT(handleRegionalInfoChange())); |
159 mSettingsModel->removeItem(mShowRegionalInfoItem); |
186 mSettingsModel->removeItem(mShowRegionalInfoItem); |
160 mRegionalpluginActive = false; |
187 mRegionalpluginActive = false; |
161 } |
188 } |
162 |
189 |
|
190 /*! |
|
191 Handles the alarm snooze time change |
|
192 */ |
163 void CalenSettings::handleAlarmSnoozeTimeChange(int index) |
193 void CalenSettings::handleAlarmSnoozeTimeChange(int index) |
164 { |
194 { |
165 switch(index) |
195 if(mAlarmSnoozeTimeHash.value(index) > KValueZero) { |
166 { |
196 mSettingsManager->writeItemValue(*mAlarmSnoozeCenrepKey, mAlarmSnoozeTimeHash[index]); |
167 case 0: |
197 } |
168 { |
198 } |
169 mSettingsManager->writeItemValue(*mAlarmSnoozeCenrepKey, 5); |
199 |
170 } |
200 /*! |
171 break; |
201 Handles the week number change |
172 case 1: |
202 */ |
173 { |
|
174 mSettingsManager->writeItemValue(*mAlarmSnoozeCenrepKey, 10); |
|
175 } |
|
176 break; |
|
177 case 2: |
|
178 { |
|
179 mSettingsManager->writeItemValue(*mAlarmSnoozeCenrepKey, 15); |
|
180 } |
|
181 break; |
|
182 case 3: |
|
183 { |
|
184 mSettingsManager->writeItemValue(*mAlarmSnoozeCenrepKey, 30); |
|
185 } |
|
186 break; |
|
187 default: |
|
188 break; |
|
189 } |
|
190 QVariant value = mSettingsManager->readItemValue(*mAlarmSnoozeCenrepKey); |
|
191 uint time = value.toUInt(); |
|
192 } |
|
193 |
|
194 void CalenSettings::handleWeekNumberChange() |
203 void CalenSettings::handleWeekNumberChange() |
195 { |
204 { |
196 QVariant data = mShowWeekNumberItem->contentWidgetData(QString("text")); |
205 QVariant data = mShowWeekNumberItem->contentWidgetData(QString("text")); |
197 QString value = data.toString(); |
206 QString value = data.toString(); |
198 if(!value.compare(hbTrId("txt_calendar_button_no"))) |
207 if (!value.compare(hbTrId("txt_calendar_button_no"))) { |
199 { |
|
200 // User has made it OFF. |
208 // User has made it OFF. |
201 mShowWeekNumber = 0; |
209 mSettingsManager->writeItemValue(*mWeekNumberCenrepKey, KValueZero); |
202 mSettingsManager->writeItemValue(*mWeekNumberCenrepKey, 0); |
210 } else if (!value.compare(hbTrId("txt_calendar_button_yes"))) { |
203 } |
|
204 else if(!value.compare(hbTrId("txt_calendar_button_yes"))) |
|
205 { |
|
206 // User has made it ON. |
211 // User has made it ON. |
207 mShowWeekNumber = 1; |
212 mSettingsManager->writeItemValue(*mWeekNumberCenrepKey, KValueOne); |
208 mSettingsManager->writeItemValue(*mWeekNumberCenrepKey, 1); |
213 } |
209 } |
214 } |
210 } |
215 |
211 |
216 /*! |
|
217 Handles the regional info option change |
|
218 */ |
212 void CalenSettings::handleRegionalInfoChange() |
219 void CalenSettings::handleRegionalInfoChange() |
213 { |
220 { |
214 QVariant data = mShowRegionalInfoItem->contentWidgetData(QString("text")); |
221 QVariant data = mShowRegionalInfoItem->contentWidgetData(QString("text")); |
215 QString value = data.toString(); |
222 QString value = data.toString(); |
216 if(!value.compare(hbTrId("txt_calendar_button_no"))) { |
223 if (!value.compare(hbTrId("txt_calendar_button_no"))) { |
217 // User has made it OFF |
224 // User has made it OFF |
218 mShowRegionalInfo = 0; |
225 mSettingsManager->writeItemValue(*mShowRegionalInfoKey, KValueZero); |
219 mSettingsManager->writeItemValue(*mShowRegionalInfoKey, 0); |
226 } else if (!value.compare(hbTrId("txt_calendar_button_yes"))) { |
220 } else if(!value.compare(hbTrId("txt_calendar_button_yes"))) { |
227 // User has made it ON. |
221 // User has made it ON. |
228 mSettingsManager->writeItemValue(*mShowRegionalInfoKey, KValueOne); |
222 mShowRegionalInfo = 1; |
229 } |
223 mSettingsManager->writeItemValue(*mShowRegionalInfoKey, 1); |
230 } |
224 } |
231 |
225 } |
232 /*! |
226 |
233 Populates the settings model |
|
234 */ |
227 void CalenSettings::populateSettingList() |
235 void CalenSettings::populateSettingList() |
228 { |
236 { |
229 // Read the values from cenrep |
237 // Read the values from cenrep |
230 // Read the initial values from the cenrep |
238 // Read the initial values from the cenrep |
231 QVariant value = mSettingsManager->readItemValue(*mAlarmSnoozeCenrepKey); |
239 QVariant value = mSettingsManager->readItemValue(*mAlarmSnoozeCenrepKey); |
232 mAlarmSnoozeTime = value.toUInt(); |
240 uint alarmSnoozeTime = value.toUInt(); |
233 |
241 |
234 value = mSettingsManager->readItemValue(*mWeekNumberCenrepKey); |
242 // Get the value from the hash and set the value to the form |
235 mShowWeekNumber = value.toUInt(); |
243 int choiceIndex = mAlarmSnoozeTimeHash.key(alarmSnoozeTime); |
236 |
244 mAlarmSnoozeTimeItem->setContentWidgetData(QString("currentIndex"), |
237 // set the value to the form |
245 choiceIndex); |
238 int choiceIndex = 0; |
|
239 switch(mAlarmSnoozeTime) |
|
240 { |
|
241 case 5: |
|
242 choiceIndex = 0; |
|
243 break; |
|
244 case 10: |
|
245 choiceIndex = 1; |
|
246 break; |
|
247 case 15: |
|
248 choiceIndex = 2; |
|
249 break; |
|
250 case 30: |
|
251 choiceIndex = 3; |
|
252 break; |
|
253 default: |
|
254 choiceIndex = 0; |
|
255 break; |
|
256 } |
|
257 mAlarmSnoozeTimeItem->setContentWidgetData(QString("currentIndex"), |
|
258 choiceIndex); |
|
259 |
|
260 // Get start of week from the locale. |
246 // Get start of week from the locale. |
261 HbExtendedLocale locale = HbExtendedLocale::system(); |
247 HbExtendedLocale locale = HbExtendedLocale::system(); |
262 mStartOfWeek = locale.startOfWeek(); |
248 mStartOfWeek = locale.startOfWeek(); |
263 |
249 |
264 |
250 mShowWeekStartOnInfoItem->setContentWidgetData("currentIndex", mStartOfWeek); |
265 mShowWeekStartOnInfoItem->setContentWidgetData("currentIndex", mStartOfWeek); |
251 //update the show week number option |
266 //update the show week number option |
252 updateShowWeekItem(); |
267 updateShowWeekItem(); |
253 // Check the the regional info plugin is loaded now or not |
268 // Check the the regional info plugin is loaded now or not |
254 if (isPluginEnabled()) { |
269 if(isPluginEnabled()) { |
255 // If the plugin was already there just populate the item |
270 // If the plugin was already there just populate the item |
256 // else add the regional info item and then populate |
271 // else add the regional info item and then populate |
257 if (mRegionalpluginActive) { |
272 if(mRegionalpluginActive) { |
258 populateRegionalInfo(); |
273 populateRegionalInfo(); |
259 }else { |
274 }else { |
260 addRegionalInfoItem(); |
275 addRegionalInfoItem(); |
261 populateRegionalInfo(); |
276 populateRegionalInfo(); |
262 } |
277 } |
263 }else { |
278 }else { |
264 // If the plugin is removed now and if it was loaded before |
279 // If the plugin is removed now and if it was loaded before |
265 // remove the item |
280 // remove the item |
266 if (mRegionalpluginActive) { |
281 if(mRegionalpluginActive) { |
267 removeRegionalInfoItem(); |
282 removeRegionalInfoItem(); |
268 } |
283 } |
269 } |
284 } |
270 mSettingsForm->setModel(mSettingsModel); |
285 mSettingsForm->setModel(mSettingsModel); |
271 } |
286 } |
272 |
287 |
273 /*! |
|
274 Populates the regional info item |
|
275 */ |
288 void CalenSettings::populateRegionalInfo() |
276 void CalenSettings::populateRegionalInfo() |
289 { |
277 { |
290 QVariant value = mSettingsManager->readItemValue(*mShowRegionalInfoKey); |
278 QVariant value = mSettingsManager->readItemValue(*mShowRegionalInfoKey); |
291 mShowRegionalInfo = value.toUInt(); |
279 uint showRegionalInfo = value.toUInt(); |
292 |
280 |
293 if (mShowRegionalInfo) { |
281 if (showRegionalInfo) { |
294 mShowRegionalInfoItem->setContentWidgetData( |
282 mShowRegionalInfoItem->setContentWidgetData( |
295 QString("text"), QString(hbTrId("txt_calendar_button_yes"))); |
283 QString("text"), QString(hbTrId("txt_calendar_button_yes"))); |
296 mShowRegionalInfoItem->setContentWidgetData( |
284 mShowRegionalInfoItem->setContentWidgetData( |
297 QString("additionalText"), QString( |
285 QString("additionalText"), QString( |
298 hbTrId("txt_calendar_button_no"))); |
286 hbTrId("txt_calendar_button_no"))); |
299 } else { |
287 } else { |
300 mShowRegionalInfoItem->setContentWidgetData( |
288 mShowRegionalInfoItem->setContentWidgetData( |
301 QString("text"), QString(hbTrId("txt_calendar_button_no"))); |
289 QString("text"), QString(hbTrId("txt_calendar_button_no"))); |
302 mShowRegionalInfoItem->setContentWidgetData( |
290 mShowRegionalInfoItem->setContentWidgetData( |
303 QString("additionalText"), QString( |
291 QString("additionalText"), QString( |
304 hbTrId("txt_calendar_button_yes"))); |
292 hbTrId("txt_calendar_button_yes"))); |
305 } |
293 } |
306 |
294 } |
307 } |
295 |
308 |
296 /*! |
|
297 Adds the week number item in the model |
|
298 */ |
309 void CalenSettings::addWeekNumberItem() |
299 void CalenSettings::addWeekNumberItem() |
310 { |
300 { |
311 mWeekNumberItemAdded = true; |
301 mWeekNumberItemAdded = true; |
312 // Append Show Week Number settings item |
302 // Append Show Week Number settings item |
313 mShowWeekNumberItem = new HbDataFormModelItem(); |
303 mShowWeekNumberItem = new HbDataFormModelItem(); |
314 mShowWeekNumberItem->setType(HbDataFormModelItem::ToggleValueItem); |
304 mShowWeekNumberItem->setType(HbDataFormModelItem::ToggleValueItem); |
315 QStringList values; |
305 |
316 values << hbTrId("txt_calendar_button_no") |
306 QStringList values; |
317 << hbTrId("txt_calendar_button_yes"); |
307 values << hbTrId("txt_calendar_button_no") |
318 mShowWeekNumberItem->setData(HbDataFormModelItem::LabelRole, |
308 << hbTrId("txt_calendar_button_yes"); |
319 QString(hbTrId("txt_calendar_setlabel_show_week_numbers"))); |
309 mShowWeekNumberItem->setData(HbDataFormModelItem::LabelRole, |
320 |
310 QString(hbTrId("txt_calendar_setlabel_show_week_numbers"))); |
321 |
311 |
322 // For HbPushButton type properties -- to be used for toggle value item |
312 mSettingsModel->appendDataFormItem(mShowWeekNumberItem); |
323 if(mShowWeekNumber) |
313 mSettingsForm->addConnection(mShowWeekNumberItem, SIGNAL(clicked()), |
324 { |
314 this, SLOT(handleWeekNumberChange())); |
325 mShowWeekNumberItem->setContentWidgetData(QString("text"), |
315 } |
326 QString(hbTrId("txt_calendar_button_yes"))); |
316 |
327 mShowWeekNumberItem->setContentWidgetData(QString("additionalText"), |
317 /*! |
328 QString(hbTrId("txt_calendar_button_no"))); |
318 Returns true if the regional plugin is loaded |
329 } |
|
330 else |
|
331 { |
|
332 mShowWeekNumberItem->setContentWidgetData(QString("text"), |
|
333 QString(hbTrId("txt_calendar_button_no"))); |
|
334 mShowWeekNumberItem->setContentWidgetData(QString("additionalText"), |
|
335 QString(hbTrId("txt_calendar_button_yes"))); |
|
336 } |
|
337 |
|
338 mSettingsForm->addConnection(mShowWeekNumberItem, SIGNAL(clicked()), |
|
339 this, SLOT(handleWeekNumberChange())); |
|
340 } |
|
341 |
|
342 /*! |
|
343 Returns true if plugin is loaded |
|
344 */ |
319 */ |
345 bool CalenSettings::isPluginEnabled() |
320 bool CalenSettings::isPluginEnabled() |
346 { |
321 { |
347 QString *pluginInfo = mServices.InfobarTextL(); |
322 QString *pluginInfo = mServices.InfobarTextL(); |
348 if (!pluginInfo) { |
323 if (!pluginInfo) { |
349 return false; |
324 return false; |
350 } else { |
325 } else { |
351 return true; |
326 return true; |
352 } |
327 } |
353 } |
328 } |
354 // --------------------------------------------------------- |
329 |
355 // CalenSettings::setStartDayOfWeek |
330 /*! |
356 // sets the start day of the week to the locale |
331 Sets the start day of the week to the locale |
357 // calls when user select week day |
332 Is called when user selects week day |
358 // --------------------------------------------------------- |
333 */ |
359 // |
|
360 void CalenSettings::setStartDayOfWeek(const int index) |
334 void CalenSettings::setStartDayOfWeek(const int index) |
361 { |
335 { |
362 TLocale locale; |
336 TLocale locale; |
363 TDay day = (TDay)index; |
337 TDay day = (TDay)index; |
364 //set the start day of the week to locale |
338 //set the start day of the week to locale |
365 locale.SetStartOfWeek(day); |
339 locale.SetStartOfWeek(day); |
366 locale.Set(); |
340 locale.Set(); |
367 updateShowWeekItem(); |
341 updateShowWeekItem(); |
368 } |
342 } |
369 |
343 |
370 // --------------------------------------------------------- |
344 /*! |
371 // CalenSettings::updateShowWeekItem |
345 Updates the show week number option |
372 // update the show week number option |
346 */ |
373 // --------------------------------------------------------- |
|
374 // |
|
375 void CalenSettings::updateShowWeekItem() |
347 void CalenSettings::updateShowWeekItem() |
376 { |
348 { |
377 // Get start of week from the locale. |
349 // Get start of week from the locale. |
378 HbExtendedLocale locale = HbExtendedLocale::system(); |
350 HbExtendedLocale locale = HbExtendedLocale::system(); |
379 mStartOfWeek = locale.startOfWeek(); |
351 mStartOfWeek = locale.startOfWeek(); |
380 mShowWeekStartOnInfoItem->setContentWidgetData("currentIndex", mStartOfWeek); |
352 mShowWeekStartOnInfoItem->setContentWidgetData("currentIndex", mStartOfWeek); |
381 //if start day is not Monday |
353 |
382 //set the show week number option dimmed , |
354 // Read the value form cenrep |
383 //else set to proper status |
355 QVariant value = mSettingsManager->readItemValue(*mWeekNumberCenrepKey); |
384 if(mStartOfWeek != HbExtendedLocale::Monday) |
356 uint showWeekNumber = value.toUInt(); |
385 { |
357 |
386 mShowWeekNumberItem->setContentWidgetData(QString("text"), |
358 //if start day is not Monday |
387 QString(hbTrId("txt_calendar_button_no"))); |
359 //set the show week number option dimmed , |
388 mShowWeekNumberItem->setContentWidgetData(QString("additionalText"), |
360 //else set to proper status |
389 QString(hbTrId("txt_calendar_button_yes"))); |
361 if(mStartOfWeek != HbExtendedLocale::Monday) { |
390 mShowWeekNumberItem->setEnabled(false); |
362 mShowWeekNumberItem->setContentWidgetData(QString("text"), |
391 } |
363 QString(hbTrId("txt_calendar_button_no"))); |
392 else |
364 mShowWeekNumberItem->setContentWidgetData(QString("additionalText"), |
393 { |
365 QString(hbTrId("txt_calendar_button_yes"))); |
394 if(mShowWeekNumber) |
366 mShowWeekNumberItem->setEnabled(false); |
395 { |
367 } else { |
396 mShowWeekNumberItem->setContentWidgetData(QString("text"), |
368 if(showWeekNumber) { |
397 QString(hbTrId("txt_calendar_button_yes"))); |
369 mShowWeekNumberItem->setContentWidgetData(QString("text"), |
398 mShowWeekNumberItem->setContentWidgetData(QString("additionalText"), |
370 QString(hbTrId("txt_calendar_button_yes"))); |
399 QString(hbTrId("txt_calendar_button_no"))); |
371 mShowWeekNumberItem->setContentWidgetData(QString("additionalText"), |
400 } |
372 QString(hbTrId("txt_calendar_button_no"))); |
401 else |
373 } else { |
402 { |
374 mShowWeekNumberItem->setContentWidgetData(QString("text"), |
403 mShowWeekNumberItem->setContentWidgetData(QString("text"), |
375 QString(hbTrId("txt_calendar_button_no"))); |
404 QString(hbTrId("txt_calendar_button_no"))); |
376 mShowWeekNumberItem->setContentWidgetData(QString("additionalText"), |
405 mShowWeekNumberItem->setContentWidgetData(QString("additionalText"), |
377 QString(hbTrId("txt_calendar_button_yes"))); |
406 QString(hbTrId("txt_calendar_button_yes"))); |
378 } |
407 } |
379 mShowWeekNumberItem->setEnabled(true); |
408 mShowWeekNumberItem->setEnabled(true); |
380 } |
409 } |
381 } |
410 } |
|
411 // End of file |
382 // End of file |