calendarui/controller/src/calenviewmanager.cpp
changeset 26 a949c2543c15
parent 23 fd30d51f876b
child 32 ea672fcb0ea0
equal deleted inserted replaced
23:fd30d51f876b 26:a949c2543c15
    51 	
    51 	
    52 	mCalenEventViewer = NULL;
    52 	mCalenEventViewer = NULL;
    53 	mMonthViewDocLoader = NULL;
    53 	mMonthViewDocLoader = NULL;
    54 	mDayViewDocLoader = NULL;	
    54 	mDayViewDocLoader = NULL;	
    55 	mDayViewAltDocLoader = NULL;
    55 	mDayViewAltDocLoader = NULL;
    56 	
    56 	mCalenDayView = NULL;
    57 	mController.MainWindow().setItemVisible(Hb::NaviPaneItem, false);
    57 	mCalenMonthView = NULL;
       
    58 	mCalenDayViewAlt = NULL;
       
    59 	
       
    60 	// Connect to instance view and entry view creation signals from agenda
       
    61 	// interface
       
    62 	connect(mController.agendaInterface(), SIGNAL(instanceViewCreationCompleted(int)),
       
    63 	        this, SLOT(handleInstanceViewCreation(int)));
       
    64 	connect(mController.agendaInterface(), SIGNAL(entryViewCreationCompleted(int)),
       
    65 		        this, SLOT(handleEntryViewCreation(int)));
    58 	
    66 	
    59 	if (isFromServiceFrmwrk) {
    67 	if (isFromServiceFrmwrk) {
    60 		// Dont load any views until our remote slot gets called in
    68 		// Dont load any views until our remote slot gets called in
    61 		// calenserviceprovider.cpp
    69 		// calenserviceprovider.cpp
    62 		// Just have an empty mainwindow
    70 		// Just have an empty mainwindow
    67 		loadMonthView();
    75 		loadMonthView();
    68 		ActivateDefaultViewL(ECalenMonthView);
    76 		ActivateDefaultViewL(ECalenMonthView);
    69 		// Connect to the view ready signal so that we construct other view 
    77 		// Connect to the view ready signal so that we construct other view 
    70 		// once this view is shown
    78 		// once this view is shown
    71 		connect(&mController.MainWindow(), SIGNAL(viewReady()), 
    79 		connect(&mController.MainWindow(), SIGNAL(viewReady()), 
    72 						this, SLOT(constructOtherViews()));
    80 						this, SLOT(handleMainViewReady()));
    73 		
    81 		
    74 		mController.MainWindow().addView(mCalenMonthView);
    82 		mController.MainWindow().addView(mCalenMonthView);
    75 		mController.MainWindow().setCurrentView(mCalenMonthView);
    83 		mController.MainWindow().setCurrentView(mCalenMonthView);
    76 	}
    84 	}
    77 	
    85 	
   104 // ----------------------------------------------------------------------------
   112 // ----------------------------------------------------------------------------
   105 //
   113 //
   106 void CalenViewManager::constructAndActivateView(int view)
   114 void CalenViewManager::constructAndActivateView(int view)
   107 {
   115 {
   108 	TRACE_ENTRY_POINT;
   116 	TRACE_ENTRY_POINT;
       
   117 	// We are here because, some other application is launching calendar with 
       
   118 	// the view, hence connect to viewReady() signal to do any lazy loading
       
   119 	// in the slot
       
   120 	
       
   121 	// Connect to the view ready signal so that we construct other view 
       
   122 	// once this view is shown
       
   123 	connect(&mController.MainWindow(), SIGNAL(viewReady()), 
       
   124 					this, SLOT(handleMainViewReady()));
   109 	if (view == ECalenMonthView) {
   125 	if (view == ECalenMonthView) {
   110 		mFirstView = ECalenMonthView;
   126 		mFirstView = ECalenMonthView;
   111 		loadMonthView();
   127 		loadMonthView();
   112 		ActivateDefaultViewL(ECalenMonthView);
   128 		ActivateDefaultViewL(ECalenMonthView);
   113 		// Add month view to mainwindow.
   129 		// Add month view to mainwindow.
   114 		mController.MainWindow().addView(mCalenMonthView);
   130 		mController.MainWindow().addView(mCalenMonthView);
       
   131 		mController.MainWindow().setCurrentView(mCalenMonthView);
   115 	} else if (view == ECalenDayView) {
   132 	} else if (view == ECalenDayView) {
   116 		mFirstView = ECalenDayView;
   133 		mFirstView = ECalenDayView;
   117 		loadDayView();
   134 		loadDayView();
   118 		ActivateDefaultViewL(ECalenDayView);
   135 		ActivateDefaultViewL(ECalenDayView);
   119 		// Add day view to mainwindow.
   136 		// Add day view to mainwindow.
   120 		mController.MainWindow().addView(mCalenDayView);
   137 		mController.MainWindow().addView(mCalenDayView);
       
   138 		mController.MainWindow().setCurrentView(mCalenDayView);
   121 	}
   139 	}
   122 	TRACE_EXIT_POINT;
   140 	TRACE_EXIT_POINT;
   123 }
   141 }
   124 
   142 
   125 // ----------------------------------------------------------------------------
   143 // ----------------------------------------------------------------------------
   148 	Q_ASSERT_X(loadSuccess, "calenviewmanager.cpp", "Unable to load XML");
   166 	Q_ASSERT_X(loadSuccess, "calenviewmanager.cpp", "Unable to load XML");
   149 	
   167 	
   150 	// Get the calenmonth view from the loader.
   168 	// Get the calenmonth view from the loader.
   151 	mCalenMonthView = static_cast<CalenMonthView *> 
   169 	mCalenMonthView = static_cast<CalenMonthView *> 
   152 							(mMonthViewDocLoader->findWidget(CALEN_MONTHVIEW));
   170 							(mMonthViewDocLoader->findWidget(CALEN_MONTHVIEW));
   153 	Q_ASSERT_X(mCalenDayView, "calenviewmanager.cpp", 
   171 	Q_ASSERT_X(mCalenMonthView, "calenviewmanager.cpp", 
   154 											"Unable to load calenMonth view");
   172 											"Unable to load calenMonth view");
   155 	
   173 	
   156 	// Setup the month view.
   174 	// Setup the month view.
   157 	mCalenMonthView->setupView(mMonthViewDocLoader);
   175 	mCalenMonthView->setupView(mMonthViewDocLoader);
   158 }
   176 }
   187 	// The following code is done to provide swipe support
   205 	// The following code is done to provide swipe support
   188 	// in day view. Idea is to create two views and keep
   206 	// in day view. Idea is to create two views and keep
   189 	// switiching between these two using view switch effects
   207 	// switiching between these two using view switch effects
   190 	// to provide an illusion of flow to the user
   208 	// to provide an illusion of flow to the user
   191 	loadAlternateDayView();
   209 	loadAlternateDayView();
       
   210 }
       
   211 
       
   212 // ----------------------------------------------------------------------------
       
   213 // CalenViewManager::handleMainViewReady
       
   214 // Slot to handle viewReady() signal from mainwindow
       
   215 // (other items were commented in a header).
       
   216 // ----------------------------------------------------------------------------
       
   217 //
       
   218 void CalenViewManager::handleMainViewReady()
       
   219 {
       
   220 	// Construct the month view part that is kept for lazy loading
       
   221 	if (mCalenMonthView) {
       
   222 		mCalenMonthView->doLazyLoading();
       
   223 	}
       
   224 	
       
   225 	// Construct other views
       
   226 	constructOtherViews();
       
   227 	
       
   228 	// disconnect the view ready signal as we dont need it anymore
       
   229 	disconnect(&mController.MainWindow(), SIGNAL(viewReady()), 
       
   230 			   this, SLOT(handleMainViewReady()));
   192 }
   231 }
   193 
   232 
   194 // ----------------------------------------------------------------------------
   233 // ----------------------------------------------------------------------------
   195 // CalenViewManager::constructOtherViews
   234 // CalenViewManager::constructOtherViews
   196 // Constructs the other views apart frm firstview and adds them to main window
   235 // Constructs the other views apart frm firstview and adds them to main window
   215 		loadDayView();
   254 		loadDayView();
   216 	}
   255 	}
   217 
   256 
   218 	// Setup the settings view
   257 	// Setup the settings view
   219 	mSettingsView = new CalenSettingsView(mController.Services());
   258 	mSettingsView = new CalenSettingsView(mController.Services());
   220 	
       
   221 	// disconnect the view ready signal as we dont need it anymore
       
   222 	disconnect(&mController.MainWindow(), SIGNAL(viewReady()), 
       
   223 	           this, SLOT(constructOtherViews()));
       
   224 }
   259 }
   225 
   260 
   226 // ----------------------------------------------------------------------------
   261 // ----------------------------------------------------------------------------
   227 // CalenViewManager::getFirstView
   262 // CalenViewManager::getFirstView
   228 // Returns the first view
   263 // Returns the first view
   281     currentDay = currentDay.addDays(-1);
   316     currentDay = currentDay.addDays(-1);
   282     mController.Services().Context().setFocusDateL(currentDay, ECalenDayView);
   317     mController.Services().Context().setFocusDateL(currentDay, ECalenDayView);
   283     mCurrentViewId = ECalenDayView;
   318     mCurrentViewId = ECalenDayView;
   284     if (mController.MainWindow().currentView() == mCalenDayView) {
   319     if (mController.MainWindow().currentView() == mCalenDayView) {
   285         HbEffect::add(mCalenDayView,
   320         HbEffect::add(mCalenDayView,
   286                       ":/fxml/view_show",
   321                       ":/fxml/view_hide_back",
   287                       "hide");
   322                       "hide");
   288         HbEffect::add(mCalenDayViewAlt,
   323         HbEffect::add(mCalenDayViewAlt,
   289                       ":/fxml/view_hide",
   324                       ":/fxml/view_show_back",
   290                       "show");
   325                       "show");
   291         mCalenDayViewAlt->doPopulation();
   326         mCalenDayViewAlt->doPopulation();
   292         mController.MainWindow().setCurrentView(mCalenDayViewAlt, true, Hb::ViewSwitchUseBackAnim);
   327         mController.MainWindow().setCurrentView(mCalenDayViewAlt, true, Hb::ViewSwitchUseNormalAnim);
   293     } else {
   328     } else {
   294         HbEffect::add(mCalenDayViewAlt,
   329         HbEffect::add(mCalenDayViewAlt,
   295                       ":/fxml/view_show",
   330                       ":/fxml/view_hide_back",
   296                       "hide");
   331                       "hide");
   297         HbEffect::add(mCalenDayView,
   332         HbEffect::add(mCalenDayView,
   298                       ":/fxml/view_hide",
   333                       ":/fxml/view_show_back",
   299                       "show");
   334                       "show");
   300         mCalenDayView->doPopulation();
   335         mCalenDayView->doPopulation();
   301         mController.MainWindow().setCurrentView(mCalenDayView, true, Hb::ViewSwitchUseBackAnim);
   336         mController.MainWindow().setCurrentView(mCalenDayView, true, Hb::ViewSwitchUseNormalAnim);
   302     }
   337     }
   303 }
   338 }
   304 
   339 
   305 // ----------------------------------------------------------------------------
   340 // ----------------------------------------------------------------------------
   306 // CalenViewManager::removeDayViews
   341 // CalenViewManager::removeDayViews
   307 // other items were commented in a header
   342 // other items were commented in a header
   308 // ----------------------------------------------------------------------------
   343 // ----------------------------------------------------------------------------
   309 //
   344 //
   310 void CalenViewManager::removeDayViews()
   345 void CalenViewManager::removeDayViews()
   311 {
   346 {
       
   347     mCalenDayView->clearListModel();
       
   348     mCalenDayViewAlt->clearListModel();
   312     mController.MainWindow().removeView(mCalenDayView);
   349     mController.MainWindow().removeView(mCalenDayView);
   313     mController.MainWindow().removeView(mCalenDayViewAlt);
   350     mController.MainWindow().removeView(mCalenDayViewAlt);
   314 }
   351 }
   315 
   352 
   316 // ----------------------------------------------------------------------------
   353 // ----------------------------------------------------------------------------
   356 			break;
   393 			break;
   357 		case ECalenDayView:
   394 		case ECalenDayView:
   358 		    if (mController.MainWindow().currentView() == mCalenDayView) {
   395 		    if (mController.MainWindow().currentView() == mCalenDayView) {
   359 		        // This happens when settings view or event viewer is opened
   396 		        // This happens when settings view or event viewer is opened
   360 		        // from the agenda view. Simply repopulate the view
   397 		        // from the agenda view. Simply repopulate the view
   361                 mCalenDayView->doPopulation();
   398 		    	if (mCalenDayView) {
   362                 mController.MainWindow().setCurrentView(mCalenDayView);
   399 					mCalenDayView->doPopulation();
       
   400 					mController.MainWindow().setCurrentView(mCalenDayView);
       
   401 		    	}
   363 		    } else if (mController.MainWindow().currentView() == mCalenDayViewAlt){
   402 		    } else if (mController.MainWindow().currentView() == mCalenDayViewAlt){
   364 		        // This happens when settings view or event viewer is opened
   403 		        // This happens when settings view or event viewer is opened
   365 		        // from the agenda view. Simply repopulate the view
   404 		        // from the agenda view. Simply repopulate the view
   366 		        mCalenDayViewAlt->doPopulation();
   405 		    	if (mCalenDayViewAlt) {
   367 		        mController.MainWindow().setCurrentView(mCalenDayViewAlt);
   406 					mCalenDayViewAlt->doPopulation();
       
   407 					mController.MainWindow().setCurrentView(mCalenDayViewAlt);
       
   408 		    	}
   368 		    } else {
   409 		    } else {
   369 		        // This is called whenever the day view is opened from the month
   410 		        // This is called whenever the day view is opened from the month
   370 		        // view. Since the day view is not added to the mainwindow,
   411 		        // view. Since the day view is not added to the mainwindow,
   371 		        // add the day views to mainwindow and set any one of them as 
   412 		        // add the day views to mainwindow and set any one of them as 
   372 		        // current view
   413 		        // current view
   373 		        mCalenDayView->doPopulation();
   414 		    	if (mCalenDayView) {
   374 		        mController.MainWindow().addView(mCalenDayView);
   415 		    		mCalenDayView->doPopulation();
   375 		        mController.MainWindow().setCurrentView(mCalenDayView);
   416 					mController.MainWindow().addView(mCalenDayView);
   376 		        mController.MainWindow().addView(mCalenDayViewAlt);
   417 					mController.MainWindow().setCurrentView(mCalenDayView);
       
   418 					mController.MainWindow().addView(mCalenDayViewAlt);
       
   419 		    	}
   377 		    }
   420 		    }
   378 			break;
   421 			break;
   379 		case ECalenLandscapeDayView:
   422 		case ECalenLandscapeDayView:
   380 			// For later implementation
   423 			// For later implementation
   381 			break;
   424 			break;
   609 	mController.Services().IssueNotificationL(ECalenNotifyEntryDeleted);
   652 	mController.Services().IssueNotificationL(ECalenNotifyEntryDeleted);
   610 	
   653 	
   611 	qDebug() <<"calendar: CalenViewManager::handleEditingStarted <--";
   654 	qDebug() <<"calendar: CalenViewManager::handleEditingStarted <--";
   612 }
   655 }
   613 
   656 
       
   657 // ----------------------------------------------------------------------------
       
   658 // CalenViewManager::handleInstanceViewCreation
       
   659 //  Slot to handle completion of instance view creation
       
   660 // (other items were commented in a header).
       
   661 // ----------------------------------------------------------------------------
       
   662 //
       
   663 void CalenViewManager::handleInstanceViewCreation(int status)
       
   664 {
       
   665 	Q_UNUSED(status);
       
   666 	mCalenMonthView->fetchEntriesAndUpdateModel();
       
   667 }
       
   668 
       
   669 // ----------------------------------------------------------------------------
       
   670 // CalenViewManager::handleDeletingCompleted
       
   671 //  Slot to handle completion of entry view creation
       
   672 // (other items were commented in a header).
       
   673 // ----------------------------------------------------------------------------
       
   674 //
       
   675 void CalenViewManager::handleEntryViewCreation(int status)
       
   676 {
       
   677 	// Nothing Yet
       
   678 	Q_UNUSED(status);
       
   679 }
   614 // End of file	--Don't remove this.
   680 // End of file	--Don't remove this.