151 handleOrientationChanged(window->orientation()); |
140 handleOrientationChanged(window->orientation()); |
152 connect( |
141 connect( |
153 window, SIGNAL(orientationChanged(Qt::Orientation)), |
142 window, SIGNAL(orientationChanged(Qt::Orientation)), |
154 this, SLOT(handleOrientationChanged(Qt::Orientation))); |
143 this, SLOT(handleOrientationChanged(Qt::Orientation))); |
155 |
144 |
156 qDebug() << "notes: NotesNoteView::setupView <--"; |
145 // Set the graphics size for the icons. |
|
146 HbListViewItem *prototype = mListView->listItemPrototype(); |
|
147 prototype->setGraphicsSize(HbListViewItem::SmallIcon); |
157 } |
148 } |
158 |
149 |
159 /*! |
150 /*! |
160 Opens the note editor to create a new note. |
151 Opens the note editor to create a new note. |
161 */ |
152 */ |
162 void NotesNoteView::createNewNote() |
153 void NotesNoteView::createNewNote() |
163 { |
154 { |
164 qDebug() << "notes: NotesNoteView::createNewNote -->"; |
|
165 |
|
166 // Here we Display an editor to the use to enter text. |
155 // Here we Display an editor to the use to enter text. |
167 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
156 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
168 connect( |
157 connect( |
169 mNotesEditor, SIGNAL(editingCompleted(bool)), |
158 mNotesEditor, SIGNAL(editingCompleted(bool)), |
170 this, SLOT(handleEditingCompleted(bool))); |
159 this, SLOT(handleEditingCompleted(bool))); |
171 mNotesEditor->create(NotesEditor::CreateNote); |
160 mNotesEditor->create(NotesEditor::CreateNote); |
172 |
|
173 qDebug() << "notes: NotesNoteView::createNewNote <--"; |
|
174 } |
161 } |
175 |
162 |
176 /*! |
163 /*! |
177 Handles the pressing of a list item in the view. |
164 Handles the pressing of a list item in the view. |
178 |
165 |
181 \param index Reference to the QModelIndex representing the view item. |
168 \param index Reference to the QModelIndex representing the view item. |
182 \sa HbAbstractViewItem |
169 \sa HbAbstractViewItem |
183 */ |
170 */ |
184 void NotesNoteView::handleItemReleased(const QModelIndex &index) |
171 void NotesNoteView::handleItemReleased(const QModelIndex &index) |
185 { |
172 { |
186 qDebug() << "notes: NotesNoteView::handleItemReleased -->"; |
|
187 |
|
188 // Sanity check. |
173 // Sanity check. |
189 if (!index.isValid()) { |
174 if (!index.isValid()) { |
190 qDebug() << "notes: NotesNoteView::handleItemReleased <--"; |
|
191 |
|
192 return; |
175 return; |
193 } |
176 } |
194 |
177 |
195 // First get the id of the note and get the corresponding information from |
178 // First get the id of the note and get the corresponding information from |
196 // agendautil. |
179 // agendautil. |
197 ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>(); |
180 ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>(); |
198 |
181 |
199 if (0 >= noteId) { |
182 if (0 >= noteId) { |
200 qDebug() << "notes: NotesNoteView::handleItemReleased <--"; |
|
201 |
|
202 // Something wrong. |
183 // Something wrong. |
203 return; |
184 return; |
204 } |
185 } |
205 |
186 |
206 // Get the entry details. |
187 // Get the entry details. |
207 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
188 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
208 |
189 |
209 if (entry.isNull()) { |
190 if (entry.isNull()) { |
210 qDebug() << "notes: NotesNoteView::handleItemReleased <--"; |
|
211 |
|
212 // Entry invalid. |
191 // Entry invalid. |
213 return; |
192 return; |
214 } |
193 } |
215 |
194 |
216 // Now launch the editor with the obtained info. |
195 // Now launch the editor with the obtained info. |
217 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
196 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
218 connect( |
197 connect( |
219 mNotesEditor, SIGNAL(editingCompleted(bool)), |
198 mNotesEditor, SIGNAL(editingCompleted(bool)), |
220 this, SLOT(handleEditingCompleted(bool))); |
199 this, SLOT(handleEditingCompleted(bool))); |
221 mNotesEditor->edit(entry); |
200 mNotesEditor->edit(entry); |
222 |
|
223 qDebug() << "notes: NotesNoteView::handleItemReleased <--"; |
|
224 } |
201 } |
225 |
202 |
226 /*! |
203 /*! |
227 Displays a list item specific context menu. |
204 Displays a list item specific context menu. |
228 |
205 |
232 \sa HbAbstractViewItem, HbListView, HbMenu. |
209 \sa HbAbstractViewItem, HbListView, HbMenu. |
233 */ |
210 */ |
234 void NotesNoteView::handleItemLongPressed( |
211 void NotesNoteView::handleItemLongPressed( |
235 HbAbstractViewItem *item, const QPointF &coords) |
212 HbAbstractViewItem *item, const QPointF &coords) |
236 { |
213 { |
237 qDebug() << "notes: NotesNoteView::handleItemLongPressed -->"; |
|
238 |
|
239 mSelectedItem = item; |
214 mSelectedItem = item; |
240 |
215 |
241 ulong noteId = item->modelIndex().data( |
216 ulong noteId = item->modelIndex().data( |
242 NotesNamespace::IdRole).value<qulonglong>(); |
217 NotesNamespace::IdRole).value<qulonglong>(); |
243 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
218 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
244 |
219 |
245 // Display a context specific menu. |
220 // Display a context specific menu. |
246 HbMenu *contextMenu = new HbMenu(); |
221 HbMenu *contextMenu = new HbMenu(); |
247 |
222 |
248 // Add actions to the context menu. |
223 // Add actions to the context menu. |
|
224 mOpenAction = |
|
225 contextMenu->addAction(hbTrId("txt_common_menu_open")); |
|
226 connect( |
|
227 mOpenAction, SIGNAL(triggered()), |
|
228 this, SLOT(openNote())); |
|
229 |
249 mDeleteAction = |
230 mDeleteAction = |
250 contextMenu->addAction(hbTrId("txt_common_menu_delete")); |
231 contextMenu->addAction(hbTrId("txt_common_menu_delete")); |
251 connect( |
232 connect( |
252 mDeleteAction, SIGNAL(triggered()), |
233 mDeleteAction, SIGNAL(triggered()), |
253 this, SLOT(deleteNote())); |
234 this, SLOT(deleteNote())); |
278 this, SLOT(markNoteAsTodo())); |
259 this, SLOT(markNoteAsTodo())); |
279 } |
260 } |
280 |
261 |
281 // Show the menu. |
262 // Show the menu. |
282 contextMenu->exec(coords); |
263 contextMenu->exec(coords); |
283 |
|
284 qDebug() << "notes: NotesNoteView::handleItemLongPressed <--"; |
|
285 } |
264 } |
286 |
265 |
287 /*! |
266 /*! |
288 Slot to delete a selected note. |
267 Slot to delete a selected note. |
289 */ |
268 */ |
290 void NotesNoteView::deleteNote() |
269 void NotesNoteView::deleteNote() |
291 { |
270 { |
292 qDebug() << "notes: NotesNoteView::deleteNote -->"; |
|
293 |
|
294 Q_ASSERT(mSelectedItem); |
271 Q_ASSERT(mSelectedItem); |
295 |
272 |
296 QModelIndex index = mSelectedItem->modelIndex(); |
273 QModelIndex index = mSelectedItem->modelIndex(); |
297 if (!index.isValid()) { |
274 if (!index.isValid()) { |
298 qDebug() << "notes: NotesNoteView::deleteNote <--"; |
|
299 |
|
300 return; |
275 return; |
301 } |
276 } |
302 ulong noteId = |
277 ulong noteId = |
303 index.data(NotesNamespace::IdRole).value<qulonglong>(); |
278 index.data(NotesNamespace::IdRole).value<qulonglong>(); |
304 if (!noteId) { |
279 if (!noteId) { |
305 qDebug() << "notes: NotesNoteView::deleteNote <--"; |
280 return; |
306 |
281 } |
307 return; |
282 // Emitting the signal , deletion would be handle in view manager. |
308 } |
283 emit deleteEntry(noteId); |
309 |
|
310 // Delete the given note. |
|
311 mAgendaUtil->deleteEntry(noteId); |
|
312 |
284 |
313 mSelectedItem = 0; |
285 mSelectedItem = 0; |
314 |
|
315 qDebug() << "notes: NotesNoteView::deleteNote <--"; |
|
316 } |
286 } |
317 |
287 |
318 /*! |
288 /*! |
319 Marks/unmarks the note as favourite. |
289 Marks/unmarks the note as favourite. |
320 */ |
290 */ |
321 void NotesNoteView::markNoteAsFavourite() |
291 void NotesNoteView::markNoteAsFavourite() |
322 { |
292 { |
323 qDebug() << "notes : NotesNoteView::markNoteAsFavourite -->"; |
|
324 |
|
325 ulong noteId = mSelectedItem->modelIndex().data( |
293 ulong noteId = mSelectedItem->modelIndex().data( |
326 NotesNamespace::IdRole).value<qulonglong>(); |
294 NotesNamespace::IdRole).value<qulonglong>(); |
327 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
295 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
328 |
296 |
329 if (entry.favourite()) { |
297 if (entry.favourite()) { |
330 entry.setFavourite(0); |
298 entry.setFavourite(0); |
331 } else { |
299 } else { |
332 entry.setFavourite(1); |
300 entry.setFavourite(1); |
333 } |
301 } |
334 mAgendaUtil->updateEntry(entry); |
302 mAgendaUtil->updateEntry(entry); |
335 |
|
336 qDebug() << "notes : NotesNoteView::markNoteAsFavourite <--"; |
|
337 } |
303 } |
338 |
304 |
339 /*! |
305 /*! |
340 Slot to make a note as to-do. |
306 Slot to make a note as to-do. |
341 */ |
307 */ |
342 void NotesNoteView::markNoteAsTodo() |
308 void NotesNoteView::markNoteAsTodo() |
343 { |
309 { |
344 qDebug() << "notes : NotesNoteView::markNoteAsTodo -->"; |
|
345 |
|
346 Q_ASSERT(mSelectedItem); |
310 Q_ASSERT(mSelectedItem); |
347 |
311 |
348 QModelIndex index = mSelectedItem->modelIndex(); |
312 QModelIndex index = mSelectedItem->modelIndex(); |
349 if (!index.isValid()) { |
313 if (!index.isValid()) { |
350 qDebug() << "notes: NotesNoteView::markNoteAsTodo <--"; |
|
351 |
|
352 return; |
314 return; |
353 } |
315 } |
354 ulong noteId = |
316 ulong noteId = |
355 index.data(NotesNamespace::IdRole).value<qulonglong>(); |
317 index.data(NotesNamespace::IdRole).value<qulonglong>(); |
356 if (!noteId) { |
318 if (!noteId) { |
357 qDebug() << "notes: NotesNoteView::markNoteAsTodo <--"; |
|
358 |
|
359 return; |
319 return; |
360 } |
320 } |
361 // Get the entry details. |
321 // Get the entry details. |
362 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
322 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
363 |
323 |
364 if (entry.isNull()) { |
324 if (entry.isNull()) { |
365 qDebug() << "notes: NotesNoteView::markNoteAsTodo <--"; |
|
366 |
|
367 // Entry invalid. |
325 // Entry invalid. |
368 return; |
326 return; |
369 } |
327 } |
370 |
328 |
371 // Here change the type of modified note and destroy the noteeditor and |
329 // Here change the type of modified note and destroy the noteeditor and |
372 // construct the to-do editor. |
330 // construct the to-do editor. |
373 entry.setType(AgendaEntry::TypeTodo); |
331 entry.setType(AgendaEntry::TypeTodo); |
374 |
332 |
375 QDateTime dueDateTime; |
333 QDateTime dueDateTime; |
376 dueDateTime.setDate(QDate::currentDate()); |
334 QDate currentDate(QDate::currentDate()); |
|
335 dueDateTime.setDate( |
|
336 QDate(currentDate.year(),currentDate.month(),currentDate.day()+1)); |
377 dueDateTime.setTime(QTime::fromString("12:00 am", "hh:mm ap")); |
337 dueDateTime.setTime(QTime::fromString("12:00 am", "hh:mm ap")); |
378 |
338 |
379 entry.setStartAndEndTime(dueDateTime, dueDateTime); |
339 entry.setStartAndEndTime(dueDateTime, dueDateTime); |
380 |
340 |
381 entry.setSummary(entry.description().left(80)); |
341 entry.setSummary(entry.description().left(80)); |
407 |
366 |
408 \sa NotesEditor. |
367 \sa NotesEditor. |
409 */ |
368 */ |
410 void NotesNoteView::handleEditingCompleted(bool status) |
369 void NotesNoteView::handleEditingCompleted(bool status) |
411 { |
370 { |
412 qDebug() << "notes: NotesNoteView::handleEditingCompleted -->"; |
|
413 |
|
414 Q_UNUSED(status) |
371 Q_UNUSED(status) |
415 |
372 |
416 // Cleanup. |
373 // Cleanup. |
417 mNotesEditor->deleteLater(); |
374 mNotesEditor->deleteLater(); |
418 |
|
419 qDebug() << "notes: NotesNoteView::handleEditingCompleted <--"; |
|
420 } |
375 } |
421 |
376 |
422 /*! |
377 /*! |
423 Directs the view manager to display the Collections view. |
378 Directs the view manager to display the Collections view. |
424 */ |
379 */ |
425 void NotesNoteView::displayCollectionView() |
380 void NotesNoteView::displayCollectionView() |
426 { |
381 { |
427 qDebug() << "notes: NotesNoteView::displayCollectionView -->"; |
|
428 |
|
429 // Switch to collections view. |
382 // Switch to collections view. |
430 mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId); |
383 mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId); |
431 |
384 |
432 qDebug() << "notes: NotesNoteView::displayCollectionView <--"; |
|
433 } |
385 } |
434 |
386 |
435 /*! |
387 /*! |
436 Directs the view manager to display the All notes view. |
388 Directs the view manager to display the All notes view. |
437 */ |
389 */ |
438 void NotesNoteView::displayAllNotesView() |
390 void NotesNoteView::displayAllNotesView() |
439 { |
391 { |
440 qDebug() << "notes: NotesNoteView::displayAllNotesView -->"; |
|
441 |
|
442 // Switch to collections view. |
392 // Switch to collections view. |
443 mAppControllerIf->switchToView(NotesNamespace::NotesMainViewId); |
393 mAppControllerIf->switchToView(NotesNamespace::NotesMainViewId); |
444 |
|
445 qDebug() << "notes: NotesNoteView::displayAllNotesView <--"; |
|
446 } |
394 } |
447 |
395 |
448 /*! |
396 /*! |
449 Slot to handle the case when the state of an action has changed. |
397 Slot to handle the case when the state of an action has changed. |
450 */ |
398 */ |
451 void NotesNoteView::handleActionStateChanged() |
399 void NotesNoteView::handleActionStateChanged() |
452 { |
400 { |
453 qDebug() << "notes: NotesNoteView::handleActionStateChanged -->"; |
|
454 |
|
455 mAllNotesAction->setChecked(true); |
401 mAllNotesAction->setChecked(true); |
456 |
|
457 qDebug() << "notes: NotesNoteView::handleActionStateChanged <--"; |
|
458 } |
402 } |
459 |
403 |
460 /*! |
404 /*! |
461 Handles the orientation changes.Updates the list |
405 Handles the orientation changes.Updates the list |
462 item when orientation is changed |
406 item when orientation is changed |
467 { |
411 { |
468 HbListViewItem *prototype = mListView->listItemPrototype(); |
412 HbListViewItem *prototype = mListView->listItemPrototype(); |
469 |
413 |
470 if (Qt::Horizontal == orientation) { |
414 if (Qt::Horizontal == orientation) { |
471 prototype->setStretchingStyle(HbListViewItem::StretchLandscape); |
415 prototype->setStretchingStyle(HbListViewItem::StretchLandscape); |
472 |
|
473 // Set the text in landscape mode |
|
474 mAllNotesAction->setText(hbTrId("txt_notes_button_all")); |
|
475 mViewCollectionAction->setText(hbTrId("txt_notes_button_collections")); |
|
476 mAddNoteAction->setText(hbTrId("txt_notes_button_new_note")); |
|
477 } else { |
416 } else { |
478 prototype->setStretchingStyle(HbListViewItem::NoStretching); |
417 prototype->setStretchingStyle(HbListViewItem::NoStretching); |
479 |
418 } |
480 // Set empty text in portriat mode so that only icons are visible. |
419 } |
481 mAllNotesAction->setText(""); |
420 |
482 mViewCollectionAction->setText(""); |
421 /* |
483 mAddNoteAction->setText(""); |
422 Opens the notes editor to edit the note. |
484 } |
423 */ |
485 } |
424 void NotesNoteView::openNote() |
486 |
425 { |
|
426 ulong noteId = mSelectedItem->modelIndex().data( |
|
427 NotesNamespace::IdRole).value<qulonglong>(); |
|
428 |
|
429 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
|
430 |
|
431 // Construct notes editor. |
|
432 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
|
433 connect( |
|
434 mNotesEditor, SIGNAL(editingCompleted(bool)), |
|
435 this, SLOT(handleEditingCompleted(bool))); |
|
436 |
|
437 // Launch the notes editor with the obtained info. |
|
438 mNotesEditor->edit(entry); |
|
439 } |
487 // End of file --Don't remove this. |
440 // End of file --Don't remove this. |
488 |
441 |