|
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 * Definition file for class NotesModel. |
|
16 * |
|
17 */ |
|
18 |
|
19 // System includes |
|
20 #include <QAbstractItemModel> |
|
21 #include <QStandardItemModel> |
|
22 #include <QTimer> |
|
23 #include <QDateTime> |
|
24 #include <HbIcon> |
|
25 #include <HbExtendedLocale> |
|
26 |
|
27 // User includes |
|
28 #include "notesmodel.h" |
|
29 #include <agendautil.h> |
|
30 #include <agendaentry.h> |
|
31 #include "notescommon.h" |
|
32 #include "OstTraceDefinitions.h" |
|
33 #ifdef OST_TRACE_COMPILER_IN_USE |
|
34 #include "notesmodelTraces.h" |
|
35 #endif |
|
36 |
|
37 |
|
38 /*! |
|
39 \class NotesModel |
|
40 |
|
41 This is the source model class for the notes application views. This owns |
|
42 a QStandardItemModel which is a model for the data containing notes, todos |
|
43 and reminders. |
|
44 */ |
|
45 |
|
46 /*! |
|
47 Constructor. |
|
48 |
|
49 \param agendaUtil Pointer to the object of AgendaUtil. |
|
50 \param parent Parent of type QObject. |
|
51 */ |
|
52 NotesModel::NotesModel(AgendaUtil *agendaUtil, QObject *parent) |
|
53 :QObject(parent), |
|
54 mAgendaUtil(agendaUtil) |
|
55 { |
|
56 OstTraceFunctionEntry0( NOTESMODEL_NOTESMODEL_ENTRY ); |
|
57 // Construct the source model. |
|
58 mSourceModel = new QStandardItemModel(0, 1, this); |
|
59 |
|
60 connect( |
|
61 mAgendaUtil, SIGNAL(entriesChanged(QList<ulong>)), |
|
62 this, SLOT(populateSourceModel(QList<ulong>))); |
|
63 |
|
64 // Connect to entryAdded signal of agendautil. |
|
65 connect( |
|
66 mAgendaUtil, SIGNAL(entryAdded(ulong)), |
|
67 this, SLOT(addEntryToModel(ulong))); |
|
68 // Connect to entryDeleted signal of agendautil. |
|
69 connect( |
|
70 mAgendaUtil, SIGNAL(entryDeleted(ulong)), |
|
71 this, SLOT(removeEntryFromModel(ulong))); |
|
72 // Connect to entryUpdated signal of agendautil. |
|
73 connect( |
|
74 mAgendaUtil, SIGNAL(entryUpdated(ulong)), |
|
75 this, SLOT(updateSourceModel(ulong))); |
|
76 |
|
77 // Connect for instance view creation completed signal |
|
78 connect( |
|
79 mAgendaUtil, SIGNAL(instanceViewCreationCompleted(int)), |
|
80 this,SLOT(handleInstanceViewCreationCompleted(int))); |
|
81 OstTraceFunctionExit0( NOTESMODEL_NOTESMODEL_EXIT ); |
|
82 } |
|
83 |
|
84 /*! |
|
85 Destructor. |
|
86 */ |
|
87 NotesModel::~NotesModel() |
|
88 { |
|
89 OstTraceFunctionEntry0( DUP1_NOTESMODEL_NOTESMODEL_ENTRY ); |
|
90 // Nothing yet. |
|
91 OstTraceFunctionExit0( DUP1_NOTESMODEL_NOTESMODEL_EXIT ); |
|
92 } |
|
93 |
|
94 /*! |
|
95 Returns the source model to be used with a view. |
|
96 |
|
97 \return QAbstractItemModel |
|
98 \sa QAbstractItemModel, HbListView. |
|
99 */ |
|
100 QAbstractItemModel *NotesModel::sourceModel() |
|
101 { |
|
102 OstTraceFunctionEntry0( NOTESMODEL_SOURCEMODEL_ENTRY ); |
|
103 Q_ASSERT(mSourceModel); |
|
104 OstTraceFunctionExit0( NOTESMODEL_SOURCEMODEL_EXIT ); |
|
105 return mSourceModel; |
|
106 } |
|
107 |
|
108 /*! |
|
109 Populates the source model. |
|
110 */ |
|
111 void NotesModel::populateSourceModel() |
|
112 { |
|
113 OstTraceFunctionEntry0( NOTESMODEL_POPULATESOURCEMODEL_ENTRY ); |
|
114 // Clear the model if it has any data already |
|
115 mSourceModel->clear(); |
|
116 mSourceModel->setColumnCount(1); |
|
117 mNotesCount = mInCompTodoCount = mCompTodoCount = 0; |
|
118 |
|
119 // The order of appending the items to the model is: |
|
120 // 1. Notes, 2. Incompleted to-dos, 3. Completed to-dos. |
|
121 // First get only the notes and populate the model. |
|
122 QList<AgendaEntry> agendaEntyList = mAgendaUtil->fetchAllEntries( |
|
123 (AgendaUtil::FilterFlags) (AgendaUtil::IncludeNotes)); |
|
124 |
|
125 // Add the notes to the model. |
|
126 appendNotesToModel(agendaEntyList); |
|
127 |
|
128 // Get the incompleted to-dos. |
|
129 agendaEntyList.clear(); |
|
130 agendaEntyList = mAgendaUtil->fetchAllEntries( |
|
131 (AgendaUtil::FilterFlags) (AgendaUtil::IncludeIncompletedTodos)); |
|
132 |
|
133 // Add the incompleted to-dos to the model. |
|
134 appendInCompTodosToModel(agendaEntyList); |
|
135 |
|
136 // Get the completed to-dos. |
|
137 agendaEntyList.clear(); |
|
138 agendaEntyList = mAgendaUtil->fetchAllEntries( |
|
139 (AgendaUtil::FilterFlags) (AgendaUtil::IncludeCompletedTodos)); |
|
140 |
|
141 // Add the completed to-dos to the model. |
|
142 appendCompTodosToModel(agendaEntyList); |
|
143 OstTraceFunctionExit0( NOTESMODEL_POPULATESOURCEMODEL_EXIT ); |
|
144 } |
|
145 |
|
146 /*! |
|
147 Updates the source model with the given entry `id'. |
|
148 The entry could be either have undergone a status change or have just been |
|
149 modified. |
|
150 |
|
151 \param id Of type ulong, identifies the entry which was changed. |
|
152 */ |
|
153 void NotesModel::updateSourceModel(ulong id) |
|
154 { |
|
155 OstTraceFunctionEntry0( NOTESMODEL_UPDATESOURCEMODEL_ENTRY ); |
|
156 AgendaEntry entry = mAgendaUtil->fetchById(id); |
|
157 if (entry.isNull()) { |
|
158 OstTraceFunctionExit0( NOTESMODEL_UPDATESOURCEMODEL_EXIT ); |
|
159 return; |
|
160 } |
|
161 |
|
162 // Entry can be updated in many ways. |
|
163 // 1. Notes can just change their content or can be marked/unmarked as |
|
164 // favourites. So for any change with a note, we move the model index |
|
165 // representing the note to the top of the list. |
|
166 if (AgendaEntry::TypeNote == entry.type()) { |
|
167 QModelIndex foundIndex; |
|
168 for (int iter = 0; iter < mNotesCount; iter++) { |
|
169 foundIndex = mSourceModel->index(iter, 0); |
|
170 if (!foundIndex.isValid()) { |
|
171 continue; |
|
172 } |
|
173 |
|
174 ulong noteId = foundIndex.data( |
|
175 NotesNamespace::IdRole).value<qulonglong>(); |
|
176 if (id == noteId) { |
|
177 break; |
|
178 } |
|
179 } |
|
180 QStandardItem *item = mSourceModel->takeItem(foundIndex.row()); |
|
181 mSourceModel->removeRow(foundIndex.row()); |
|
182 mNotesCount--; |
|
183 |
|
184 // Insert the note to the 0th postion. |
|
185 insertNoteToModel(foundIndex, id); |
|
186 |
|
187 } else if (AgendaEntry::TypeTodo == entry.type()) { |
|
188 // 2. To-dos content can be modified. |
|
189 // So we check the status of the to-do. If the status has changed, we |
|
190 // check the previous status and remove the model index from the |
|
191 // corresponding section. Else we just update the to-do contents. |
|
192 QModelIndex foundIndex; |
|
193 for (int iter = mNotesCount; |
|
194 iter < mNotesCount + mInCompTodoCount + mCompTodoCount + 1; |
|
195 iter++) { |
|
196 foundIndex = mSourceModel->index(iter, 0); |
|
197 if (!foundIndex.isValid()) { |
|
198 continue; |
|
199 } |
|
200 |
|
201 ulong noteId = foundIndex.data( |
|
202 NotesNamespace::IdRole).value<qulonglong>(); |
|
203 if (id == noteId) { |
|
204 break; |
|
205 } |
|
206 } |
|
207 |
|
208 // Get the status of the to-do. |
|
209 AgendaEntry::Status entryStatus = (AgendaEntry::Status) foundIndex.data( |
|
210 NotesNamespace::StatusRole).value<int>(); |
|
211 |
|
212 if (entry.status() == entryStatus) { |
|
213 if (AgendaEntry::TodoNeedsAction == entryStatus) { |
|
214 // Make sure that the old model index is removed. |
|
215 mSourceModel->removeRow(foundIndex.row()); |
|
216 mInCompTodoCount--; |
|
217 |
|
218 // Now insert the to-do. |
|
219 insertInCompTodoToModel(foundIndex, id); |
|
220 |
|
221 } else if (AgendaEntry::TodoCompleted == entryStatus) { |
|
222 // Make sure that the old model index is removed. |
|
223 mSourceModel->removeRow(foundIndex.row()); |
|
224 mCompTodoCount--; |
|
225 |
|
226 // Now insert the completed to-do. |
|
227 insertCompTodoToModel(foundIndex, id); |
|
228 |
|
229 } |
|
230 } else { |
|
231 if (AgendaEntry::TodoNeedsAction == entryStatus) { |
|
232 // Here the to-do was marked completed. Hence we need to remove |
|
233 // the incompleted to-do and insert a completed to-do. |
|
234 mSourceModel->removeRow(foundIndex.row()); |
|
235 mInCompTodoCount--; |
|
236 |
|
237 // Now insert the completed to-do. |
|
238 insertCompTodoToModel(foundIndex, id); |
|
239 |
|
240 } else if (AgendaEntry::TodoCompleted == entryStatus) { |
|
241 // Here the to-do was marked incompleted. Hence we need to |
|
242 // remove the completed to-do and insert an incompleted to-do. |
|
243 mSourceModel->removeRow(foundIndex.row()); |
|
244 mCompTodoCount--; |
|
245 |
|
246 // Now insert the incompleted to-do. |
|
247 insertInCompTodoToModel(foundIndex, id); |
|
248 |
|
249 } |
|
250 } |
|
251 } |
|
252 OstTraceFunctionExit0( DUP1_NOTESMODEL_UPDATESOURCEMODEL_EXIT ); |
|
253 } |
|
254 |
|
255 /*! |
|
256 Populates the source model. This slot is called when we get a db change |
|
257 notification from agenda server caused by another session. |
|
258 |
|
259 \param ids List of ids containing the entries that got changed. |
|
260 */ |
|
261 void NotesModel::populateSourceModel(QList<ulong> ids) |
|
262 { |
|
263 OstTraceFunctionEntry0( DUP1_NOTESMODEL_POPULATESOURCEMODEL_ENTRY ); |
|
264 Q_UNUSED(ids) |
|
265 |
|
266 QTimer::singleShot(1, this, SLOT(populateSourceModel())); |
|
267 OstTraceFunctionExit0( DUP1_NOTESMODEL_POPULATESOURCEMODEL_EXIT ); |
|
268 } |
|
269 |
|
270 /*! |
|
271 Adds an entry to the model i.e., creates a QModelIndex and inserts it to the |
|
272 model. |
|
273 |
|
274 \param id The id of the entry to be added to the model. |
|
275 */ |
|
276 void NotesModel::addEntryToModel(ulong id) |
|
277 { |
|
278 OstTraceFunctionEntry0( NOTESMODEL_ADDENTRYTOMODEL_ENTRY ); |
|
279 // We have different logic for adding a note or an incompleted to-do or a |
|
280 // completed to-do. |
|
281 AgendaEntry entry = mAgendaUtil->fetchById(id); |
|
282 if (entry.isNull()) { |
|
283 OstTraceFunctionExit0( NOTESMODEL_ADDENTRYTOMODEL_EXIT ); |
|
284 return; |
|
285 } |
|
286 bool notify = false; |
|
287 QModelIndex indexToNotify; |
|
288 |
|
289 if (AgendaEntry::TypeNote == entry.type()) { |
|
290 // All new notes are inserted at the top of the list by default. |
|
291 // Create a new model index at the 0th position. |
|
292 notify = insertNoteToModel(indexToNotify, id); |
|
293 |
|
294 } else if (AgendaEntry::TypeTodo == entry.type()) { |
|
295 if (AgendaEntry::TodoNeedsAction == entry.status()) { |
|
296 // Try to insert the to-do at its appropriate position. |
|
297 notify = insertInCompTodoToModel(indexToNotify, id); |
|
298 |
|
299 } else if (AgendaEntry::TodoCompleted == entry.status()) { |
|
300 // Try to insert the to-do at its appropriate position. |
|
301 insertCompTodoToModel(indexToNotify, id); |
|
302 } |
|
303 } |
|
304 |
|
305 if (notify) { |
|
306 emit rowAdded(indexToNotify); |
|
307 } |
|
308 OstTraceFunctionExit0( DUP1_NOTESMODEL_ADDENTRYTOMODEL_EXIT ); |
|
309 } |
|
310 |
|
311 /*! |
|
312 Deletes an entry from model. |
|
313 |
|
314 \param Deletes the entry from model and hence updating the view. |
|
315 */ |
|
316 void NotesModel::removeEntryFromModel(ulong id) |
|
317 { |
|
318 OstTraceFunctionEntry0( NOTESMODEL_REMOVEENTRYFROMMODEL_ENTRY ); |
|
319 for (int iter = 0; iter < mSourceModel->rowCount(); iter++) { |
|
320 QModelIndex mdlIndex = mSourceModel->index(iter, 0); |
|
321 |
|
322 if (!mdlIndex.isValid()) { |
|
323 OstTraceFunctionExit0( NOTESMODEL_REMOVEENTRYFROMMODEL_EXIT ); |
|
324 return; |
|
325 } |
|
326 |
|
327 ulong noteId = mdlIndex.data( |
|
328 NotesNamespace::IdRole).value<qulonglong>(); |
|
329 AgendaEntry::Type entryType = (AgendaEntry::Type) mdlIndex.data( |
|
330 NotesNamespace::TypeRole).value<int>(); |
|
331 AgendaEntry::Status entryStatus = (AgendaEntry::Status) mdlIndex.data( |
|
332 NotesNamespace::StatusRole).value<int>(); |
|
333 |
|
334 if (id == noteId) { |
|
335 mSourceModel->removeRow(mdlIndex.row()); |
|
336 |
|
337 // Update the note, to-do counts depending on the type. |
|
338 if (entryType == AgendaEntry::TypeNote) { |
|
339 mNotesCount--; |
|
340 } else if (entryType == AgendaEntry::TypeTodo) { |
|
341 if (entryStatus == AgendaEntry::TodoCompleted) { |
|
342 mCompTodoCount--; |
|
343 } else if (entryStatus == AgendaEntry::TodoNeedsAction) { |
|
344 mInCompTodoCount--; |
|
345 } |
|
346 } |
|
347 break; |
|
348 } |
|
349 } |
|
350 OstTraceFunctionExit0( DUP1_NOTESMODEL_REMOVEENTRYFROMMODEL_EXIT ); |
|
351 } |
|
352 |
|
353 /*! |
|
354 Populate the model after instance view creation. |
|
355 */ |
|
356 void NotesModel::handleInstanceViewCreationCompleted(int status) |
|
357 { |
|
358 OstTraceFunctionEntry0( NOTESMODEL_HANDLEINSTANCEVIEWCREATIONCOMPLETED_ENTRY ); |
|
359 Q_UNUSED(status); |
|
360 populateSourceModel(); |
|
361 OstTraceFunctionExit0( NOTESMODEL_HANDLEINSTANCEVIEWCREATIONCOMPLETED_EXIT ); |
|
362 } |
|
363 |
|
364 /*! |
|
365 Modifies the content of a given `row' with the data of the entry given by |
|
366 `id'. |
|
367 |
|
368 \param id The id of the entry. |
|
369 \param row The row corresponding to the given id. |
|
370 */ |
|
371 void NotesModel::modifyEntryInModel(ulong id, int row) |
|
372 { |
|
373 OstTraceFunctionEntry0( NOTESMODEL_MODIFYENTRYINMODEL_ENTRY ); |
|
374 // Get the model index. |
|
375 QModelIndex modelIndex = mSourceModel->index(row, 0); |
|
376 Q_ASSERT(modelIndex.isValid()); |
|
377 |
|
378 // Fetch the entry |
|
379 AgendaEntry entry = mAgendaUtil->fetchById(id); |
|
380 Q_ASSERT(!entry.isNull()); |
|
381 |
|
382 // Set the note id. |
|
383 mSourceModel->setData( |
|
384 modelIndex, (qulonglong) id, NotesNamespace::IdRole); |
|
385 // Set the type of the note. |
|
386 mSourceModel->setData( |
|
387 modelIndex, entry.type(), NotesNamespace::TypeRole); |
|
388 |
|
389 // Set the display data to the index. |
|
390 if (AgendaEntry::TypeNote == entry.type()) { |
|
391 QString displayText; |
|
392 QString dateTimeText; |
|
393 QString modifiedText; |
|
394 |
|
395 // Read modification time from agenda entry |
|
396 QDateTime entryStartDateTime = entry.startTime(); |
|
397 |
|
398 // If modified on today,show only modified time otherwise show the |
|
399 // modified date. |
|
400 if ((QDate::currentDate()) == entryStartDateTime.date() ) { |
|
401 dateTimeText = |
|
402 hbTrId("txt_notes_dblist_note_modified_at_time"); |
|
403 modifiedText = |
|
404 entryStartDateTime.time().toString(timeFormatString()); |
|
405 } else { |
|
406 dateTimeText = |
|
407 hbTrId("txt_notes_dblist_note_modified_on_date"); |
|
408 modifiedText = |
|
409 entryStartDateTime.date().toString(dateFormatString()); |
|
410 } |
|
411 |
|
412 displayText = dateTimeText.arg(modifiedText); |
|
413 |
|
414 QStringList stringList; |
|
415 stringList << entry.description().left(15) << displayText; |
|
416 // Set the data. |
|
417 mSourceModel->setData( |
|
418 modelIndex, stringList, Qt::DisplayRole); |
|
419 // Set the favourite icon. |
|
420 if (entry.favourite()) { |
|
421 QList<QVariant> iconList; |
|
422 iconList.append(HbIcon("qtg_small_note")); |
|
423 iconList.append(HbIcon("qtg_mono_favourites")); |
|
424 mSourceModel->setData(modelIndex, iconList, Qt::DecorationRole); |
|
425 } else { |
|
426 QList<QVariant> iconList; |
|
427 iconList.append(HbIcon("qtg_small_note")); |
|
428 iconList.append(QVariant(QVariant::Invalid)); |
|
429 mSourceModel->setData(modelIndex, iconList, Qt::DecorationRole); |
|
430 } |
|
431 } else if (AgendaEntry::TypeTodo == entry.type()) { |
|
432 QStringList stringList; |
|
433 if (entry.summary().isEmpty()) { |
|
434 // If empty set unnamed text |
|
435 stringList<<hbTrId("txt_notes_dblist_unnamed"); |
|
436 } else { |
|
437 stringList << entry.summary(); |
|
438 } |
|
439 if (AgendaEntry::TodoNeedsAction == entry.status()) { |
|
440 // Read due date from agenda entry |
|
441 QString displayText; |
|
442 QString timeText(hbTrId("txt_notes_dblist_val_due_on_1")); |
|
443 QString dueDateText = |
|
444 entry.startTime().toString(dateFormatString()); |
|
445 displayText = timeText.arg(dueDateText); |
|
446 stringList << displayText; |
|
447 } |
|
448 // Set the data. |
|
449 mSourceModel->setData( |
|
450 modelIndex, stringList, Qt::DisplayRole); |
|
451 |
|
452 // Set the to-do done/undone icon based on the status. |
|
453 QList<QVariant> iconList; |
|
454 if (AgendaEntry::TodoCompleted == entry.status()) { |
|
455 iconList.append(HbIcon("qtg_small_todo_done")); |
|
456 } else { |
|
457 iconList.append(HbIcon("qtg_small_todo")); |
|
458 } |
|
459 |
|
460 if (1 == entry.priority()) { |
|
461 // Set the High Priority icon if priority is high. |
|
462 iconList.append(HbIcon("qtg_small_priority_high")); |
|
463 } else if (!entry.alarm().isNull()) { |
|
464 // Set the alarm if set. |
|
465 iconList.append(HbIcon("qtg_mono_alarm")); |
|
466 } else { |
|
467 iconList.append(QVariant(QVariant::Invalid)); |
|
468 } |
|
469 |
|
470 // Set the icons. |
|
471 mSourceModel->setData(modelIndex, iconList, Qt::DecorationRole); |
|
472 } |
|
473 OstTraceFunctionExit0( NOTESMODEL_MODIFYENTRYINMODEL_EXIT ); |
|
474 } |
|
475 |
|
476 /*! |
|
477 Appends notes to the model. |
|
478 |
|
479 \param ids QList of uids containing the notes. |
|
480 */ |
|
481 void NotesModel::appendNotesToModel(QList<AgendaEntry> &agendaEntryList) |
|
482 { |
|
483 OstTraceFunctionEntry0( NOTESMODEL_APPENDNOTESTOMODEL_ENTRY ); |
|
484 int entriesCount = agendaEntryList.count(); |
|
485 // Iterate and add notes to the model. |
|
486 mSourceModel->insertRows(mSourceModel->rowCount(), entriesCount); |
|
487 int rowCount = mSourceModel->rowCount(); |
|
488 for (int idIter = 0, modelIter = rowCount - entriesCount; |
|
489 idIter < entriesCount; idIter++, modelIter++) { |
|
490 |
|
491 // Read the note details. |
|
492 AgendaEntry entry = agendaEntryList[rowCount - 1 - idIter]; |
|
493 |
|
494 if (AgendaEntry::TypeNote != entry.type()) { |
|
495 continue; |
|
496 } |
|
497 |
|
498 // Create a model index. |
|
499 QModelIndex mdlIndex = mSourceModel->index(qAbs(modelIter), 0); |
|
500 |
|
501 // Set the note id. |
|
502 mSourceModel->setData( |
|
503 mdlIndex, (qulonglong) entry.id(), NotesNamespace::IdRole); |
|
504 // Set the type of the note. |
|
505 mSourceModel->setData( |
|
506 mdlIndex, entry.type(), NotesNamespace::TypeRole); |
|
507 // Set the favourite property. |
|
508 mSourceModel->setData( |
|
509 mdlIndex, entry.favourite(), NotesNamespace::FavouriteRole); |
|
510 |
|
511 // Set the display data now. |
|
512 // Read modification time from agenda entry |
|
513 QString displayText; |
|
514 QString dateTimeText; |
|
515 QString modifiedText; |
|
516 |
|
517 // Show the creation time if entry is not modified. |
|
518 if (entry.dtStamp().isValid()) { |
|
519 QDateTime creationDateTime = entry.dtStamp(); |
|
520 |
|
521 // If created on today,show only creation time otherwise show the |
|
522 // creation date. |
|
523 if ((QDate::currentDate()) == creationDateTime.date()) { |
|
524 dateTimeText = |
|
525 hbTrId("txt_notes_dblist_note_created_at_time"); |
|
526 modifiedText = |
|
527 creationDateTime.time().toString(timeFormatString()); |
|
528 } else { |
|
529 dateTimeText = |
|
530 hbTrId("txt_notes_dblist_note_created_on_date"); |
|
531 modifiedText = |
|
532 creationDateTime.date().toString(dateFormatString()); |
|
533 } |
|
534 } else { |
|
535 QDateTime modifiedDateTime = entry.lastModifiedDateTime(); |
|
536 |
|
537 // If modified on today,show only modified time otherwise show the |
|
538 // modified date. |
|
539 if ((QDate::currentDate()) == modifiedDateTime.date() ) { |
|
540 dateTimeText = |
|
541 hbTrId("txt_notes_dblist_note_modified_at_time"); |
|
542 modifiedText = |
|
543 modifiedDateTime.time().toString(timeFormatString()); |
|
544 } else { |
|
545 dateTimeText = |
|
546 hbTrId("txt_notes_dblist_note_modified_on_date"); |
|
547 modifiedText = |
|
548 modifiedDateTime.date().toString(dateFormatString()); |
|
549 } |
|
550 } |
|
551 |
|
552 displayText = dateTimeText.arg(modifiedText); |
|
553 |
|
554 QStringList stringList; |
|
555 stringList << entry.description().left(100) << displayText; |
|
556 // Set the data. |
|
557 mSourceModel->setData( |
|
558 mdlIndex, stringList, Qt::DisplayRole); |
|
559 |
|
560 if (entry.favourite()) { |
|
561 // Set the favourite icon. |
|
562 QList<QVariant> iconList; |
|
563 iconList.append(HbIcon("qtg_small_note")); |
|
564 iconList.append(HbIcon("qtg_mono_favourites")); |
|
565 mSourceModel->setData(mdlIndex, iconList, Qt::DecorationRole); |
|
566 } else { |
|
567 QList<QVariant> iconList; |
|
568 iconList.append(HbIcon("qtg_small_note")); |
|
569 iconList.append(QVariant(QVariant::Invalid)); |
|
570 mSourceModel->setData(mdlIndex, iconList, Qt::DecorationRole); |
|
571 } |
|
572 |
|
573 // Update the notes count. |
|
574 mNotesCount++; |
|
575 } |
|
576 OstTraceFunctionExit0( NOTESMODEL_APPENDNOTESTOMODEL_EXIT ); |
|
577 } |
|
578 |
|
579 /*! |
|
580 Appends incompleted to-dos to the model. |
|
581 |
|
582 \param ids QList of uids containing the incompleted to-dos. |
|
583 */ |
|
584 void NotesModel::appendInCompTodosToModel(QList<AgendaEntry> &agendaEntryList) |
|
585 { |
|
586 OstTraceFunctionEntry0( NOTESMODEL_APPENDINCOMPTODOSTOMODEL_ENTRY ); |
|
587 int entriesCount = agendaEntryList.count(); |
|
588 // Iterate and add incomplete to-do to the model. |
|
589 mSourceModel->insertRows(mSourceModel->rowCount(), entriesCount); |
|
590 int rowCount = mSourceModel->rowCount(); |
|
591 for (int idIter = 0, modelIter = rowCount - entriesCount; |
|
592 idIter < entriesCount; idIter++, modelIter++) { |
|
593 |
|
594 // Read the to-do details. |
|
595 AgendaEntry entry = agendaEntryList[idIter]; |
|
596 |
|
597 if (AgendaEntry::TypeTodo != entry.type()) { |
|
598 continue; |
|
599 } |
|
600 |
|
601 if (AgendaEntry::TodoNeedsAction != entry.status()) { |
|
602 continue; |
|
603 } |
|
604 |
|
605 // Create a model index. |
|
606 QModelIndex mdlIndex = mSourceModel->index(modelIter, 0); |
|
607 |
|
608 // Set the to-do id. |
|
609 mSourceModel->setData( |
|
610 mdlIndex, (qulonglong) entry.id(), NotesNamespace::IdRole); |
|
611 // Set the type of the to-do. |
|
612 mSourceModel->setData( |
|
613 mdlIndex, entry.type(), NotesNamespace::TypeRole); |
|
614 // Set the status of the to-do. |
|
615 mSourceModel->setData( |
|
616 mdlIndex, (int) entry.status(), NotesNamespace::StatusRole); |
|
617 |
|
618 // Set the display data now. |
|
619 QStringList stringList; |
|
620 if (entry.summary().isEmpty()) { |
|
621 // If empty set unnamed text |
|
622 stringList<<hbTrId("txt_notes_dblist_unnamed"); |
|
623 } else { |
|
624 stringList << entry.summary(); |
|
625 } |
|
626 |
|
627 if (AgendaEntry::TodoNeedsAction == entry.status()) { |
|
628 // Read due date from agenda entry |
|
629 QString displayText; |
|
630 QString timeText(hbTrId("txt_notes_dblist_val_due_on_1")); |
|
631 QString dueDateText = |
|
632 entry.startTime().toString(dateFormatString()); |
|
633 displayText = timeText.arg(dueDateText); |
|
634 stringList << displayText; |
|
635 } |
|
636 // Set the data. |
|
637 mSourceModel->setData(mdlIndex, stringList, Qt::DisplayRole); |
|
638 // Set the to-do done/undone icon based on the status. |
|
639 QList<QVariant> iconList; |
|
640 iconList.append(HbIcon("qtg_small_todo")); |
|
641 |
|
642 if (1 == entry.priority()) { |
|
643 // Set the High Priority icon if priority is high. |
|
644 iconList.append(HbIcon("qtg_small_priority_high")); |
|
645 } else if (!entry.alarm().isNull()) { |
|
646 // Set the alarm if set. |
|
647 iconList.append(HbIcon("qtg_mono_alarm")); |
|
648 } else { |
|
649 iconList.append(QVariant(QVariant::Invalid)); |
|
650 } |
|
651 |
|
652 // Set the icons. |
|
653 mSourceModel->setData(mdlIndex, iconList, Qt::DecorationRole); |
|
654 |
|
655 // Update the incompleted to-do count. |
|
656 mInCompTodoCount++; |
|
657 } |
|
658 OstTraceFunctionExit0( NOTESMODEL_APPENDINCOMPTODOSTOMODEL_EXIT ); |
|
659 } |
|
660 |
|
661 /*! |
|
662 Appends incompleted to-dos to the model. |
|
663 |
|
664 \param ids QList of uids containing the completed to-dos. |
|
665 */ |
|
666 void NotesModel::appendCompTodosToModel(QList<AgendaEntry> &agendaEntryList) |
|
667 { |
|
668 OstTraceFunctionEntry0( NOTESMODEL_APPENDCOMPTODOSTOMODEL_ENTRY ); |
|
669 int entriesCount = agendaEntryList.count(); |
|
670 // Iterate and add complete to-do to the model. |
|
671 mSourceModel->insertRows(mSourceModel->rowCount(), entriesCount); |
|
672 int rowCount = mSourceModel->rowCount(); |
|
673 for (int idIter = 0, modelIter = rowCount - entriesCount; |
|
674 idIter < entriesCount; idIter++, modelIter++) { |
|
675 |
|
676 // Read the completed to-do details. |
|
677 AgendaEntry entry = agendaEntryList[idIter]; |
|
678 |
|
679 if (AgendaEntry::TypeTodo != entry.type()) { |
|
680 continue; |
|
681 } |
|
682 |
|
683 if (AgendaEntry::TodoCompleted != entry.status()) { |
|
684 continue; |
|
685 } |
|
686 |
|
687 // Create a model index. |
|
688 QModelIndex mdlIndex = mSourceModel->index(modelIter, 0); |
|
689 |
|
690 // Set the to-do id. |
|
691 mSourceModel->setData( |
|
692 mdlIndex, (qulonglong) entry.id(), NotesNamespace::IdRole); |
|
693 // Set the type of the to-do. |
|
694 mSourceModel->setData( |
|
695 mdlIndex, entry.type(), NotesNamespace::TypeRole); |
|
696 // Set the status of the to-do. |
|
697 mSourceModel->setData( |
|
698 mdlIndex, (int) entry.status(), NotesNamespace::StatusRole); |
|
699 |
|
700 // Set the display data now. |
|
701 QStringList stringList; |
|
702 if (entry.summary().isEmpty()) { |
|
703 // If empty set unnamed text |
|
704 stringList<<hbTrId("txt_notes_dblist_unnamed"); |
|
705 } else { |
|
706 stringList << entry.summary(); |
|
707 } |
|
708 if (AgendaEntry::TodoCompleted == entry.status()) { |
|
709 // Read completed date from agenda entry |
|
710 QString displayText; |
|
711 QString timeText(hbTrId("txt_notes_dblist_val_completed_on_1")); |
|
712 QString completedTimeText = |
|
713 entry.completedDateTime().toString(dateFormatString()); |
|
714 displayText = timeText.arg(completedTimeText); |
|
715 stringList << displayText; |
|
716 } |
|
717 // Set the data. |
|
718 mSourceModel->setData(mdlIndex, stringList, Qt::DisplayRole); |
|
719 |
|
720 // Set the to-do done icon. |
|
721 QList<QVariant> iconList; |
|
722 iconList.append(HbIcon("qtg_small_todo_done")); |
|
723 // To-do is already completed. No need to set alarm. |
|
724 iconList.append(QVariant(QVariant::Invalid)); |
|
725 |
|
726 // Set the icons. |
|
727 mSourceModel->setData(mdlIndex, iconList, Qt::DecorationRole); |
|
728 |
|
729 // Update the completed to-do count. |
|
730 mCompTodoCount++; |
|
731 } |
|
732 OstTraceFunctionExit0( NOTESMODEL_APPENDCOMPTODOSTOMODEL_EXIT ); |
|
733 } |
|
734 |
|
735 /*! |
|
736 Inserts a note at the 0th position. |
|
737 |
|
738 \param index Will contain the model index of the newly created row. |
|
739 \param id The id of the note to be inserted. |
|
740 \return bool true if the insertion was successful, false otherwise. |
|
741 */ |
|
742 bool NotesModel::insertNoteToModel(QModelIndex &index, ulong id) |
|
743 { |
|
744 OstTraceFunctionEntry0( NOTESMODEL_INSERTNOTETOMODEL_ENTRY ); |
|
745 AgendaEntry entry = mAgendaUtil->fetchById(id); |
|
746 if (entry.isNull()) { |
|
747 OstTraceFunctionExit0( NOTESMODEL_INSERTNOTETOMODEL_EXIT ); |
|
748 return false; |
|
749 } |
|
750 |
|
751 mSourceModel->insertRows(0, 1); |
|
752 QModelIndex mdlIndex = mSourceModel->index(0, 0); |
|
753 |
|
754 // Now set the details of this note. |
|
755 // Set the note id. |
|
756 mSourceModel->setData( |
|
757 mdlIndex, (qulonglong) id, NotesNamespace::IdRole); |
|
758 // Set the type of the note. |
|
759 mSourceModel->setData( |
|
760 mdlIndex, entry.type(), NotesNamespace::TypeRole); |
|
761 // Set the favourite property. |
|
762 mSourceModel->setData( |
|
763 mdlIndex, entry.favourite(), NotesNamespace::FavouriteRole); |
|
764 |
|
765 // Set the display data now. |
|
766 // Read modification time from agenda entry |
|
767 QString displayText; |
|
768 QString dateTimeText; |
|
769 QString modifiedText; |
|
770 |
|
771 // Show the creation time if entry is not modified. |
|
772 if (entry.dtStamp().isValid()) { |
|
773 QDateTime creationDateTime = entry.dtStamp(); |
|
774 |
|
775 // If created on today,show only creation time otherwise show the |
|
776 // creation date. |
|
777 if ((QDate::currentDate()) == creationDateTime.date()) { |
|
778 dateTimeText = |
|
779 hbTrId("txt_notes_dblist_note_created_at_time"); |
|
780 modifiedText = |
|
781 creationDateTime.time().toString(timeFormatString()); |
|
782 } else { |
|
783 dateTimeText = |
|
784 hbTrId("txt_notes_dblist_note_created_on_date"); |
|
785 modifiedText = |
|
786 creationDateTime.date().toString(dateFormatString()); |
|
787 } |
|
788 } else { |
|
789 QDateTime modifiedDateTime = entry.lastModifiedDateTime(); |
|
790 |
|
791 // If modified on today,show only modified time otherwise show the |
|
792 // modified date. |
|
793 if ((QDate::currentDate()) == modifiedDateTime.date() ) { |
|
794 dateTimeText = |
|
795 hbTrId("txt_notes_dblist_note_modified_at_time"); |
|
796 modifiedText = |
|
797 modifiedDateTime.time().toString(timeFormatString()); |
|
798 } else { |
|
799 dateTimeText = |
|
800 hbTrId("txt_notes_dblist_note_modified_on_date"); |
|
801 modifiedText = |
|
802 modifiedDateTime.date().toString(dateFormatString()); |
|
803 } |
|
804 } |
|
805 displayText = dateTimeText.arg(modifiedText); |
|
806 |
|
807 QStringList stringList; |
|
808 stringList << entry.description().left(100) << displayText; |
|
809 // Set the data. |
|
810 mSourceModel->setData( |
|
811 mdlIndex, stringList, Qt::DisplayRole); |
|
812 |
|
813 // Set the favourite icon. |
|
814 if (entry.favourite()) { |
|
815 QList<QVariant> iconList; |
|
816 iconList.append(HbIcon("qtg_small_note")); |
|
817 iconList.append(HbIcon("qtg_mono_favourites")); |
|
818 mSourceModel->setData(mdlIndex, iconList, Qt::DecorationRole); |
|
819 } else { |
|
820 QList<QVariant> iconList; |
|
821 iconList.append(HbIcon("qtg_small_note")); |
|
822 iconList.append(QVariant(QVariant::Invalid)); |
|
823 mSourceModel->setData(mdlIndex, iconList, Qt::DecorationRole); |
|
824 } |
|
825 // Update the notes count. |
|
826 mNotesCount++; |
|
827 |
|
828 index = mdlIndex; |
|
829 |
|
830 OstTraceFunctionExit0( DUP1_NOTESMODEL_INSERTNOTETOMODEL_EXIT ); |
|
831 return true; |
|
832 } |
|
833 |
|
834 /*! |
|
835 Inserts an incomplete to-do at a position based on the id of the |
|
836 to-do given. |
|
837 |
|
838 \param index This will hold the model index of the newly inserted to-do. |
|
839 \param id The id of the to-do to be inserted. |
|
840 \return bool true if the Insertion was successful, false otherwise. |
|
841 */ |
|
842 bool NotesModel::insertInCompTodoToModel(QModelIndex &index, ulong id) |
|
843 { |
|
844 OstTraceFunctionEntry0( NOTESMODEL_INSERTINCOMPTODOTOMODEL_ENTRY ); |
|
845 |
|
846 bool success = false; |
|
847 |
|
848 // Fetch the entry first. |
|
849 AgendaEntry entry = mAgendaUtil->fetchById(id); |
|
850 if (entry.isNull()) { |
|
851 OstTraceFunctionExit0( NOTESMODEL_INSERTINCOMPTODOTOMODEL_EXIT ); |
|
852 return success; |
|
853 } |
|
854 |
|
855 // First fetch the list of incompleted to-dos. |
|
856 QList<ulong> entryIds = mAgendaUtil->entryIds( |
|
857 (AgendaUtil::FilterFlags) (AgendaUtil::IncludeIncompletedTodos)); |
|
858 |
|
859 // Get the index of the added to-do in the above list. |
|
860 int newTodoIndex = -1; |
|
861 for (int iter = 0; iter < entryIds.count(); iter++) { |
|
862 if (id == entryIds[iter]) { |
|
863 newTodoIndex = iter; |
|
864 break; |
|
865 } |
|
866 } |
|
867 |
|
868 // We display the to-dos in the same order that we get from the |
|
869 // agenda server. This is a new to-do that has been added. Hence we |
|
870 // have to insert a model index at the same position as we found the |
|
871 // id in the list of to-dos above. |
|
872 // Calculate the position. |
|
873 if (-1 != newTodoIndex) { |
|
874 mSourceModel->insertRows(mNotesCount + newTodoIndex, 1); |
|
875 QModelIndex newModelIndex = |
|
876 mSourceModel->index(mNotesCount + newTodoIndex, 0); |
|
877 |
|
878 // We continue only if the index is valid. |
|
879 if (newModelIndex.isValid()) { |
|
880 // Things look ok, start adding data to the model index. |
|
881 // Set the to-do id. |
|
882 mSourceModel->setData( |
|
883 newModelIndex, (qulonglong) id, NotesNamespace::IdRole); |
|
884 // Set the type of the to-do. |
|
885 mSourceModel->setData( |
|
886 newModelIndex, entry.type(), NotesNamespace::TypeRole); |
|
887 // Set the status of the to-do. |
|
888 mSourceModel->setData( |
|
889 newModelIndex, (int) entry.status(), |
|
890 NotesNamespace::StatusRole); |
|
891 |
|
892 // Set the display data now. |
|
893 QStringList stringList; |
|
894 if (entry.summary().isEmpty()) { |
|
895 // If empty set unnamed text |
|
896 stringList<<hbTrId("txt_notes_dblist_unnamed"); |
|
897 } else { |
|
898 stringList << entry.summary(); |
|
899 } |
|
900 if (AgendaEntry::TodoNeedsAction == entry.status()) { |
|
901 // Read due date from agenda entry |
|
902 QString displayText; |
|
903 QString timeText(hbTrId("txt_notes_dblist_val_due_on_1")); |
|
904 QString dueDateText = |
|
905 entry.startTime().toString(dateFormatString()); |
|
906 displayText = timeText.arg(dueDateText); |
|
907 stringList << displayText; |
|
908 } |
|
909 // Set the data. |
|
910 mSourceModel->setData( |
|
911 newModelIndex, stringList, Qt::DisplayRole); |
|
912 // Set the to-do done/undone icon based on the status. |
|
913 QList<QVariant> iconList; |
|
914 iconList.append(HbIcon("qtg_small_todo")); |
|
915 |
|
916 if (1 == entry.priority()) { |
|
917 // Set the High Priority icon if priority is high. |
|
918 iconList.append(HbIcon("qtg_small_priority_high")); |
|
919 } else if (!entry.alarm().isNull()) { |
|
920 // Set the alarm if set. |
|
921 iconList.append(HbIcon("qtg_mono_alarm")); |
|
922 } else { |
|
923 iconList.append(QVariant(QVariant::Invalid)); |
|
924 } |
|
925 |
|
926 // Set the icons. |
|
927 mSourceModel->setData( |
|
928 newModelIndex, iconList, Qt::DecorationRole); |
|
929 |
|
930 // Update the incompleted to-do count. |
|
931 mInCompTodoCount++; |
|
932 |
|
933 success = true; |
|
934 index = newModelIndex; |
|
935 } |
|
936 } |
|
937 |
|
938 OstTraceFunctionExit0( DUP1_NOTESMODEL_INSERTINCOMPTODOTOMODEL_EXIT ); |
|
939 return success; |
|
940 } |
|
941 |
|
942 /*! |
|
943 Inserts a complete to-do at a position based on the id of the |
|
944 to-do given. |
|
945 |
|
946 \param index This will hold the model index of the newly inserted to-do. |
|
947 \param id The id of the to-do to be inserted. |
|
948 \return bool true if the Insertion was successful, false otherwise. |
|
949 */ |
|
950 bool NotesModel::insertCompTodoToModel(QModelIndex &index, ulong id) |
|
951 { |
|
952 OstTraceFunctionEntry0( NOTESMODEL_INSERTCOMPTODOTOMODEL_ENTRY ); |
|
953 bool success = false; |
|
954 |
|
955 // Fetch the entry first. |
|
956 AgendaEntry entry = mAgendaUtil->fetchById(id); |
|
957 if (entry.isNull()) { |
|
958 OstTraceFunctionExit0( NOTESMODEL_INSERTCOMPTODOTOMODEL_EXIT ); |
|
959 return success; |
|
960 } |
|
961 |
|
962 // Now fetch all the incomplete to-dos again and add them. |
|
963 QList<ulong> entryIds = mAgendaUtil->entryIds( |
|
964 (AgendaUtil::FilterFlags) (AgendaUtil::IncludeCompletedTodos)); |
|
965 |
|
966 // Get the index of the added to-do in the above list. |
|
967 int newTodoIndex = -1; |
|
968 for (int iter = 0; iter < entryIds.count(); iter++) { |
|
969 if (id == entryIds[iter]) { |
|
970 newTodoIndex = iter; |
|
971 break; |
|
972 } |
|
973 } |
|
974 |
|
975 // We display the to-dos in the same order that we get from the |
|
976 // agenda server. This is a new to-do that has been added. Hence we |
|
977 // have to insert a model index at the same position as we found the |
|
978 // id in the list of to-dos above. |
|
979 // Calculate the position. |
|
980 if (-1 != newTodoIndex) { |
|
981 mSourceModel->insertRows( |
|
982 mNotesCount + mInCompTodoCount + newTodoIndex, 1); |
|
983 QModelIndex newModelIndex = mSourceModel->index( |
|
984 mNotesCount + mInCompTodoCount + newTodoIndex, 0); |
|
985 |
|
986 // We continue only if the index is valid. |
|
987 if (newModelIndex.isValid()) { |
|
988 // Things look ok, start adding data to the model index. |
|
989 AgendaEntry entry = mAgendaUtil->fetchById(id); |
|
990 |
|
991 // Set the to-do id. |
|
992 mSourceModel->setData( |
|
993 newModelIndex, (qulonglong) id, NotesNamespace::IdRole); |
|
994 // Set the type of the to-do. |
|
995 mSourceModel->setData( |
|
996 newModelIndex, entry.type(), NotesNamespace::TypeRole); |
|
997 // Set the status of the to-do. |
|
998 mSourceModel->setData( |
|
999 newModelIndex, (int) entry.status(), |
|
1000 NotesNamespace::StatusRole); |
|
1001 |
|
1002 // Set the display data now. |
|
1003 QStringList stringList; |
|
1004 if (entry.summary().isEmpty()) { |
|
1005 // If empty set unnamed text |
|
1006 stringList<<hbTrId("txt_notes_dblist_unnamed"); |
|
1007 } else { |
|
1008 stringList << entry.summary(); |
|
1009 } |
|
1010 if (AgendaEntry::TodoCompleted == entry.status()) { |
|
1011 // Read completed date from agenda entry |
|
1012 QString displayText; |
|
1013 QString timeText(hbTrId("txt_notes_dblist_val_completed_on_1")); |
|
1014 QString completedTimeText = |
|
1015 entry.completedDateTime().toString(dateFormatString()); |
|
1016 displayText = timeText.arg(completedTimeText); |
|
1017 stringList << displayText; |
|
1018 } |
|
1019 // Set the data. |
|
1020 mSourceModel->setData( |
|
1021 newModelIndex, stringList, Qt::DisplayRole); |
|
1022 |
|
1023 // Set the to-do done icon. |
|
1024 QList<QVariant> iconList; |
|
1025 iconList.append(HbIcon("qtg_small_todo_done")); |
|
1026 if (1 == entry.priority()) { |
|
1027 // Set the High Priority icon if priority is high or else not. |
|
1028 iconList.append(HbIcon("qtg_small_priority_high")); |
|
1029 } else { |
|
1030 // To-do is already completed. No need to set alarm. |
|
1031 iconList.append(QVariant(QVariant::Invalid)); |
|
1032 } |
|
1033 |
|
1034 // Set the icons. |
|
1035 mSourceModel->setData( |
|
1036 newModelIndex, iconList, Qt::DecorationRole); |
|
1037 |
|
1038 // Update the completed to-do count. |
|
1039 mCompTodoCount++; |
|
1040 |
|
1041 success = true; |
|
1042 index = newModelIndex; |
|
1043 } |
|
1044 } |
|
1045 |
|
1046 OstTraceFunctionExit0( DUP1_NOTESMODEL_INSERTCOMPTODOTOMODEL_EXIT ); |
|
1047 return success; |
|
1048 } |
|
1049 |
|
1050 /*! |
|
1051 Retruns the dateformat based current locale settings. |
|
1052 Common method can be used by any class. |
|
1053 Can be removed once format strings are defined in hb. |
|
1054 */ |
|
1055 QString NotesModel::dateFormatString() |
|
1056 { |
|
1057 OstTraceFunctionEntry0( NOTESMODEL_DATEFORMATSTRING_ENTRY ); |
|
1058 HbExtendedLocale locale = HbExtendedLocale::system(); |
|
1059 |
|
1060 QString dateFormat; |
|
1061 switch (locale.dateStyle()) { |
|
1062 case HbExtendedLocale::American: |
|
1063 dateFormat.append("MM"); |
|
1064 dateFormat.append(locale.dateSeparator(1)); |
|
1065 dateFormat.append("dd"); |
|
1066 dateFormat.append(locale.dateSeparator(1)); |
|
1067 dateFormat.append("yyyy"); |
|
1068 break; |
|
1069 |
|
1070 case HbExtendedLocale::European: |
|
1071 dateFormat.append("dd"); |
|
1072 dateFormat.append(locale.dateSeparator(1)); |
|
1073 dateFormat.append("MM"); |
|
1074 dateFormat.append(locale.dateSeparator(1)); |
|
1075 dateFormat.append("yyyy"); |
|
1076 break; |
|
1077 |
|
1078 case HbExtendedLocale::Japanese: |
|
1079 dateFormat.append("yyyy"); |
|
1080 dateFormat.append(locale.dateSeparator(1)); |
|
1081 dateFormat.append("MM"); |
|
1082 dateFormat.append(locale.dateSeparator(1)); |
|
1083 dateFormat.append("dd"); |
|
1084 break; |
|
1085 } |
|
1086 |
|
1087 OstTraceFunctionExit0( NOTESMODEL_DATEFORMATSTRING_EXIT ); |
|
1088 return dateFormat; |
|
1089 } |
|
1090 |
|
1091 /*! |
|
1092 Retruns the timeformat string based on current locale settings |
|
1093 Common method can be used by any class. |
|
1094 Can be removed once format strings are defined in hb. |
|
1095 */ |
|
1096 QString NotesModel::timeFormatString() |
|
1097 { |
|
1098 OstTraceFunctionEntry0( NOTESMODEL_TIMEFORMATSTRING_ENTRY ); |
|
1099 QString timeFormat; |
|
1100 |
|
1101 HbExtendedLocale locale = HbExtendedLocale::system(); |
|
1102 |
|
1103 if (locale.timeStyle() == HbExtendedLocale::Time12) { |
|
1104 timeFormat.append("h"); |
|
1105 timeFormat.append(locale.timeSeparator(1)); |
|
1106 timeFormat.append("mm"); |
|
1107 timeFormat.append(" ap"); |
|
1108 } else { |
|
1109 timeFormat.append("hh"); |
|
1110 timeFormat.append(locale.timeSeparator(1)); |
|
1111 timeFormat.append("mm"); |
|
1112 } |
|
1113 |
|
1114 OstTraceFunctionExit0( NOTESMODEL_TIMEFORMATSTRING_EXIT ); |
|
1115 return timeFormat; |
|
1116 } |
|
1117 |
|
1118 |
|
1119 // End of file --Don't remove this. |