clock/clockui/clockwidget/clockwidgetimpl/src/clockwidget.cpp
changeset 57 bb2d3e476f29
parent 45 b6db4fd4947b
equal deleted inserted replaced
55:2c54b51f39c4 57:bb2d3e476f29
    20 
    20 
    21 // User includes
    21 // User includes
    22 #include "clockwidget.h"
    22 #include "clockwidget.h"
    23 #include "analogclockwidget.h"
    23 #include "analogclockwidget.h"
    24 #include "digitalclockwidget.h"
    24 #include "digitalclockwidget.h"
       
    25 #include "OstTraceDefinitions.h"
       
    26 #ifdef OST_TRACE_COMPILER_IN_USE
       
    27 #include "clockwidgetTraces.h"
       
    28 #endif
       
    29 
    25 
    30 
    26 /*!
    31 /*!
    27     \class ClockWidget
    32     \class ClockWidget
    28 
    33 
    29     This is the generic wrapper for the clockwidget which manages analog and ditial clockwidgets.
    34     This is the generic wrapper for the clockwidget which manages analog and ditial clockwidgets.
    34  */
    39  */
    35 ClockWidget::ClockWidget(QGraphicsItem *parent, Qt::WindowFlags flags)
    40 ClockWidget::ClockWidget(QGraphicsItem *parent, Qt::WindowFlags flags)
    36     : HbWidget(parent, flags),
    41     : HbWidget(parent, flags),
    37       mClockType(ClockTypeDigital)
    42       mClockType(ClockTypeDigital)
    38 {    
    43 {    
       
    44     OstTraceFunctionEntry0( CLOCKWIDGET_CLOCKWIDGET_ENTRY );
    39     loadClockWidget();
    45     loadClockWidget();
       
    46 OstTraceFunctionExit0( CLOCKWIDGET_CLOCKWIDGET_EXIT );
    40 }
    47 }
    41 
    48 
    42 /*!
    49 /*!
    43     Destructor.
    50     Destructor.
    44 */
    51 */
    45 ClockWidget::~ClockWidget()
    52 ClockWidget::~ClockWidget()
    46 {    
    53 {    
       
    54     OstTraceFunctionEntry0( DUP1_CLOCKWIDGET_CLOCKWIDGET_ENTRY );
    47     
    55     
       
    56 OstTraceFunctionExit0( DUP1_CLOCKWIDGET_CLOCKWIDGET_EXIT );
    48 }
    57 }
    49 
    58 
    50 /*!
    59 /*!
    51     Returns the clock type.
    60     Returns the clock type.
    52 */
    61 */
    53 ClockWidget::ClockType ClockWidget::clockType() const
    62 ClockWidget::ClockType ClockWidget::clockType() const
    54 {
    63 {
       
    64     OstTraceFunctionEntry0( CLOCKWIDGET_CLOCKTYPE_ENTRY );
       
    65     OstTraceFunctionExit0( CLOCKWIDGET_CLOCKTYPE_EXIT );
    55     return mClockType;
    66     return mClockType;
    56 }
    67 }
    57   
    68   
    58 /*!
    69 /*!
    59     Sets the clock type;
    70     Sets the clock type;
    60 */
    71 */
    61 void ClockWidget::setClockType(const ClockType &type)
    72 void ClockWidget::setClockType(const ClockType &type)
    62 {
    73 {
       
    74     OstTraceFunctionEntry0( CLOCKWIDGET_SETCLOCKTYPE_ENTRY );
    63     if (type == ClockTypeAnalog) {
    75     if (type == ClockTypeAnalog) {
    64         if(type != mClockType){
    76         if(type != mClockType){
    65 	        mClockType = ClockTypeAnalog;
    77 	        mClockType = ClockTypeAnalog;
    66 	        updateClockWidget();
    78 	        updateClockWidget();
    67         }
    79         }
    69         if(type != mClockType){
    81         if(type != mClockType){
    70             mClockType = ClockTypeDigital;
    82             mClockType = ClockTypeDigital;
    71             updateClockWidget();
    83             updateClockWidget();
    72         }      
    84         }      
    73     }
    85     }
       
    86 OstTraceFunctionExit0( CLOCKWIDGET_SETCLOCKTYPE_EXIT );
    74 }
    87 }
    75 
    88 
    76 /*!
    89 /*!
    77     Updates the clock time with every second
    90     Updates the clock time with every second
    78 */
    91 */
    79 void ClockWidget::updateTime()
    92 void ClockWidget::updateTime()
    80 {
    93 {
       
    94     OstTraceFunctionEntry0( CLOCKWIDGET_UPDATETIME_ENTRY );
    81     if (mClockType == ClockTypeAnalog) {  
    95     if (mClockType == ClockTypeAnalog) {  
    82         mAnalogClock->tick();    
    96         mAnalogClock->tick();    
    83     } else {
    97     } else {
    84     	mDigitalClock->updatePrimitives();
    98     	mDigitalClock->updatePrimitives();
    85     }
    99     }
       
   100 OstTraceFunctionExit0( CLOCKWIDGET_UPDATETIME_EXIT );
    86 }
   101 }
    87 
   102 
    88 /*!
   103 /*!
    89     Constructs the clockwidget based upon its type.
   104     Constructs the clockwidget based upon its type.
    90 */
   105 */
    91 void ClockWidget::loadClockWidget()
   106 void ClockWidget::loadClockWidget()
    92 {
   107 {
       
   108     OstTraceFunctionEntry0( CLOCKWIDGET_LOADCLOCKWIDGET_ENTRY );
    93     mLayout = new QGraphicsLinearLayout(Qt::Vertical);
   109     mLayout = new QGraphicsLinearLayout(Qt::Vertical);
    94     mLayout->setContentsMargins(0,0,0,0); 
   110     mLayout->setContentsMargins(0,0,0,0); 
    95 
   111 
    96     if (mClockType == ClockTypeAnalog) {
   112     if (mClockType == ClockTypeAnalog) {
    97 	    mAnalogClock = new AnalogClockWidget(this);        
   113 	    mAnalogClock = new AnalogClockWidget(this);        
   100 	    bool useAmPm = false;
   116 	    bool useAmPm = false;
   101 	    mDigitalClock = new DigitalClockWidget(useAmPm, this);
   117 	    mDigitalClock = new DigitalClockWidget(useAmPm, this);
   102 	    mLayout->addItem(mDigitalClock);
   118 	    mLayout->addItem(mDigitalClock);
   103     }
   119     }
   104     setLayout(mLayout);  
   120     setLayout(mLayout);  
       
   121 OstTraceFunctionExit0( CLOCKWIDGET_LOADCLOCKWIDGET_EXIT );
   105 }
   122 }
   106 
   123 
   107 /*!
   124 /*!
   108     Constructs the clockwidget based upon its type.
   125     Constructs the clockwidget based upon its type.
   109 */
   126 */
   110 void ClockWidget::updateClockWidget()
   127 void ClockWidget::updateClockWidget()
   111 {
   128 {
       
   129     OstTraceFunctionEntry0( CLOCKWIDGET_UPDATECLOCKWIDGET_ENTRY );
   112     if (mClockType == ClockTypeAnalog) {        
   130     if (mClockType == ClockTypeAnalog) {        
   113         mLayout->removeItem(mDigitalClock);
   131         mLayout->removeItem(mDigitalClock);
   114         delete mDigitalClock;
   132         delete mDigitalClock;
   115         if (!mAnalogClock) {
   133         if (!mAnalogClock) {
   116         	mAnalogClock = new AnalogClockWidget(this);
   134         	mAnalogClock = new AnalogClockWidget(this);
   123         bool useAmPm = false; // find out this fronm the settings utility
   141         bool useAmPm = false; // find out this fronm the settings utility
   124         mDigitalClock = new DigitalClockWidget(useAmPm, this);
   142         mDigitalClock = new DigitalClockWidget(useAmPm, this);
   125     }
   143     }
   126     mLayout->addItem(mDigitalClock);
   144     mLayout->addItem(mDigitalClock);
   127     }           
   145     }           
       
   146 OstTraceFunctionExit0( CLOCKWIDGET_UPDATECLOCKWIDGET_EXIT );
   128 }
   147 }
   129 
   148 
   130 ClockWidget::TimeFormat ClockWidget::timeFormat() const
   149 ClockWidget::TimeFormat ClockWidget::timeFormat() const
   131 {
   150 {
       
   151     OstTraceFunctionEntry0( CLOCKWIDGET_TIMEFORMAT_ENTRY );
       
   152     OstTraceFunctionExit0( CLOCKWIDGET_TIMEFORMAT_EXIT );
   132     return mTimeFormat;
   153     return mTimeFormat;
   133 }
   154 }
   134 
   155 
   135 void ClockWidget::setTimeFormat(const TimeFormat &timeFormat)
   156 void ClockWidget::setTimeFormat(const TimeFormat &timeFormat)
   136 {
   157 {
       
   158     OstTraceFunctionEntry0( CLOCKWIDGET_SETTIMEFORMAT_ENTRY );
   137     if(mDigitalClock){
   159     if(mDigitalClock){
   138 	    mTimeFormat = timeFormat;
   160 	    mTimeFormat = timeFormat;
   139 		if (timeFormat == ClockWidget::TimeFormat12Hrs) {
   161 		if (timeFormat == ClockWidget::TimeFormat12Hrs) {
   140 			mDigitalClock->setAmPm(true);
   162 			mDigitalClock->setAmPm(true);
   141 		} else {
   163 		} else {
   142 			mDigitalClock->setAmPm(false);
   164 			mDigitalClock->setAmPm(false);
   143 		}
   165 		}
   144     }
   166     }
       
   167 OstTraceFunctionExit0( CLOCKWIDGET_SETTIMEFORMAT_EXIT );
   145 }
   168 }
   146 // End of file  --Don't remove this.
   169 // End of file  --Don't remove this.