calendarui/views/dayview/src/calendayview.cpp
changeset 57 bb2d3e476f29
parent 55 2c54b51f39c4
child 63 a3cb48f6c889
equal deleted inserted replaced
55:2c54b51f39c4 57:bb2d3e476f29
    45 #include "calenpluginlabel.h"
    45 #include "calenpluginlabel.h"
    46 #include "calendaymodel.h"
    46 #include "calendaymodel.h"
    47 
    47 
    48 //constants
    48 //constants
    49 
    49 
    50 // -----------------------------------------------------------------------------
    50 
    51 // CalenDayView()
    51 /*!
    52 // Constructor.
    52  \brief Constructor
    53 // -----------------------------------------------------------------------------
    53 */
    54 //
       
    55 CalenDayView::CalenDayView(MCalenServices &services) :
    54 CalenDayView::CalenDayView(MCalenServices &services) :
    56     CalenNativeView(services), mContentScrollArea(NULL), mContentWidget(NULL),
    55     CalenNativeView(services), mContentScrollArea(NULL), mContentWidget(NULL),
    57         mHourScrollArea(NULL), mVLayout(NULL), mDocLoader(NULL), mIsLaunching(
    56         mHourScrollArea(NULL), mVLayout(NULL), mDocLoader(NULL), mIsLaunching(
    58             true), mSettingsManager(NULL), mRegionalInfo(
    57             true), mSettingsManager(NULL), mRegionalInfo(
    59             XQSettingsKey::TargetCentralRepository, KCRUidCalendar,
    58             XQSettingsKey::TargetCentralRepository, KCRUidCalendar,
    78     HbStyleLoader::registerFilePath(":/calendayhourelement.css");
    77     HbStyleLoader::registerFilePath(":/calendayhourelement.css");
    79     HbStyleLoader::registerFilePath(":/calendayhourelement.widgetml");
    78     HbStyleLoader::registerFilePath(":/calendayhourelement.widgetml");
    80     HbStyleLoader::registerFilePath(":/calendayitem.css");
    79     HbStyleLoader::registerFilePath(":/calendayitem.css");
    81     HbStyleLoader::registerFilePath(":/calendayitem.widgetml");
    80     HbStyleLoader::registerFilePath(":/calendayitem.widgetml");
    82     HbStyleLoader::registerFilePath(":/calendayeventspane.css");
    81     HbStyleLoader::registerFilePath(":/calendayeventspane.css");
    83 }
    82     HbStyleLoader::registerFilePath(":/calendayhourscrollarea.css");
    84 
    83 }
    85 // -----------------------------------------------------------------------------
    84 
    86 // ~CalenDayView()
    85 /*!
    87 // Destructor.
    86  \brief Destructor
    88 // -----------------------------------------------------------------------------
    87 */
    89 //
       
    90 CalenDayView::~CalenDayView()
    88 CalenDayView::~CalenDayView()
    91 {
    89 {
    92     mSettingsManager->stopMonitoring(mRegionalInfo);
    90     mSettingsManager->stopMonitoring(mRegionalInfo);
    93     if (mDocLoader) {
    91     if (mDocLoader) {
    94         delete mDocLoader;
    92         delete mDocLoader;
    95         mDocLoader = NULL;
    93         mDocLoader = NULL;
    96     }
    94     }
    97 }
    95 }
    98 
    96 
    99 // -----------------------------------------------------------------------------
    97 /*!
   100 // onLocaleChanged()
    98  \brief Handles locale change.
   101 // Handles locale change.
    99  
   102 // -----------------------------------------------------------------------------
   100  \param reason the reason of a change
   103 //
   101 */
   104 void CalenDayView::onLocaleChanged(int reason)
   102 void CalenDayView::onLocaleChanged(int reason)
   105 {
   103 {
   106     Q_UNUSED( reason )
   104     Q_UNUSED( reason )
   107 }
   105 }
   108 
   106 
   109 // -----------------------------------------------------------------------------
   107 /*!
   110 // From CalenView
   108  \brief Reimplemented from CalenView. Handles view (re)population
   111 // doPopulation()
   109 */
   112 // Handles view (re)population.
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 void CalenDayView::doPopulation()
   110 void CalenDayView::doPopulation()
   116 {
   111 {
   117     // Triggers fading effect for heading label
   112     // Triggers fading effect for heading label
   118     getCurrentDate();
   113     getCurrentDate();
   119     HbEffect::start(mHeadingLabel, "fadeOut", this, "setHeadingText");
   114     HbEffect::start(mHeadingLabel, "fadeOut", this, "setHeadingText");
   141     }
   136     }
   142 	
   137 	
   143     populationComplete();
   138     populationComplete();
   144 }
   139 }
   145 
   140 
   146 // -----------------------------------------------------------------------------
   141 /*!
   147 // From CalenView
   142  \brief Reimplemented from CalenView. Informs the organizer that the view's population is complete.
   148 // populationComplete()
   143 */
   149 // Informs the organizer that the view's population is complete.
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 void CalenDayView::populationComplete()
   144 void CalenDayView::populationComplete()
   153 {
   145 {
   154     CalenNativeView::populationComplete();
   146     CalenNativeView::populationComplete();
   155 }
   147 }
   156 
   148 
   157 // -----------------------------------------------------------------------------
   149 /*!
   158 // From MCalenNotificationHandler
   150  \brief Reimplemented from MCalenNotificationHandler. The function handles calendar notifications
   159 // HandleNotification()
   151  
   160 // The function handles calendar notifications.
   152  \param notification notification type
   161 // -----------------------------------------------------------------------------
   153 */
   162 //
       
   163 void CalenDayView::HandleNotification(const TCalenNotification notification)
   154 void CalenDayView::HandleNotification(const TCalenNotification notification)
   164 {
   155 {
   165     Q_UNUSED( notification )
   156     Q_UNUSED( notification )
   166 }
   157 }
   167 
   158 
   168 // -----------------------------------------------------------------------------
   159 
   169 // setupView()
   160 /*!
   170 // Sets up the view accroding to the 'xml'
   161  \brief Sets up the view accroding to the 'xml'
   171 // -----------------------------------------------------------------------------
   162  
   172 //
   163  \param docLoader Pointer to document loader
       
   164 */
   173 void CalenDayView::setupView(CalenDocLoader* docLoader)
   165 void CalenDayView::setupView(CalenDocLoader* docLoader)
   174 {
   166 {
   175     // Store document loader for further use
   167     // Store document loader for further use
   176     mDocLoader = docLoader;
   168     mDocLoader = docLoader;
   177 
   169 
   202     setupSlots();
   194     setupSlots();
   203 }
   195 }
   204 
   196 
   205 //private slots
   197 //private slots
   206 
   198 
   207 // -----------------------------------------------------------------------------
   199 /*!
   208 // onBack()
   200  \brief Handles 'back' functionality
   209 // Handles 'back' functionality;
   201 */
   210 // -----------------------------------------------------------------------------
       
   211 //
       
   212 void CalenDayView::onBack()
   202 void CalenDayView::onBack()
   213 {
   203 {
   214     TRAP_IGNORE(mServices.IssueCommandL(ECalenMonthView));
   204     TRAP_IGNORE(mServices.IssueCommandL(ECalenMonthView));
   215 }
   205 }
   216 
   206 
   217 // -----------------------------------------------------------------------------
   207 /*!
   218 // dayChange()
   208  \brief Slot that handles first phase of day change
   219 // -----------------------------------------------------------------------------
   209  
   220 //
   210  \param direction indicates to which day view needs to be scrolled (previous or next day)
       
   211 */
   221 void CalenDayView::dayChangeStarted(CalenScrollDirection direction)
   212 void CalenDayView::dayChangeStarted(CalenScrollDirection direction)
   222 {
   213 {
   223     if (direction == ECalenScrollToNext) {
   214     if (direction == ECalenScrollToNext) {
   224         mDate = mDate.addDays(1);	
   215         mDate = mDate.addDays(1);	
   225     }
   216     }
   241     HbEffect::start(mRegionalInfoGroupBox, "fadeOut", this, "showRegionalInformation");
   232     HbEffect::start(mRegionalInfoGroupBox, "fadeOut", this, "showRegionalInformation");
   242     
   233     
   243     mServices.Context().setFocusDate(mDate);
   234     mServices.Context().setFocusDate(mDate);
   244 }
   235 }
   245 
   236 
   246 // -----------------------------------------------------------------------------
   237 /*!
   247 // dayChanged()
   238  \brief Slot that is triggered when operation of day change is completed
   248 // -----------------------------------------------------------------------------
   239  
   249 //
   240  \param direction ndicates to which day view was scrolled (previous or next day)
       
   241 */
   250 void CalenDayView::dayChanged(CalenScrollDirection direction)
   242 void CalenDayView::dayChanged(CalenScrollDirection direction)
   251 {
   243 {
   252     mModelManager->viewsScrollingFinished(direction);
   244     mModelManager->viewsScrollingFinished(direction);
   253 	mHourScrollArea->setDateTime(mDate);
   245 	mHourScrollArea->setDateTime(mDate);
   254 }
   246 }
   255 
   247 
   256 // -----------------------------------------------------------------------------
   248 /*!
   257 // getCurrentDate()
   249  \brief Gets current date from context
   258 // -----------------------------------------------------------------------------
   250 */
   259 //
       
   260 void CalenDayView::getCurrentDate()
   251 void CalenDayView::getCurrentDate()
   261 {
   252 {
   262     mDate = CalenNativeView::mServices.Context().focusDateAndTime();
   253     mDate = CalenNativeView::mServices.Context().focusDateAndTime();
   263 }
   254 }
   264 
   255 
   265 // -----------------------------------------------------------------------------
   256 /*!
   266 // setupMenu()
   257  \brief Sets the menu for day view
   267 // -----------------------------------------------------------------------------
   258 */
   268 //
       
   269 void CalenDayView::setupMenu()
   259 void CalenDayView::setupMenu()
   270 {
   260 {
   271     menu()->addAction(hbTrId("txt_calendar_opt_new_event"), this, SLOT(runNewMeeting()));
   261     menu()->addAction(hbTrId("txt_calendar_opt_new_event"), this, SLOT(runNewMeeting()));
   272     //get pointer to this position, because need to change visibility
   262     //get pointer to this position, because need to change visibility
   273     mGoToTodayMenuAction = menu()->addAction(hbTrId("txt_calendar_opt_go_to_today"), this, SLOT(runGoToToday()));
   263     mGoToTodayMenuAction = menu()->addAction(hbTrId("txt_calendar_opt_go_to_today"), this, SLOT(runGoToToday()));
   283     	}
   273     	}
   284     menu()->addAction(hbTrId("txt_calendar_opt_settings"), this, SLOT(launchSettingsView()));
   274     menu()->addAction(hbTrId("txt_calendar_opt_settings"), this, SLOT(launchSettingsView()));
   285 }
   275 }
   286 
   276 
   287 /*!
   277 /*!
   288    \brief Ot change Day view to Agenda View
   278    \brief To change Day view to Agenda View
   289  */
   279  */
   290 void CalenDayView::runChangeToAgendaView()
   280 void CalenDayView::runChangeToAgendaView()
   291 {
   281 {
   292     changeView(ECalenAgendaView);
   282     changeView(ECalenAgendaView);
   293 }
   283 }
   298 void CalenDayView::runLunarData()
   288 void CalenDayView::runLunarData()
   299 {
   289 {
   300 	TRAP_IGNORE(mServices.IssueCommandL(ECalenRegionalPluginTapEvent));
   290 	TRAP_IGNORE(mServices.IssueCommandL(ECalenRegionalPluginTapEvent));
   301 }
   291 }
   302 
   292 
   303 // -----------------------------------------------------------------------------
   293 /*!
   304 // setupSlots()
   294    \brief This is a helper function to established connections between signals and slots
   305 // -----------------------------------------------------------------------------
   295 */
   306 //
       
   307 void CalenDayView::setupSlots()
   296 void CalenDayView::setupSlots()
   308 {
   297 {
   309     // Connecting other view-related signals/slots
   298     // Connecting other view-related signals/slots
   310     connect(mContentScrollArea,
   299     connect(mContentScrollArea,
   311         SIGNAL(scrollAreaMoveStarted(CalenScrollDirection)), this,
   300         SIGNAL(scrollAreaMoveStarted(CalenScrollDirection)), this,
   331     
   320     
   332     connect(mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)),
   321     connect(mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)),
   333         this, SLOT(showHideRegionalInformationChanged(XQSettingsKey, QVariant)));
   322         this, SLOT(showHideRegionalInformationChanged(XQSettingsKey, QVariant)));
   334 }
   323 }
   335 
   324 
   336 // -----------------------------------------------------------------------------
   325 /*!
   337 // runNewMeeting()
   326    \brief This slot triggers new meeting creation view
   338 // -----------------------------------------------------------------------------
   327 */
   339 //
       
   340 void CalenDayView::runNewMeeting()
   328 void CalenDayView::runNewMeeting()
   341 {
   329 {
   342     QDateTime dateTime(mDate);
   330     QDateTime dateTime(mDate);
   343     TRAP_IGNORE(
   331     TRAP_IGNORE(
   344         dateTime.setTime(mServices.Context().defaultCalTimeForViewsL().time());
   332         dateTime.setTime(mServices.Context().defaultCalTimeForViewsL().time());
   345         mServices.Context().setFocusDateAndTime(dateTime);
   333         mServices.Context().setFocusDateAndTime(dateTime);
   346         mServices.IssueCommandL(ECalenNewMeeting)
   334         mServices.IssueCommandL(ECalenNewMeeting)
   347     );
   335     );
   348 }
   336 }
   349 
   337 
   350 // -----------------------------------------------------------------------------
   338 /*!
   351 // runGoToToday()
   339    \brief This slot switches current view to today
   352 // -----------------------------------------------------------------------------
   340 */
   353 //
       
   354 void CalenDayView::runGoToToday()
   341 void CalenDayView::runGoToToday()
   355 {
   342 {
   356     mServices.Context().setFocusDateAndTime(CalenDateUtils::today());
   343     mServices.Context().setFocusDateAndTime(CalenDateUtils::today());
   357     TRAP_IGNORE(mServices.IssueCommandL(ECalenGotoToday));
   344     TRAP_IGNORE(mServices.IssueCommandL(ECalenGotoToday));
   358     refreshViewOnGoToDate();
   345     refreshViewOnGoToDate();
   359 }
   346 }
   360 
   347 
   361 
   348 
   362 // -----------------------------------------------------------------------------
   349 /*!
   363 // changeView()
   350    \brief This slot switches current view to the given by id
   364 // -----------------------------------------------------------------------------
   351    
   365 //
   352    \param viewId id of the view that needs to be displayed
       
   353 */
   366 void CalenDayView::changeView(TCalenCommandId viewId)
   354 void CalenDayView::changeView(TCalenCommandId viewId)
   367 {
   355 {
   368     TRAP_IGNORE(mServices.IssueCommandL(viewId));
   356     TRAP_IGNORE(mServices.IssueCommandL(viewId));
   369 }
   357 }
   370 
   358 
   371 // ----------------------------------------------------------------------------
   359 /*!
   372 // CalenDayView::setHeadingText
   360    \brief Sets heading text according to date from model and locale.
   373 // Sets heading text according to date from model and locale.
   361           It's connected to modelReset signal.
   374 // It's connected to modelReset signal
   362    
   375 // ----------------------------------------------------------------------------
   363    \param status Parameter required in order to call this slot autmatically
   376 //
   364                  when an effect is complete.
       
   365 */
   377 void CalenDayView::setHeadingText(const HbEffect::EffectStatus &status)
   366 void CalenDayView::setHeadingText(const HbEffect::EffectStatus &status)
   378 {   
   367 {   
   379     Q_UNUSED(status)
   368     Q_UNUSED(status)
   380 
   369 
   381     // Format the date as per the device locale settings
   370     // Format the date as per the device locale settings
   392         systemLocale.format(mDate.date(), r_qtn_date_usual_with_zero)));
   381         systemLocale.format(mDate.date(), r_qtn_date_usual_with_zero)));
   393 
   382 
   394     HbEffect::start(mHeadingLabel, "fadeIn");
   383     HbEffect::start(mHeadingLabel, "fadeIn");
   395 }
   384 }
   396 
   385 
   397 // ----------------------------------------------------------------------------
   386 /*!
   398 // CalenDayView::showHideRegionalInformation
   387    \brief Displays regional information
   399 // To run effect on lunar data label
   388    
   400 // ----------------------------------------------------------------------------
   389    \param status Parameter required in order to call this slot autmatically
   401 //
   390                  when an effect is complete.
       
   391 */
   402 void CalenDayView::showRegionalInformation(const HbEffect::EffectStatus &status)
   392 void CalenDayView::showRegionalInformation(const HbEffect::EffectStatus &status)
   403 {
   393 {
   404 	Q_UNUSED(status);
   394 	Q_UNUSED(status);
   405 	showRegionalInformationFadeIn();
   395 	showRegionalInformationFadeIn();
   406 }
   396 }
   407 
   397 
   408 // ----------------------------------------------------------------------------
   398 /*!
   409 // CalenDayView::showRegionalInformationFadeIn
   399    \brief Runs effect on lunar data label and change text according to date change.
   410 // To run effect on lunar data label and change text according to date change
   400 */
   411 // ----------------------------------------------------------------------------
       
   412 //
       
   413 void CalenDayView::showRegionalInformationFadeIn()
   401 void CalenDayView::showRegionalInformationFadeIn()
   414 	{
   402 {
   415 	showHideRegionalInformationChanged(mRegionalInfo, 3);
   403 	showHideRegionalInformationChanged(mRegionalInfo, 3);
   416 	HbEffect::start(mRegionalInfoGroupBox, "fadeIn");
   404 	HbEffect::start(mRegionalInfoGroupBox, "fadeIn");
   417 	}
   405 }
   418 
   406 
   419 // ----------------------------------------------------------------------------
   407 /*!
   420 // CalenDayView::showHideRegionalInformationChanged
   408    \brief To Show and hide regional plugin label depends upon settings.
   421 // To Show and hide regional plugin label depends upon settings
   409 */
   422 // ----------------------------------------------------------------------------
       
   423 //
       
   424 void CalenDayView::showHideRegionalInformationChanged(
   410 void CalenDayView::showHideRegionalInformationChanged(
   425     const XQSettingsKey& key,
   411     const XQSettingsKey& key,
   426     const QVariant&)
   412     const QVariant&)
   427 {
   413 {
   428     if (key.key() == mRegionalInfo.key()) {
   414     if (key.key() == mRegionalInfo.key()) {
   462             }
   448             }
   463         }
   449         }
   464     }
   450     }
   465 }
   451 }
   466 
   452 
   467 // ----------------------------------------------------------------------------
   453 /*!
   468 // CalenDayView::setupViewport
   454    \brief Scrolls view according to current day and events.
   469 // Scrolls view according to current day and events
   455 */
   470 // ----------------------------------------------------------------------------
       
   471 //
       
   472 void CalenDayView::setupViewport()
   456 void CalenDayView::setupViewport()
   473 {
   457 {
   474     QDateTime currentTime = QDateTime::currentDateTime();
   458     QDateTime currentTime = QDateTime::currentDateTime();
   475 
   459 
   476     // If we have event in current day and hour, scroll to this event
   460     // If we have event in current day and hour, scroll to this event