30 #include <HbAbstractViewItem> |
30 #include <HbAbstractViewItem> |
31 #include <HbGroupBox> |
31 #include <HbGroupBox> |
32 #include <HbStyleLoader> |
32 #include <HbStyleLoader> |
33 |
33 |
34 // User includes |
34 // User includes |
|
35 #include <agendautil.h> |
35 #include "notescollectionview.h" |
36 #include "notescollectionview.h" |
36 #include "notescommon.h" |
37 #include "notescommon.h" |
37 #include "notesdocloader.h" |
38 #include "notesdocloader.h" |
38 #include "agendautil.h" |
|
39 #include "notesmodel.h" |
39 #include "notesmodel.h" |
40 #include "noteseditor.h" |
40 #include "noteseditor.h" |
41 #include "notessortfilterproxymodel.h" |
41 #include "notessortfilterproxymodel.h" |
|
42 #include "OstTraceDefinitions.h" |
|
43 #ifdef OST_TRACE_COMPILER_IN_USE |
|
44 #include "notescollectionviewTraces.h" |
|
45 #endif |
|
46 |
42 |
47 |
43 /*! |
48 /*! |
44 \class NotesCollectionView |
49 \class NotesCollectionView |
45 \brief The main view of the notes application. Responsible for displaying |
50 \brief The main view of the notes application. Responsible for displaying |
46 notes and todos. |
51 notes and todos. |
150 "notescollectionview.cpp", |
160 "notescollectionview.cpp", |
151 "Unable to find addNoteAction."); |
161 "Unable to find addNoteAction."); |
152 connect( |
162 connect( |
153 mAddNoteAction, SIGNAL(triggered()), |
163 mAddNoteAction, SIGNAL(triggered()), |
154 this, SLOT(createNewNote())); |
164 this, SLOT(createNewNote())); |
|
165 OstTraceFunctionExit0( NOTESCOLLECTIONVIEW_SETUPVIEW_EXIT ); |
155 } |
166 } |
156 |
167 |
157 /*! |
168 /*! |
158 Populate the content of the view. |
169 Populate the content of the view. |
159 */ |
170 */ |
160 void NotesCollectionView::populateListView() |
171 void NotesCollectionView::populateListView() |
161 { |
172 { |
|
173 OstTraceFunctionEntry0( NOTESCOLLECTIONVIEW_POPULATELISTVIEW_ENTRY ); |
162 QStandardItemModel *model = new QStandardItemModel(this); |
174 QStandardItemModel *model = new QStandardItemModel(this); |
163 model->setColumnCount(1); |
175 model->setColumnCount(1); |
164 |
176 |
165 QString countString(hbTrId("txt_notes_list_note_count")); |
177 QString countString(hbTrId("txt_notes_list_note_count")); |
166 |
178 |
190 model->appendRow(item); |
202 model->appendRow(item); |
191 |
203 |
192 HbStyleLoader::registerFilePath(":/style"); |
204 HbStyleLoader::registerFilePath(":/style"); |
193 mListView->setLayoutName("custom"); |
205 mListView->setLayoutName("custom"); |
194 mListView->setModel(model); |
206 mListView->setModel(model); |
|
207 OstTraceFunctionExit0( NOTESCOLLECTIONVIEW_POPULATELISTVIEW_EXIT ); |
195 } |
208 } |
196 |
209 |
197 /*! |
210 /*! |
198 Displays all notes view. |
211 Displays all notes view. |
199 */ |
212 */ |
200 void NotesCollectionView::displayAllNotesView() |
213 void NotesCollectionView::displayAllNotesView() |
201 { |
214 { |
|
215 OstTraceFunctionEntry0( NOTESCOLLECTIONVIEW_DISPLAYALLNOTESVIEW_ENTRY ); |
202 // Switch to collections view. |
216 // Switch to collections view. |
203 mAppControllerIf->switchToView(NotesNamespace::NotesMainViewId); |
217 mAppControllerIf->switchToView(NotesNamespace::NotesMainViewId); |
|
218 OstTraceFunctionExit0( NOTESCOLLECTIONVIEW_DISPLAYALLNOTESVIEW_EXIT ); |
204 } |
219 } |
205 |
220 |
206 /*! |
221 /*! |
207 Refreshes the content of the collection view if needed. |
222 Refreshes the content of the collection view if needed. |
208 */ |
223 */ |
209 void NotesCollectionView::resetCollectionView() |
224 void NotesCollectionView::resetCollectionView() |
210 { |
225 { |
|
226 OstTraceFunctionEntry0( NOTESCOLLECTIONVIEW_RESETCOLLECTIONVIEW_ENTRY ); |
211 QString countString(hbTrId("txt_notes_list_note_count")); |
227 QString countString(hbTrId("txt_notes_list_note_count")); |
212 |
228 |
213 // Update the count of to-do's. |
229 // Update the count of to-do's. |
214 QModelIndex mdlIndex = mListView->model()->index(0, 0); |
230 QModelIndex mdlIndex = mListView->model()->index(0, 0); |
215 QStringList todoStringList; |
231 QStringList todoStringList; |
222 QStringList notesStringList; |
238 QStringList notesStringList; |
223 notesStringList.append(hbTrId("txt_notes_list_plain_notes")); |
239 notesStringList.append(hbTrId("txt_notes_list_plain_notes")); |
224 notesStringList.append( |
240 notesStringList.append( |
225 countString.arg(QString::number(recentNotesCount()))); |
241 countString.arg(QString::number(recentNotesCount()))); |
226 mListView->model()->setData(mdlIndex, notesStringList, Qt::DisplayRole); |
242 mListView->model()->setData(mdlIndex, notesStringList, Qt::DisplayRole); |
|
243 OstTraceFunctionExit0( NOTESCOLLECTIONVIEW_RESETCOLLECTIONVIEW_EXIT ); |
227 } |
244 } |
228 |
245 |
229 /*! |
246 /*! |
230 Create a new Note |
247 Create a new Note |
231 */ |
248 */ |
232 void NotesCollectionView::createNewNote() |
249 void NotesCollectionView::createNewNote() |
233 { |
250 { |
|
251 OstTraceFunctionEntry0( NOTESCOLLECTIONVIEW_CREATENEWNOTE_ENTRY ); |
234 // Here we Display an editor to the use to enter text. |
252 // Here we Display an editor to the use to enter text. |
235 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
253 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
236 connect( |
254 connect( |
237 mNotesEditor, SIGNAL(editingCompleted(bool)), |
255 mNotesEditor, SIGNAL(editingCompleted(bool)), |
238 this, SLOT(handleEditingCompleted(bool))); |
256 this, SLOT(handleEditingCompleted(bool))); |
239 |
257 |
240 mNotesEditor->create(NotesEditor::CreateNote); |
258 mNotesEditor->create(NotesEditor::CreateNote); |
|
259 OstTraceFunctionExit0( NOTESCOLLECTIONVIEW_CREATENEWNOTE_EXIT ); |
241 } |
260 } |
242 |
261 |
243 /*! |
262 /*! |
244 Handles editing complete of the notes editor |
263 Handles editing complete of the notes editor |
245 */ |
264 */ |
246 void NotesCollectionView::handleEditingCompleted(bool status) |
265 void NotesCollectionView::handleEditingCompleted(bool status) |
247 { |
266 { |
|
267 OstTraceFunctionEntry0( NOTESCOLLECTIONVIEW_HANDLEEDITINGCOMPLETED_ENTRY ); |
248 Q_UNUSED(status) |
268 Q_UNUSED(status) |
249 |
269 |
250 // Refresh the content of the view. |
270 // Refresh the content of the view. |
251 resetCollectionView(); |
271 resetCollectionView(); |
252 |
272 |
253 // Cleanup. |
273 // Cleanup. |
254 mNotesEditor->deleteLater(); |
274 mNotesEditor->deleteLater(); |
255 |
275 |
256 mAppControllerIf->switchToView(NotesNamespace::NotesMainViewId); |
276 mAppControllerIf->switchToView(NotesNamespace::NotesMainViewId); |
|
277 OstTraceFunctionExit0( NOTESCOLLECTIONVIEW_HANDLEEDITINGCOMPLETED_EXIT ); |
257 } |
278 } |
258 |
279 |
259 /*! |
280 /*! |
260 Updates the view data in case of changes in the database. |
281 Updates the view data in case of changes in the database. |
261 Handles the case when entry is added or deleted by notes application. |
282 Handles the case when entry is added or deleted by notes application. |
262 */ |
283 */ |
263 void NotesCollectionView::updateData(ulong id) |
284 void NotesCollectionView::updateData(ulong id) |
264 { |
285 { |
|
286 OstTraceFunctionEntry0( NOTESCOLLECTIONVIEW_UPDATEDATA_ENTRY ); |
265 Q_UNUSED(id) |
287 Q_UNUSED(id) |
266 |
288 |
267 // Refresh the content of the view. |
289 // Refresh the content of the view. |
268 resetCollectionView(); |
290 resetCollectionView(); |
|
291 OstTraceFunctionExit0( NOTESCOLLECTIONVIEW_UPDATEDATA_EXIT ); |
269 } |
292 } |
270 |
293 |
271 /*! |
294 /*! |
272 Updates the view data in case of changes in the database. |
295 Updates the view data in case of changes in the database. |
273 Handles the case when db is updated by a different client. |
296 Handles the case when db is updated by a different client. |
274 */ |
297 */ |
275 void NotesCollectionView::updateData(QList<ulong> ids) |
298 void NotesCollectionView::updateData(QList<ulong> ids) |
276 { |
299 { |
|
300 OstTraceFunctionEntry0( DUP1_NOTESCOLLECTIONVIEW_UPDATEDATA_ENTRY ); |
277 Q_UNUSED(ids) |
301 Q_UNUSED(ids) |
278 |
302 |
279 // Refresh the content of the view. |
303 // Refresh the content of the view. |
280 resetCollectionView(); |
304 resetCollectionView(); |
|
305 OstTraceFunctionExit0( DUP1_NOTESCOLLECTIONVIEW_UPDATEDATA_EXIT ); |
281 } |
306 } |
282 |
307 |
283 /*! |
308 /*! |
284 Handles the case when a list item is activated and the corresponding |
309 Handles the case when a list item is activated and the corresponding |
285 collections view (viz., notes, to-dos, favourites) is opened. |
310 collections view (viz., notes, to-dos, favourites) is opened. |
286 |
311 |
287 \param index The index of the item that was activated. |
312 \param index The index of the item that was activated. |
288 */ |
313 */ |
289 void NotesCollectionView::handleActivated(const QModelIndex &index) |
314 void NotesCollectionView::handleActivated(const QModelIndex &index) |
290 { |
315 { |
|
316 OstTraceFunctionEntry0( NOTESCOLLECTIONVIEW_HANDLEACTIVATED_ENTRY ); |
291 |
317 |
292 switch (index.row()) { |
318 switch (index.row()) { |
293 case 0: { |
319 case 0: { |
294 if (todosCount()) { |
320 if (todosCount()) { |
295 // To-do item selected. |
321 // To-do item selected. |
346 QStringList favStringList; |
374 QStringList favStringList; |
347 favStringList.append(hbTrId("txt_notes_list_favorites")); |
375 favStringList.append(hbTrId("txt_notes_list_favorites")); |
348 favStringList.append(countString.arg(mFavouriteModel->rowCount())); |
376 favStringList.append(countString.arg(mFavouriteModel->rowCount())); |
349 mListView->model()->setData(mdlIndex, favStringList, Qt::DisplayRole); |
377 mListView->model()->setData(mdlIndex, favStringList, Qt::DisplayRole); |
350 } |
378 } |
|
379 OstTraceFunctionExit0( NOTESCOLLECTIONVIEW_UPDATEFAVOURITESCOUNT_EXIT ); |
351 } |
380 } |
352 |
381 |
353 /*! |
382 /*! |
354 Slot to handle the case when the state of an action has changed. |
383 Slot to handle the case when the state of an action has changed. |
355 */ |
384 */ |
356 void NotesCollectionView::handleActionStateChanged() |
385 void NotesCollectionView::handleActionStateChanged() |
357 { |
386 { |
|
387 OstTraceFunctionEntry0( NOTESCOLLECTIONVIEW_HANDLEACTIONSTATECHANGED_ENTRY ); |
358 mViewCollectionAction->setChecked(true); |
388 mViewCollectionAction->setChecked(true); |
|
389 OstTraceFunctionExit0( NOTESCOLLECTIONVIEW_HANDLEACTIONSTATECHANGED_EXIT ); |
359 } |
390 } |
360 |
391 |
361 |
392 |
362 /*! |
393 /*! |
363 Returns the todos count |
394 Returns the todos count |
364 |
395 |
365 \return int todos count. |
396 \return int todos count. |
366 */ |
397 */ |
367 int NotesCollectionView::todosCount() |
398 int NotesCollectionView::todosCount() |
368 { |
399 { |
|
400 OstTraceFunctionEntry0( NOTESCOLLECTIONVIEW_TODOSCOUNT_ENTRY ); |
369 QList<ulong> entries = mAgendaUtil->entryIds( |
401 QList<ulong> entries = mAgendaUtil->entryIds( |
370 (AgendaUtil::FilterFlags) |
402 (AgendaUtil::FilterFlags) |
371 (AgendaUtil::IncludeCompletedTodos |
403 (AgendaUtil::IncludeCompletedTodos |
372 | AgendaUtil::IncludeIncompletedTodos)); |
404 | AgendaUtil::IncludeIncompletedTodos)); |
373 return entries.count(); |
405 return entries.count(); |