155 mRepeatComboBox->setItemData(RepeatYearly, RepeatYearly, userRole); |
189 mRepeatComboBox->setItemData(RepeatYearly, RepeatYearly, userRole); |
156 |
190 |
157 if (mCalenEditor->editedEntry()->isRepeating()) { |
191 if (mCalenEditor->editedEntry()->isRepeating()) { |
158 switch (mCalenEditor->editedEntry()->repeatRule().type()) { |
192 switch (mCalenEditor->editedEntry()->repeatRule().type()) { |
159 case AgendaRepeatRule::DailyRule: { |
193 case AgendaRepeatRule::DailyRule: { |
160 mRepeatComboBox->setCurrentIndex(1); |
194 mRepeatComboBox->setCurrentIndex(DailyRole); |
161 } |
195 } |
162 break; |
196 break; |
163 case AgendaRepeatRule::WeeklyRule: { |
197 case AgendaRepeatRule::WeeklyRule: { |
164 bool isWorkdays = AgendaUtil::isWorkdaysRepeatingEntry( |
198 bool isWorkdays = AgendaUtil::isWorkdaysRepeatingEntry( |
165 mCalenEditor->editedEntry()->repeatRule()); |
199 mCalenEditor->editedEntry()->repeatRule()); |
166 if (isWorkdays) { |
200 if (isWorkdays) { |
167 mRepeatComboBox->setCurrentIndex(2); |
201 mRepeatComboBox->setCurrentIndex(WorkdaysRole); |
168 mIsWorkdays = true; |
202 mIsWorkdays = true; |
169 } else { |
203 } else { |
170 if (mCalenEditor->editedEntry()->repeatRule().interval() == 1) { |
204 if (mCalenEditor->editedEntry()->repeatRule().interval() == 1) { |
171 mRepeatComboBox->setCurrentIndex(3); |
205 mRepeatComboBox->setCurrentIndex(WeeklyRole); |
172 } else { |
206 } else { |
173 mRepeatComboBox->setCurrentIndex(4); |
207 mRepeatComboBox->setCurrentIndex(BiWeeklyRole); |
174 mIsBiWeekly = true; |
208 mIsBiWeekly = true; |
175 } |
209 } |
176 } |
210 } |
177 } |
211 } |
178 break; |
212 break; |
179 case AgendaRepeatRule::MonthlyRule: { |
213 case AgendaRepeatRule::MonthlyRule: { |
180 mRepeatComboBox->setCurrentIndex(5); |
214 mRepeatComboBox->setCurrentIndex(MonthlyRole); |
181 } |
215 } |
182 break; |
216 break; |
183 case AgendaRepeatRule::YearlyRule: { |
217 case AgendaRepeatRule::YearlyRule: { |
184 mRepeatComboBox->setCurrentIndex(6); |
218 mRepeatComboBox->setCurrentIndex(YearlyRole); |
185 } |
219 } |
186 break; |
220 break; |
187 default: |
221 default: |
188 break; |
222 break; |
189 } |
223 } |
218 HbExtendedLocale locale = HbExtendedLocale::system(); |
252 HbExtendedLocale locale = HbExtendedLocale::system(); |
219 // Get the user role we have set for this index |
253 // Get the user role we have set for this index |
220 QVariant role = mRepeatComboBox->itemData(index, userRole); |
254 QVariant role = mRepeatComboBox->itemData(index, userRole); |
221 int value = role.toInt(); |
255 int value = role.toInt(); |
222 switch (value) { |
256 switch (value) { |
223 case 1: { |
257 case DailyRole: { |
224 if (!mRepeatUntilItemAdded) { |
258 if (!mRepeatUntilItemAdded) { |
225 insertRepeatUntilItem(); |
259 insertRepeatUntilItem(); |
226 } |
260 } |
227 if (mCustomRepeatUntilItem) { |
261 if (mCustomRepeatUntilItem) { |
|
262 // Show default repeat until date till one year for daily rule |
228 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
263 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
229 mCustomRepeatUntilItem->setContentWidgetData( "text", |
264 mCustomRepeatUntilItem->setContentWidgetData( "text", |
230 locale.format( mRepeatUntilDate, |
265 locale.format( mRepeatUntilDate, |
231 r_qtn_date_usual_with_zero)); |
266 r_qtn_date_usual_with_zero)); |
232 } |
267 } |
233 mRepeatRuleType = AgendaRepeatRule::DailyRule; |
268 mRepeatRuleType = AgendaRepeatRule::DailyRule; |
234 } |
269 } |
235 break; |
270 break; |
236 case 2: { |
271 case WorkdaysRole: { |
237 if (!mRepeatUntilItemAdded) { |
272 if (!mRepeatUntilItemAdded) { |
238 insertRepeatUntilItem(); |
273 insertRepeatUntilItem(); |
239 } |
274 } |
240 if (mCustomRepeatUntilItem) { |
275 if (mCustomRepeatUntilItem) { |
|
276 // Show default repeat until date till one year for workdays rule |
241 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
277 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
242 mCustomRepeatUntilItem->setContentWidgetData( "text", |
278 mCustomRepeatUntilItem->setContentWidgetData( "text", |
243 locale.format( mRepeatUntilDate, |
279 locale.format( mRepeatUntilDate, |
244 r_qtn_date_usual_with_zero)); |
280 r_qtn_date_usual_with_zero)); |
245 } |
281 } |
246 mRepeatRuleType = AgendaRepeatRule::WeeklyRule; |
282 mRepeatRuleType = AgendaRepeatRule::WeeklyRule; |
247 mIsWorkdays = true; |
283 mIsWorkdays = true; |
248 } |
284 } |
249 break; |
285 break; |
250 case 3: { |
286 case WeeklyRole: { |
251 if (!mRepeatUntilItemAdded) { |
287 if (!mRepeatUntilItemAdded) { |
252 insertRepeatUntilItem(); |
288 insertRepeatUntilItem(); |
253 } |
289 } |
254 if (mCustomRepeatUntilItem) { |
290 if (mCustomRepeatUntilItem) { |
|
291 // Show default repeat until date till one year for weekly rule |
255 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
292 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
256 mCustomRepeatUntilItem->setContentWidgetData( "text", |
293 mCustomRepeatUntilItem->setContentWidgetData( "text", |
257 locale.format( mRepeatUntilDate, |
294 locale.format( mRepeatUntilDate, |
258 r_qtn_date_usual_with_zero)); |
295 r_qtn_date_usual_with_zero)); |
259 |
296 |
260 } |
297 } |
261 mRepeatRuleType = AgendaRepeatRule::WeeklyRule; |
298 mRepeatRuleType = AgendaRepeatRule::WeeklyRule; |
262 } |
299 } |
263 break; |
300 break; |
264 case 4: { |
301 case BiWeeklyRole: { |
265 if (!mRepeatUntilItemAdded) { |
302 if (!mRepeatUntilItemAdded) { |
266 insertRepeatUntilItem(); |
303 insertRepeatUntilItem(); |
267 } |
304 } |
268 if (mCustomRepeatUntilItem) { |
305 if (mCustomRepeatUntilItem) { |
|
306 // Show default repeat until date till one year for bi-weekly rule |
269 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
307 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
270 mCustomRepeatUntilItem->setContentWidgetData( "text", |
308 mCustomRepeatUntilItem->setContentWidgetData( "text", |
271 locale.format( mRepeatUntilDate, |
309 locale.format( mRepeatUntilDate, |
272 r_qtn_date_usual_with_zero)); |
310 r_qtn_date_usual_with_zero)); |
273 } |
311 } |
274 mRepeatRuleType = AgendaRepeatRule::WeeklyRule; |
312 mRepeatRuleType = AgendaRepeatRule::WeeklyRule; |
275 mIsBiWeekly = true; |
313 mIsBiWeekly = true; |
276 } |
314 } |
277 break; |
315 break; |
278 case 5: { |
316 case MonthlyRole: { |
279 if (!mRepeatUntilItemAdded) { |
317 if (!mRepeatUntilItemAdded) { |
280 insertRepeatUntilItem(); |
318 insertRepeatUntilItem(); |
281 } |
319 } |
282 if (mCustomRepeatUntilItem) { |
320 if (mCustomRepeatUntilItem) { |
283 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(5); |
321 // Show default repeat until date till one year for monthly rule |
|
322 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
284 mCustomRepeatUntilItem->setContentWidgetData( "text", |
323 mCustomRepeatUntilItem->setContentWidgetData( "text", |
285 locale.format( mRepeatUntilDate, |
324 locale.format( mRepeatUntilDate, |
286 r_qtn_date_usual_with_zero)); |
325 r_qtn_date_usual_with_zero)); |
287 } |
326 } |
288 mRepeatRuleType = AgendaRepeatRule::MonthlyRule; |
327 mRepeatRuleType = AgendaRepeatRule::MonthlyRule; |
289 } |
328 } |
290 break; |
329 break; |
291 case 6: { |
330 case YearlyRole: { |
292 if (!mRepeatUntilItemAdded) { |
331 if (!mRepeatUntilItemAdded) { |
293 insertRepeatUntilItem(); |
332 insertRepeatUntilItem(); |
294 } |
333 } |
295 if (mCustomRepeatUntilItem) { |
334 if (mCustomRepeatUntilItem) { |
|
335 // Show default repeat until date till ten years for yearly rule |
296 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(10); |
336 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(10); |
297 mCustomRepeatUntilItem->setContentWidgetData( "text", |
337 mCustomRepeatUntilItem->setContentWidgetData( "text", |
298 locale.format( mRepeatUntilDate, |
338 locale.format( mRepeatUntilDate, |
299 r_qtn_date_usual_with_zero)); |
339 r_qtn_date_usual_with_zero)); |
300 } |
340 } |
390 popUp->setHeadingWidget( new HbLabel( |
431 popUp->setHeadingWidget( new HbLabel( |
391 hbTrId("txt_calendar_title_repeat_until"))); |
432 hbTrId("txt_calendar_title_repeat_until"))); |
392 popUp->setAttribute( Qt::WA_DeleteOnClose, true ); |
433 popUp->setAttribute( Qt::WA_DeleteOnClose, true ); |
393 |
434 |
394 if (mDatePicker) { |
435 if (mDatePicker) { |
395 mDatePicker = NULL; |
436 mDatePicker = 0; |
396 } |
437 } |
397 if (mRepeatRuleType == AgendaRepeatRule::DailyRule) { |
438 if (mRepeatRuleType == AgendaRepeatRule::DailyRule) { |
398 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addDays(1); |
439 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addDays(1); |
399 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
440 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
400 mDatePicker->setMinimumDate(minDate); |
441 mDatePicker->setMinimumDate(minDate); |
401 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
442 mDatePicker->setMaximumDate(CalenDateUtils::maxTime().date()); |
402 mDatePicker->setDate(mRepeatUntilDate); |
443 mDatePicker->setDate(mRepeatUntilDate); |
403 } else if (mRepeatRuleType == AgendaRepeatRule::WeeklyRule) { |
444 } else if (mRepeatRuleType == AgendaRepeatRule::WeeklyRule) { |
404 QDate minDate; |
445 QDate minDate; |
405 if (!mIsBiWeekly || mIsWorkdays) { |
446 if (!mIsBiWeekly || mIsWorkdays) { |
406 minDate = mCalenEditor->editedEntry()->endTime().date().addDays(7); |
447 minDate = mCalenEditor->editedEntry()->endTime().date().addDays(7); |
407 } else { |
448 } else { |
408 minDate = mCalenEditor->editedEntry()->endTime().date().addDays(14); |
449 minDate = mCalenEditor->editedEntry()->endTime().date().addDays(14); |
409 } |
450 } |
410 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
451 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
411 mDatePicker->setMinimumDate(minDate); |
452 mDatePicker->setMinimumDate(minDate); |
412 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
453 mDatePicker->setMaximumDate(CalenDateUtils::maxTime().date()); |
413 mDatePicker->setDate(mRepeatUntilDate); |
454 mDatePicker->setDate(mRepeatUntilDate); |
414 } else if (mRepeatRuleType == AgendaRepeatRule::MonthlyRule) { |
455 } else if (mRepeatRuleType == AgendaRepeatRule::MonthlyRule) { |
415 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addMonths(1); |
456 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addMonths(1); |
416 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
457 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
417 mDatePicker->setMinimumDate(minDate); |
458 mDatePicker->setMinimumDate(minDate); |
418 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
459 mDatePicker->setMaximumDate(CalenDateUtils::maxTime().date()); |
419 mDatePicker->setDate(mRepeatUntilDate); |
460 mDatePicker->setDate(mRepeatUntilDate); |
420 } else if (mRepeatRuleType == AgendaRepeatRule::YearlyRule) { |
461 } else if (mRepeatRuleType == AgendaRepeatRule::YearlyRule) { |
421 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addYears(1); |
462 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addYears(1); |
422 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
463 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
423 mDatePicker->setMinimumDate(minDate); |
464 mDatePicker->setMinimumDate(minDate); |
424 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
465 mDatePicker->setMaximumDate(CalenDateUtils::maxTime().date()); |
425 mDatePicker->setDate(mRepeatUntilDate); |
466 mDatePicker->setDate(mRepeatUntilDate); |
426 } |
467 } |
427 popUp->setContentWidget(mDatePicker); |
468 popUp->setContentWidget(mDatePicker); |
428 |
469 |
429 HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok")); |
470 HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok")); |
645 days.append(AgendaRepeatRule::Day(dayOfWeek - 1)); |
686 days.append(AgendaRepeatRule::Day(dayOfWeek - 1)); |
646 repeatRule.setByDay(days); |
687 repeatRule.setByDay(days); |
647 } |
688 } |
648 } else if (mRepeatRuleType == AgendaRepeatRule::MonthlyRule) { |
689 } else if (mRepeatRuleType == AgendaRepeatRule::MonthlyRule) { |
649 QList<int> monthDays; |
690 QList<int> monthDays; |
650 //TODO : |
|
651 int dayNoInMonth = mCalenEditor->editedEntry()->startTime().date().day(); |
691 int dayNoInMonth = mCalenEditor->editedEntry()->startTime().date().day(); |
652 monthDays.append(dayNoInMonth); |
692 monthDays.append(dayNoInMonth); |
653 repeatRule.setByMonthDay(monthDays); |
693 repeatRule.setByMonthDay(monthDays); |
654 } else if (mRepeatRuleType == AgendaRepeatRule::YearlyRule) { |
694 } else if (mRepeatRuleType == AgendaRepeatRule::YearlyRule) { |
655 //TODO : Add yearly rule.Check if required. |
|
656 } |
695 } |
657 mCalenEditor->editedEntry()->setRepeatRule(repeatRule); |
696 mCalenEditor->editedEntry()->setRepeatRule(repeatRule); |
658 } else { |
697 } else { |
659 mCalenEditor->editedEntry()->setRepeatRule( AgendaRepeatRule( |
698 mCalenEditor->editedEntry()->setRepeatRule( AgendaRepeatRule( |
660 AgendaRepeatRule::InvalidRule)); |
699 AgendaRepeatRule::InvalidRule)); |
661 } |
700 } |
662 // TODO: Need to update rDates here |
701 // TODO: Need to update rDates here for 10.2 if required |
663 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_SAVEREPEATRULE_EXIT ); |
702 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_SAVEREPEATRULE_EXIT ); |
664 } |
703 } |
665 |
704 |
666 // End of file --Don't remove this. |
705 // End of file --Don't remove this. |