src/hbwidgets/sliders/hbprogressbar.cpp
changeset 0 16d8024aca5e
child 1 f7ac710697a9
equal deleted inserted replaced
-1:000000000000 0:16d8024aca5e
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbWidgets module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 
       
    26 
       
    27 #include <hbprogressbar.h>
       
    28 #include <hbstyleoptionprogressbar.h>
       
    29 #include "hbprogressbar_p.h"
       
    30 
       
    31 #ifdef HB_EFFECTS
       
    32 #include <hbeffect.h>
       
    33 #include "hbeffectinternal_p.h"
       
    34 #define HB_PRGRESSBAR_ITEM_TYPE "HB_PROGRESSBAR"
       
    35 #endif
       
    36 
       
    37 
       
    38 /*!
       
    39     @beta
       
    40     @hbwidgets
       
    41     \class HbProgressBar
       
    42 
       
    43     \brief HbProgressBar widget provides a vertical and horizontal progress bar.
       
    44     An infinite progressbar is also available.
       
    45 
       
    46     A progress bar is used to give the user an indication of the progress of an operation and to 
       
    47     reassure them that the application is still running.
       
    48 
       
    49     The progress bar uses the concept of steps. User can set it up by specifying the minimum and 
       
    50     maximum possible step values, and it will display the percentage of steps that have been completed
       
    51     when you later give it the current step value. 
       
    52     
       
    53     The percentage is calculated by dividing the progress (progressValue() - minimum()) divided by maximum() - minimum().
       
    54 
       
    55     User can specify the minimum and maximum number of steps with setMinimum() and setMaximum() APIs. 
       
    56     The current number of steps is set with setProgressValue(). 
       
    57 
       
    58     If minimum and maximum both are set to 0, the bar shows a busy indicator instead of a percentage of steps.
       
    59     This is useful, for example, when using ftp or http to download items when they are unable to 
       
    60     determine the size of the item being downloaded.
       
    61 
       
    62     ProgressBar also supports adding text . min max text pair is also supported which is commonly 
       
    63     used for progress indication for music.
       
    64     
       
    65     \image html hbprogressbartext.png Left Aligned Text, Min Max Text.
       
    66 
       
    67     Progress bar provides below signal.
       
    68 
       
    69     \li valueChanged(int value) Emitted when the value of the progressbar is changed.
       
    70 */
       
    71 
       
    72 /*!
       
    73     @beta
       
    74     \fn void HbProgressBar::valueChanged(int value)
       
    75     
       
    76     Emitted when the value of the progressbar is changed.
       
    77 */
       
    78 
       
    79 
       
    80 /*!
       
    81     @beta
       
    82     \reimp
       
    83     \fn int HbProgressBar::type() const
       
    84  */
       
    85 
       
    86 /*!
       
    87     @beta
       
    88     \enum HbProgressBar::ProgressBarType
       
    89 
       
    90     This enum defines available progress bar types.
       
    91 */
       
    92 
       
    93 
       
    94 /*
       
    95     HbProgressBarPrivate
       
    96     private class constructor     
       
    97 */
       
    98 HbProgressBarPrivate::HbProgressBarPrivate() :
       
    99     mFrame(0),
       
   100     mTrack(0),
       
   101     mWaitTrack(0),
       
   102     mMinTextItem(0),
       
   103     mMaxTextItem(0),
       
   104     mMinMaxTextVisible(false),
       
   105     mMaximum(100),
       
   106     mMinimum(0),
       
   107     mProgressValue(0),
       
   108     mInvertedAppearance(false),
       
   109     mMinMaxTextAlignment(Qt::AlignBottom),
       
   110     mMinText(QString()),
       
   111     mMaxText(QString()),
       
   112     mOrientation(Qt::Horizontal),
       
   113     mDelayHideInProgress(true)
       
   114 {
       
   115 }
       
   116 
       
   117 /*
       
   118     HbProgressBarPrivate
       
   119     destructor     
       
   120 */
       
   121 HbProgressBarPrivate::~HbProgressBarPrivate() 
       
   122 {
       
   123 }
       
   124 
       
   125 /*
       
   126     \internal
       
   127     initialises progressbar
       
   128 */
       
   129 void HbProgressBarPrivate::init() 
       
   130 {
       
   131     Q_Q(HbProgressBar);
       
   132 
       
   133     HbStyle *style = qobject_cast<HbStyle*>(q->style());
       
   134     Q_ASSERT(style);
       
   135 
       
   136     mFrame = style->createPrimitive(HbStyle::P_ProgressBar_frame,q);
       
   137     mTrack = style->createPrimitive(HbStyle::P_ProgressBar_track,mFrame);
       
   138     mWaitTrack = style->createPrimitive(HbStyle::P_ProgressBar_waittrack,mFrame);    
       
   139     mWaitTrack->setVisible(false);
       
   140 
       
   141     if(q->layoutDirection() == Qt::RightToLeft) {
       
   142         q->setInvertedAppearance(true);
       
   143     }
       
   144 
       
   145 #ifdef HB_EFFECTS
       
   146     HbEffectInternal::add(HB_PRGRESSBAR_ITEM_TYPE,"progressbar_appear", "progressbar_appear");
       
   147     HbEffectInternal::add(HB_PRGRESSBAR_ITEM_TYPE,"progressbar_disappear", "progressbar_disappear");
       
   148     HbEffectInternal::add(HB_PRGRESSBAR_ITEM_TYPE,"progressbar_progress_complete", "progressbar_progress_complete");
       
   149 #endif
       
   150 }
       
   151 
       
   152 /*
       
   153     createTextPrimitives
       
   154 */
       
   155 void HbProgressBarPrivate::createTextPrimitives()
       
   156 {
       
   157     Q_Q(HbProgressBar);
       
   158 
       
   159     mMinTextItem = q->style()->createPrimitive(HbStyle::P_ProgressBar_mintext,q);
       
   160     mMaxTextItem = q->style()->createPrimitive(HbStyle::P_ProgressBar_maxtext,q);
       
   161 }
       
   162 
       
   163 /*!
       
   164     \internal
       
   165     Sets the progressbar range
       
   166 */
       
   167 void HbProgressBarPrivate::setRange(int minimum, int maximum)
       
   168 {
       
   169     Q_Q(HbProgressBar);
       
   170     if( minimum > maximum ){
       
   171         maximum = minimum ;
       
   172     }
       
   173     mMinimum = minimum;
       
   174     mMaximum = maximum;
       
   175 
       
   176     if ( mProgressValue < mMinimum){
       
   177         mProgressValue = mMinimum;
       
   178     }
       
   179 
       
   180     if(mProgressValue > mMaximum){
       
   181         mProgressValue = mMaximum;
       
   182     }
       
   183 
       
   184     if( (mMinimum == 0) && (mMaximum == 0) && (mType != HbProgressBar::RatingProgressBar) ) {
       
   185         mWaitTrack->setVisible(true);
       
   186         mTrack->setVisible(false);
       
   187     } else {
       
   188         mWaitTrack->setVisible(false);
       
   189         mTrack->setVisible(true);
       
   190     }
       
   191     q->updatePrimitives();
       
   192 }
       
   193 
       
   194 /*!
       
   195     \internal
       
   196     Sets the progressbar orientation.
       
   197     Can be either vertical or Horizontal.
       
   198 */
       
   199 void HbProgressBarPrivate::setOrientation(Qt::Orientation orientation)
       
   200 {
       
   201     Q_Q(HbProgressBar);
       
   202     if (mOrientation != orientation) {
       
   203         mOrientation = orientation;
       
   204         q->repolish();
       
   205         q->updatePrimitives();
       
   206     }
       
   207 }
       
   208 
       
   209 /*!
       
   210     \internal
       
   211     Private slot which delays the hiding effect.
       
   212 */
       
   213 #ifdef HB_EFFECTS
       
   214 void HbProgressBarPrivate::_q_delayedHide(HbEffect::EffectStatus status)
       
   215 {
       
   216     Q_Q(HbProgressBar);
       
   217 
       
   218     if (status.reason != Hb::EffectNotStarted) {
       
   219         q->setVisible(false);
       
   220     } 
       
   221 }
       
   222 #endif
       
   223 
       
   224 /*!
       
   225     Constructs a progressbar of a given \a type and \a parent. The default type is SimpleProgressBar.
       
   226 
       
   227     \deprecated HbProgressBar::HbProgressBar(HbProgressBar::ProgressBarType, QGraphicsItem*)
       
   228         is deprecated. Please use HbProgressBar::HbProgressBar(QGraphicsItem *parent) instead.
       
   229 */
       
   230 HbProgressBar::HbProgressBar(ProgressBarType type, QGraphicsItem *parent) : 
       
   231     HbWidget(*new HbProgressBarPrivate, parent)
       
   232 {    
       
   233     Q_D( HbProgressBar );
       
   234     d->q_ptr = this;
       
   235     d->init();
       
   236     d->mType = type;
       
   237 }
       
   238 
       
   239 /*!
       
   240     @beta
       
   241     Constructs a progressbar of a given \a parent.
       
   242 */
       
   243 HbProgressBar::HbProgressBar(QGraphicsItem *parent) : 
       
   244     HbWidget(*new HbProgressBarPrivate, parent)
       
   245 {    
       
   246     Q_D( HbProgressBar );
       
   247     d->q_ptr = this;
       
   248     d->init();
       
   249 }
       
   250 
       
   251 /*!
       
   252     \deprecated HbProgressBar::HbProgressBar(HbProgressBarPrivate&, HbProgressBar::ProgressBarType, QGraphicsItem*)
       
   253         is deprecated. Please use HbProgressBar::HbProgressBar(HbProgressBarPrivate &dd, QGraphicsItem *parent) instead.
       
   254 */
       
   255 HbProgressBar::HbProgressBar(HbProgressBarPrivate &dd, ProgressBarType type, QGraphicsItem *parent) : 
       
   256     HbWidget( dd, parent)
       
   257 {   
       
   258     Q_D( HbProgressBar );
       
   259     d->init();
       
   260     d->mType = type;
       
   261 }
       
   262 
       
   263 
       
   264 HbProgressBar::HbProgressBar(HbProgressBarPrivate &dd, QGraphicsItem *parent) : 
       
   265     HbWidget( dd, parent)
       
   266 {   
       
   267     Q_D( HbProgressBar );
       
   268     d->init();
       
   269 }
       
   270 
       
   271 
       
   272 /*!
       
   273     @beta
       
   274     Destructor for the progressbar.
       
   275 */
       
   276 HbProgressBar::~HbProgressBar() 
       
   277 {    
       
   278 }
       
   279 
       
   280 /*!
       
   281     @beta
       
   282    This property holds whether or not a progress bar shows its progress inverted. The function
       
   283    returns the value of this property.
       
   284 
       
   285    Not implemented yet.
       
   286 
       
   287    \sa setInvertedAppearance()
       
   288  */
       
   289 bool HbProgressBar::invertedAppearance() const 
       
   290 {
       
   291     Q_D( const HbProgressBar );
       
   292     return d->mInvertedAppearance;
       
   293 }
       
   294 
       
   295 /*!
       
   296     @beta
       
   297    This property holds whether or not a progress bar shows its progress inverted. The function
       
   298    sets the property to the \a inverted value.
       
   299 
       
   300    Not implemented yet.
       
   301 
       
   302    \sa invertedAppearance()
       
   303  */
       
   304 void HbProgressBar::setInvertedAppearance(bool inverted)
       
   305 {
       
   306     Q_D( HbProgressBar );
       
   307     d->mInvertedAppearance=inverted;
       
   308     updatePrimitives();
       
   309 }
       
   310 
       
   311 /*!
       
   312     @beta
       
   313     Returns the maximum value of the progress bar.
       
   314 
       
   315     The default value is \c 100.
       
   316 
       
   317     \sa setMaximum()
       
   318 */
       
   319 int HbProgressBar::maximum() const
       
   320 {   
       
   321     Q_D( const HbProgressBar );
       
   322     return d->mMaximum;
       
   323 }
       
   324 
       
   325 /*!
       
   326     @beta
       
   327     Sets the maximum value of the progress bar.
       
   328     when setting this property, the minimum is adjusted to ensure
       
   329     that the range remains valid.
       
   330 
       
   331     \sa maximum(),minimum(),setMinimum()
       
   332 */
       
   333 void HbProgressBar::setMaximum(int maximum)
       
   334 {
       
   335     Q_D( HbProgressBar );
       
   336     d->setRange(qMin(d->mMinimum,maximum),maximum);
       
   337 }
       
   338 
       
   339 /*!
       
   340     @beta
       
   341     Returns the minimum value of the progress bar.
       
   342 
       
   343     The default value is \c 0.
       
   344 
       
   345     \sa setMinimum()
       
   346 */
       
   347 int HbProgressBar::minimum() const
       
   348 {
       
   349     Q_D( const HbProgressBar );
       
   350     return d->mMinimum;
       
   351 }
       
   352 
       
   353 /*!
       
   354     @beta
       
   355     Sets the minimum value of the progress bar.
       
   356     when setting this property, the maximum is adjusted to ensure
       
   357     that the range remains valid.
       
   358 
       
   359     \sa maximum(),minimum(),setMaximum()
       
   360 
       
   361 */
       
   362 void HbProgressBar::setMinimum(int minimum)
       
   363 {
       
   364     Q_D( HbProgressBar );
       
   365     d->setRange(minimum,qMax(d->mMaximum,minimum));
       
   366 }
       
   367 
       
   368 /*!
       
   369     @beta
       
   370     Returns the current value of the progress bar.
       
   371 
       
   372     The default progressValue is \c 0.
       
   373 */
       
   374 int HbProgressBar::progressValue() const
       
   375 {
       
   376     Q_D( const HbProgressBar );
       
   377     return d->mProgressValue;
       
   378 }
       
   379 
       
   380 /*!
       
   381     @beta
       
   382     Sets the current value of the progress bar.
       
   383 
       
   384     The progress bar forces the value to be within the legal range: \b
       
   385     minimum <= \c value <= \b maximum.
       
   386 
       
   387     \sa progressValue()
       
   388 */
       
   389 void HbProgressBar::setProgressValue(int value)
       
   390 {
       
   391     Q_D( HbProgressBar );
       
   392     if (d->mProgressValue == value) {
       
   393         return;
       
   394     }
       
   395     if (value >= d->mMaximum) {
       
   396         value = d->mMaximum;
       
   397 #ifdef HB_EFFECTS
       
   398         HbEffect::start(d->mTrack, HB_PRGRESSBAR_ITEM_TYPE, "progressbar_progress_complete");
       
   399 #endif
       
   400     }
       
   401     else if (value<d->mMinimum) {
       
   402         value = d->mMinimum;
       
   403     }
       
   404     d->mProgressValue=value;
       
   405 
       
   406     //redraw track
       
   407     HbStyleOptionProgressBar progressBarOption;
       
   408     initStyleOption(&progressBarOption);
       
   409     if(d->mTrack) {
       
   410         style()->updatePrimitive(d->mTrack, HbStyle::P_ProgressBar_track, &progressBarOption);
       
   411     }
       
   412 
       
   413     emit valueChanged(value);
       
   414 }
       
   415 
       
   416 /*!
       
   417     @beta
       
   418     This function is provided for convenience.
       
   419 
       
   420     Sets the progress bar's minimum to \a minimum and its maximum to \a max.
       
   421 
       
   422     If \a maximum is smaller than minimum, minimum becomes the only valid legal
       
   423     value.
       
   424 
       
   425     \sa setMinimum(), setMaximum()
       
   426 */
       
   427 void HbProgressBar::setRange(int minimum, int maximum) 
       
   428 {
       
   429     Q_D( HbProgressBar );
       
   430     d->setRange(minimum , maximum);
       
   431 }
       
   432 
       
   433 /*!
       
   434     @beta
       
   435     Set the \a Min text shown on the progressbar.
       
   436     \sa text()
       
   437 */
       
   438 void HbProgressBar::setMinText(const QString &text)
       
   439 {
       
   440     Q_D(HbProgressBar);
       
   441     if (d->mMinText != text) {
       
   442         d->mMinText = text;
       
   443         HbStyleOptionProgressBar progressBarOption;
       
   444         initStyleOption(&progressBarOption);
       
   445         style()->updatePrimitive(d->mMinTextItem,HbStyle::P_ProgressBar_mintext,&progressBarOption);
       
   446      }
       
   447 }
       
   448 
       
   449 /*!
       
   450     @beta
       
   451     Returns the Min Text of the progress bar.
       
   452 
       
   453     The default progressValue is \c 0.
       
   454 */
       
   455 QString HbProgressBar::minText() const
       
   456 {
       
   457     Q_D( const HbProgressBar );
       
   458     return d->mMinText;
       
   459 }
       
   460 
       
   461 /*!
       
   462     @beta
       
   463     Set the \a Max text shown on the progressbar.
       
   464     \sa text()
       
   465 */
       
   466 void HbProgressBar::setMaxText(const QString &text)
       
   467 {
       
   468   	Q_D(HbProgressBar);
       
   469     if (d->mMaxText != text) {
       
   470         d->mMaxText = text;
       
   471         HbStyleOptionProgressBar progressBarOption;
       
   472         initStyleOption(&progressBarOption);
       
   473         style()->updatePrimitive(d->mMaxTextItem,HbStyle::P_ProgressBar_maxtext,&progressBarOption);
       
   474     }
       
   475 }
       
   476 
       
   477 /*!
       
   478     @beta
       
   479     Returns the Max Text of the progress bar.
       
   480 
       
   481     The default progressValue is \c 0.
       
   482 */
       
   483 QString HbProgressBar::maxText() const
       
   484 {
       
   485     Q_D( const HbProgressBar );
       
   486     return d->mMaxText;
       
   487 }
       
   488 
       
   489 /*!
       
   490     @beta 
       
   491     Set the MinMaxtext visibility \a true for showing text,false for hiding the text.
       
   492     The default is \c false. Min Max text doesnt have a background and would have a transparent background.
       
   493     \sa isMinMaxTextVisible().
       
   494 */
       
   495 void HbProgressBar::setMinMaxTextVisible(bool visible)
       
   496 {
       
   497     Q_D(HbProgressBar);
       
   498     if (d->mMinMaxTextVisible != visible) {
       
   499         d->mMinMaxTextVisible = visible;
       
   500 
       
   501     if(d->mMinMaxTextVisible) {
       
   502         if(!d->mMinTextItem && !d->mMaxTextItem){
       
   503             d->createTextPrimitives();
       
   504         }
       
   505             d->mMinTextItem->show();
       
   506             d->mMaxTextItem->show();
       
   507     } else {
       
   508         if(d->mMinTextItem && d->mMaxTextItem){
       
   509             d->mMinTextItem->hide();
       
   510             d->mMaxTextItem->hide();
       
   511         }
       
   512     }
       
   513     repolish();
       
   514     updatePrimitives();
       
   515     }
       
   516 }
       
   517 
       
   518 /*!
       
   519     @beta
       
   520     This property holds whether the MinMax text should be displayed.
       
   521     Return the value of this property.
       
   522 
       
   523     \sa setMinMaxTextVisibile()
       
   524 */
       
   525 bool HbProgressBar::isMinMaxTextVisible() const
       
   526 {
       
   527     Q_D(const HbProgressBar);
       
   528     return d->mMinMaxTextVisible;
       
   529 }
       
   530 
       
   531 /*!
       
   532     @beta
       
   533     Sets the Min-Max text alignment
       
   534 	
       
   535 	Supportted alignments are (in both horizontal and vertical orientations)
       
   536 	Qt::AlignTop
       
   537 	Qt::AlignBottom
       
   538 	Qt::AlignCenter
       
   539 
       
   540     In Vertical orienatation,     
       
   541     AlignTop is equivalent to Left
       
   542     AlignBottom is equivalent to Right
       
   543 
       
   544 */
       
   545 void HbProgressBar::setMinMaxTextAlignment(Qt::Alignment alignment)
       
   546 {
       
   547 	Q_D(HbProgressBar);
       
   548 	if( (alignment != Qt::AlignBottom) && (alignment != Qt::AlignTop) && (alignment != Qt::AlignCenter) ) {
       
   549 		return;
       
   550 	}
       
   551 	if (d->mMinMaxTextAlignment != alignment) {
       
   552         d->mMinMaxTextAlignment = alignment;
       
   553 		if (d->mMinMaxTextVisible) {
       
   554             repolish();
       
   555         }
       
   556         updatePrimitives();
       
   557     }
       
   558 
       
   559 }
       
   560 /*!
       
   561     @beta
       
   562     Returns the minmax Text alignment.
       
   563    
       
   564 */
       
   565 Qt::Alignment HbProgressBar::minMaxTextAlignment() const
       
   566 {
       
   567 	Q_D(const HbProgressBar);
       
   568 	return d->mMinMaxTextAlignment;
       
   569 }
       
   570 
       
   571 /*!
       
   572     @beta
       
   573     sets the orientation of the progressbar.It can be vertical or horizontal.
       
   574 */
       
   575 void HbProgressBar::setOrientation(Qt::Orientation orientation)
       
   576 {
       
   577     //TODO: Add vertical slider related info.
       
   578     Q_D(HbProgressBar);
       
   579     d->setOrientation(orientation);
       
   580 }
       
   581 
       
   582 /*!
       
   583     @beta
       
   584     Returns the orientation of the progressbar.It can be vertical or horizontal.
       
   585 */
       
   586 Qt::Orientation HbProgressBar::orientation() const
       
   587 {
       
   588     //TODO: Add vertical slider related info.
       
   589     Q_D(const HbProgressBar);
       
   590     return d->mOrientation;    
       
   591 }
       
   592 
       
   593 /*!
       
   594     Returns the pointer for \a primitive passed.
       
   595     Will return NULL if \a primitive passed is invalid
       
   596 */
       
   597 QGraphicsItem* HbProgressBar::primitive(HbStyle::Primitive primitive) const
       
   598 {
       
   599     Q_D(const HbProgressBar);
       
   600 
       
   601     switch (primitive) {
       
   602         case HbStyle::P_ProgressBar_frame:
       
   603             return d->mFrame;
       
   604         case HbStyle::P_ProgressBar_track:
       
   605             return d->mTrack;  
       
   606         case HbStyle::P_ProgressBar_waittrack:
       
   607             return d->mWaitTrack;
       
   608         case HbStyle::P_ProgressBar_mintext:
       
   609             return d->mMinTextItem;
       
   610         case HbStyle::P_ProgressBar_maxtext:
       
   611             return d->mMaxTextItem;
       
   612         default:
       
   613             return 0;
       
   614     }
       
   615 }
       
   616 
       
   617 /*!
       
   618     \reimp
       
   619  */
       
   620 void HbProgressBar::updatePrimitives()
       
   621 {
       
   622     Q_D(HbProgressBar);
       
   623 
       
   624     if(isVisible()){
       
   625         HbStyleOptionProgressBar progressBarOption;
       
   626         initStyleOption(&progressBarOption);
       
   627         if (d->mFrame) {
       
   628             style()->updatePrimitive(d->mFrame, HbStyle::P_ProgressBar_frame, &progressBarOption);			
       
   629         }
       
   630      
       
   631         if (d->mTrack) {
       
   632                 style()->updatePrimitive(d->mTrack, HbStyle::P_ProgressBar_track, &progressBarOption);
       
   633         }
       
   634         
       
   635         if (d->mWaitTrack) {
       
   636                 style()->updatePrimitive(d->mWaitTrack, HbStyle::P_ProgressBar_waittrack, &progressBarOption);
       
   637         }
       
   638         
       
   639         if(d->mMinTextItem && d->mMinMaxTextVisible) {
       
   640             style()->updatePrimitive(d->mMinTextItem,HbStyle::P_ProgressBar_mintext,&progressBarOption);	
       
   641         }
       
   642 
       
   643         if(d->mMaxTextItem && d->mMinMaxTextVisible) {
       
   644             style()->updatePrimitive(d->mMaxTextItem,HbStyle::P_ProgressBar_maxtext,&progressBarOption);	
       
   645         }
       
   646     }
       
   647     HbWidget::updatePrimitives();
       
   648 }
       
   649 
       
   650 /*!
       
   651     Initializes \a option with the values from this HbProgressBar. This method 
       
   652     is useful for subclasses when they need a HbStyleOptionProgressBar, but don't
       
   653     want to fill in all the information themselves.
       
   654  */
       
   655 
       
   656 void HbProgressBar::initStyleOption(HbStyleOption *hboption) const
       
   657 {
       
   658     Q_D( const HbProgressBar );
       
   659     Q_ASSERT(hboption);
       
   660 
       
   661     HbWidget::initStyleOption(hboption);
       
   662     HbStyleOptionProgressBar *option = 0;
       
   663     if ((option = qstyleoption_cast< HbStyleOptionProgressBar *>(hboption)) != 0) {
       
   664         
       
   665         option->progressValue = d->mProgressValue;
       
   666         option->maximum = d->mMaximum;
       
   667         option->minimum = d->mMinimum;
       
   668         option->minText = d->mMinText;
       
   669         option->maxText = d->mMaxText;
       
   670         option->orientation = d->mOrientation;
       
   671         option->isSlider=d->mType == HbProgressBar::RatingProgressBar;
       
   672         option->inverted = d->mInvertedAppearance;
       
   673         option->stopWaitAnimation = false;
       
   674         option->minMaxTextAlignment = d->mMinMaxTextAlignment;
       
   675 		QRect rect(d->mFrame->boundingRect().x(),d->mFrame->boundingRect().y(),d->mFrame->boundingRect().width(),
       
   676 		d->mFrame->boundingRect().height());
       
   677 		option->rect = rect;
       
   678     }
       
   679 }
       
   680 
       
   681 /*!
       
   682     \reimp
       
   683  */
       
   684 void HbProgressBar::closeEvent ( QCloseEvent * event )
       
   685 {
       
   686     Q_D(HbProgressBar);
       
   687     HbStyleOptionProgressBar progressBarOption;
       
   688     initStyleOption(&progressBarOption);
       
   689     progressBarOption.stopWaitAnimation = true;
       
   690     if (d->mWaitTrack) {
       
   691         style()->updatePrimitive(d->mWaitTrack, HbStyle::P_ProgressBar_waittrack, &progressBarOption);
       
   692     }
       
   693     event->accept();
       
   694 }
       
   695 
       
   696 /*!
       
   697     \reimp
       
   698  */
       
   699 QVariant HbProgressBar::itemChange(GraphicsItemChange change, const QVariant &value)
       
   700 {
       
   701     if(change == ItemVisibleHasChanged && value.toBool()){
       
   702         updatePrimitives();
       
   703     }
       
   704 #ifdef HB_EFFECTS
       
   705     Q_D(HbProgressBar);
       
   706     if(change == QGraphicsItem::ItemVisibleChange){
       
   707         if(value.toBool()) {
       
   708 
       
   709             HbEffect::start(this, HB_PRGRESSBAR_ITEM_TYPE, "progressbar_appear");
       
   710 
       
   711             d->mDelayHideInProgress  = false;
       
   712         }
       
   713         else if(!d->mDelayHideInProgress) {
       
   714             //parentItemVisibility check is a hack . Other wise if visibility 
       
   715             // change happends due to view switch we should not call explicit hide on 
       
   716             // progress bar.
       
   717             if(parentItem() && parentItem()->isVisible())
       
   718                 if(HbEffect::start(this, HB_PRGRESSBAR_ITEM_TYPE, "progressbar_disappear",this,"_q_delayedHide")){
       
   719                     d->mDelayHideInProgress = true;
       
   720                     return true;
       
   721                 }
       
   722         }
       
   723     }
       
   724 #endif//HB_EFFECTS
       
   725 
       
   726    return HbWidget::itemChange(change,value);
       
   727 }
       
   728 
       
   729 /*!
       
   730     \reimp
       
   731  */
       
   732 void HbProgressBar::changeEvent(QEvent *event)
       
   733 {
       
   734     HbWidget::changeEvent(event);
       
   735     
       
   736     switch (event->type()) {
       
   737     case QEvent::LayoutDirectionChange:
       
   738 	    if(layoutDirection() == Qt::RightToLeft) {
       
   739             setInvertedAppearance(true);
       
   740         }
       
   741         else {
       
   742             setInvertedAppearance(false);
       
   743         }
       
   744         break;
       
   745     default:
       
   746         break;
       
   747     }
       
   748 }
       
   749 
       
   750 #include "moc_hbprogressbar.cpp"
       
   751