clock/clockui/clockwidget/clockwidgetimpl/src/clockwidget.cpp
changeset 26 a949c2543c15
child 50 579cc610882e
equal deleted inserted replaced
23:fd30d51f876b 26:a949c2543c15
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Clockwidget
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <QGraphicsLinearLayout>
       
    20 
       
    21 // User includes
       
    22 #include "clockwidget.h"
       
    23 #include "analogclockwidget.h"
       
    24 
       
    25 /*!
       
    26     \class ClockWidget
       
    27 
       
    28     This is the generic wrapper for the clockwidget which manages analog and ditial clockwidgets.
       
    29  */
       
    30 
       
    31 /*!
       
    32     Constructor.
       
    33  */
       
    34 ClockWidget::ClockWidget(QGraphicsItem *parent, Qt::WindowFlags flags)
       
    35     : HbWidget(parent, flags),
       
    36       mClockType(ClockTypeAnalog)
       
    37 {    
       
    38     loadClockWidget();
       
    39 }
       
    40 
       
    41 /*!
       
    42     Destructor.
       
    43 */
       
    44 ClockWidget::~ClockWidget()
       
    45 {    
       
    46     
       
    47 }
       
    48 
       
    49 /*!
       
    50     Returns the clock type.
       
    51 */
       
    52 ClockWidget::ClockType ClockWidget::clockType() const
       
    53 {
       
    54     return mClockType;
       
    55 }
       
    56   
       
    57 /*!
       
    58     Sets the clock type;
       
    59 */
       
    60 void ClockWidget::setClockType(const ClockType &type)
       
    61 {
       
    62     if (type == ClockTypeDigital) {
       
    63         mClockType = ClockTypeDigital;
       
    64     } else {
       
    65         mClockType = ClockTypeAnalog;
       
    66     }
       
    67 }
       
    68 
       
    69 /*!
       
    70     Updates the clock time with every second
       
    71 */
       
    72 void ClockWidget::updateTime()
       
    73 {
       
    74     if (mClockType == ClockTypeAnalog) {  
       
    75         mAnalogClock->tick();    
       
    76     }
       
    77 }
       
    78 
       
    79 /*!
       
    80     Constructs the clockwidget based upon its type.
       
    81 */
       
    82 void ClockWidget::loadClockWidget()
       
    83 {
       
    84     if (mClockType == ClockTypeAnalog) {
       
    85         mAnalogClock = new AnalogClockWidget(this);        
       
    86         mLayout = new QGraphicsLinearLayout(Qt::Vertical);
       
    87         mLayout->setContentsMargins(0,0,0,0);
       
    88         mLayout->addItem(mAnalogClock);
       
    89         setLayout(mLayout);
       
    90     }
       
    91 }
       
    92 
       
    93 // End of file  --Don't remove this.