--- a/calendarui/views/dayview/src/calendayview.cpp Tue Jul 06 14:14:56 2010 +0300
+++ b/calendarui/views/dayview/src/calendayview.cpp Wed Aug 18 09:47:38 2010 +0300
@@ -15,10 +15,11 @@
*
*/
-//system includes
+// System includes
#include <QDateTime>
#include <QGraphicsLinearLayout>
#include <xqsettingsmanager.h>
+#include <HbWidget>
#include <hbaction.h>
#include <hbmenu.h>
#include <hbmainwindow.h>
@@ -27,8 +28,10 @@
#include <hbgroupbox.h>
#include <hbextendedlocale.h>
#include <agendautil.h>
-//user includes
+
+// User includes
#include "calendayview.h"
+#include "calencommon.h"
#include "calencontext.h"
#include "calenservices.h"
#include "calendocloader.h"
@@ -44,63 +47,24 @@
//constants
-// -----------------------------------------------------------------------------
-// CalenDayView()
-// Constructor.
-// -----------------------------------------------------------------------------
-//
+
+/*!
+ \brief Constructor
+*/
CalenDayView::CalenDayView(MCalenServices &services) :
CalenNativeView(services), mContentScrollArea(NULL), mContentWidget(NULL),
- mHourScrollArea(NULL), mSettingsManager(NULL),
- mRegionalInfo(XQSettingsKey::TargetCentralRepository, KCRUidCalendar,
- KCalendarShowRegionalInfo),
- mServices(services), mRegionalInfoGroupBox(NULL), mGoToTodayMenuAction(NULL)
+ mHourScrollArea(NULL), mVLayout(NULL), mDocLoader(NULL), mIsLaunching(
+ true), mSettingsManager(NULL), mRegionalInfo(
+ XQSettingsKey::TargetCentralRepository, KCRUidCalendar,
+ KCalendarShowRegionalInfo), mServices(services),
+ mRegionalInfoGroupBox(NULL), mGoToTodayMenuAction(NULL)
{
setupMenu();
-
+
// Create model manager
- mModelManager = new CalenDayModelManager(mServices, true, this);
-
- mVLayout = new QGraphicsLinearLayout(Qt::Vertical, NULL);
- mVLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0);
- mVLayout->setSpacing(0.0);
-
- // Create heading label and insert into layout
- mHeadingLabel = new HbGroupBox();
- HbEffect::add(mHeadingLabel, ":/fade_out.fxml", "fadeOut");
- HbEffect::add(mHeadingLabel, ":/fade_in.fxml", "fadeIn");
-
+ mModelManager = new CalenDayModelManager(mServices, true, this);
mSettingsManager = new XQSettingsManager(this);
-
- // Add day info
- mVLayout->addItem(mHeadingLabel);
-
- //show regional info if set so
- showRegionalInformationFadeIn();
mSettingsManager->startMonitoring(mRegionalInfo);
-
- // Put hour scroll area and content scroll area into horizontal layout
- QGraphicsLinearLayout *hLayout = new QGraphicsLinearLayout(Qt::Horizontal, NULL);
- hLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0);
- hLayout->setSpacing(0.0);
-
- // Create scroll area for content (events)
- mContentScrollArea = new CalenDayContentScrollArea(this);
-
- // Create and apply central widget for scroll area
- mContentWidget = new CalenDayContentWidget(*mModelManager, mContentScrollArea);
- mContentScrollArea->setContentWidget(mContentWidget);
-
- // Create scroll area for hour elements
- mHourScrollArea = new CalenDayHourScrollArea(this);
-
- hLayout->addItem(mHourScrollArea);
- hLayout->addItem(mContentScrollArea);
-
- mVLayout->addItem(hLayout);
- setLayout(mVLayout);
-
- setupSlots();
//setup Back functionality
if (ECalenDayView != mServices.getFirstView()) {
@@ -114,34 +78,35 @@
HbStyleLoader::registerFilePath(":/calendayhourelement.widgetml");
HbStyleLoader::registerFilePath(":/calendayitem.css");
HbStyleLoader::registerFilePath(":/calendayitem.widgetml");
+ HbStyleLoader::registerFilePath(":/calendayeventspane.css");
+ HbStyleLoader::registerFilePath(":/calendayhourscrollarea.css");
}
-// -----------------------------------------------------------------------------
-// ~CalenDayView()
-// Destructor.
-// -----------------------------------------------------------------------------
-//
+/*!
+ \brief Destructor
+*/
CalenDayView::~CalenDayView()
{
- mSettingsManager->stopMonitoring(mRegionalInfo);
+ mSettingsManager->stopMonitoring(mRegionalInfo);
+ if (mDocLoader) {
+ delete mDocLoader;
+ mDocLoader = NULL;
+ }
}
-// -----------------------------------------------------------------------------
-// onLocaleChanged()
-// Handles locale change.
-// -----------------------------------------------------------------------------
-//
+/*!
+ \brief Handles locale change.
+
+ \param reason the reason of a change
+*/
void CalenDayView::onLocaleChanged(int reason)
{
Q_UNUSED( reason )
}
-// -----------------------------------------------------------------------------
-// From CalenView
-// doPopulation()
-// Handles view (re)population.
-// -----------------------------------------------------------------------------
-//
+/*!
+ \brief Reimplemented from CalenView. Handles view (re)population
+*/
void CalenDayView::doPopulation()
{
// Triggers fading effect for heading label
@@ -162,59 +127,88 @@
mGoToTodayMenuAction->setVisible(true);
}
- setupViewport();
+ // Call async. if the view is loaded first time (fix to ou1cimx1#482516)
+ if (mIsLaunching) {
+ mIsLaunching = false;
+ QMetaObject::invokeMethod(this, "setupViewport", Qt::QueuedConnection);
+ } else {
+ setupViewport();
+ }
populationComplete();
}
-// -----------------------------------------------------------------------------
-// From CalenView
-// populationComplete()
-// Informs the organizer that the view's population is complete.
-// -----------------------------------------------------------------------------
-//
+/*!
+ \brief Reimplemented from CalenView. Informs the organizer that the view's population is complete.
+*/
void CalenDayView::populationComplete()
{
CalenNativeView::populationComplete();
}
-// -----------------------------------------------------------------------------
-// From MCalenNotificationHandler
-// HandleNotification()
-// The function handles calendar notifications.
-// -----------------------------------------------------------------------------
-//
+/*!
+ \brief Reimplemented from MCalenNotificationHandler. The function handles calendar notifications
+
+ \param notification notification type
+*/
void CalenDayView::HandleNotification(const TCalenNotification notification)
{
Q_UNUSED( notification )
}
-// -----------------------------------------------------------------------------
-// setupView()
-// Sets up the view accroding to the 'xml'
-// -----------------------------------------------------------------------------
-//
+
+/*!
+ \brief Sets up the view accroding to the 'xml'
+
+ \param docLoader Pointer to document loader
+*/
void CalenDayView::setupView(CalenDocLoader* docLoader)
{
- Q_UNUSED( docLoader )
+ // Store document loader for further use
+ mDocLoader = docLoader;
+
+ // Get vertical layout from day view
+ mVLayout = static_cast<QGraphicsLinearLayout *> (this->layout());
+
+ // Set up day info
+ mHeadingLabel = qobject_cast<HbGroupBox *> (mDocLoader->findWidget(
+ CALEN_DAYVIEW_DAYINFO));
+ HbEffect::add(mHeadingLabel, ":/fade_out.fxml", "fadeOut");
+ HbEffect::add(mHeadingLabel, ":/fade_in.fxml", "fadeIn");
+
+ // Set up hour scroll area
+ mHourScrollArea
+ = static_cast<CalenDayHourScrollArea *> (mDocLoader->findWidget(
+ CALEN_DAYVIEW_HOURSCROLLAREA));
+
+ // Set up content scroll area
+ mContentScrollArea
+ = static_cast<CalenDayContentScrollArea *> (mDocLoader->findWidget(
+ CALEN_DAYVIEW_CONTENTSCROLLAREA));
+ mContentWidget = new CalenDayContentWidget(*mModelManager, NULL);
+ mContentScrollArea->setContentWidget(mContentWidget);
+
+ // Set up regional info if variant is correct
+ showRegionalInformationFadeIn();
+
+ setupSlots();
}
//private slots
-// -----------------------------------------------------------------------------
-// onBack()
-// Handles 'back' functionality;
-// -----------------------------------------------------------------------------
-//
+/*!
+ \brief Handles 'back' functionality
+*/
void CalenDayView::onBack()
{
TRAP_IGNORE(mServices.IssueCommandL(ECalenMonthView));
}
-// -----------------------------------------------------------------------------
-// dayChange()
-// -----------------------------------------------------------------------------
-//
+/*!
+ \brief Slot that handles first phase of day change
+
+ \param direction indicates to which day view needs to be scrolled (previous or next day)
+*/
void CalenDayView::dayChangeStarted(CalenScrollDirection direction)
{
if (direction == ECalenScrollToNext) {
@@ -240,29 +234,28 @@
mServices.Context().setFocusDate(mDate);
}
-// -----------------------------------------------------------------------------
-// dayChanged()
-// -----------------------------------------------------------------------------
-//
+/*!
+ \brief Slot that is triggered when operation of day change is completed
+
+ \param direction ndicates to which day view was scrolled (previous or next day)
+*/
void CalenDayView::dayChanged(CalenScrollDirection direction)
{
mModelManager->viewsScrollingFinished(direction);
mHourScrollArea->setDateTime(mDate);
}
-// -----------------------------------------------------------------------------
-// getCurrentDate()
-// -----------------------------------------------------------------------------
-//
+/*!
+ \brief Gets current date from context
+*/
void CalenDayView::getCurrentDate()
{
mDate = CalenNativeView::mServices.Context().focusDateAndTime();
}
-// -----------------------------------------------------------------------------
-// setupMenu()
-// -----------------------------------------------------------------------------
-//
+/*!
+ \brief Sets the menu for day view
+*/
void CalenDayView::setupMenu()
{
menu()->addAction(hbTrId("txt_calendar_opt_new_event"), this, SLOT(runNewMeeting()));
@@ -282,7 +275,7 @@
}
/*!
- \brief Ot change Day view to Agenda View
+ \brief To change Day view to Agenda View
*/
void CalenDayView::runChangeToAgendaView()
{
@@ -297,10 +290,9 @@
TRAP_IGNORE(mServices.IssueCommandL(ECalenRegionalPluginTapEvent));
}
-// -----------------------------------------------------------------------------
-// setupSlots()
-// -----------------------------------------------------------------------------
-//
+/*!
+ \brief This is a helper function to established connections between signals and slots
+*/
void CalenDayView::setupSlots()
{
// Connecting other view-related signals/slots
@@ -330,10 +322,9 @@
this, SLOT(showHideRegionalInformationChanged(XQSettingsKey, QVariant)));
}
-// -----------------------------------------------------------------------------
-// runNewMeeting()
-// -----------------------------------------------------------------------------
-//
+/*!
+ \brief This slot triggers new meeting creation view
+*/
void CalenDayView::runNewMeeting()
{
QDateTime dateTime(mDate);
@@ -341,13 +332,12 @@
dateTime.setTime(mServices.Context().defaultCalTimeForViewsL().time());
mServices.Context().setFocusDateAndTime(dateTime);
mServices.IssueCommandL(ECalenNewMeeting)
- );
+ );
}
-// -----------------------------------------------------------------------------
-// runGoToToday()
-// -----------------------------------------------------------------------------
-//
+/*!
+ \brief This slot switches current view to today
+*/
void CalenDayView::runGoToToday()
{
mServices.Context().setFocusDateAndTime(CalenDateUtils::today());
@@ -356,21 +346,23 @@
}
-// -----------------------------------------------------------------------------
-// changeView()
-// -----------------------------------------------------------------------------
-//
+/*!
+ \brief This slot switches current view to the given by id
+
+ \param viewId id of the view that needs to be displayed
+*/
void CalenDayView::changeView(TCalenCommandId viewId)
{
TRAP_IGNORE(mServices.IssueCommandL(viewId));
}
-// ----------------------------------------------------------------------------
-// CalenDayView::setHeadingText
-// Sets heading text according to date from model and locale.
-// It's connected to modelReset signal
-// ----------------------------------------------------------------------------
-//
+/*!
+ \brief Sets heading text according to date from model and locale.
+ It's connected to modelReset signal.
+
+ \param status Parameter required in order to call this slot autmatically
+ when an effect is complete.
+*/
void CalenDayView::setHeadingText(const HbEffect::EffectStatus &status)
{
Q_UNUSED(status)
@@ -391,123 +383,101 @@
HbEffect::start(mHeadingLabel, "fadeIn");
}
-// ----------------------------------------------------------------------------
-// CalenDayView::showHideRegionalInformation
-// To run effect on lunar data label
-// ----------------------------------------------------------------------------
-//
+/*!
+ \brief Displays regional information
+
+ \param status Parameter required in order to call this slot autmatically
+ when an effect is complete.
+*/
void CalenDayView::showRegionalInformation(const HbEffect::EffectStatus &status)
{
Q_UNUSED(status);
showRegionalInformationFadeIn();
}
-// ----------------------------------------------------------------------------
-// CalenDayView::showRegionalInformationFadeIn
-// To run effect on lunar data label and change text according to date change
-// ----------------------------------------------------------------------------
-//
+/*!
+ \brief Runs effect on lunar data label and change text according to date change.
+*/
void CalenDayView::showRegionalInformationFadeIn()
- {
+{
showHideRegionalInformationChanged(mRegionalInfo, 3);
HbEffect::start(mRegionalInfoGroupBox, "fadeIn");
- }
-
-// ----------------------------------------------------------------------------
-// CalenDayView::showHideRegionalInformationChanged
-// To Show and hide regional plugin label depends upon settings
-// ----------------------------------------------------------------------------
-//
-void CalenDayView::showHideRegionalInformationChanged(const XQSettingsKey& key, const QVariant&)
- {
- if (key.key() == mRegionalInfo.key())
- {
- int showRegionalInfo =
- mSettingsManager->readItemValue(mRegionalInfo).toUInt();
+}
- if (showRegionalInfo)
- {
- QString *pluginString = pluginText();
- if (pluginString)
- {
- if (!mRegionalInfoGroupBox)
- {
- mRegionalInfoGroupBox = new HbGroupBox();
- CalenPluginLabel *regionalInfo = new CalenPluginLabel(
- mServices, this);
- HbEffect::add(mRegionalInfoGroupBox, ":/fade_out.fxml",
- "fadeOut");
- HbEffect::add(mRegionalInfoGroupBox, ":/fade_in.fxml", "fadeIn");
-
- // add margins to calenpluginlabel
+/*!
+ \brief To Show and hide regional plugin label depends upon settings.
+*/
+void CalenDayView::showHideRegionalInformationChanged(
+ const XQSettingsKey& key,
+ const QVariant&)
+{
+ if (key.key() == mRegionalInfo.key()) {
+ int showRegionalInfo =
+ mSettingsManager->readItemValue(mRegionalInfo).toUInt();
- HbStyle style;
- HbDeviceProfile deviceProfile;
- qreal marginLeft = 0.0;
- qreal marginRight = 0.0;
- qreal marginTop = 0.0;
- qreal marginBottom = 0.0;
- style.parameter(QString("hb-param-margin-gene-left"), marginLeft, deviceProfile);
- style.parameter(QString("hb-param-margin-gene-right"), marginRight, deviceProfile);
- style.parameter(QString("hb-param-margin-gene-top"), marginTop, deviceProfile);
- style.parameter(QString("hb-param-margin-gene-bottom"), marginBottom, deviceProfile);
-
- regionalInfo->setContentsMargins(1, 1, 1, 1);
-
- // qreal width = mRegionalInfoGroupBox->size().width();
- // qreal height = mRegionalInfoGroupBox->size().height() + marginTop + marginBottom;
-
- // mRegionalInfoGroupBox->resize(width, height);
-
- mRegionalInfoGroupBox->setContentWidget(regionalInfo);
- }
+ if (showRegionalInfo) {
+ QString *pluginString = pluginText();
+ if (pluginString) {
+ if (!mRegionalInfoGroupBox) {
+ mRegionalInfoGroupBox = qobject_cast<HbGroupBox *> (
+ mDocLoader->findWidget(CALEN_DAYVIEW_REGIONALINFO));
+ CalenPluginLabel *regionalInfo = new CalenPluginLabel(
+ mServices, this);
+ HbEffect::add(mRegionalInfoGroupBox, ":/fade_out.fxml",
+ "fadeOut");
+ HbEffect::add(mRegionalInfoGroupBox, ":/fade_in.fxml",
+ "fadeIn");
+ regionalInfo->setContentsMargins(1, 1, 1, 1);
+ mRegionalInfoGroupBox->setContentWidget(regionalInfo);
+ }
- if (pluginEnabled())
- {
- HbLabel *pluginInfoLabel = qobject_cast<HbLabel *> (
- mRegionalInfoGroupBox->contentWidget());
-
- pluginInfoLabel->setPlainText(*pluginString);
-
- mVLayout->insertItem(1, mRegionalInfoGroupBox);
- }
- }
- }
- else
- {
+ if (pluginEnabled()) {
+ HbLabel *pluginInfoLabel = qobject_cast<HbLabel *> (
+ mRegionalInfoGroupBox->contentWidget());
- if (mRegionalInfoGroupBox)
- {
- mVLayout->removeItem(mRegionalInfoGroupBox);
- delete mRegionalInfoGroupBox;
- mRegionalInfoGroupBox = NULL;
- }
- }
- }
- }
+ pluginInfoLabel->setPlainText(*pluginString);
+ mVLayout->insertItem(1, mRegionalInfoGroupBox);
+ }
+ }
+ }
+ else {
+ if (mRegionalInfoGroupBox) {
+ mVLayout->removeItem(mRegionalInfoGroupBox);
+ delete mRegionalInfoGroupBox;
+ mRegionalInfoGroupBox = NULL;
+ }
+ }
+ }
+}
-// ----------------------------------------------------------------------------
-// CalenDayView::setupViewport
-// Scrolls view according to current day and events
-// ----------------------------------------------------------------------------
-//
+/*!
+ \brief Scrolls view according to current day and events.
+*/
void CalenDayView::setupViewport()
{
QDateTime currentTime = QDateTime::currentDateTime();
-
- //Filter flags (only timed events)
- AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags(
- AgendaUtil::IncludeAppointments );
- QList<AgendaEntry> list;
- // Fetch the instance list from the agenda interface
- list = mServices.agendaInterface()->fetchEntriesInRange(currentTime, currentTime, filter);
-
+
// If we have event in current day and hour, scroll to this event
- if(mDate.date() == currentTime.date() && !list.isEmpty()){
- int hourToScrollTo(list.first().startTime().time().hour());
- mHourScrollArea->scrollToHour(hourToScrollTo);
+ if (mDate.date() == currentTime.date()){
+
+ QDateTime midnight = currentTime;
+ midnight.setTime(QTime(23, 59));
+
+ //Filter flags (only timed events)
+ AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags(AgendaUtil::IncludeAppointments);
+ QList<AgendaEntry> list;
+ // Fetch the instance list from the agenda interface
+ list = mServices.agendaInterface()->fetchEntriesInRange(currentTime, midnight, filter);
+
+ if(!list.isEmpty()){
+ int hourToScrollTo(list.first().startTime().time().hour());
+ mHourScrollArea->scrollToHour(hourToScrollTo);
+ }
+ else{
+ mHourScrollArea->scrollToHour(currentTime.time().hour());
+ }
}
- else{
+ else {
//Scroll view to 7am
mHourScrollArea->scrollToHour(7);
}