src/hbwidgets/sliders/hbprogressbar.cpp
changeset 6 c3690ec91ef8
parent 5 627c4a0fd0e7
child 7 923ff622b8b9
equal deleted inserted replaced
5:627c4a0fd0e7 6:c3690ec91ef8
    20 **
    20 **
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 #include "hbprogressbar_p.h"
    26 #include <hbprogressbar.h>
    26 #include <hbprogressbar.h>
    27 #include <hbstyleoptionprogressbar_p.h>
    27 #include <hbstyleoptionprogressbar_p.h>
    28 #include "hbprogressbar_p.h"
       
    29 #include "hbglobal_p.h"
    28 #include "hbglobal_p.h"
    30 
    29 
    31 #ifdef HB_EFFECTS
    30 #ifdef HB_EFFECTS
    32 #include <hbeffect.h>
    31 #include <hbeffect.h>
    33 #include "hbeffectinternal_p.h"
    32 #include "hbeffectinternal_p.h"
   233 
   232 
   234     if(mProgressValue > mMaximum){
   233     if(mProgressValue > mMaximum){
   235         mProgressValue = mMaximum;
   234         mProgressValue = mMaximum;
   236     }
   235     }
   237 
   236 
       
   237     // update primitve optimization, update only track primitive 
       
   238     // incase of normal as well as in infinite progressbar
       
   239     HbStyleOptionProgressBar progressBarOption;
       
   240     q->initStyleOption(&progressBarOption);
       
   241 
   238     if( (mMinimum == 0) && (mMaximum == 0) ) {
   242     if( (mMinimum == 0) && (mMaximum == 0) ) {
   239         mWaitTrack->setVisible(true);
   243         mWaitTrack->setVisible(true);
   240         mTrack->setVisible(false);
   244         mTrack->setVisible(false);
       
   245 
       
   246         q->style()->updatePrimitive(mWaitTrack, HbStyle::P_ProgressBar_waittrack, &progressBarOption);
   241     } else {
   247     } else {
   242         mWaitTrack->setVisible(false);
   248         mWaitTrack->setVisible(false);
   243         mTrack->setVisible(true);
   249         mTrack->setVisible(true);
   244     }
   250 
   245     q->updatePrimitives();
   251         q->style()->updatePrimitive(mTrack, HbStyle::P_ProgressBar_track, &progressBarOption);
       
   252     }
       
   253     //q->updatePrimitives();
   246 } 
   254 } 
   247 
   255 
   248 /*!
   256 /*!
   249     \internal
   257     \internal
   250     Sets the progressbar orientation.
   258     Sets the progressbar orientation.
   315 {    
   323 {    
   316 }
   324 }
   317 
   325 
   318 /*!
   326 /*!
   319     @beta
   327     @beta
   320     Return the inverted appearence property. 
   328     Return the inverted appearance property. 
   321     \sa setInvertedAppearance()
   329     \sa setInvertedAppearance()
   322 */
   330 */
   323 bool HbProgressBar::invertedAppearance() const 
   331 bool HbProgressBar::invertedAppearance() const 
   324 {
   332 {
   325     Q_D( const HbProgressBar );
   333     Q_D( const HbProgressBar );
   499 }
   507 }
   500 
   508 
   501 /*!
   509 /*!
   502     @beta 
   510     @beta 
   503     Set the MinMaxtext visibility. true for showing text,false for hiding the text.
   511     Set the MinMaxtext visibility. true for showing text,false for hiding the text.
   504     The default is  false. Min Max text doesnt have a background and would have a transparent background.
   512     The default is  false. Min Max text does not have a background and would have a transparent background.
   505     \param visible true or false.
   513     \param visible true or false.
   506     \sa isMinMaxTextVisible().
   514     \sa isMinMaxTextVisible().
   507 */
   515 */
   508 void HbProgressBar::setMinMaxTextVisible(bool visible)
   516 void HbProgressBar::setMinMaxTextVisible(bool visible)
   509 {
   517 {
   513 
   521 
   514     if(d->mMinMaxTextVisible) {
   522     if(d->mMinMaxTextVisible) {
   515         if(!d->mMinTextItem && !d->mMaxTextItem){
   523         if(!d->mMinTextItem && !d->mMaxTextItem){
   516             d->createTextPrimitives();
   524             d->createTextPrimitives();
   517         }
   525         }
       
   526         
       
   527     // update primitve optimization, update only text primitives 
       
   528     // incase of with and without min-max text
       
   529     HbStyleOptionProgressBar progressBarOption;
       
   530     initStyleOption(&progressBarOption);
       
   531 
       
   532     style()->updatePrimitive(d->mMinTextItem,HbStyle::P_ProgressBar_mintext,&progressBarOption);    
       
   533     style()->updatePrimitive(d->mMaxTextItem,HbStyle::P_ProgressBar_maxtext,&progressBarOption); 
       
   534 
   518             d->mMinTextItem->show();
   535             d->mMinTextItem->show();
   519             d->mMaxTextItem->show();
   536             d->mMaxTextItem->show();
   520     } else {
   537     } else {
   521         if(d->mMinTextItem && d->mMaxTextItem){
   538         if(d->mMinTextItem && d->mMaxTextItem){
   522             d->mMinTextItem->hide();
   539             d->mMinTextItem->hide();
   523             d->mMaxTextItem->hide();
   540             d->mMaxTextItem->hide();
   524         }
   541         }
   525     }
   542     }
   526     repolish();
   543     repolish();
   527     updatePrimitives();
   544     //updatePrimitives();
   528     }
   545     }
   529 }
   546 }
   530 
   547 
   531 /*!
   548 /*!
   532     @beta
   549     @beta
   550 
   567 
   551     In Vertical orienatation,     
   568     In Vertical orienatation,     
   552     AlignTop is equivalent to Left
   569     AlignTop is equivalent to Left
   553     AlignBottom is equivalent to Right
   570     AlignBottom is equivalent to Right
   554 
   571 
   555     \param alignment alignement for the min max text
   572     \param alignment alignment for the min max text
   556     \sa isMinMaxTextVisible().
   573     \sa isMinMaxTextVisible().
   557 
   574 
   558 */
   575 */
   559 void HbProgressBar::setMinMaxTextAlignment(Qt::Alignment alignment)
   576 void HbProgressBar::setMinMaxTextAlignment(Qt::Alignment alignment)
   560 {
   577 {
   565     if (d->mMinMaxTextAlignment != alignment) {
   582     if (d->mMinMaxTextAlignment != alignment) {
   566         d->mMinMaxTextAlignment = alignment;
   583         d->mMinMaxTextAlignment = alignment;
   567         if (d->mMinMaxTextVisible) {
   584         if (d->mMinMaxTextVisible) {
   568             repolish();
   585             repolish();
   569         }
   586         }
   570         updatePrimitives();
   587         // no need for primitve updation, only layout change is required
       
   588         //updatePrimitives();
   571     }
   589     }
   572 
   590 
   573 }
   591 }
   574 /*!
   592 /*!
   575     @beta
   593     @beta
   682     option->maxText = d->mMaxText;
   700     option->maxText = d->mMaxText;
   683     option->orientation = d->mOrientation;
   701     option->orientation = d->mOrientation;
   684     option->inverted = d->mInvertedAppearance;
   702     option->inverted = d->mInvertedAppearance;
   685     option->stopWaitAnimation = false;
   703     option->stopWaitAnimation = false;
   686     option->minMaxTextAlignment = d->mMinMaxTextAlignment;
   704     option->minMaxTextAlignment = d->mMinMaxTextAlignment;
   687     QRect rect((int)d->mFrame->boundingRect().x(),(int)d->mFrame->boundingRect().y(),(int)d->mFrame->boundingRect().width(),
   705 
   688     (int)d->mFrame->boundingRect().height());
       
   689     option->rect = rect;
       
   690 }
   706 }
   691 
   707 
   692 /*!
   708 /*!
   693     \reimp
   709     \reimp
   694  */
   710  */