src/hbwidgets/sliders/hbprogressbar.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 3 11d3954df52a
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    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 
    26 
       
    27 #include <hbprogressbar.h>
    26 #include <hbprogressbar.h>
    28 #include <hbstyleoptionprogressbar.h>
    27 #include <hbstyleoptionprogressbar_p.h>
    29 #include "hbprogressbar_p.h"
    28 #include "hbprogressbar_p.h"
    30 #include "hbglobal_p.h"
    29 #include "hbglobal_p.h"
    31 
    30 
    32 #ifdef HB_EFFECTS
    31 #ifdef HB_EFFECTS
    33 #include <hbeffect.h>
    32 #include <hbeffect.h>
    34 #include "hbeffectinternal_p.h"
    33 #include "hbeffectinternal_p.h"
    35 #define HB_PRGRESSBAR_ITEM_TYPE "HB_PROGRESSBAR"
    34 #define HB_PRGRESSBAR_ITEM_TYPE "HB_PROGRESSBAR"
    36 #endif
    35 #endif
    37 
       
    38 
    36 
    39 /*!
    37 /*!
    40     @beta
    38     @beta
    41     @hbwidgets
    39     @hbwidgets
    42     \class HbProgressBar
    40     \class HbProgressBar
   159     Q_Q(HbProgressBar);
   157     Q_Q(HbProgressBar);
   160 
   158 
   161     mMinTextItem = q->style()->createPrimitive(HbStyle::P_ProgressBar_mintext,q);
   159     mMinTextItem = q->style()->createPrimitive(HbStyle::P_ProgressBar_mintext,q);
   162     mMaxTextItem = q->style()->createPrimitive(HbStyle::P_ProgressBar_maxtext,q);
   160     mMaxTextItem = q->style()->createPrimitive(HbStyle::P_ProgressBar_maxtext,q);
   163 }
   161 }
       
   162 
   164 void HbProgressBarPrivate::setProgressValue(int value)
   163 void HbProgressBarPrivate::setProgressValue(int value)
   165 {
   164 {
   166    Q_Q(HbProgressBar);
   165    Q_Q(HbProgressBar);
   167    if (mProgressValue == value) {
   166    if (mProgressValue == value) {
   168         return;
   167         return;
   187     }
   186     }
   188 
   187 
   189     emit q->valueChanged(value);
   188     emit q->valueChanged(value);
   190     
   189     
   191 }
   190 }
       
   191 
   192 /*
   192 /*
   193     \internal
   193     \internal
   194     Sets the progressbar enabling/disabling
   194     Sets the progressbar enabling/disabling
   195 */
   195 */
   196 void HbProgressBarPrivate::setEnableFlag(bool flag)
   196 void HbProgressBarPrivate::setEnableFlag(bool flag)
   199     if(!flag) {
   199     if(!flag) {
   200         q->setProgressValue(q->minimum());
   200         q->setProgressValue(q->minimum());
   201 
   201 
   202     }
   202     }
   203 }
   203 }
       
   204 
   204 /*
   205 /*
   205     \internal
   206     \internal
   206     Sets the progressbar range
   207     Sets the progressbar range
   207 */
   208 */
   208 void HbProgressBarPrivate::setRange(int minimum, int maximum)
   209 void HbProgressBarPrivate::setRange(int minimum, int maximum)
   220 
   221 
   221     if(mProgressValue > mMaximum){
   222     if(mProgressValue > mMaximum){
   222         mProgressValue = mMaximum;
   223         mProgressValue = mMaximum;
   223     }
   224     }
   224 
   225 
   225     if( (mMinimum == 0) && (mMaximum == 0) && (mType != HbProgressBar::RatingProgressBar) ) {
   226     if( (mMinimum == 0) && (mMaximum == 0) ) {
   226         mWaitTrack->setVisible(true);
   227         mWaitTrack->setVisible(true);
   227         mTrack->setVisible(false);
   228         mTrack->setVisible(false);
   228     } else {
   229     } else {
   229         mWaitTrack->setVisible(false);
   230         mWaitTrack->setVisible(false);
   230         mTrack->setVisible(true);
   231         mTrack->setVisible(true);
   231     }
   232     }
   232     q->updatePrimitives();
   233     q->updatePrimitives();
   233 }
   234 } 
   234 
   235 
   235 /*!
   236 /*!
   236     \internal
   237     \internal
   237     Sets the progressbar orientation.
   238     Sets the progressbar orientation.
   238     Can be either vertical or Horizontal.
   239     Can be either vertical or Horizontal.
   269 {
   270 {
   270     Q_UNUSED(status);
   271     Q_UNUSED(status);
   271     mShowEffectInProgress = false;
   272     mShowEffectInProgress = false;
   272 }
   273 }
   273 #endif
   274 #endif
   274 
       
   275 /*!
       
   276     Constructs a progressbar of a given \a type and \a parent. The default type is SimpleProgressBar.
       
   277 
       
   278     \deprecated HbProgressBar::HbProgressBar(HbProgressBar::ProgressBarType, QGraphicsItem*)
       
   279         is deprecated. Please use HbProgressBar::HbProgressBar(QGraphicsItem *parent) instead.
       
   280 
       
   281 */
       
   282 HbProgressBar::HbProgressBar(ProgressBarType type, QGraphicsItem *parent) : 
       
   283     HbWidget(*new HbProgressBarPrivate, parent)
       
   284 {    
       
   285     HB_DEPRECATED("HbProgressBar::HbProgressBar(HbProgressBar::ProgressBarType, QGraphicsItem*) is deprecated. Use HbProgressBar::HbProgressBar(QGraphicsItem *parent) instead.");
       
   286 
       
   287     Q_D( HbProgressBar );
       
   288     d->q_ptr = this;
       
   289     d->init();
       
   290     d->mType = type;
       
   291 }
       
   292 
   275 
   293 /*!
   276 /*!
   294     @beta
   277     @beta
   295     Constructor of  Progressbar.
   278     Constructor of  Progressbar.
   296     \param parent. Parent widget
   279     \param parent. Parent widget
   302     Q_D( HbProgressBar );
   285     Q_D( HbProgressBar );
   303     d->q_ptr = this;
   286     d->q_ptr = this;
   304     d->init();
   287     d->init();
   305 }
   288 }
   306 
   289 
   307 /*!
       
   308     \deprecated HbProgressBar::HbProgressBar(HbProgressBarPrivate&, HbProgressBar::ProgressBarType, QGraphicsItem*)
       
   309         is deprecated. Please use HbProgressBar::HbProgressBar(HbProgressBarPrivate &dd, QGraphicsItem *parent) instead.
       
   310 
       
   311 */
       
   312 HbProgressBar::HbProgressBar(HbProgressBarPrivate &dd, ProgressBarType type, QGraphicsItem *parent) : 
       
   313     HbWidget( dd, parent)
       
   314 {   
       
   315     HB_DEPRECATED("HbProgressBar::HbProgressBar(HbProgressBarPrivate&, HbProgressBar::ProgressBarType, QGraphicsItem*) is deprecated. Use HbProgressBar::HbProgressBar(HbProgressBarPrivate &dd, QGraphicsItem *parent) instead.");
       
   316 
       
   317     Q_D( HbProgressBar );
       
   318     d->init();
       
   319     d->mType = type;
       
   320 }
       
   321 
       
   322 
       
   323 HbProgressBar::HbProgressBar(HbProgressBarPrivate &dd, QGraphicsItem *parent) : 
   290 HbProgressBar::HbProgressBar(HbProgressBarPrivate &dd, QGraphicsItem *parent) : 
   324     HbWidget( dd, parent)
   291     HbWidget( dd, parent)
   325 {   
   292 {   
   326     Q_D( HbProgressBar );
   293     Q_D( HbProgressBar );
   327     d->init();
   294     d->init();
   328 }
   295 }
   329 
   296 
   330 
       
   331 /*!
   297 /*!
   332     @beta
   298     @beta
   333     Destructor for the progressbar.
   299     Destructor for the progressbar.
   334 */
   300 */
   335 HbProgressBar::~HbProgressBar() 
   301 HbProgressBar::~HbProgressBar() 
   471 {
   437 {
   472     Q_D(HbProgressBar);
   438     Q_D(HbProgressBar);
   473     if (d->mMinText != text) {
   439     if (d->mMinText != text) {
   474         d->mMinText = text;
   440         d->mMinText = text;
   475         HbStyleOptionProgressBar progressBarOption;
   441         HbStyleOptionProgressBar progressBarOption;
   476         initStyleOption(&progressBarOption);
   442         progressBarOption.minText = d->mMinText;
   477         style()->updatePrimitive(d->mMinTextItem,HbStyle::P_ProgressBar_mintext,&progressBarOption);
   443         style()->updatePrimitive(d->mMinTextItem,HbStyle::P_ProgressBar_mintext,&progressBarOption);
   478      }
   444      }
   479 }
   445 }
   480 
   446 
   481 /*!
   447 /*!
   501 {
   467 {
   502     Q_D(HbProgressBar);
   468     Q_D(HbProgressBar);
   503     if (d->mMaxText != text) {
   469     if (d->mMaxText != text) {
   504         d->mMaxText = text;
   470         d->mMaxText = text;
   505         HbStyleOptionProgressBar progressBarOption;
   471         HbStyleOptionProgressBar progressBarOption;
   506         initStyleOption(&progressBarOption);
   472         progressBarOption.maxText = d->mMaxText;
   507         style()->updatePrimitive(d->mMaxTextItem,HbStyle::P_ProgressBar_maxtext,&progressBarOption);
   473         style()->updatePrimitive(d->mMaxTextItem,HbStyle::P_ProgressBar_maxtext,&progressBarOption);
   508     }
   474     }
   509 }
   475 }
   510 
   476 
   511 /*!
   477 /*!
   702     option->maximum = d->mMaximum;
   668     option->maximum = d->mMaximum;
   703     option->minimum = d->mMinimum;
   669     option->minimum = d->mMinimum;
   704     option->minText = d->mMinText;
   670     option->minText = d->mMinText;
   705     option->maxText = d->mMaxText;
   671     option->maxText = d->mMaxText;
   706     option->orientation = d->mOrientation;
   672     option->orientation = d->mOrientation;
   707     option->isSlider=d->mType == HbProgressBar::RatingProgressBar;
       
   708     option->inverted = d->mInvertedAppearance;
   673     option->inverted = d->mInvertedAppearance;
   709     option->stopWaitAnimation = false;
   674     option->stopWaitAnimation = false;
   710     option->minMaxTextAlignment = d->mMinMaxTextAlignment;
   675     option->minMaxTextAlignment = d->mMinMaxTextAlignment;
   711     QRect rect((int)d->mFrame->boundingRect().x(),(int)d->mFrame->boundingRect().y(),(int)d->mFrame->boundingRect().width(),
   676     QRect rect((int)d->mFrame->boundingRect().x(),(int)d->mFrame->boundingRect().y(),(int)d->mFrame->boundingRect().width(),
   712     (int)d->mFrame->boundingRect().height());
   677     (int)d->mFrame->boundingRect().height());
   795 
   760 
   796     HbWidget::changeEvent(event);
   761     HbWidget::changeEvent(event);
   797 }
   762 }
   798 
   763 
   799 #include "moc_hbprogressbar.cpp"
   764 #include "moc_hbprogressbar.cpp"
   800