51 QObject *parent) |
90 QObject *parent) |
52 :QObject(parent), |
91 :QObject(parent), |
53 mCalenEditor(calenEditor), |
92 mCalenEditor(calenEditor), |
54 mEditorForm(form), |
93 mEditorForm(form), |
55 mCalenEditorModel(model), |
94 mCalenEditorModel(model), |
56 mRepeatItem(NULL), |
95 mRepeatItem(0), |
57 mRepeatComboBox(NULL), |
96 mRepeatComboBox(0), |
58 mCustomRepeatUntilItem(NULL), |
97 mCustomRepeatUntilItem(0), |
|
98 mRepeatRoleValue(0), |
59 mIsBiWeekly(false), |
99 mIsBiWeekly(false), |
60 mIsWorkdays(false), |
100 mIsWorkdays(false), |
61 mRepeatUntilItemAdded(false) |
101 mRepeatUntilItemAdded(false) |
62 { |
102 { |
|
103 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_CALENEDITORREPEATFIELD_ENTRY ); |
63 if (!mCalenEditor->editedEntry()->repeatRule().isNull()) { |
104 if (!mCalenEditor->editedEntry()->repeatRule().isNull()) { |
64 mRepeatRuleType = mCalenEditor->editedEntry()->repeatRule().type(); |
105 mRepeatRuleType = mCalenEditor->editedEntry()->repeatRule().type(); |
65 mRepeatUntilDate = mCalenEditor->editedEntry()->repeatRule().until().date(); |
106 mRepeatUntilDate = mCalenEditor->editedEntry()->repeatRule().until().date(); |
66 } |
107 } |
67 |
108 |
68 mRepeatItem = new HbDataFormModelItem(); |
109 mRepeatItem = new HbDataFormModelItem(); |
69 mRepeatItem->setType(HbDataFormModelItem::ComboBoxItem); |
110 mRepeatItem->setType(HbDataFormModelItem::ComboBoxItem); |
70 mRepeatItem->setData(HbDataFormModelItem::LabelRole, |
111 mRepeatItem->setData(HbDataFormModelItem::LabelRole, |
71 hbTrId("txt_calendar_setlabel_repeat")); |
112 hbTrId("txt_calendar_setlabel_repeat")); |
72 |
113 |
73 // Create the repeat choices |
114 // Create the repeat choices |
74 QStringList repeatChoices; |
115 QStringList repeatChoices; |
75 repeatChoices << hbTrId("txt_calendar_setlabel_repeat_val_only_once") |
116 repeatChoices << hbTrId("txt_calendar_setlabel_repeat_val_only_once") |
76 << hbTrId("txt_calendar_setlabel_repeat_val_daily") |
117 << hbTrId("txt_calendar_setlabel_repeat_val_daily") |
77 << hbTrId("txt_calendar_setlabel_repeat_val_workdays") |
118 << hbTrId("txt_calendar_setlabel_repeat_val_workdays") |
78 << hbTrId("txt_calendar_setlabel_repeat_val_weekly") |
119 << hbTrId("txt_calendar_setlabel_repeat_val_weekly") |
79 << hbTrId("txt_calendar_setlabel_repeat_val_fortnightly") |
120 << hbTrId("txt_calendar_setlabel_repeat_val_fortnightly") |
80 << hbTrId("txt_calendar_setlabel_repeat_val_monthly") |
121 << hbTrId("txt_calendar_setlabel_repeat_val_monthly") |
81 << hbTrId("txt_calendar_setlabel_repeat_val_yearly"); |
122 << hbTrId("txt_calendar_setlabel_repeat_val_yearly"); |
82 |
123 |
83 mRepeatItem->setContentWidgetData(QString("items"), repeatChoices); |
124 mRepeatItem->setContentWidgetData("items", repeatChoices); |
|
125 mRepeatItem->setContentWidgetData("objectName", "repeatItem"); |
84 mCalenEditorModel->appendDataFormItem( mRepeatItem, |
126 mCalenEditorModel->appendDataFormItem( mRepeatItem, |
85 mCalenEditorModel->invisibleRootItem()); |
127 mCalenEditorModel->invisibleRootItem()); |
|
128 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_CALENEDITORREPEATFIELD_EXIT ); |
86 } |
129 } |
87 |
130 |
88 /*! |
131 /*! |
89 Destructor |
132 Destructor |
90 */ |
133 */ |
91 CalenEditorRepeatField::~CalenEditorRepeatField() |
134 CalenEditorRepeatField::~CalenEditorRepeatField() |
92 { |
135 { |
|
136 OstTraceFunctionEntry0( DUP1_CALENEDITORREPEATFIELD_CALENEDITORREPEATFIELD_ENTRY ); |
93 // Nothing Yet |
137 // Nothing Yet |
|
138 OstTraceFunctionExit0( DUP1_CALENEDITORREPEATFIELD_CALENEDITORREPEATFIELD_EXIT ); |
94 } |
139 } |
95 |
140 |
96 /*! |
141 /*! |
97 Adds repeat item to the model |
142 Adds repeat item to the model |
98 */ |
143 */ |
99 void CalenEditorRepeatField::addItemToModel() |
144 void CalenEditorRepeatField::addItemToModel() |
100 { |
145 { |
|
146 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_ADDITEMTOMODEL_ENTRY ); |
101 // Add reminder to the model |
147 // Add reminder to the model |
102 mCalenEditorModel->appendDataFormItem( mRepeatItem, |
148 mCalenEditorModel->appendDataFormItem( mRepeatItem, |
103 mCalenEditorModel->invisibleRootItem()); |
149 mCalenEditorModel->invisibleRootItem()); |
|
150 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_ADDITEMTOMODEL_EXIT ); |
104 } |
151 } |
105 |
152 |
106 /*! |
153 /*! |
107 Removes the repeat item from the model |
154 Removes the repeat item from the model |
108 */ |
155 */ |
109 void CalenEditorRepeatField::removeItemFromModel() |
156 void CalenEditorRepeatField::removeItemFromModel() |
110 { |
157 { |
|
158 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_REMOVEITEMFROMMODEL_ENTRY ); |
111 mCalenEditorModel->removeItem(modelIndex()); |
159 mCalenEditorModel->removeItem(modelIndex()); |
|
160 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_REMOVEITEMFROMMODEL_EXIT ); |
112 } |
161 } |
113 |
162 |
114 /*! |
163 /*! |
115 Populates repeat item with the options available |
164 Populates repeat item with the options available |
116 \param index index at which repeat item needs to be added |
165 \param index index at which repeat item needs to be added |
117 */ |
166 */ |
118 void CalenEditorRepeatField::populateRepeatItem(int index) |
167 void CalenEditorRepeatField::populateRepeatItem(int index) |
119 { |
168 { |
|
169 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_POPULATEREPEATITEM_ENTRY ); |
120 HbDataFormViewItem |
170 HbDataFormViewItem |
121 *item = |
171 *item = |
122 qobject_cast<HbDataFormViewItem *> ( |
172 qobject_cast<HbDataFormViewItem *> ( |
123 mEditorForm->itemByIndex( |
173 mEditorForm->itemByIndex( |
124 mCalenEditorModel->index( index, 0))); |
174 mCalenEditorModel->index( index, 0))); |
179 // Set the Original entry value also. |
229 // Set the Original entry value also. |
180 mCalenEditor->originalEntry()->setRepeatRule( |
230 mCalenEditor->originalEntry()->setRepeatRule( |
181 AgendaRepeatRule( |
231 AgendaRepeatRule( |
182 AgendaRepeatRule::InvalidRule)); |
232 AgendaRepeatRule::InvalidRule)); |
183 } |
233 } |
184 |
234 // Connect the slot once the updation of mRepeatComboBox is done |
|
235 connect(mRepeatComboBox, SIGNAL(currentIndexChanged(int)), this, |
|
236 SLOT(handleRepeatIndexChanged(int))); |
185 // Update the repeat choices depending upon the duration |
237 // Update the repeat choices depending upon the duration |
186 updateRepeatChoices(); |
238 updateRepeatChoices(); |
187 connect(mRepeatComboBox, SIGNAL(currentIndexChanged(int)), this, |
239 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_POPULATEREPEATITEM_EXIT ); |
188 SLOT(handleRepeatIndexChanged(int))); |
240 } |
|
241 |
|
242 /*! |
|
243 Removes the repeat until item from the model |
|
244 and removed the connection for date picker launch too. |
|
245 */ |
|
246 void CalenEditorRepeatField::removeRepeatUntilItem() |
|
247 { |
|
248 mRepeatRuleType = AgendaRepeatRule::InvalidRule; |
|
249 if (mRepeatUntilItemAdded) { |
|
250 mEditorForm->removeConnection(mCustomRepeatUntilItem, SIGNAL(clicked()), |
|
251 this, SLOT(launchRepeatUntilDatePicker())); |
|
252 QModelIndex repeatIndex = |
|
253 mCalenEditorModel->indexFromItem(mRepeatItem); |
|
254 mCalenEditorModel->removeItem( |
|
255 mCalenEditorModel->index( |
|
256 repeatIndex.row()+ 1, 0)); |
|
257 mRepeatUntilItemAdded = false; |
|
258 mCustomRepeatUntilItem = 0; |
|
259 } |
189 } |
260 } |
190 |
261 |
191 /*! |
262 /*! |
192 Triggerd from tapping on reminder item. |
263 Triggerd from tapping on reminder item. |
193 Handles the reminder time change and updates the same in the event. |
264 Handles the reminder time change and updates the same in the event. |
194 \param index The new index chosen in the reminder list. |
265 \param index The new index chosen in the reminder list. |
195 */ |
266 */ |
196 void CalenEditorRepeatField::handleRepeatIndexChanged(int index) |
267 void CalenEditorRepeatField::handleRepeatIndexChanged(int index) |
197 { |
268 { |
|
269 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_HANDLEREPEATINDEXCHANGED_ENTRY ); |
198 mIsBiWeekly = false; |
270 mIsBiWeekly = false; |
199 mIsWorkdays = false; |
271 mIsWorkdays = false; |
200 |
272 |
201 HbExtendedLocale locale = HbExtendedLocale::system(); |
273 HbExtendedLocale locale = HbExtendedLocale::system(); |
202 // Get the user role we have set for this index |
274 // Get the user role we have set for this index |
203 QVariant role = mRepeatComboBox->itemData(index, userRole); |
275 QVariant role = mRepeatComboBox->itemData(index, userRole); |
204 int value = role.toInt(); |
276 int value = role.toInt(); |
205 switch (value) { |
277 |
206 case 1: { |
278 // Boolean to check if the repeating property of the entry is changed. |
|
279 // based on the value and mRepeatUntilItemAdded |
|
280 // ie. From repeating to non repeating OR vice versa OR No change |
|
281 bool repeatPropertyChange = false; |
|
282 if (value > 0 && value <= 6 && !mRepeatUntilItemAdded) { |
|
283 // Non repeating to repeating |
|
284 repeatPropertyChange = true; |
|
285 }else if(mRepeatUntilItemAdded && value == 0) { |
|
286 // Repeating to non repeating |
|
287 repeatPropertyChange = true; |
|
288 }else { |
|
289 // No change in repeat value |
|
290 repeatPropertyChange = false; |
|
291 } |
|
292 QDate repeatUntilDate = mRepeatUntilDate; |
|
293 |
|
294 if (value != mRepeatRoleValue) |
|
295 { |
|
296 mRepeatRoleValue = value; |
|
297 switch (value) { |
|
298 case DailyRole: { |
207 if (!mRepeatUntilItemAdded) { |
299 if (!mRepeatUntilItemAdded) { |
208 insertRepeatUntilItem(); |
300 insertRepeatUntilItem(); |
209 } |
301 } |
210 if (mCustomRepeatUntilItem) { |
302 if (mCustomRepeatUntilItem) { |
|
303 // Show default repeat until date till one year for daily rule |
211 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
304 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
212 mCustomRepeatUntilItem->setContentWidgetData( "text", |
305 mCustomRepeatUntilItem->setContentWidgetData( "text", |
213 locale.format( mRepeatUntilDate, |
306 locale.format( mRepeatUntilDate, |
214 r_qtn_date_usual_with_zero)); |
307 r_qtn_date_usual_with_zero)); |
215 } |
308 } |
216 mRepeatRuleType = AgendaRepeatRule::DailyRule; |
309 mRepeatRuleType = AgendaRepeatRule::DailyRule; |
217 } |
310 } |
218 break; |
311 break; |
219 case 2: { |
312 case WorkdaysRole: { |
220 if (!mRepeatUntilItemAdded) { |
313 if (!mRepeatUntilItemAdded) { |
221 insertRepeatUntilItem(); |
314 insertRepeatUntilItem(); |
222 } |
315 } |
223 if (mCustomRepeatUntilItem) { |
316 if (mCustomRepeatUntilItem) { |
|
317 // Show default repeat until date till one year for workdays rule |
224 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
318 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
225 mCustomRepeatUntilItem->setContentWidgetData( "text", |
319 mCustomRepeatUntilItem->setContentWidgetData( "text", |
226 locale.format( mRepeatUntilDate, |
320 locale.format( mRepeatUntilDate, |
227 r_qtn_date_usual_with_zero)); |
321 r_qtn_date_usual_with_zero)); |
228 } |
322 } |
229 mRepeatRuleType = AgendaRepeatRule::WeeklyRule; |
323 mRepeatRuleType = AgendaRepeatRule::WeeklyRule; |
230 mIsWorkdays = true; |
324 mIsWorkdays = true; |
231 } |
325 } |
232 break; |
326 break; |
233 case 3: { |
327 case WeeklyRole: { |
234 if (!mRepeatUntilItemAdded) { |
328 if (!mRepeatUntilItemAdded) { |
235 insertRepeatUntilItem(); |
329 insertRepeatUntilItem(); |
236 } |
330 } |
237 if (mCustomRepeatUntilItem) { |
331 if (mCustomRepeatUntilItem) { |
|
332 // Show default repeat until date till one year for weekly rule |
238 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
333 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
239 mCustomRepeatUntilItem->setContentWidgetData( "text", |
334 mCustomRepeatUntilItem->setContentWidgetData( "text", |
240 locale.format( mRepeatUntilDate, |
335 locale.format( mRepeatUntilDate, |
241 r_qtn_date_usual_with_zero)); |
336 r_qtn_date_usual_with_zero)); |
242 |
|
243 } |
337 } |
244 mRepeatRuleType = AgendaRepeatRule::WeeklyRule; |
338 mRepeatRuleType = AgendaRepeatRule::WeeklyRule; |
245 } |
339 } |
246 break; |
340 break; |
247 case 4: { |
341 case BiWeeklyRole: { |
248 if (!mRepeatUntilItemAdded) { |
342 if (!mRepeatUntilItemAdded) { |
249 insertRepeatUntilItem(); |
343 insertRepeatUntilItem(); |
250 } |
344 } |
251 if (mCustomRepeatUntilItem) { |
345 if (mCustomRepeatUntilItem) { |
|
346 // Show default repeat until date till one year for bi-weekly rule |
252 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
347 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
253 mCustomRepeatUntilItem->setContentWidgetData( "text", |
348 mCustomRepeatUntilItem->setContentWidgetData( "text", |
254 locale.format( mRepeatUntilDate, |
349 locale.format( mRepeatUntilDate, |
255 r_qtn_date_usual_with_zero)); |
350 r_qtn_date_usual_with_zero)); |
256 } |
351 } |
257 mRepeatRuleType = AgendaRepeatRule::WeeklyRule; |
352 mRepeatRuleType = AgendaRepeatRule::WeeklyRule; |
258 mIsBiWeekly = true; |
353 mIsBiWeekly = true; |
259 } |
354 } |
260 break; |
355 break; |
261 case 5: { |
356 case MonthlyRole: { |
262 if (!mRepeatUntilItemAdded) { |
357 if (!mRepeatUntilItemAdded) { |
263 insertRepeatUntilItem(); |
358 insertRepeatUntilItem(); |
264 } |
359 } |
265 if (mCustomRepeatUntilItem) { |
360 if (mCustomRepeatUntilItem) { |
266 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(5); |
361 // Show default repeat until date till one year for monthly rule |
|
362 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
267 mCustomRepeatUntilItem->setContentWidgetData( "text", |
363 mCustomRepeatUntilItem->setContentWidgetData( "text", |
268 locale.format( mRepeatUntilDate, |
364 locale.format( mRepeatUntilDate, |
269 r_qtn_date_usual_with_zero)); |
365 r_qtn_date_usual_with_zero)); |
270 } |
366 } |
271 mRepeatRuleType = AgendaRepeatRule::MonthlyRule; |
367 mRepeatRuleType = AgendaRepeatRule::MonthlyRule; |
272 } |
368 } |
273 break; |
369 break; |
274 case 6: { |
370 case YearlyRole: { |
275 if (!mRepeatUntilItemAdded) { |
371 if (!mRepeatUntilItemAdded) { |
276 insertRepeatUntilItem(); |
372 insertRepeatUntilItem(); |
277 } |
373 } |
278 if (mCustomRepeatUntilItem) { |
374 if (mCustomRepeatUntilItem) { |
|
375 // Show default repeat until date till ten years for yearly rule |
279 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(10); |
376 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(10); |
280 mCustomRepeatUntilItem->setContentWidgetData( "text", |
377 mCustomRepeatUntilItem->setContentWidgetData( "text", |
281 locale.format( mRepeatUntilDate, |
378 locale.format( mRepeatUntilDate, |
282 r_qtn_date_usual_with_zero)); |
379 r_qtn_date_usual_with_zero)); |
283 } |
380 } |
284 mRepeatRuleType = AgendaRepeatRule::YearlyRule; |
381 mRepeatRuleType = AgendaRepeatRule::YearlyRule; |
285 } |
382 } |
286 break; |
383 break; |
287 default: { |
384 default: { |
288 mRepeatRuleType = AgendaRepeatRule::InvalidRule; |
385 removeRepeatUntilItem(); |
289 if (mRepeatUntilItemAdded) { |
|
290 QModelIndex repeatIndex = |
|
291 mCalenEditorModel->indexFromItem(mRepeatItem); |
|
292 mCalenEditorModel->removeItem( |
|
293 mCalenEditorModel->index( |
|
294 repeatIndex.row()+ 1, 0)); |
|
295 mRepeatUntilItemAdded = false; |
|
296 mCustomRepeatUntilItem = NULL; |
|
297 } |
|
298 } |
386 } |
299 break; |
387 break; |
|
388 } |
300 } |
389 } |
301 if(!mCalenEditor->isNewEntry()) { |
390 if(!mCalenEditor->isNewEntry()) { |
302 mCalenEditor->addDiscardAction(); |
391 mCalenEditor->addDiscardAction(); |
303 } |
392 } |
304 mCalenEditor->updateReminderChoices(); |
393 // Depending on repeatPropertyChange value and the repeatuntil date change |
|
394 // the reminder choices are updated |
|
395 if(repeatPropertyChange || repeatUntilDate != mRepeatUntilDate) { |
|
396 mCalenEditor->updateReminderChoices(); |
|
397 } |
|
398 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_HANDLEREPEATINDEXCHANGED_EXIT ); |
305 } |
399 } |
306 |
400 |
307 /*! |
401 /*! |
308 Returns model index of the repeat item |
402 Returns model index of the repeat item |
309 \return Model index of the repeat item |
403 \return Model index of the repeat item |
310 */ |
404 */ |
311 QModelIndex CalenEditorRepeatField::modelIndex() |
405 QModelIndex CalenEditorRepeatField::modelIndex() |
312 { |
406 { |
|
407 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_MODELINDEX_ENTRY ); |
313 return mCalenEditorModel->indexFromItem(mRepeatItem); |
408 return mCalenEditorModel->indexFromItem(mRepeatItem); |
314 } |
409 } |
315 |
410 |
316 /*! |
411 /*! |
317 Inserts the repeat until item to the dataform model |
412 Inserts the repeat until item to the dataform model |
318 */ |
413 */ |
319 void CalenEditorRepeatField::insertRepeatUntilItem() |
414 void CalenEditorRepeatField::insertRepeatUntilItem() |
320 { |
415 { |
|
416 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_INSERTREPEATUNTILITEM_ENTRY ); |
321 HbDataFormModelItem::DataItemType itemType = |
417 HbDataFormModelItem::DataItemType itemType = |
322 static_cast<HbDataFormModelItem::DataItemType> (RepeatUntilOffset); |
418 static_cast<HbDataFormModelItem::DataItemType> (RepeatUntilOffset); |
323 |
419 |
324 int index = CalenEditorPrivate::RepeatUntilItem; |
420 int index = CalenEditorPrivate::RepeatUntilItem; |
325 if (!mCalenEditor->isReminderTimeForAllDayAdded()) { |
421 if (!mCalenEditor->isReminderTimeForAllDayAdded()) { |
341 QString dateString = locale.format( |
437 QString dateString = locale.format( |
342 mCalenEditor->editedEntry()->repeatRule().until().date(), |
438 mCalenEditor->editedEntry()->repeatRule().until().date(), |
343 r_qtn_date_usual_with_zero); |
439 r_qtn_date_usual_with_zero); |
344 mCustomRepeatUntilItem->setContentWidgetData("text", dateString); |
440 mCustomRepeatUntilItem->setContentWidgetData("text", dateString); |
345 } |
441 } |
346 //TODO: Scroll to functionality has to be implemented |
442 //Scroll to repeat until item added |
|
443 mEditorForm->scrollTo(mCalenEditorModel->index(index, 0), HbAbstractItemView::EnsureVisible); |
|
444 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_INSERTREPEATUNTILITEM_EXIT ); |
347 } |
445 } |
348 |
446 |
349 /*! |
447 /*! |
350 Informs if repeat until item has been added or not |
448 Informs if repeat until item has been added or not |
351 \return true if repeat until item is added else false |
449 \return true if repeat until item is added else false |
352 */ |
450 */ |
353 bool CalenEditorRepeatField::isRepeatUntilItemAdded() |
451 bool CalenEditorRepeatField::isRepeatUntilItemAdded() |
354 { |
452 { |
|
453 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_ISREPEATUNTILITEMADDED_ENTRY ); |
|
454 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_ISREPEATUNTILITEMADDED_EXIT ); |
355 return mRepeatUntilItemAdded; |
455 return mRepeatUntilItemAdded; |
356 } |
456 } |
357 |
457 |
358 /*! |
458 /*! |
359 Launches the date picker by tapping on the repaet until pushbutton |
459 Launches the date picker by tapping on the repaet until pushbutton |
360 */ |
460 */ |
361 void CalenEditorRepeatField::launchRepeatUntilDatePicker() |
461 void CalenEditorRepeatField::launchRepeatUntilDatePicker() |
362 { |
462 { |
|
463 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_LAUNCHREPEATUNTILDATEPICKER_ENTRY ); |
363 HbDialog *popUp = new HbDialog(); |
464 HbDialog *popUp = new HbDialog(); |
364 popUp->setDismissPolicy(HbDialog::NoDismiss); |
465 popUp->setDismissPolicy(HbDialog::NoDismiss); |
365 popUp->setTimeout(HbDialog::NoTimeout); |
466 popUp->setTimeout(HbDialog::NoTimeout); |
366 popUp->setHeadingWidget( new HbLabel( |
467 popUp->setHeadingWidget( new HbLabel( |
367 hbTrId("txt_calendar_title_repeat_until"))); |
468 hbTrId("txt_calendar_title_repeat_until"))); |
368 popUp->setAttribute( Qt::WA_DeleteOnClose, true ); |
469 popUp->setAttribute( Qt::WA_DeleteOnClose, true ); |
369 |
470 |
370 if (mDatePicker) { |
471 if (mDatePicker) { |
371 mDatePicker = NULL; |
472 mDatePicker = 0; |
372 } |
473 } |
373 if (mRepeatRuleType == AgendaRepeatRule::DailyRule) { |
474 if (mRepeatRuleType == AgendaRepeatRule::DailyRule) { |
374 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addDays(1); |
475 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addDays(1); |
375 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
476 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
376 mDatePicker->setMinimumDate(minDate); |
477 mDatePicker->setMinimumDate(minDate); |
377 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
478 mDatePicker->setMaximumDate(CalenDateUtils::maxTime().date()); |
378 mDatePicker->setDate(mRepeatUntilDate); |
479 mDatePicker->setDate(mRepeatUntilDate); |
379 } else if (mRepeatRuleType == AgendaRepeatRule::WeeklyRule) { |
480 } else if (mRepeatRuleType == AgendaRepeatRule::WeeklyRule) { |
380 QDate minDate; |
481 QDate minDate; |
381 if (!mIsBiWeekly || mIsWorkdays) { |
482 if (!mIsBiWeekly || mIsWorkdays) { |
382 minDate = mCalenEditor->editedEntry()->endTime().date().addDays(7); |
483 minDate = mCalenEditor->editedEntry()->endTime().date().addDays(7); |
383 } else { |
484 } else { |
384 minDate = mCalenEditor->editedEntry()->endTime().date().addDays(14); |
485 minDate = mCalenEditor->editedEntry()->endTime().date().addDays(14); |
385 } |
486 } |
386 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
487 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
387 mDatePicker->setMinimumDate(minDate); |
488 mDatePicker->setMinimumDate(minDate); |
388 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
489 mDatePicker->setMaximumDate(CalenDateUtils::maxTime().date()); |
389 mDatePicker->setDate(mRepeatUntilDate); |
490 mDatePicker->setDate(mRepeatUntilDate); |
390 } else if (mRepeatRuleType == AgendaRepeatRule::MonthlyRule) { |
491 } else if (mRepeatRuleType == AgendaRepeatRule::MonthlyRule) { |
391 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addMonths(1); |
492 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addMonths(1); |
392 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
493 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
393 mDatePicker->setMinimumDate(minDate); |
494 mDatePicker->setMinimumDate(minDate); |
394 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
495 mDatePicker->setMaximumDate(CalenDateUtils::maxTime().date()); |
395 mDatePicker->setDate(mRepeatUntilDate); |
496 mDatePicker->setDate(mRepeatUntilDate); |
396 } else if (mRepeatRuleType == AgendaRepeatRule::YearlyRule) { |
497 } else if (mRepeatRuleType == AgendaRepeatRule::YearlyRule) { |
397 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addYears(1); |
498 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addYears(1); |
398 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
499 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
399 mDatePicker->setMinimumDate(minDate); |
500 mDatePicker->setMinimumDate(minDate); |
400 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
501 mDatePicker->setMaximumDate(CalenDateUtils::maxTime().date()); |
401 mDatePicker->setDate(mRepeatUntilDate); |
502 mDatePicker->setDate(mRepeatUntilDate); |
402 } |
503 } |
403 popUp->setContentWidget(mDatePicker); |
504 popUp->setContentWidget(mDatePicker); |
404 |
505 |
405 HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok")); |
506 HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok")); |
406 popUp->addAction(okAction); |
507 popUp->addAction(okAction); |
407 connect(okAction, SIGNAL(triggered()), this, SLOT(setRepeatUntilDate())); |
508 connect(okAction, SIGNAL(triggered()), this, SLOT(setRepeatUntilDate())); |
408 popUp->addAction(new HbAction(hbTrId("txt_common_button_cancel"), popUp)); |
509 popUp->addAction(new HbAction(hbTrId("txt_common_button_cancel"), popUp)); |
409 popUp->open(); |
510 popUp->open(); |
|
511 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_LAUNCHREPEATUNTILDATEPICKER_EXIT ); |
410 } |
512 } |
411 |
513 |
412 /*! |
514 /*! |
413 Sets the repeat until date on the repeat until item |
515 Sets the repeat until date on the repeat until item |
414 */ |
516 */ |
415 void CalenEditorRepeatField::setRepeatUntilDate() |
517 void CalenEditorRepeatField::setRepeatUntilDate() |
416 { |
518 { |
|
519 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_SETREPEATUNTILDATE_ENTRY ); |
417 mRepeatUntilDate = mDatePicker->date(); |
520 mRepeatUntilDate = mDatePicker->date(); |
418 if (mRepeatUntilDate.isValid()) { |
521 if (mRepeatUntilDate.isValid()) { |
419 HbExtendedLocale locale = HbExtendedLocale::system(); |
522 HbExtendedLocale locale = HbExtendedLocale::system(); |
420 QString dateString = locale.format(mRepeatUntilDate, |
523 QString dateString = locale.format(mRepeatUntilDate, |
421 r_qtn_date_usual_with_zero); |
524 r_qtn_date_usual_with_zero); |
422 mCustomRepeatUntilItem->setContentWidgetData("text", dateString); |
525 mCustomRepeatUntilItem->setContentWidgetData("text", dateString); |
423 } |
526 } |
424 mCalenEditor->updateReminderChoices(); |
527 mCalenEditor->updateReminderChoices(); |
|
528 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_SETREPEATUNTILDATE_EXIT ); |
425 } |
529 } |
426 |
530 |
427 /*! |
531 /*! |
428 Returns the repeatuntildate displayed. |
532 Returns the repeatuntildate displayed. |
429 */ |
533 */ |
430 QDate CalenEditorRepeatField::repeatUntilDate() |
534 QDate CalenEditorRepeatField::repeatUntilDate() |
431 { |
535 { |
|
536 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_REPEATUNTILDATE_ENTRY ); |
|
537 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_REPEATUNTILDATE_EXIT ); |
432 return mRepeatUntilDate; |
538 return mRepeatUntilDate; |
433 } |
539 } |
434 |
540 |
435 /*! |
541 /*! |
436 Updates the repeat choices depending on the meeting duration |
542 Updates the repeat choices depending on the meeting duration |
437 */ |
543 */ |
438 void CalenEditorRepeatField::updateRepeatChoices() |
544 void CalenEditorRepeatField::updateRepeatChoices() |
439 { |
545 { |
|
546 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_UPDATEREPEATCHOICES_ENTRY ); |
440 if (!mRepeatComboBox) { |
547 if (!mRepeatComboBox) { |
|
548 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_UPDATEREPEATCHOICES_EXIT ); |
441 return; |
549 return; |
442 } |
550 } |
|
551 // Disconnect the slot and connect it back again at end to avoid unnecessary |
|
552 // calls to handleRepeatIndexChanged slot. Or else the slot gets called |
|
553 // when we add all of items to the repeat combobox. |
|
554 disconnect(mRepeatComboBox, SIGNAL(currentIndexChanged(int)), this, |
|
555 SLOT(handleRepeatIndexChanged(int))); |
443 // Clear all the choices and add it again. If we dont do it |
556 // Clear all the choices and add it again. If we dont do it |
444 // as user would have changed the end times many times and we would have |
557 // as user would have changed the end times many times and we would have |
445 // deleted repeat options depending upon that |
558 // deleted repeat options depending upon that |
446 // Get the current choice |
559 // Get the current choice |
447 int choice = mRepeatComboBox->currentIndex(); |
560 int choice = mRepeatComboBox->currentIndex(); |
|
561 |
|
562 QVariant role = mRepeatComboBox->itemData(choice, userRole); |
|
563 mRepeatRoleValue = role.toInt(); |
|
564 |
448 int previousCount = mRepeatComboBox->count(); |
565 int previousCount = mRepeatComboBox->count(); |
449 mRepeatComboBox->clear(); |
566 mRepeatComboBox->clear(); |
450 QStringList repeatChoices; |
567 QStringList repeatChoices; |
451 repeatChoices << hbTrId("txt_calendar_setlabel_repeat_val_only_once") |
568 repeatChoices << hbTrId("txt_calendar_setlabel_repeat_val_only_once") |
452 << hbTrId("txt_calendar_setlabel_repeat_val_daily") |
569 << hbTrId("txt_calendar_setlabel_repeat_val_daily") |