30 |
30 |
31 // User includes. |
31 // User includes. |
32 #include "notestodoeditorcustomitem.h" |
32 #include "notestodoeditorcustomitem.h" |
33 #include "noteseditor_p.h" |
33 #include "noteseditor_p.h" |
34 #include "noteseditorcommon.h" |
34 #include "noteseditorcommon.h" |
|
35 #include "OstTraceDefinitions.h" |
|
36 #ifdef OST_TRACE_COMPILER_IN_USE |
|
37 #include "notestodoeditorcustomitemTraces.h" |
|
38 #endif |
|
39 |
35 |
40 |
36 /*! |
41 /*! |
37 \class NotesTodoEditorCustomItem |
42 \class NotesTodoEditorCustomItem |
38 |
43 |
39 This class is responsible for creating customitem for Alarm Time field in |
44 This class is responsible for creating customitem for Alarm Time field in |
51 NotesEditorPrivate* noteseditorPvt,QGraphicsItem *parent) |
56 NotesEditorPrivate* noteseditorPvt,QGraphicsItem *parent) |
52 :HbDataFormViewItem(parent), |
57 :HbDataFormViewItem(parent), |
53 mNotesTodoeditorPvt(noteseditorPvt), |
58 mNotesTodoeditorPvt(noteseditorPvt), |
54 mDueDatePickerIsActive(false) |
59 mDueDatePickerIsActive(false) |
55 { |
60 { |
56 |
61 OstTraceFunctionEntry0( NOTESTODOEDITORCUSTOMITEM_NOTESTODOEDITORCUSTOMITEM_ENTRY ); |
|
62 |
|
63 OstTraceFunctionExit0( NOTESTODOEDITORCUSTOMITEM_NOTESTODOEDITORCUSTOMITEM_EXIT ); |
57 } |
64 } |
58 |
65 |
59 /*! |
66 /*! |
60 Destructor. |
67 Destructor. |
61 */ |
68 */ |
62 NotesTodoEditorCustomItem::~NotesTodoEditorCustomItem() |
69 NotesTodoEditorCustomItem::~NotesTodoEditorCustomItem() |
63 { |
70 { |
|
71 OstTraceFunctionEntry0( DUP1_NOTESTODOEDITORCUSTOMITEM_NOTESTODOEDITORCUSTOMITEM_ENTRY ); |
|
72 OstTraceFunctionExit0( DUP1_NOTESTODOEDITORCUSTOMITEM_NOTESTODOEDITORCUSTOMITEM_EXIT ); |
64 } |
73 } |
65 |
74 |
66 /*! |
75 /*! |
67 Create customitem. |
76 Create customitem. |
68 |
77 |
69 \return HbAbstractViewItem* Pointer to NotesTodoEditorCustomItem object. |
78 \return HbAbstractViewItem* Pointer to NotesTodoEditorCustomItem object. |
70 */ |
79 */ |
71 HbAbstractViewItem* NotesTodoEditorCustomItem::createItem() |
80 HbAbstractViewItem* NotesTodoEditorCustomItem::createItem() |
72 { |
81 { |
|
82 OstTraceFunctionEntry0( NOTESTODOEDITORCUSTOMITEM_CREATEITEM_ENTRY ); |
73 return new NotesTodoEditorCustomItem(*this); |
83 return new NotesTodoEditorCustomItem(*this); |
74 } |
84 } |
75 |
85 |
76 /*! |
86 /*! |
77 Create customwidget. |
87 Create customwidget. |
78 |
88 |
79 \return HbWidget* Holds the custom widget pointer. |
89 \return HbWidget* Holds the custom widget pointer. |
80 */ |
90 */ |
81 HbWidget* NotesTodoEditorCustomItem::createCustomWidget() |
91 HbWidget* NotesTodoEditorCustomItem::createCustomWidget() |
82 { |
92 { |
|
93 OstTraceFunctionEntry0( NOTESTODOEDITORCUSTOMITEM_CREATECUSTOMWIDGET_ENTRY ); |
83 HbDataFormModelItem::DataItemType itemType = |
94 HbDataFormModelItem::DataItemType itemType = |
84 static_cast<HbDataFormModelItem::DataItemType>(modelIndex() |
95 static_cast<HbDataFormModelItem::DataItemType>(modelIndex() |
85 .data(HbDataFormModelItem::ItemTypeRole).toInt()); |
96 .data(HbDataFormModelItem::ItemTypeRole).toInt()); |
86 |
97 |
87 switch(itemType) { |
98 switch(itemType) { |
89 mDueDateItem = new HbPushButton(); |
100 mDueDateItem = new HbPushButton(); |
90 mDueDateItem->setObjectName("dueDateItem"); |
101 mDueDateItem->setObjectName("dueDateItem"); |
91 connect( |
102 connect( |
92 mDueDateItem, SIGNAL(clicked()), |
103 mDueDateItem, SIGNAL(clicked()), |
93 this, SLOT(selectDueDate())); |
104 this, SLOT(selectDueDate())); |
|
105 OstTraceFunctionExit0( NOTESTODOEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
94 return mDueDateItem; |
106 return mDueDateItem; |
95 } |
107 } |
96 |
108 |
97 case HbDataFormModelItem::CustomItemBase + AlarmDateItemOffset: { |
109 case HbDataFormModelItem::CustomItemBase + AlarmDateItemOffset: { |
98 // Adding two push buttions. |
110 // Adding two push buttions. |
112 mDateWidget->setObjectName("alarmDate"); |
124 mDateWidget->setObjectName("alarmDate"); |
113 layout->addItem(mDateWidget); |
125 layout->addItem(mDateWidget); |
114 connect( |
126 connect( |
115 mDateWidget, SIGNAL(clicked()), |
127 mDateWidget, SIGNAL(clicked()), |
116 this, SLOT(launchDatePicker())); |
128 this, SLOT(launchDatePicker())); |
|
129 OstTraceFunctionExit0( DUP1_NOTESTODOEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
117 return widget; |
130 return widget; |
118 } |
131 } |
119 case HbDataFormModelItem::CustomItemBase + ItemOffsetUnKnown: |
132 case HbDataFormModelItem::CustomItemBase + ItemOffsetUnKnown: |
120 default: |
133 default: |
121 return 0; |
134 return 0; |
125 /*! |
138 /*! |
126 Override method to enable the custom items. |
139 Override method to enable the custom items. |
127 */ |
140 */ |
128 bool NotesTodoEditorCustomItem::canSetModelIndex(const QModelIndex &index) const |
141 bool NotesTodoEditorCustomItem::canSetModelIndex(const QModelIndex &index) const |
129 { |
142 { |
|
143 OstTraceFunctionEntry0( NOTESTODOEDITORCUSTOMITEM_CANSETMODELINDEX_ENTRY ); |
130 HbDataFormModelItem::DataItemType itemType = |
144 HbDataFormModelItem::DataItemType itemType = |
131 static_cast<HbDataFormModelItem::DataItemType>( |
145 static_cast<HbDataFormModelItem::DataItemType>( |
132 index.data(HbDataFormModelItem::ItemTypeRole).toInt()); |
146 index.data(HbDataFormModelItem::ItemTypeRole).toInt()); |
133 |
147 |
134 if( itemType == (HbDataFormModelItem::CustomItemBase + DueDateItemOffset) || |
148 if( itemType == (HbDataFormModelItem::CustomItemBase + DueDateItemOffset) || |
135 itemType == (HbDataFormModelItem::CustomItemBase + AlarmDateItemOffset)) { |
149 itemType == (HbDataFormModelItem::CustomItemBase + AlarmDateItemOffset)) { |
|
150 OstTraceFunctionExit0( NOTESTODOEDITORCUSTOMITEM_CANSETMODELINDEX_EXIT ); |
136 return true; |
151 return true; |
137 } else { |
152 } else { |
|
153 OstTraceFunctionExit0( DUP1_NOTESTODOEDITORCUSTOMITEM_CANSETMODELINDEX_EXIT ); |
138 return false; |
154 return false; |
139 } |
155 } |
140 } |
156 } |
141 |
157 |
142 /*! |
158 /*! |
143 Set the text for the custom widgets using the |
159 Set the text for the custom widgets using the |
144 model item's content widget data |
160 model item's content widget data |
145 */ |
161 */ |
146 void NotesTodoEditorCustomItem::restore() |
162 void NotesTodoEditorCustomItem::restore() |
147 { |
163 { |
|
164 OstTraceFunctionEntry0( NOTESTODOEDITORCUSTOMITEM_RESTORE_ENTRY ); |
148 HbDataFormModelItem::DataItemType itemType = |
165 HbDataFormModelItem::DataItemType itemType = |
149 static_cast<HbDataFormModelItem::DataItemType>( |
166 static_cast<HbDataFormModelItem::DataItemType>( |
150 modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt()); |
167 modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt()); |
151 |
168 |
152 HbDataFormModel* model = |
169 HbDataFormModel* model = |
167 break; |
184 break; |
168 |
185 |
169 default: |
186 default: |
170 break; |
187 break; |
171 } |
188 } |
|
189 OstTraceFunctionExit0( NOTESTODOEDITORCUSTOMITEM_RESTORE_EXIT ); |
172 } |
190 } |
173 |
191 |
174 /*! |
192 /*! |
175 Launches the time picker dialog. |
193 Launches the time picker dialog. |
176 */ |
194 */ |
177 void NotesTodoEditorCustomItem::launchTimePicker() |
195 void NotesTodoEditorCustomItem::launchTimePicker() |
178 { |
196 { |
|
197 OstTraceFunctionEntry0( NOTESTODOEDITORCUSTOMITEM_LAUNCHTIMEPICKER_ENTRY ); |
179 if (mTimePickerDialog) { |
198 if (mTimePickerDialog) { |
180 delete mTimePickerDialog; |
199 delete mTimePickerDialog; |
181 } |
200 } |
182 |
201 |
183 // Create the dialog. |
202 // Create the dialog. |
208 mCancelAction = new HbAction( |
227 mCancelAction = new HbAction( |
209 hbTrId("txt_common_button_cancel"), mTimePickerDialog); |
228 hbTrId("txt_common_button_cancel"), mTimePickerDialog); |
210 mTimePickerDialog->addAction(mCancelAction); |
229 mTimePickerDialog->addAction(mCancelAction); |
211 |
230 |
212 mTimePickerDialog->open(this, SLOT(selectedAction(HbAction *))); |
231 mTimePickerDialog->open(this, SLOT(selectedAction(HbAction *))); |
|
232 OstTraceFunctionExit0( NOTESTODOEDITORCUSTOMITEM_LAUNCHTIMEPICKER_EXIT ); |
213 } |
233 } |
214 |
234 |
215 /*! |
235 /*! |
216 Launches the date picker dialog. |
236 Launches the date picker dialog. |
217 */ |
237 */ |
218 void NotesTodoEditorCustomItem::launchDatePicker() |
238 void NotesTodoEditorCustomItem::launchDatePicker() |
219 { |
239 { |
|
240 OstTraceFunctionEntry0( NOTESTODOEDITORCUSTOMITEM_LAUNCHDATEPICKER_ENTRY ); |
220 if (mDatePickerDialog) { |
241 if (mDatePickerDialog) { |
221 delete mDatePickerDialog; |
242 delete mDatePickerDialog; |
222 } |
243 } |
223 |
244 |
224 // Create the dialog. |
245 // Create the dialog. |
255 mCancelAction = new HbAction( |
276 mCancelAction = new HbAction( |
256 hbTrId("txt_common_button_cancel"), mDatePickerDialog); |
277 hbTrId("txt_common_button_cancel"), mDatePickerDialog); |
257 mDatePickerDialog->addAction(mCancelAction); |
278 mDatePickerDialog->addAction(mCancelAction); |
258 |
279 |
259 mDatePickerDialog->open(this, SLOT(selectedAction(HbAction *))); |
280 mDatePickerDialog->open(this, SLOT(selectedAction(HbAction *))); |
|
281 OstTraceFunctionExit0( NOTESTODOEDITORCUSTOMITEM_LAUNCHDATEPICKER_EXIT ); |
260 } |
282 } |
261 |
283 |
262 /* |
284 /* |
263 Launches date picker for selecting the due date |
285 Launches date picker for selecting the due date |
264 */ |
286 */ |
265 void NotesTodoEditorCustomItem::selectDueDate() |
287 void NotesTodoEditorCustomItem::selectDueDate() |
266 { |
288 { |
|
289 OstTraceFunctionEntry0( NOTESTODOEDITORCUSTOMITEM_SELECTDUEDATE_ENTRY ); |
267 if( mDueDateItem->isDown()) { |
290 if( mDueDateItem->isDown()) { |
268 mDueDateItem->setDown(false); |
291 mDueDateItem->setDown(false); |
|
292 OstTraceFunctionExit0( NOTESTODOEDITORCUSTOMITEM_SELECTDUEDATE_EXIT ); |
269 return; |
293 return; |
270 } |
294 } |
271 |
295 |
272 mDueDatePickerIsActive = true; |
296 mDueDatePickerIsActive = true; |
273 |
297 |
308 mCancelAction = new HbAction( |
332 mCancelAction = new HbAction( |
309 hbTrId("txt_common_button_cancel"), mDatePickerDialog); |
333 hbTrId("txt_common_button_cancel"), mDatePickerDialog); |
310 mDatePickerDialog->addAction(mCancelAction); |
334 mDatePickerDialog->addAction(mCancelAction); |
311 |
335 |
312 mDatePickerDialog->open(this, SLOT(selectedAction(HbAction *))); |
336 mDatePickerDialog->open(this, SLOT(selectedAction(HbAction *))); |
|
337 OstTraceFunctionExit0( DUP1_NOTESTODOEDITORCUSTOMITEM_SELECTDUEDATE_EXIT ); |
313 } |
338 } |
314 |
339 |
315 /*! |
340 /*! |
316 Slot to handle the selected action. |
341 Slot to handle the selected action. |
317 */ |
342 */ |
318 void NotesTodoEditorCustomItem::selectedAction(HbAction *action) |
343 void NotesTodoEditorCustomItem::selectedAction(HbAction *action) |
319 { |
344 { |
|
345 OstTraceFunctionEntry0( NOTESTODOEDITORCUSTOMITEM_SELECTEDACTION_ENTRY ); |
320 if (action == mOkAction) { |
346 if (action == mOkAction) { |
321 handleOkAction(); |
347 handleOkAction(); |
322 } |
348 } |
|
349 OstTraceFunctionExit0( NOTESTODOEDITORCUSTOMITEM_SELECTEDACTION_EXIT ); |
323 } |
350 } |
324 |
351 |
325 /*! |
352 /*! |
326 Handles the ok action of date/time picker dialog. |
353 Handles the ok action of date/time picker dialog. |
327 */ |
354 */ |
328 void NotesTodoEditorCustomItem::handleOkAction() |
355 void NotesTodoEditorCustomItem::handleOkAction() |
329 { |
356 { |
|
357 OstTraceFunctionEntry0( NOTESTODOEDITORCUSTOMITEM_HANDLEOKACTION_ENTRY ); |
330 HbExtendedLocale locale = HbExtendedLocale::system(); |
358 HbExtendedLocale locale = HbExtendedLocale::system(); |
331 |
359 |
332 HbDataFormModelItem *modelItem = |
360 HbDataFormModelItem *modelItem = |
333 static_cast<HbDataFormModel*>( |
361 static_cast<HbDataFormModel*>( |
334 itemView()->model())->itemFromIndex(modelIndex());; |
362 itemView()->model())->itemFromIndex(modelIndex());; |