notes/notesui/notesmodel/src/notesmodel.cpp
changeset 58 ef813d54df51
parent 26 a949c2543c15
child 80 fa7c359294fa
equal deleted inserted replaced
50:579cc610882e 58:ef813d54df51
    24 #include <HbIcon>
    24 #include <HbIcon>
    25 #include <HbExtendedLocale>
    25 #include <HbExtendedLocale>
    26 
    26 
    27 // User includes
    27 // User includes
    28 #include "notesmodel.h"
    28 #include "notesmodel.h"
    29 #include "agendautil.h"
    29 #include <agendautil.h>
    30 #include "agendaentry.h"
    30 #include <agendaentry.h>
    31 #include "notescommon.h"
    31 #include "notescommon.h"
       
    32 #include "OstTraceDefinitions.h"
       
    33 #ifdef OST_TRACE_COMPILER_IN_USE
       
    34 #include "notesmodelTraces.h"
       
    35 #endif
       
    36 
    32 
    37 
    33 /*!
    38 /*!
    34 	\class NotesModel
    39 	\class NotesModel
    35 
    40 
    36 	This is the source model class for the notes application views. This owns
    41 	This is the source model class for the notes application views. This owns
    46  */
    51  */
    47 NotesModel::NotesModel(AgendaUtil *agendaUtil, QObject *parent)
    52 NotesModel::NotesModel(AgendaUtil *agendaUtil, QObject *parent)
    48 :QObject(parent),
    53 :QObject(parent),
    49  mAgendaUtil(agendaUtil)
    54  mAgendaUtil(agendaUtil)
    50 {
    55 {
       
    56 	OstTraceFunctionEntry0( NOTESMODEL_NOTESMODEL_ENTRY );
    51 	// Construct the source model.
    57 	// Construct the source model.
    52 	mSourceModel = new QStandardItemModel(0, 1, this);
    58 	mSourceModel = new QStandardItemModel(0, 1, this);
    53 
    59 
    54 	connect(
    60 	connect(
    55 			mAgendaUtil, SIGNAL(entriesChanged(QList<ulong>)),
    61 			mAgendaUtil, SIGNAL(entriesChanged(QList<ulong>)),
    70 
    76 
    71 	// Connect for instance view creation completed signal
    77 	// Connect for instance view creation completed signal
    72 	connect(
    78 	connect(
    73 			mAgendaUtil, SIGNAL(instanceViewCreationCompleted(int)),
    79 			mAgendaUtil, SIGNAL(instanceViewCreationCompleted(int)),
    74 			this,SLOT(handleInstanceViewCreationCompleted(int)));
    80 			this,SLOT(handleInstanceViewCreationCompleted(int)));
       
    81 	OstTraceFunctionExit0( NOTESMODEL_NOTESMODEL_EXIT );
    75 }
    82 }
    76 
    83 
    77 /*!
    84 /*!
    78 	Destructor.
    85 	Destructor.
    79  */
    86  */
    80 NotesModel::~NotesModel()
    87 NotesModel::~NotesModel()
    81 {
    88 {
       
    89 	OstTraceFunctionEntry0( DUP1_NOTESMODEL_NOTESMODEL_ENTRY );
    82 	// Nothing yet.
    90 	// Nothing yet.
       
    91 	OstTraceFunctionExit0( DUP1_NOTESMODEL_NOTESMODEL_EXIT );
    83 }
    92 }
    84 
    93 
    85 /*!
    94 /*!
    86 	Returns the source model to be used with a view.
    95 	Returns the source model to be used with a view.
    87 
    96 
    88 	\return QAbstractItemModel
    97 	\return QAbstractItemModel
    89 	\sa QAbstractItemModel, HbListView.
    98 	\sa QAbstractItemModel, HbListView.
    90  */
    99  */
    91 QAbstractItemModel *NotesModel::sourceModel()
   100 QAbstractItemModel *NotesModel::sourceModel()
    92 {
   101 {
       
   102 	OstTraceFunctionEntry0( NOTESMODEL_SOURCEMODEL_ENTRY );
    93 	Q_ASSERT(mSourceModel);
   103 	Q_ASSERT(mSourceModel);
       
   104 	OstTraceFunctionExit0( NOTESMODEL_SOURCEMODEL_EXIT );
    94 	return mSourceModel;
   105 	return mSourceModel;
    95 }
   106 }
    96 
   107 
    97 /*!
   108 /*!
    98 	Populates the source model.
   109 	Populates the source model.
    99  */
   110  */
   100 void NotesModel::populateSourceModel()
   111 void NotesModel::populateSourceModel()
   101 {
   112 {
       
   113 	OstTraceFunctionEntry0( NOTESMODEL_POPULATESOURCEMODEL_ENTRY );
   102 	// Clear the model if it has any data already
   114 	// Clear the model if it has any data already
   103 	mSourceModel->clear();
   115 	mSourceModel->clear();
   104 	mSourceModel->setColumnCount(1);
   116 	mSourceModel->setColumnCount(1);
   105 	mNotesCount = mInCompTodoCount = mCompTodoCount = 0;
   117 	mNotesCount = mInCompTodoCount = mCompTodoCount = 0;
   106 
   118 
   126 	agendaEntyList = mAgendaUtil->fetchAllEntries(
   138 	agendaEntyList = mAgendaUtil->fetchAllEntries(
   127 			(AgendaUtil::FilterFlags) (AgendaUtil::IncludeCompletedTodos));
   139 			(AgendaUtil::FilterFlags) (AgendaUtil::IncludeCompletedTodos));
   128 
   140 
   129 	// Add the completed to-dos to the model.
   141 	// Add the completed to-dos to the model.
   130 	appendCompTodosToModel(agendaEntyList);
   142 	appendCompTodosToModel(agendaEntyList);
       
   143 	OstTraceFunctionExit0( NOTESMODEL_POPULATESOURCEMODEL_EXIT );
   131 }
   144 }
   132 
   145 
   133 /*!
   146 /*!
   134 	Updates the source model with the given entry `id'.
   147 	Updates the source model with the given entry `id'.
   135 	The entry could be either have undergone a status change or have just been
   148 	The entry could be either have undergone a status change or have just been
   137 
   150 
   138 	\param id Of type ulong, identifies the entry which was changed.
   151 	\param id Of type ulong, identifies the entry which was changed.
   139  */
   152  */
   140 void NotesModel::updateSourceModel(ulong id)
   153 void NotesModel::updateSourceModel(ulong id)
   141 {
   154 {
       
   155 	OstTraceFunctionEntry0( NOTESMODEL_UPDATESOURCEMODEL_ENTRY );
   142 	AgendaEntry entry = mAgendaUtil->fetchById(id);
   156 	AgendaEntry entry = mAgendaUtil->fetchById(id);
   143 	if (entry.isNull()) {
   157 	if (entry.isNull()) {
       
   158 		OstTraceFunctionExit0( NOTESMODEL_UPDATESOURCEMODEL_EXIT );
   144 		return;
   159 		return;
   145 	}
   160 	}
   146 
   161 
   147 	// Entry can be updated in many ways.
   162 	// Entry can be updated in many ways.
   148 	// 1. Notes can just change their content or can be marked/unmarked as
   163 	// 1. Notes can just change their content or can be marked/unmarked as
   232 				insertInCompTodoToModel(foundIndex, id);
   247 				insertInCompTodoToModel(foundIndex, id);
   233 
   248 
   234 			}
   249 			}
   235 		}
   250 		}
   236 	}
   251 	}
       
   252 	OstTraceFunctionExit0( DUP1_NOTESMODEL_UPDATESOURCEMODEL_EXIT );
   237 }
   253 }
   238 
   254 
   239 /*!
   255 /*!
   240 	Populates the source model. This slot is called when we get a db change
   256 	Populates the source model. This slot is called when we get a db change
   241 	notification from agenda server caused by another session.
   257 	notification from agenda server caused by another session.
   242 
   258 
   243 	\param ids List of ids containing the entries that got changed.
   259 	\param ids List of ids containing the entries that got changed.
   244  */
   260  */
   245 void NotesModel::populateSourceModel(QList<ulong> ids)
   261 void NotesModel::populateSourceModel(QList<ulong> ids)
   246 {
   262 {
       
   263 	OstTraceFunctionEntry0( DUP1_NOTESMODEL_POPULATESOURCEMODEL_ENTRY );
   247 	Q_UNUSED(ids)
   264 	Q_UNUSED(ids)
   248 
   265 
   249 	QTimer::singleShot(1, this, SLOT(populateSourceModel()));
   266 	QTimer::singleShot(1, this, SLOT(populateSourceModel()));
       
   267 	OstTraceFunctionExit0( DUP1_NOTESMODEL_POPULATESOURCEMODEL_EXIT );
   250 }
   268 }
   251 
   269 
   252 /*!
   270 /*!
   253 	Adds an entry to the model i.e., creates a QModelIndex and inserts it to the
   271 	Adds an entry to the model i.e., creates a QModelIndex and inserts it to the
   254 	model.
   272 	model.
   255 
   273 
   256 	\param id The id of the entry to be added to the model.
   274 	\param id The id of the entry to be added to the model.
   257  */
   275  */
   258 void NotesModel::addEntryToModel(ulong id)
   276 void NotesModel::addEntryToModel(ulong id)
   259 {
   277 {
       
   278 	OstTraceFunctionEntry0( NOTESMODEL_ADDENTRYTOMODEL_ENTRY );
   260 	// We have different logic for adding a note or an incompleted to-do or a
   279 	// We have different logic for adding a note or an incompleted to-do or a
   261 	// completed to-do.
   280 	// completed to-do.
   262 	AgendaEntry entry = mAgendaUtil->fetchById(id);
   281 	AgendaEntry entry = mAgendaUtil->fetchById(id);
   263 	if (entry.isNull()) {
   282 	if (entry.isNull()) {
       
   283 		OstTraceFunctionExit0( NOTESMODEL_ADDENTRYTOMODEL_EXIT );
   264 		return;
   284 		return;
   265 	}
   285 	}
   266 	bool notify = false;
   286 	bool notify = false;
   267 	QModelIndex indexToNotify;
   287 	QModelIndex indexToNotify;
   268 
   288 
   283 	}
   303 	}
   284 
   304 
   285 	if (notify) {
   305 	if (notify) {
   286 		emit rowAdded(indexToNotify);
   306 		emit rowAdded(indexToNotify);
   287 	}
   307 	}
       
   308 	OstTraceFunctionExit0( DUP1_NOTESMODEL_ADDENTRYTOMODEL_EXIT );
   288 }
   309 }
   289 
   310 
   290 /*!
   311 /*!
   291 	Deletes an entry from model.
   312 	Deletes an entry from model.
   292 
   313 
   293 	\param Deletes the entry from model and hence updating the view.
   314 	\param Deletes the entry from model and hence updating the view.
   294  */
   315  */
   295 void NotesModel::removeEntryFromModel(ulong id)
   316 void NotesModel::removeEntryFromModel(ulong id)
   296 {
   317 {
       
   318 	OstTraceFunctionEntry0( NOTESMODEL_REMOVEENTRYFROMMODEL_ENTRY );
   297 	for (int iter = 0; iter < mSourceModel->rowCount(); iter++) {
   319 	for (int iter = 0; iter < mSourceModel->rowCount(); iter++) {
   298 		QModelIndex mdlIndex = mSourceModel->index(iter, 0);
   320 		QModelIndex mdlIndex = mSourceModel->index(iter, 0);
   299 
   321 
   300 		if (!mdlIndex.isValid()) {
   322 		if (!mdlIndex.isValid()) {
       
   323 			OstTraceFunctionExit0( NOTESMODEL_REMOVEENTRYFROMMODEL_EXIT );
   301 			return;
   324 			return;
   302 		}
   325 		}
   303 
   326 
   304 		ulong noteId = mdlIndex.data(
   327 		ulong noteId = mdlIndex.data(
   305 				NotesNamespace::IdRole).value<qulonglong>();
   328 				NotesNamespace::IdRole).value<qulonglong>();
   322 				}
   345 				}
   323 			}
   346 			}
   324 			break;
   347 			break;
   325 		}
   348 		}
   326 	}
   349 	}
       
   350 	OstTraceFunctionExit0( DUP1_NOTESMODEL_REMOVEENTRYFROMMODEL_EXIT );
   327 }
   351 }
   328 
   352 
   329 /*!
   353 /*!
   330 	Populate the model after instance view creation.
   354 	Populate the model after instance view creation.
   331  */
   355  */
   332 void NotesModel::handleInstanceViewCreationCompleted(int status)
   356 void NotesModel::handleInstanceViewCreationCompleted(int status)
   333 {
   357 {
       
   358 	OstTraceFunctionEntry0( NOTESMODEL_HANDLEINSTANCEVIEWCREATIONCOMPLETED_ENTRY );
   334 	Q_UNUSED(status);
   359 	Q_UNUSED(status);
   335 	populateSourceModel();
   360 	populateSourceModel();
       
   361 	OstTraceFunctionExit0( NOTESMODEL_HANDLEINSTANCEVIEWCREATIONCOMPLETED_EXIT );
   336 }
   362 }
   337 
   363 
   338 /*!
   364 /*!
   339 	Modifies the content of a given `row' with the data of the entry given by
   365 	Modifies the content of a given `row' with the data of the entry given by
   340 	`id'.
   366 	`id'.
   342 	\param id The id of the entry.
   368 	\param id The id of the entry.
   343 	\param row The row corresponding to the given id.
   369 	\param row The row corresponding to the given id.
   344  */
   370  */
   345 void NotesModel::modifyEntryInModel(ulong id, int row)
   371 void NotesModel::modifyEntryInModel(ulong id, int row)
   346 {
   372 {
       
   373 	OstTraceFunctionEntry0( NOTESMODEL_MODIFYENTRYINMODEL_ENTRY );
   347 	// Get the model index.
   374 	// Get the model index.
   348 	QModelIndex modelIndex = mSourceModel->index(row, 0);
   375 	QModelIndex modelIndex = mSourceModel->index(row, 0);
   349 	Q_ASSERT(modelIndex.isValid());
   376 	Q_ASSERT(modelIndex.isValid());
   350 
   377 
   351 	// Fetch the entry
   378 	// Fetch the entry
   441 		}
   468 		}
   442 
   469 
   443 		// Set the icons.
   470 		// Set the icons.
   444 		mSourceModel->setData(modelIndex, iconList, Qt::DecorationRole);
   471 		mSourceModel->setData(modelIndex, iconList, Qt::DecorationRole);
   445 	}
   472 	}
       
   473 	OstTraceFunctionExit0( NOTESMODEL_MODIFYENTRYINMODEL_EXIT );
   446 }
   474 }
   447 
   475 
   448 /*!
   476 /*!
   449 	Appends notes to the model.
   477 	Appends notes to the model.
   450 
   478 
   451 	\param ids QList of uids containing the notes.
   479 	\param ids QList of uids containing the notes.
   452  */
   480  */
   453 void NotesModel::appendNotesToModel(QList<AgendaEntry> &agendaEntryList)
   481 void NotesModel::appendNotesToModel(QList<AgendaEntry> &agendaEntryList)
   454 {
   482 {
       
   483 	OstTraceFunctionEntry0( NOTESMODEL_APPENDNOTESTOMODEL_ENTRY );
   455 	int entriesCount = agendaEntryList.count();
   484 	int entriesCount = agendaEntryList.count();
   456 	// Iterate and add notes to the model.
   485 	// Iterate and add notes to the model.
   457 	mSourceModel->insertRows(mSourceModel->rowCount(), entriesCount);
   486 	mSourceModel->insertRows(mSourceModel->rowCount(), entriesCount);
   458 	int rowCount = mSourceModel->rowCount();
   487 	int rowCount = mSourceModel->rowCount();
   459 	for (int idIter = 0, modelIter = rowCount - entriesCount;
   488 	for (int idIter = 0, modelIter = rowCount - entriesCount;
   542 		}
   571 		}
   543 
   572 
   544 		// Update the notes count.
   573 		// Update the notes count.
   545 		mNotesCount++;
   574 		mNotesCount++;
   546 	}
   575 	}
       
   576 	OstTraceFunctionExit0( NOTESMODEL_APPENDNOTESTOMODEL_EXIT );
   547 }
   577 }
   548 
   578 
   549 /*!
   579 /*!
   550 	Appends incompleted to-dos to the model.
   580 	Appends incompleted to-dos to the model.
   551 
   581 
   552 	\param ids QList of uids containing the incompleted to-dos.
   582 	\param ids QList of uids containing the incompleted to-dos.
   553  */
   583  */
   554 void NotesModel::appendInCompTodosToModel(QList<AgendaEntry> &agendaEntryList)
   584 void NotesModel::appendInCompTodosToModel(QList<AgendaEntry> &agendaEntryList)
   555 {
   585 {
       
   586 	OstTraceFunctionEntry0( NOTESMODEL_APPENDINCOMPTODOSTOMODEL_ENTRY );
   556 	int entriesCount = agendaEntryList.count();
   587 	int entriesCount = agendaEntryList.count();
   557 	// Iterate and add incomplete to-do to the model.
   588 	// Iterate and add incomplete to-do to the model.
   558 	mSourceModel->insertRows(mSourceModel->rowCount(), entriesCount);
   589 	mSourceModel->insertRows(mSourceModel->rowCount(), entriesCount);
   559 	int rowCount = mSourceModel->rowCount();
   590 	int rowCount = mSourceModel->rowCount();
   560 	for (int idIter = 0, modelIter = rowCount - entriesCount;
   591 	for (int idIter = 0, modelIter = rowCount - entriesCount;
   622 		mSourceModel->setData(mdlIndex, iconList, Qt::DecorationRole);
   653 		mSourceModel->setData(mdlIndex, iconList, Qt::DecorationRole);
   623 
   654 
   624 		// Update the incompleted to-do count.
   655 		// Update the incompleted to-do count.
   625 		mInCompTodoCount++;
   656 		mInCompTodoCount++;
   626 	}
   657 	}
       
   658 	OstTraceFunctionExit0( NOTESMODEL_APPENDINCOMPTODOSTOMODEL_EXIT );
   627 }
   659 }
   628 
   660 
   629 /*!
   661 /*!
   630 	Appends incompleted to-dos to the model.
   662 	Appends incompleted to-dos to the model.
   631 
   663 
   632 	\param ids QList of uids containing the completed to-dos.
   664 	\param ids QList of uids containing the completed to-dos.
   633  */
   665  */
   634 void NotesModel::appendCompTodosToModel(QList<AgendaEntry> &agendaEntryList)
   666 void NotesModel::appendCompTodosToModel(QList<AgendaEntry> &agendaEntryList)
   635 {
   667 {
       
   668 	OstTraceFunctionEntry0( NOTESMODEL_APPENDCOMPTODOSTOMODEL_ENTRY );
   636 	int entriesCount = agendaEntryList.count();
   669 	int entriesCount = agendaEntryList.count();
   637 	// Iterate and add complete to-do to the model.
   670 	// Iterate and add complete to-do to the model.
   638 	mSourceModel->insertRows(mSourceModel->rowCount(), entriesCount);
   671 	mSourceModel->insertRows(mSourceModel->rowCount(), entriesCount);
   639 	int rowCount = mSourceModel->rowCount();
   672 	int rowCount = mSourceModel->rowCount();
   640 	for (int idIter = 0, modelIter = rowCount - entriesCount;
   673 	for (int idIter = 0, modelIter = rowCount - entriesCount;
   694 		mSourceModel->setData(mdlIndex, iconList, Qt::DecorationRole);
   727 		mSourceModel->setData(mdlIndex, iconList, Qt::DecorationRole);
   695 
   728 
   696 		// Update the completed to-do count.
   729 		// Update the completed to-do count.
   697 		mCompTodoCount++;
   730 		mCompTodoCount++;
   698 	}
   731 	}
       
   732 	OstTraceFunctionExit0( NOTESMODEL_APPENDCOMPTODOSTOMODEL_EXIT );
   699 }
   733 }
   700 
   734 
   701 /*!
   735 /*!
   702 	Inserts a note at the 0th position.
   736 	Inserts a note at the 0th position.
   703 
   737 
   705 	\param id The id of the note to be inserted.
   739 	\param id The id of the note to be inserted.
   706 	\return bool true if the insertion was successful, false otherwise.
   740 	\return bool true if the insertion was successful, false otherwise.
   707  */
   741  */
   708 bool NotesModel::insertNoteToModel(QModelIndex &index, ulong id)
   742 bool NotesModel::insertNoteToModel(QModelIndex &index, ulong id)
   709 {
   743 {
       
   744 	OstTraceFunctionEntry0( NOTESMODEL_INSERTNOTETOMODEL_ENTRY );
   710 	AgendaEntry entry = mAgendaUtil->fetchById(id);
   745 	AgendaEntry entry = mAgendaUtil->fetchById(id);
   711 	if (entry.isNull()) {
   746 	if (entry.isNull()) {
       
   747 		OstTraceFunctionExit0( NOTESMODEL_INSERTNOTETOMODEL_EXIT );
   712 		return false;
   748 		return false;
   713 	}
   749 	}
   714 
   750 
   715 	mSourceModel->insertRows(0, 1);
   751 	mSourceModel->insertRows(0, 1);
   716 	QModelIndex mdlIndex = mSourceModel->index(0, 0);
   752 	QModelIndex mdlIndex = mSourceModel->index(0, 0);
   789 	// Update the notes count.
   825 	// Update the notes count.
   790 	mNotesCount++;
   826 	mNotesCount++;
   791 
   827 
   792 	index = mdlIndex;
   828 	index = mdlIndex;
   793 
   829 
       
   830 	OstTraceFunctionExit0( DUP1_NOTESMODEL_INSERTNOTETOMODEL_EXIT );
   794 	return true;
   831 	return true;
   795 }
   832 }
   796 
   833 
   797 /*!
   834 /*!
   798 	Inserts an incomplete to-do at a position based on the id of the
   835 	Inserts an incomplete to-do at a position based on the id of the
   802 	\param id The id of the to-do to be inserted.
   839 	\param id The id of the to-do to be inserted.
   803 	\return bool true if the Insertion was successful, false otherwise.
   840 	\return bool true if the Insertion was successful, false otherwise.
   804  */
   841  */
   805 bool NotesModel::insertInCompTodoToModel(QModelIndex &index, ulong id)
   842 bool NotesModel::insertInCompTodoToModel(QModelIndex &index, ulong id)
   806 {
   843 {
       
   844 	OstTraceFunctionEntry0( NOTESMODEL_INSERTINCOMPTODOTOMODEL_ENTRY );
   807 
   845 
   808 	bool success = false;
   846 	bool success = false;
   809 
   847 
   810 	// Fetch the entry first.
   848 	// Fetch the entry first.
   811 	AgendaEntry entry = mAgendaUtil->fetchById(id);
   849 	AgendaEntry entry = mAgendaUtil->fetchById(id);
   812 	if (entry.isNull()) {
   850 	if (entry.isNull()) {
       
   851 		OstTraceFunctionExit0( NOTESMODEL_INSERTINCOMPTODOTOMODEL_EXIT );
   813 		return success;
   852 		return success;
   814 	}
   853 	}
   815 
   854 
   816 	// First fetch the list of incompleted to-dos.
   855 	// First fetch the list of incompleted to-dos.
   817 	QList<ulong> entryIds = mAgendaUtil->entryIds(
   856 	QList<ulong> entryIds = mAgendaUtil->entryIds(
   894 			success = true;
   933 			success = true;
   895 			index = newModelIndex;
   934 			index = newModelIndex;
   896 		}
   935 		}
   897 	}
   936 	}
   898 
   937 
       
   938 	OstTraceFunctionExit0( DUP1_NOTESMODEL_INSERTINCOMPTODOTOMODEL_EXIT );
   899 	return success;
   939 	return success;
   900 }
   940 }
   901 
   941 
   902 /*!
   942 /*!
   903 	Inserts a complete to-do at a position based on the id of the
   943 	Inserts a complete to-do at a position based on the id of the
   907 	\param id The id of the to-do to be inserted.
   947 	\param id The id of the to-do to be inserted.
   908 	\return bool true if the Insertion was successful, false otherwise.
   948 	\return bool true if the Insertion was successful, false otherwise.
   909  */
   949  */
   910 bool NotesModel::insertCompTodoToModel(QModelIndex &index, ulong id)
   950 bool NotesModel::insertCompTodoToModel(QModelIndex &index, ulong id)
   911 {
   951 {
       
   952 	OstTraceFunctionEntry0( NOTESMODEL_INSERTCOMPTODOTOMODEL_ENTRY );
   912 	bool success = false;
   953 	bool success = false;
   913 
   954 
   914 	// Fetch the entry first.
   955 	// Fetch the entry first.
   915 	AgendaEntry entry = mAgendaUtil->fetchById(id);
   956 	AgendaEntry entry = mAgendaUtil->fetchById(id);
   916 	if (entry.isNull()) {
   957 	if (entry.isNull()) {
       
   958 		OstTraceFunctionExit0( NOTESMODEL_INSERTCOMPTODOTOMODEL_EXIT );
   917 		return success;
   959 		return success;
   918 	}
   960 	}
   919 
   961 
   920 	// Now fetch all the incomplete to-dos again and add them.
   962 	// Now fetch all the incomplete to-dos again and add them.
   921 	QList<ulong> entryIds = mAgendaUtil->entryIds(
   963 	QList<ulong> entryIds = mAgendaUtil->entryIds(
   979 					newModelIndex, stringList, Qt::DisplayRole);
  1021 					newModelIndex, stringList, Qt::DisplayRole);
   980 
  1022 
   981 			// Set the to-do done icon.
  1023 			// Set the to-do done icon.
   982 			QList<QVariant> iconList;
  1024 			QList<QVariant> iconList;
   983 			iconList.append(HbIcon("qtg_small_todo_done"));
  1025 			iconList.append(HbIcon("qtg_small_todo_done"));
   984 			// To-do is already completed. No need to set alarm.
  1026 			if (1 == entry.priority()) {
   985 			iconList.append(QVariant(QVariant::Invalid));
  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 			}
   986 
  1033 
   987 			// Set the icons.
  1034 			// Set the icons.
   988 			mSourceModel->setData(
  1035 			mSourceModel->setData(
   989 					newModelIndex, iconList, Qt::DecorationRole);
  1036 					newModelIndex, iconList, Qt::DecorationRole);
   990 
  1037 
   994 			success = true;
  1041 			success = true;
   995 			index = newModelIndex;
  1042 			index = newModelIndex;
   996 		}
  1043 		}
   997 	}
  1044 	}
   998 
  1045 
       
  1046 	OstTraceFunctionExit0( DUP1_NOTESMODEL_INSERTCOMPTODOTOMODEL_EXIT );
   999 	return success;
  1047 	return success;
  1000 }
  1048 }
  1001 
  1049 
  1002 /*!
  1050 /*!
  1003 	Retruns the dateformat based current locale settings.
  1051 	Retruns the dateformat based current locale settings.
  1004 	Common method can be used by any class.
  1052 	Common method can be used by any class.
  1005 	Can be removed once format strings are defined in hb.
  1053 	Can be removed once format strings are defined in hb.
  1006  */
  1054  */
  1007 QString NotesModel::dateFormatString()
  1055 QString NotesModel::dateFormatString()
  1008 {
  1056 {
       
  1057 	OstTraceFunctionEntry0( NOTESMODEL_DATEFORMATSTRING_ENTRY );
  1009 	HbExtendedLocale locale = HbExtendedLocale::system();
  1058 	HbExtendedLocale locale = HbExtendedLocale::system();
  1010 
  1059 
  1011 	QString dateFormat;
  1060 	QString dateFormat;
  1012 	switch (locale.dateStyle()) {
  1061 	switch (locale.dateStyle()) {
  1013 		case HbExtendedLocale::American:
  1062 		case HbExtendedLocale::American:
  1033 			dateFormat.append(locale.dateSeparator(1));
  1082 			dateFormat.append(locale.dateSeparator(1));
  1034 			dateFormat.append("dd");
  1083 			dateFormat.append("dd");
  1035 			break;
  1084 			break;
  1036 	}
  1085 	}
  1037 
  1086 
       
  1087 	OstTraceFunctionExit0( NOTESMODEL_DATEFORMATSTRING_EXIT );
  1038 	return dateFormat;
  1088 	return dateFormat;
  1039 }
  1089 }
  1040 
  1090 
  1041 /*!
  1091 /*!
  1042 	Retruns the timeformat string based on current locale settings
  1092 	Retruns the timeformat string based on current locale settings
  1043 	Common method can be used by any class.
  1093 	Common method can be used by any class.
  1044 	Can be removed once format strings are defined in hb.
  1094 	Can be removed once format strings are defined in hb.
  1045  */
  1095  */
  1046 QString NotesModel::timeFormatString()
  1096 QString NotesModel::timeFormatString()
  1047 {
  1097 {
       
  1098 	OstTraceFunctionEntry0( NOTESMODEL_TIMEFORMATSTRING_ENTRY );
  1048 	QString timeFormat;
  1099 	QString timeFormat;
  1049 
  1100 
  1050 	HbExtendedLocale locale = HbExtendedLocale::system();
  1101 	HbExtendedLocale locale = HbExtendedLocale::system();
  1051 
  1102 
  1052 	if (locale.timeStyle() == HbExtendedLocale::Time12) {
  1103 	if (locale.timeStyle() == HbExtendedLocale::Time12) {
  1058 		timeFormat.append("hh");
  1109 		timeFormat.append("hh");
  1059 		timeFormat.append(locale.timeSeparator(1));
  1110 		timeFormat.append(locale.timeSeparator(1));
  1060 		timeFormat.append("mm");
  1111 		timeFormat.append("mm");
  1061 	}
  1112 	}
  1062 
  1113 
       
  1114 	OstTraceFunctionExit0( NOTESMODEL_TIMEFORMATSTRING_EXIT );
  1063 	return timeFormat;
  1115 	return timeFormat;
  1064 }
  1116 }
  1065 
  1117 
  1066 
  1118 
  1067 // End of file	--Don't remove this.
  1119 // End of file	--Don't remove this.