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