calendarui/views/dayview/src/calendayview.cpp
changeset 58 ef813d54df51
parent 50 579cc610882e
child 68 a5a1242fd2e8
equal deleted inserted replaced
50:579cc610882e 58:ef813d54df51
    13  *
    13  *
    14  * Description: CalenDayView class definition.
    14  * Description: CalenDayView class definition.
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 //system includes
    18 // System includes
    19 #include <QDateTime>
    19 #include <QDateTime>
    20 #include <QGraphicsLinearLayout>
    20 #include <QGraphicsLinearLayout>
    21 #include <xqsettingsmanager.h>
    21 #include <xqsettingsmanager.h>
       
    22 #include <HbWidget>
    22 #include <hbaction.h>
    23 #include <hbaction.h>
    23 #include <hbmenu.h>
    24 #include <hbmenu.h>
    24 #include <hbmainwindow.h>
    25 #include <hbmainwindow.h>
    25 #include <hbmodeliterator.h>
    26 #include <hbmodeliterator.h>
    26 #include <hbstyleloader.h>
    27 #include <hbstyleloader.h>
    27 #include <hbgroupbox.h>
    28 #include <hbgroupbox.h>
    28 #include <hbextendedlocale.h>
    29 #include <hbextendedlocale.h>
    29 #include <agendautil.h>
    30 #include <agendautil.h>
    30 //user includes
    31 
       
    32 // User includes
    31 #include "calendayview.h"
    33 #include "calendayview.h"
       
    34 #include "calencommon.h"
    32 #include "calencontext.h"
    35 #include "calencontext.h"
    33 #include "calenservices.h"
    36 #include "calenservices.h"
    34 #include "calendocloader.h"
    37 #include "calendocloader.h"
    35 #include "calendateutils.h" //useful date/time utils
    38 #include "calendateutils.h" //useful date/time utils
    36 #include "calendaycontentscrollarea.h"
    39 #include "calendaycontentscrollarea.h"
    42 #include "calenpluginlabel.h"
    45 #include "calenpluginlabel.h"
    43 #include "calendaymodel.h"
    46 #include "calendaymodel.h"
    44 
    47 
    45 //constants
    48 //constants
    46 
    49 
    47 // -----------------------------------------------------------------------------
    50 
    48 // CalenDayView()
    51 /*!
    49 // Constructor.
    52  \brief Constructor
    50 // -----------------------------------------------------------------------------
    53 */
    51 //
       
    52 CalenDayView::CalenDayView(MCalenServices &services) :
    54 CalenDayView::CalenDayView(MCalenServices &services) :
    53     CalenNativeView(services), mContentScrollArea(NULL), mContentWidget(NULL),
    55     CalenNativeView(services), mContentScrollArea(NULL), mContentWidget(NULL),
    54     mHourScrollArea(NULL), mSettingsManager(NULL),
    56         mHourScrollArea(NULL), mVLayout(NULL), mDocLoader(NULL), mIsLaunching(
    55     mRegionalInfo(XQSettingsKey::TargetCentralRepository, KCRUidCalendar, 
    57             true), mSettingsManager(NULL), mRegionalInfo(
    56             KCalendarShowRegionalInfo), 
    58             XQSettingsKey::TargetCentralRepository, KCRUidCalendar,
    57     mServices(services), mRegionalInfoGroupBox(NULL), mGoToTodayMenuAction(NULL)
    59             KCalendarShowRegionalInfo), mServices(services),
       
    60         mRegionalInfoGroupBox(NULL), mGoToTodayMenuAction(NULL)
    58 {
    61 {
    59     setupMenu();
    62     setupMenu();
    60     
    63 
    61     // Create model manager
    64     // Create model manager
    62     mModelManager = new CalenDayModelManager(mServices, true, this);   
    65     mModelManager = new CalenDayModelManager(mServices, true, this);
    63     
       
    64     mVLayout = new QGraphicsLinearLayout(Qt::Vertical, NULL);
       
    65     mVLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0);
       
    66     mVLayout->setSpacing(0.0);    
       
    67       
       
    68     // Create heading label and insert into layout
       
    69     mHeadingLabel = new HbGroupBox();
       
    70     HbEffect::add(mHeadingLabel, ":/fade_out.fxml", "fadeOut");
       
    71     HbEffect::add(mHeadingLabel, ":/fade_in.fxml", "fadeIn");
       
    72     
       
    73     mSettingsManager = new XQSettingsManager(this);
    66     mSettingsManager = new XQSettingsManager(this);
    74 
       
    75     // Add day info
       
    76     mVLayout->addItem(mHeadingLabel);
       
    77     
       
    78     //show regional info if set so
       
    79     showRegionalInformationFadeIn();
       
    80     mSettingsManager->startMonitoring(mRegionalInfo);
    67     mSettingsManager->startMonitoring(mRegionalInfo);
    81     
       
    82     // Put hour scroll area and content scroll area into horizontal layout
       
    83     QGraphicsLinearLayout *hLayout = new QGraphicsLinearLayout(Qt::Horizontal, NULL);
       
    84     hLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0);
       
    85     hLayout->setSpacing(0.0);
       
    86     
       
    87     // Create scroll area for content (events)
       
    88     mContentScrollArea = new CalenDayContentScrollArea(this);
       
    89 
       
    90     // Create and apply central widget for scroll area
       
    91     mContentWidget = new CalenDayContentWidget(*mModelManager, mContentScrollArea);
       
    92     mContentScrollArea->setContentWidget(mContentWidget);
       
    93     
       
    94     // Create scroll area for hour elements
       
    95     mHourScrollArea = new CalenDayHourScrollArea(this);
       
    96         
       
    97     hLayout->addItem(mHourScrollArea);
       
    98     hLayout->addItem(mContentScrollArea);
       
    99     
       
   100     mVLayout->addItem(hLayout);
       
   101     setLayout(mVLayout);
       
   102     
       
   103     setupSlots();
       
   104 
    68 
   105     //setup Back functionality
    69     //setup Back functionality
   106     if (ECalenDayView != mServices.getFirstView()) {
    70     if (ECalenDayView != mServices.getFirstView()) {
   107         HbAction* action = new HbAction(Hb::BackNaviAction, this);
    71         HbAction* action = new HbAction(Hb::BackNaviAction, this);
   108         setNavigationAction(action);
    72         setNavigationAction(action);
   112 
    76 
   113     HbStyleLoader::registerFilePath(":/calendayhourelement.css");
    77     HbStyleLoader::registerFilePath(":/calendayhourelement.css");
   114     HbStyleLoader::registerFilePath(":/calendayhourelement.widgetml");
    78     HbStyleLoader::registerFilePath(":/calendayhourelement.widgetml");
   115     HbStyleLoader::registerFilePath(":/calendayitem.css");
    79     HbStyleLoader::registerFilePath(":/calendayitem.css");
   116     HbStyleLoader::registerFilePath(":/calendayitem.widgetml");
    80     HbStyleLoader::registerFilePath(":/calendayitem.widgetml");
   117 }
    81     HbStyleLoader::registerFilePath(":/calendayeventspane.css");
   118 
    82     HbStyleLoader::registerFilePath(":/calendayhourscrollarea.css");
   119 // -----------------------------------------------------------------------------
    83 }
   120 // ~CalenDayView()
    84 
   121 // Destructor.
    85 /*!
   122 // -----------------------------------------------------------------------------
    86  \brief Destructor
   123 //
    87 */
   124 CalenDayView::~CalenDayView()
    88 CalenDayView::~CalenDayView()
   125 {
    89 {
   126 	mSettingsManager->stopMonitoring(mRegionalInfo);
    90     mSettingsManager->stopMonitoring(mRegionalInfo);
   127 }
    91     if (mDocLoader) {
   128 
    92         delete mDocLoader;
   129 // -----------------------------------------------------------------------------
    93         mDocLoader = NULL;
   130 // onLocaleChanged()
    94     }
   131 // Handles locale change.
    95 }
   132 // -----------------------------------------------------------------------------
    96 
   133 //
    97 /*!
       
    98  \brief Handles locale change.
       
    99  
       
   100  \param reason the reason of a change
       
   101 */
   134 void CalenDayView::onLocaleChanged(int reason)
   102 void CalenDayView::onLocaleChanged(int reason)
   135 {
   103 {
   136     Q_UNUSED( reason )
   104     Q_UNUSED( reason )
   137 }
   105 }
   138 
   106 
   139 // -----------------------------------------------------------------------------
   107 /*!
   140 // From CalenView
   108  \brief Reimplemented from CalenView. Handles view (re)population
   141 // doPopulation()
   109 */
   142 // Handles view (re)population.
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 void CalenDayView::doPopulation()
   110 void CalenDayView::doPopulation()
   146 {
   111 {
   147     // Triggers fading effect for heading label
   112     // Triggers fading effect for heading label
   148     getCurrentDate();
   113     getCurrentDate();
   149     HbEffect::start(mHeadingLabel, "fadeOut", this, "setHeadingText");
   114     HbEffect::start(mHeadingLabel, "fadeOut", this, "setHeadingText");
   160     }
   125     }
   161     else if(mGoToTodayMenuAction) {
   126     else if(mGoToTodayMenuAction) {
   162         mGoToTodayMenuAction->setVisible(true);
   127         mGoToTodayMenuAction->setVisible(true);
   163     }
   128     }
   164     
   129     
   165 	setupViewport();
   130     // Call async. if the view is loaded first time (fix to ou1cimx1#482516)
       
   131     if (mIsLaunching) {
       
   132         mIsLaunching = false;
       
   133         QMetaObject::invokeMethod(this, "setupViewport", Qt::QueuedConnection);
       
   134     } else {
       
   135         setupViewport();
       
   136     }
   166 	
   137 	
   167     populationComplete();
   138     populationComplete();
   168 }
   139 }
   169 
   140 
   170 // -----------------------------------------------------------------------------
   141 /*!
   171 // From CalenView
   142  \brief Reimplemented from CalenView. Informs the organizer that the view's population is complete.
   172 // populationComplete()
   143 */
   173 // Informs the organizer that the view's population is complete.
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 void CalenDayView::populationComplete()
   144 void CalenDayView::populationComplete()
   177 {
   145 {
   178     CalenNativeView::populationComplete();
   146     CalenNativeView::populationComplete();
   179 }
   147 }
   180 
   148 
   181 // -----------------------------------------------------------------------------
   149 /*!
   182 // From MCalenNotificationHandler
   150  \brief Reimplemented from MCalenNotificationHandler. The function handles calendar notifications
   183 // HandleNotification()
   151  
   184 // The function handles calendar notifications.
   152  \param notification notification type
   185 // -----------------------------------------------------------------------------
   153 */
   186 //
       
   187 void CalenDayView::HandleNotification(const TCalenNotification notification)
   154 void CalenDayView::HandleNotification(const TCalenNotification notification)
   188 {
   155 {
   189     Q_UNUSED( notification )
   156     Q_UNUSED( notification )
   190 }
   157 }
   191 
   158 
   192 // -----------------------------------------------------------------------------
   159 
   193 // setupView()
   160 /*!
   194 // Sets up the view accroding to the 'xml'
   161  \brief Sets up the view accroding to the 'xml'
   195 // -----------------------------------------------------------------------------
   162  
   196 //
   163  \param docLoader Pointer to document loader
       
   164 */
   197 void CalenDayView::setupView(CalenDocLoader* docLoader)
   165 void CalenDayView::setupView(CalenDocLoader* docLoader)
   198 {
   166 {
   199     Q_UNUSED( docLoader )
   167     // Store document loader for further use
       
   168     mDocLoader = docLoader;
       
   169 
       
   170     // Get vertical layout from day view
       
   171     mVLayout = static_cast<QGraphicsLinearLayout *> (this->layout());
       
   172 
       
   173     // Set up day info
       
   174     mHeadingLabel = qobject_cast<HbGroupBox *> (mDocLoader->findWidget(
       
   175         CALEN_DAYVIEW_DAYINFO));
       
   176     HbEffect::add(mHeadingLabel, ":/fade_out.fxml", "fadeOut");
       
   177     HbEffect::add(mHeadingLabel, ":/fade_in.fxml", "fadeIn");
       
   178 
       
   179     // Set up hour scroll area
       
   180     mHourScrollArea
       
   181         = static_cast<CalenDayHourScrollArea *> (mDocLoader->findWidget(
       
   182             CALEN_DAYVIEW_HOURSCROLLAREA));
       
   183 
       
   184     // Set up content scroll area
       
   185     mContentScrollArea
       
   186         = static_cast<CalenDayContentScrollArea *> (mDocLoader->findWidget(
       
   187             CALEN_DAYVIEW_CONTENTSCROLLAREA));
       
   188     mContentWidget = new CalenDayContentWidget(*mModelManager, NULL);
       
   189     mContentScrollArea->setContentWidget(mContentWidget);
       
   190 
       
   191     // Set up regional info if variant is correct
       
   192     showRegionalInformationFadeIn();
       
   193 
       
   194     setupSlots();
   200 }
   195 }
   201 
   196 
   202 //private slots
   197 //private slots
   203 
   198 
   204 // -----------------------------------------------------------------------------
   199 /*!
   205 // onBack()
   200  \brief Handles 'back' functionality
   206 // Handles 'back' functionality;
   201 */
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 void CalenDayView::onBack()
   202 void CalenDayView::onBack()
   210 {
   203 {
   211     TRAP_IGNORE(mServices.IssueCommandL(ECalenMonthView));
   204     TRAP_IGNORE(mServices.IssueCommandL(ECalenMonthView));
   212 }
   205 }
   213 
   206 
   214 // -----------------------------------------------------------------------------
   207 /*!
   215 // dayChange()
   208  \brief Slot that handles first phase of day change
   216 // -----------------------------------------------------------------------------
   209  
   217 //
   210  \param direction indicates to which day view needs to be scrolled (previous or next day)
       
   211 */
   218 void CalenDayView::dayChangeStarted(CalenScrollDirection direction)
   212 void CalenDayView::dayChangeStarted(CalenScrollDirection direction)
   219 {
   213 {
   220     if (direction == ECalenScrollToNext) {
   214     if (direction == ECalenScrollToNext) {
   221         mDate = mDate.addDays(1);	
   215         mDate = mDate.addDays(1);	
   222     }
   216     }
   238     HbEffect::start(mRegionalInfoGroupBox, "fadeOut", this, "showRegionalInformation");
   232     HbEffect::start(mRegionalInfoGroupBox, "fadeOut", this, "showRegionalInformation");
   239     
   233     
   240     mServices.Context().setFocusDate(mDate);
   234     mServices.Context().setFocusDate(mDate);
   241 }
   235 }
   242 
   236 
   243 // -----------------------------------------------------------------------------
   237 /*!
   244 // dayChanged()
   238  \brief Slot that is triggered when operation of day change is completed
   245 // -----------------------------------------------------------------------------
   239  
   246 //
   240  \param direction ndicates to which day view was scrolled (previous or next day)
       
   241 */
   247 void CalenDayView::dayChanged(CalenScrollDirection direction)
   242 void CalenDayView::dayChanged(CalenScrollDirection direction)
   248 {
   243 {
   249     mModelManager->viewsScrollingFinished(direction);
   244     mModelManager->viewsScrollingFinished(direction);
   250 	mHourScrollArea->setDateTime(mDate);
   245 	mHourScrollArea->setDateTime(mDate);
   251 }
   246 }
   252 
   247 
   253 // -----------------------------------------------------------------------------
   248 /*!
   254 // getCurrentDate()
   249  \brief Gets current date from context
   255 // -----------------------------------------------------------------------------
   250 */
   256 //
       
   257 void CalenDayView::getCurrentDate()
   251 void CalenDayView::getCurrentDate()
   258 {
   252 {
   259     mDate = CalenNativeView::mServices.Context().focusDateAndTime();
   253     mDate = CalenNativeView::mServices.Context().focusDateAndTime();
   260 }
   254 }
   261 
   255 
   262 // -----------------------------------------------------------------------------
   256 /*!
   263 // setupMenu()
   257  \brief Sets the menu for day view
   264 // -----------------------------------------------------------------------------
   258 */
   265 //
       
   266 void CalenDayView::setupMenu()
   259 void CalenDayView::setupMenu()
   267 {
   260 {
   268     menu()->addAction(hbTrId("txt_calendar_opt_new_event"), this, SLOT(runNewMeeting()));
   261     menu()->addAction(hbTrId("txt_calendar_opt_new_event"), this, SLOT(runNewMeeting()));
   269     //get pointer to this position, because need to change visibility
   262     //get pointer to this position, because need to change visibility
   270     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()));
   280     	}
   273     	}
   281     menu()->addAction(hbTrId("txt_calendar_opt_settings"), this, SLOT(launchSettingsView()));
   274     menu()->addAction(hbTrId("txt_calendar_opt_settings"), this, SLOT(launchSettingsView()));
   282 }
   275 }
   283 
   276 
   284 /*!
   277 /*!
   285    \brief Ot change Day view to Agenda View
   278    \brief To change Day view to Agenda View
   286  */
   279  */
   287 void CalenDayView::runChangeToAgendaView()
   280 void CalenDayView::runChangeToAgendaView()
   288 {
   281 {
   289     changeView(ECalenAgendaView);
   282     changeView(ECalenAgendaView);
   290 }
   283 }
   295 void CalenDayView::runLunarData()
   288 void CalenDayView::runLunarData()
   296 {
   289 {
   297 	TRAP_IGNORE(mServices.IssueCommandL(ECalenRegionalPluginTapEvent));
   290 	TRAP_IGNORE(mServices.IssueCommandL(ECalenRegionalPluginTapEvent));
   298 }
   291 }
   299 
   292 
   300 // -----------------------------------------------------------------------------
   293 /*!
   301 // setupSlots()
   294    \brief This is a helper function to established connections between signals and slots
   302 // -----------------------------------------------------------------------------
   295 */
   303 //
       
   304 void CalenDayView::setupSlots()
   296 void CalenDayView::setupSlots()
   305 {
   297 {
   306     // Connecting other view-related signals/slots
   298     // Connecting other view-related signals/slots
   307     connect(mContentScrollArea,
   299     connect(mContentScrollArea,
   308         SIGNAL(scrollAreaMoveStarted(CalenScrollDirection)), this,
   300         SIGNAL(scrollAreaMoveStarted(CalenScrollDirection)), this,
   328     
   320     
   329     connect(mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)),
   321     connect(mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)),
   330         this, SLOT(showHideRegionalInformationChanged(XQSettingsKey, QVariant)));
   322         this, SLOT(showHideRegionalInformationChanged(XQSettingsKey, QVariant)));
   331 }
   323 }
   332 
   324 
   333 // -----------------------------------------------------------------------------
   325 /*!
   334 // runNewMeeting()
   326    \brief This slot triggers new meeting creation view
   335 // -----------------------------------------------------------------------------
   327 */
   336 //
       
   337 void CalenDayView::runNewMeeting()
   328 void CalenDayView::runNewMeeting()
   338 {
   329 {
   339     QDateTime dateTime(mDate);
   330     QDateTime dateTime(mDate);
   340     TRAP_IGNORE(
   331     TRAP_IGNORE(
   341         dateTime.setTime(mServices.Context().defaultCalTimeForViewsL().time());
   332         dateTime.setTime(mServices.Context().defaultCalTimeForViewsL().time());
   342         mServices.Context().setFocusDateAndTime(dateTime);
   333         mServices.Context().setFocusDateAndTime(dateTime);
   343         mServices.IssueCommandL(ECalenNewMeeting)
   334         mServices.IssueCommandL(ECalenNewMeeting)
   344             );
   335     );
   345 }
   336 }
   346 
   337 
   347 // -----------------------------------------------------------------------------
   338 /*!
   348 // runGoToToday()
   339    \brief This slot switches current view to today
   349 // -----------------------------------------------------------------------------
   340 */
   350 //
       
   351 void CalenDayView::runGoToToday()
   341 void CalenDayView::runGoToToday()
   352 {
   342 {
   353     mServices.Context().setFocusDateAndTime(CalenDateUtils::today());
   343     mServices.Context().setFocusDateAndTime(CalenDateUtils::today());
   354     TRAP_IGNORE(mServices.IssueCommandL(ECalenGotoToday));
   344     TRAP_IGNORE(mServices.IssueCommandL(ECalenGotoToday));
   355     refreshViewOnGoToDate();
   345     refreshViewOnGoToDate();
   356 }
   346 }
   357 
   347 
   358 
   348 
   359 // -----------------------------------------------------------------------------
   349 /*!
   360 // changeView()
   350    \brief This slot switches current view to the given by id
   361 // -----------------------------------------------------------------------------
   351    
   362 //
   352    \param viewId id of the view that needs to be displayed
       
   353 */
   363 void CalenDayView::changeView(TCalenCommandId viewId)
   354 void CalenDayView::changeView(TCalenCommandId viewId)
   364 {
   355 {
   365     TRAP_IGNORE(mServices.IssueCommandL(viewId));
   356     TRAP_IGNORE(mServices.IssueCommandL(viewId));
   366 }
   357 }
   367 
   358 
   368 // ----------------------------------------------------------------------------
   359 /*!
   369 // CalenDayView::setHeadingText
   360    \brief Sets heading text according to date from model and locale.
   370 // Sets heading text according to date from model and locale.
   361           It's connected to modelReset signal.
   371 // It's connected to modelReset signal
   362    
   372 // ----------------------------------------------------------------------------
   363    \param status Parameter required in order to call this slot autmatically
   373 //
   364                  when an effect is complete.
       
   365 */
   374 void CalenDayView::setHeadingText(const HbEffect::EffectStatus &status)
   366 void CalenDayView::setHeadingText(const HbEffect::EffectStatus &status)
   375 {   
   367 {   
   376     Q_UNUSED(status)
   368     Q_UNUSED(status)
   377 
   369 
   378     // Format the date as per the device locale settings
   370     // Format the date as per the device locale settings
   389         systemLocale.format(mDate.date(), r_qtn_date_usual_with_zero)));
   381         systemLocale.format(mDate.date(), r_qtn_date_usual_with_zero)));
   390 
   382 
   391     HbEffect::start(mHeadingLabel, "fadeIn");
   383     HbEffect::start(mHeadingLabel, "fadeIn");
   392 }
   384 }
   393 
   385 
   394 // ----------------------------------------------------------------------------
   386 /*!
   395 // CalenDayView::showHideRegionalInformation
   387    \brief Displays regional information
   396 // To run effect on lunar data label
   388    
   397 // ----------------------------------------------------------------------------
   389    \param status Parameter required in order to call this slot autmatically
   398 //
   390                  when an effect is complete.
       
   391 */
   399 void CalenDayView::showRegionalInformation(const HbEffect::EffectStatus &status)
   392 void CalenDayView::showRegionalInformation(const HbEffect::EffectStatus &status)
   400 {
   393 {
   401 	Q_UNUSED(status);
   394 	Q_UNUSED(status);
   402 	showRegionalInformationFadeIn();
   395 	showRegionalInformationFadeIn();
   403 }
   396 }
   404 
   397 
   405 // ----------------------------------------------------------------------------
   398 /*!
   406 // CalenDayView::showRegionalInformationFadeIn
   399    \brief Runs effect on lunar data label and change text according to date change.
   407 // To run effect on lunar data label and change text according to date change
   400 */
   408 // ----------------------------------------------------------------------------
       
   409 //
       
   410 void CalenDayView::showRegionalInformationFadeIn()
   401 void CalenDayView::showRegionalInformationFadeIn()
   411 	{
   402 {
   412 	showHideRegionalInformationChanged(mRegionalInfo, 3);
   403 	showHideRegionalInformationChanged(mRegionalInfo, 3);
   413 	HbEffect::start(mRegionalInfoGroupBox, "fadeIn");
   404 	HbEffect::start(mRegionalInfoGroupBox, "fadeIn");
   414 	}
   405 }
   415 
   406 
   416 // ----------------------------------------------------------------------------
   407 /*!
   417 // CalenDayView::showHideRegionalInformationChanged
   408    \brief To Show and hide regional plugin label depends upon settings.
   418 // To Show and hide regional plugin label depends upon settings
   409 */
   419 // ----------------------------------------------------------------------------
   410 void CalenDayView::showHideRegionalInformationChanged(
   420 //
   411     const XQSettingsKey& key,
   421 void CalenDayView::showHideRegionalInformationChanged(const XQSettingsKey& key, const QVariant&)
   412     const QVariant&)
   422 	{
   413 {
   423 	if (key.key() == mRegionalInfo.key())
   414     if (key.key() == mRegionalInfo.key()) {
   424 		{
   415         int showRegionalInfo =
   425 		int showRegionalInfo =
   416             mSettingsManager->readItemValue(mRegionalInfo).toUInt();
   426 				mSettingsManager->readItemValue(mRegionalInfo).toUInt();
   417 
   427 
   418         if (showRegionalInfo) {
   428 		if (showRegionalInfo)
   419             QString *pluginString = pluginText();
   429 			{
   420             if (pluginString) {
   430 			QString *pluginString = pluginText();
   421                 if (!mRegionalInfoGroupBox) {
   431 			if (pluginString)
   422                     mRegionalInfoGroupBox = qobject_cast<HbGroupBox *> (
   432 				{
   423                         mDocLoader->findWidget(CALEN_DAYVIEW_REGIONALINFO));
   433 				if (!mRegionalInfoGroupBox)
   424                     CalenPluginLabel *regionalInfo = new CalenPluginLabel(
   434 					{
   425                         mServices, this);
   435 					mRegionalInfoGroupBox = new HbGroupBox();
   426                     HbEffect::add(mRegionalInfoGroupBox, ":/fade_out.fxml",
   436 					CalenPluginLabel *regionalInfo = new CalenPluginLabel(
   427                         "fadeOut");
   437 							mServices, this);
   428                     HbEffect::add(mRegionalInfoGroupBox, ":/fade_in.fxml",
   438 					HbEffect::add(mRegionalInfoGroupBox, ":/fade_out.fxml",
   429                         "fadeIn");
   439 							"fadeOut");
   430                     regionalInfo->setContentsMargins(1, 1, 1, 1);
   440 					HbEffect::add(mRegionalInfoGroupBox, ":/fade_in.fxml", "fadeIn");
   431                     mRegionalInfoGroupBox->setContentWidget(regionalInfo);
   441 
   432                 }
   442 					// add margins to calenpluginlabel
   433 
   443 
   434                 if (pluginEnabled()) {
   444 					HbStyle style;
   435                     HbLabel *pluginInfoLabel = qobject_cast<HbLabel *> (
   445 					HbDeviceProfile deviceProfile;
   436                         mRegionalInfoGroupBox->contentWidget());
   446 					qreal marginLeft = 0.0;
   437 
   447 					qreal marginRight = 0.0;
   438                     pluginInfoLabel->setPlainText(*pluginString);
   448 					qreal marginTop = 0.0;
   439                     mVLayout->insertItem(1, mRegionalInfoGroupBox);
   449 					qreal marginBottom = 0.0;
   440                 }
   450 					style.parameter(QString("hb-param-margin-gene-left"), marginLeft, deviceProfile);
   441             }
   451 					style.parameter(QString("hb-param-margin-gene-right"), marginRight, deviceProfile);
   442         }
   452 					style.parameter(QString("hb-param-margin-gene-top"), marginTop, deviceProfile);
   443         else {
   453 					style.parameter(QString("hb-param-margin-gene-bottom"), marginBottom, deviceProfile);
   444             if (mRegionalInfoGroupBox) {
   454 
   445                 mVLayout->removeItem(mRegionalInfoGroupBox);
   455 					regionalInfo->setContentsMargins(1, 1, 1, 1);
   446                 delete mRegionalInfoGroupBox;
   456 
   447                 mRegionalInfoGroupBox = NULL;
   457 					//	qreal width = mRegionalInfoGroupBox->size().width();
   448             }
   458 					//	qreal height = mRegionalInfoGroupBox->size().height() + marginTop + marginBottom;
   449         }
   459 
   450     }
   460 					//	mRegionalInfoGroupBox->resize(width, height);
   451 }
   461 
   452 
   462 					mRegionalInfoGroupBox->setContentWidget(regionalInfo);
   453 /*!
   463 					}
   454    \brief Scrolls view according to current day and events.
   464 
   455 */
   465 				if (pluginEnabled())
       
   466 					{
       
   467 					HbLabel *pluginInfoLabel = qobject_cast<HbLabel *> (
       
   468 							mRegionalInfoGroupBox->contentWidget());
       
   469 
       
   470 					pluginInfoLabel->setPlainText(*pluginString);
       
   471 
       
   472 					mVLayout->insertItem(1, mRegionalInfoGroupBox);
       
   473 					}
       
   474 				}
       
   475 			}
       
   476 		else
       
   477 			{
       
   478 
       
   479 			if (mRegionalInfoGroupBox)
       
   480 				{
       
   481 				mVLayout->removeItem(mRegionalInfoGroupBox);
       
   482 				delete mRegionalInfoGroupBox;
       
   483 				mRegionalInfoGroupBox = NULL;
       
   484 				}
       
   485 			}
       
   486 		}
       
   487 	}
       
   488 
       
   489 // ----------------------------------------------------------------------------
       
   490 // CalenDayView::setupViewport
       
   491 // Scrolls view according to current day and events
       
   492 // ----------------------------------------------------------------------------
       
   493 //
       
   494 void CalenDayView::setupViewport()
   456 void CalenDayView::setupViewport()
   495 {
   457 {
   496     QDateTime currentTime = QDateTime::currentDateTime();
   458     QDateTime currentTime = QDateTime::currentDateTime();
   497     
   459 
   498     //Filter flags (only timed events)
       
   499 	AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags(
       
   500 			AgendaUtil::IncludeAppointments );
       
   501 	QList<AgendaEntry> list;
       
   502 	// Fetch the instance list from the agenda interface
       
   503 	list = mServices.agendaInterface()->fetchEntriesInRange(currentTime, currentTime, filter);
       
   504     
       
   505     // 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
   506     if(mDate.date() == currentTime.date() && !list.isEmpty()){
   461     if (mDate.date() == currentTime.date()){
   507     	int hourToScrollTo(list.first().startTime().time().hour());
   462 
   508         mHourScrollArea->scrollToHour(hourToScrollTo);
   463         QDateTime midnight = currentTime;
   509     }
   464         midnight.setTime(QTime(23, 59));
   510     else{
   465 
       
   466         //Filter flags (only timed events)
       
   467         AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags(AgendaUtil::IncludeAppointments);
       
   468         QList<AgendaEntry> list;
       
   469         // Fetch the instance list from the agenda interface
       
   470         list = mServices.agendaInterface()->fetchEntriesInRange(currentTime, midnight, filter);
       
   471 
       
   472         if(!list.isEmpty()){
       
   473             int hourToScrollTo(list.first().startTime().time().hour());
       
   474             mHourScrollArea->scrollToHour(hourToScrollTo);           
       
   475         }
       
   476         else{
       
   477             mHourScrollArea->scrollToHour(currentTime.time().hour());
       
   478         }
       
   479     }
       
   480     else {
   511         //Scroll view to 7am
   481         //Scroll view to 7am
   512         mHourScrollArea->scrollToHour(7);
   482         mHourScrollArea->scrollToHour(7);
   513     }
   483     }
   514 }
   484 }
   515 
   485