notes/notesui/notesviewmanager/src/notesviewmanager.cpp
changeset 70 a5ed90760192
parent 55 2c54b51f39c4
child 81 ce92091cbd61
equal deleted inserted replaced
64:1881ad52dc45 70:a5ed90760192
    58 	\param controller A reference to the object of NotesAppController.
    58 	\param controller A reference to the object of NotesAppController.
    59  */
    59  */
    60 NotesViewManager::NotesViewManager(
    60 NotesViewManager::NotesViewManager(
    61 		NotesAppControllerIf &controllerIf, QObject *parent)
    61 		NotesAppControllerIf &controllerIf, QObject *parent)
    62 :QObject(parent),
    62 :QObject(parent),
    63  mAppControllerIf(controllerIf)
    63  mAppControllerIf(controllerIf),
       
    64  mMainView(0),
       
    65  mCollectionView(0),
       
    66  mTodoView(0),
       
    67  mFavoriteView(0),
       
    68  mNoteView(0),
       
    69  instanceViewCreated(false)
    64 {
    70 {
    65 	OstTraceFunctionEntry0( NOTESVIEWMANAGER_NOTESVIEWMANAGER_ENTRY );
    71 	OstTraceFunctionEntry0( NOTESVIEWMANAGER_NOTESVIEWMANAGER_ENTRY );
    66 	HbMainWindow *window = hbInstance->allMainWindows().first();
    72 	HbMainWindow *window = hbInstance->allMainWindows().first();
    67 
    73 
    68 	mAgendaUtil = mAppControllerIf.agendaUtil();
    74 	mAgendaUtil = mAppControllerIf.agendaUtil();
   200 	// Construct the document loader instance
   206 	// Construct the document loader instance
   201 	NotesDocLoader *docLoader = new NotesDocLoader();
   207 	NotesDocLoader *docLoader = new NotesDocLoader();
   202 
   208 
   203 	// Load the application xml.
   209 	// Load the application xml.
   204 	docLoader->load(NOTES_MAIN_VIEW_XML, &loadSuccess);
   210 	docLoader->load(NOTES_MAIN_VIEW_XML, &loadSuccess);
   205 	Q_ASSERT_X(
   211 	
   206 			loadSuccess,
       
   207 			"notesviewmanager.cpp",
       
   208 			"Unable to load the main view app xml");
       
   209 
       
   210 	// Find the main view.
   212 	// Find the main view.
   211 	mMainView = static_cast<NotesMainView *> (
   213 	mMainView = static_cast<NotesMainView *> (
   212 			docLoader->findWidget(NOTES_MAIN_VIEW));
   214 			docLoader->findWidget(NOTES_MAIN_VIEW));
   213 	Q_ASSERT_X(
   215 	mMainView->setParent(this);
   214 			mMainView, "notesviewmanager.cpp", "Unable to find the main view.");
   216 	
   215 	// Setup the view.
   217 	// Setup the view.
   216 	mMainView->setupView(mAppControllerIf, docLoader);
   218 	mMainView->setupView(mAppControllerIf, docLoader);
   217 	// Connect to main view signal for entry deletion.
   219 	// Connect to main view signal for entry deletion.
   218 	connect (
   220 	connect (
   219 			mMainView, SIGNAL(deleteEntry(ulong)),
   221 			mMainView, SIGNAL(deleteEntry(ulong)),
   239 	docLoader->load(NOTES_COLLECTION_VIEW_XML, &loadSuccess);
   241 	docLoader->load(NOTES_COLLECTION_VIEW_XML, &loadSuccess);
   240 
   242 
   241 	// Find the collection view.
   243 	// Find the collection view.
   242 	mCollectionView = static_cast<NotesCollectionView *> (
   244 	mCollectionView = static_cast<NotesCollectionView *> (
   243 			docLoader->findWidget(NOTES_COLLECTION_VIEW));
   245 			docLoader->findWidget(NOTES_COLLECTION_VIEW));
       
   246 	mCollectionView->setParent(this);
       
   247 	
   244 	// Setup the view.
   248 	// Setup the view.
   245 	mCollectionView->setupView(mAppControllerIf, docLoader);
   249 	mCollectionView->setupView(mAppControllerIf, docLoader);
   246 	OstTraceFunctionExit0( NOTESVIEWMANAGER_LOADNOTESCOLLECTIONVIEW_EXIT );
   250 	OstTraceFunctionExit0( NOTESVIEWMANAGER_LOADNOTESCOLLECTIONVIEW_EXIT );
   247 }
   251 }
   248 
   252 
   262 	docLoader->load(NOTES_TODO_VIEW_XML, &loadSuccess);
   266 	docLoader->load(NOTES_TODO_VIEW_XML, &loadSuccess);
   263 
   267 
   264 	// Find the to-do view.
   268 	// Find the to-do view.
   265 	mTodoView = static_cast<NotesTodoView *> (
   269 	mTodoView = static_cast<NotesTodoView *> (
   266 			docLoader->findWidget(NOTES_TODO_VIEW));
   270 			docLoader->findWidget(NOTES_TODO_VIEW));
       
   271 	mTodoView->setParent(this);
       
   272 	
   267 	// Setup the view.
   273 	// Setup the view.
   268 	mTodoView->setupView(mAppControllerIf, docLoader);
   274 	mTodoView->setupView(mAppControllerIf, docLoader);
   269 	// Connect to to-do view signal for entry deletion.
   275 	// Connect to to-do view signal for entry deletion.
   270 	connect (
   276 	connect (
   271 			mTodoView, SIGNAL(deleteEntry(ulong)),
   277 			mTodoView, SIGNAL(deleteEntry(ulong)),
   288 	docLoader->load(NOTES_FAVORITES_VIEW_XML, &loadSuccess);
   294 	docLoader->load(NOTES_FAVORITES_VIEW_XML, &loadSuccess);
   289 
   295 
   290 	// Find the favorites view.
   296 	// Find the favorites view.
   291 	mFavoriteView = static_cast<NotesFavoriteView *> (
   297 	mFavoriteView = static_cast<NotesFavoriteView *> (
   292 			docLoader->findWidget(NOTES_FAVORITES_VIEW));
   298 			docLoader->findWidget(NOTES_FAVORITES_VIEW));
       
   299 	mFavoriteView->setParent(this);
   293 	// Setup the view.
   300 	// Setup the view.
   294 	mFavoriteView->setupView(mAppControllerIf, docLoader);
   301 	mFavoriteView->setupView(mAppControllerIf, docLoader);
   295 
   302 
   296 	// Connect to favourite view signal for entry deletion.
   303 	// Connect to favourite view signal for entry deletion.
   297 	connect (
   304 	connect (
   315 	docLoader->load(NOTES_NOTE_VIEW_XML, &loadSuccess);
   322 	docLoader->load(NOTES_NOTE_VIEW_XML, &loadSuccess);
   316 
   323 
   317 	// Find the note view.
   324 	// Find the note view.
   318 	mNoteView = static_cast<NotesNoteView *> (
   325 	mNoteView = static_cast<NotesNoteView *> (
   319 			docLoader->findWidget(NOTES_NOTE_VIEW));
   326 			docLoader->findWidget(NOTES_NOTE_VIEW));
       
   327 	mNoteView->setParent(this);
       
   328 	
   320 	// Setup the view.
   329 	// Setup the view.
   321 	mNoteView->setupView(mAppControllerIf, docLoader);
   330 	mNoteView->setupView(mAppControllerIf, docLoader);
   322 
   331 
   323 	connect(
   332 	connect(
   324 			mNoteView, SIGNAL(deleteEntry(ulong)),
   333 			mNoteView, SIGNAL(deleteEntry(ulong)),
   325 			this, SLOT(deleteEntryFromView(ulong)));
   334 			this, SLOT(deleteEntryFromView(ulong)));
   326 	OstTraceFunctionExit0( NOTESVIEWMANAGER_LOADNOTEVIEW_EXIT );
   335 	OstTraceFunctionExit0( NOTESVIEWMANAGER_LOADNOTEVIEW_EXIT );
       
   336 }
       
   337 
       
   338 /*!
       
   339 	Update all the other views.
       
   340  */
       
   341 void NotesViewManager::updateOtherViews()
       
   342 {
       
   343 	if (mCollectionView) {
       
   344 		// Populate collections view.
       
   345 		mCollectionView->populateListView();
       
   346 	}
       
   347 
       
   348 	if (mTodoView) {
       
   349 		// Update the title for to-do view.
       
   350 		mTodoView->updateTitle();
       
   351 	}
       
   352 	
       
   353 	if (mNoteView) {
       
   354 		// Update the plain notes view.
       
   355 		mNoteView->updateNoteView();
       
   356 	}
       
   357 	
       
   358 	if (mFavoriteView) {
       
   359 		// Update the favorites view.
       
   360 		mFavoriteView->updateFavoriteView();
       
   361 	}
       
   362 	
   327 }
   363 }
   328 
   364 
   329 /*!
   365 /*!
   330 	Loads other views from the docml file.
   366 	Loads other views from the docml file.
   331  */
   367  */
   341 	// Load the favorites view.
   377 	// Load the favorites view.
   342 	loadFavoritesView();
   378 	loadFavoritesView();
   343 	// Load the recent notes view.
   379 	// Load the recent notes view.
   344 	loadNoteView();
   380 	loadNoteView();
   345 
   381 
       
   382 	if (instanceViewCreated) {
       
   383 		// update other views.
       
   384 		updateOtherViews();
       
   385 	}
   346 	// Disconnect the signal viewReady as all the views are loaded.
   386 	// Disconnect the signal viewReady as all the views are loaded.
   347 	HbMainWindow *window = hbInstance->allMainWindows().first();
   387 	HbMainWindow *window = hbInstance->allMainWindows().first();
   348 	disconnect(
   388 	disconnect(
   349 			window, SIGNAL(viewReady()),
   389 			window, SIGNAL(viewReady()),
   350 			this, SLOT(loadOtherViews()));
   390 			this, SLOT(loadOtherViews()));
   381 		confirmationQuery->removeAction(defaultActions[index]);
   421 		confirmationQuery->removeAction(defaultActions[index]);
   382 	}
   422 	}
   383 	defaultActions.clear();
   423 	defaultActions.clear();
   384 
   424 
   385 	// Add delete and cancel actions
   425 	// Add delete and cancel actions
   386 	mDeleteAction = new HbAction(hbTrId("txt_notes_button_dialog_delete"));
   426 	mDeleteAction = new HbAction(hbTrId("txt_common_button_delete"));
   387 	mCancelAction = new HbAction(hbTrId("txt_common_button_cancel"));
   427 	mCancelAction = new HbAction(hbTrId("txt_common_button_cancel"));
   388 
   428 
   389 	confirmationQuery->addAction(mDeleteAction);
   429 	confirmationQuery->addAction(mDeleteAction);
   390 	confirmationQuery->addAction(mCancelAction);
   430 	confirmationQuery->addAction(mCancelAction);
   391 
   431 
   411  */
   451  */
   412 void NotesViewManager::handleInstanceViewCreationCompleted(int status)
   452 void NotesViewManager::handleInstanceViewCreationCompleted(int status)
   413 {
   453 {
   414 	OstTraceFunctionEntry0( NOTESVIEWMANAGER_HANDLEINSTANCEVIEWCREATIONCOMPLETED_ENTRY );
   454 	OstTraceFunctionEntry0( NOTESVIEWMANAGER_HANDLEINSTANCEVIEWCREATIONCOMPLETED_ENTRY );
   415 	Q_UNUSED(status)
   455 	Q_UNUSED(status)
   416 
   456 	
   417 	// Update the title for main view.
   457 	instanceViewCreated = true;
   418 	mMainView->updateTitle();
   458 	
   419 
   459 	if (mMainView) {
   420 	// Populate collections view.
   460 		// Update the title for main view.
   421 	mCollectionView->populateListView();
   461 		mMainView->updateTitle();
   422 
   462 	}
   423 	// Update the title for to-do view.
   463 
   424 	mTodoView->updateTitle();
   464 	// update other views.
   425 	
   465 	updateOtherViews();
   426 	// Update the plain notes view.
   466 
   427 	mNoteView->updateNoteView();
       
   428 	
       
   429 	// Update the favorites view.
       
   430 	mFavoriteView->updateFavoriteView();
       
   431 	
       
   432 	// Need to emit this signal after the view is fully constructed & populated
   467 	// Need to emit this signal after the view is fully constructed & populated
   433 	// with actual data and ready to be used. So entry view & instance view
   468 	// with actual data and ready to be used. So entry view & instance view
   434 	// needs to be created so that a new entry can also be created. Finally
   469 	// needs to be created so that a new entry can also be created. Finally
   435 	// NotesApplication object needs to emit applicationReady Signal.
   470 	// NotesApplication object needs to emit applicationReady Signal.
   436 	emit appReady();
   471 	emit appReady();