calendarui/views/dayview/src/calendayhourscrollarea.cpp
changeset 55 2c54b51f39c4
parent 45 b6db4fd4947b
child 57 bb2d3e476f29
equal deleted inserted replaced
51:0b38fc5b94c6 55:2c54b51f39c4
    40  */
    40  */
    41 CalenDayHourScrollArea::CalenDayHourScrollArea(QGraphicsItem *parent) :
    41 CalenDayHourScrollArea::CalenDayHourScrollArea(QGraphicsItem *parent) :
    42     HbScrollArea(parent),
    42     HbScrollArea(parent),
    43     mDateTime(QDateTime())
    43     mDateTime(QDateTime())
    44 {
    44 {
    45     // Set scroll settings
    45     grabGesture(Qt::PanGesture);
    46     setScrollDirections(Qt::Vertical);
       
    47     setScrollingStyle(HbScrollArea::PanWithFollowOn);
       
    48     setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
       
    49     grabGesture(Qt::PanGesture, Qt::ReceivePartialGestures);
       
    50     
    46     
    51     // Get height and width of hour elements and set fixed size policy
    47     // Get width of hour elements and fix its size
    52     qreal hourElementHeight = CalenDayUtils::instance()->hourElementHeight();
       
    53     qreal hourElementWidth = CalenDayUtils::instance()->hourElementWidth();
    48     qreal hourElementWidth = CalenDayUtils::instance()->hourElementWidth();
    54 
    49 
    55     // Create widget for hour elements
    50     // Create widget for hour elements
    56     HbWidget *hourWidget = new HbWidget();
    51     HbWidget *hourWidget = new HbWidget();
    57 
    52 
    59     QGraphicsLinearLayout* hourLayout = new QGraphicsLinearLayout(Qt::Vertical,
    54     QGraphicsLinearLayout* hourLayout = new QGraphicsLinearLayout(Qt::Vertical,
    60         NULL);
    55         NULL);
    61     for (int i = 0; i < 24; i++) {
    56     for (int i = 0; i < 24; i++) {
    62         CalenDayHourElement* element = new CalenDayHourElement(QTime(i, 0),
    57         CalenDayHourElement* element = new CalenDayHourElement(QTime(i, 0),
    63             this);
    58             this);
    64         element->setPreferredWidth(hourElementWidth);
       
    65         element->setPreferredHeight(hourElementHeight);
       
    66         element->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, 
       
    67             QSizePolicy::Fixed));
       
    68         hourLayout->addItem(element);
    59         hourLayout->addItem(element);
    69         
       
    70         mHourElements.append(element);
    60         mHourElements.append(element);
    71     }
    61     }
    72     
       
    73     hourLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0);
    62     hourLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0);
    74     hourLayout->setSpacing(0.0);
    63     hourLayout->setSpacing(0.0);
    75     
    64     
    76     // Fix the size of scroll area
    65     // Fix the size of scroll area
    77     setMinimumWidth(hourElementWidth);
    66     setMinimumWidth(hourElementWidth);
    85 /*!
    74 /*!
    86  \brief Destructor
    75  \brief Destructor
    87  */
    76  */
    88 CalenDayHourScrollArea::~CalenDayHourScrollArea()
    77 CalenDayHourScrollArea::~CalenDayHourScrollArea()
    89 {
    78 {
       
    79     mHourElements.clear();
    90 }
    80 }
    91 
    81 
    92 /*!
    82 /*!
    93  \brief SLOT scrolls the view vertically to new position.
    83  \brief SLOT scrolls the view vertically to new position.
    94  
    84