src/hbwidgets/sliders/hbprogressslider.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 2 06ff229162e9
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
    26 #include <hbprogressslider.h>
    26 #include <hbprogressslider.h>
    27 #include "hbprogressslider_p.h"
    27 #include "hbprogressslider_p.h"
    28 
    28 
    29 #include <hbstyleoptionprogressbar.h>
    29 #include <hbstyleoptionprogressslider.h>
    30 #include <hbtooltip.h>
    30 #include <hbtooltip.h>
    31 #include <hbwidgetfeedback.h>
    31 #include <hbwidgetfeedback.h>
       
    32 #include "hbglobal_p.h"
    32 
    33 
    33 #include <QGraphicsSceneMouseEvent>
    34 #include <QGraphicsSceneMouseEvent>
    34 #include <QApplication>
    35 #include <QApplication>
    35 
    36 
    36 #ifdef HB_EFFECTS
    37 #ifdef HB_EFFECTS
    39 #define HB_PRGRESSSLIDER_ITEM_TYPE "HB_PROGRESSSLIDER"
    40 #define HB_PRGRESSSLIDER_ITEM_TYPE "HB_PROGRESSSLIDER"
    40 #endif
    41 #endif
    41 
    42 
    42 HbProgressSliderPrivate::HbProgressSliderPrivate()
    43 HbProgressSliderPrivate::HbProgressSliderPrivate()
    43 {
    44 {
    44     downState=false;
    45     mDownState=false;
    45     handle = 0;
    46     handle = 0;
    46     mSliderValue = 0;
    47     mSliderValue = 0;
    47     thumbIcon = HbIcon();
    48     thumbIcon = HbIcon();
    48     state = HbProgressSlider::SliderStatePlayNormal;
    49     state = HbProgressSlider::SliderStatePlayNormal;
    49 }
    50     mHandlePath = QString();
    50 
    51 }
    51 
    52 
    52 HbProgressSliderPrivate::~HbProgressSliderPrivate()
    53 HbProgressSliderPrivate::~HbProgressSliderPrivate()
    53 {
    54 {
    54     if (handle) {
    55     if (handle) {
    55         delete handle;
    56         delete handle;
    56     }
    57     }
    57 }
    58 }
    58 
    59 
       
    60 void HbProgressSliderPrivate::setProgressValue(int value)
       
    61 {
       
    62    Q_Q(HbProgressSlider);
       
    63    if (mProgressValue == value) {
       
    64         return;
       
    65     }
       
    66     if (value >= mMaximum) {
       
    67         value = mMaximum;
       
    68 #ifdef HB_EFFECTS
       
    69        // HbEffect::start(mTrack, HB_PRGRESSSLIDER_ITEM_TYPE, "progressbar_progress_complete");
       
    70 #endif
       
    71     }
       
    72     else if (value < mMinimum) {
       
    73         value = mMinimum;
       
    74     }
       
    75     
       
    76     mProgressValue=value;
       
    77 
       
    78     //redraw track
       
    79     HbStyleOptionProgressSlider sliderOption;
       
    80     q->initStyleOption(&sliderOption);
       
    81     if(mTrack) {
       
    82         q->style()->updatePrimitive(mTrack, HbStyle::P_ProgressSlider_track, &sliderOption);
       
    83     }
       
    84 
       
    85     emit q->valueChanged(value);
       
    86 }
       
    87 
       
    88 void HbProgressSliderPrivate::setEnableFlag(bool flag)
       
    89 {
       
    90     Q_Q(HbProgressSlider);
       
    91     if(!flag) {
       
    92         q->setProgressValue(q->minimum());
       
    93         q->setSliderValue(q->minimum());
       
    94     }
       
    95 }
    59 
    96 
    60 void HbProgressSliderPrivate::init()
    97 void HbProgressSliderPrivate::init()
    61 {
    98 {
    62     Q_Q(HbProgressSlider);
    99     Q_Q(HbProgressSlider);
    63     mSliderGraphicItem  = q->style()->createPrimitive(HbStyle::P_ProgressBar_slidertrack,mFrame);
   100 
    64 	   	// Show the touch area which is created in ProgressBar//
   101     mSliderGraphicItem  = q->style()->createPrimitive(HbStyle::P_ProgressSlider_slidertrack,mFrame);
    65     mTouchAreaItem = q->style()->createPrimitive(HbStyle::P_ProgressBar_toucharea,q);
   102     // Show the touch area which is created in ProgressBar//
    66 	mFrame->setZValue(mTouchAreaItem->zValue()+1);
   103     mTouchAreaItem = q->style()->createPrimitive(HbStyle::P_ProgressSlider_toucharea,q);
       
   104     mFrame->setZValue(mTouchAreaItem->zValue()+1);
       
   105 
    67 #ifdef HB_EFFECTS
   106 #ifdef HB_EFFECTS
    68     HbEffectInternal::add(HB_PRGRESSSLIDER_ITEM_TYPE,"progressslider_trackpress", "progressslider_trackpress");
   107     HbEffectInternal::add(HB_PRGRESSSLIDER_ITEM_TYPE,"progressslider_trackpress", "progressslider_trackpress");
    69     HbEffectInternal::add(HB_PRGRESSSLIDER_ITEM_TYPE,"progressslider_trackrelease", "progressslider_trackrelease");
   108     HbEffectInternal::add(HB_PRGRESSSLIDER_ITEM_TYPE,"progressslider_trackrelease", "progressslider_trackrelease");
    70 #endif
   109 #endif
       
   110 
       
   111     q->grabGesture(Qt::TapGesture);
       
   112 
       
   113     if(QGraphicsObject *touchArea = mTouchAreaItem->toGraphicsObject()) {
       
   114         touchArea->grabGesture(Qt::TapGesture);
       
   115     }
    71 }
   116 }
    72 
   117 
    73 void HbProgressSliderPrivate::emitSliderPressed()
   118 void HbProgressSliderPrivate::emitSliderPressed()
    74 {
   119 {
    75     Q_Q(HbProgressSlider);
   120     Q_Q(HbProgressSlider);
    76     emit q->sliderPressed();
   121     emit q->sliderPressed();
    77 }
   122 }
    78 
       
    79 
   123 
    80 void HbProgressSliderPrivate::emitSliderReleased()
   124 void HbProgressSliderPrivate::emitSliderReleased()
    81 {
   125 {
    82     Q_Q(HbProgressSlider);
   126     Q_Q(HbProgressSlider);
    83     emit q->sliderReleased();
   127     emit q->sliderReleased();
   148     return Qt::AlignTop;
   192     return Qt::AlignTop;
   149 }
   193 }
   150 Qt::Orientation HbProgressSliderPrivate::orientation()
   194 Qt::Orientation HbProgressSliderPrivate::orientation()
   151 {
   195 {
   152     return mOrientation;
   196     return mOrientation;
   153 }
       
   154 
       
   155 void HbProgressSliderPrivate::updateMaskWidth(qreal width)
       
   156 {
       
   157     Q_Q( HbProgressSlider );
       
   158     HbStyleOptionProgressBar progressBarOption;
       
   159     q->initStyleOption(&progressBarOption);
       
   160     progressBarOption.maskWidth = width;
       
   161 
       
   162     if(mTrack) {
       
   163         q->style()->updatePrimitive(mTrack, HbStyle::P_ProgressBar_slidertrack, &progressBarOption);
       
   164     }
       
   165 }
   197 }
   166 
   198 
   167 void HbProgressSliderPrivate::setRange(int minimum, int maximum)
   199 void HbProgressSliderPrivate::setRange(int minimum, int maximum)
   168 {
   200 {
   169     Q_Q( HbProgressSlider );
   201     Q_Q( HbProgressSlider );
   181     There is also a progressValue which indicates the amount of buffered data.General use
   213     There is also a progressValue which indicates the amount of buffered data.General use
   182     for this widget would be for playing music online which indicates sliderValue as currentTime and 
   214     for this widget would be for playing music online which indicates sliderValue as currentTime and 
   183     progressValue as the buffered amount.
   215     progressValue as the buffered amount.
   184 
   216 
   185     HbProgressSlider is derived from HbProgressBar so it supports all the features supported by HbProgressBar.
   217     HbProgressSlider is derived from HbProgressBar so it supports all the features supported by HbProgressBar.
   186     infinite and rating progress bar feature is disabled in HbProgressSlider.
   218 
   187     \sa HbProgressBar
   219     HbProgressSlider emits below signals 
   188 */
   220 
       
   221     void sliderPressed();
       
   222     void sliderReleased();
       
   223     void sliderMoved(int value);
       
   224 
       
   225     sliderPressed is emits when the track is pressed. 
       
   226     sliderReleased is emits when the track is released.
       
   227     sliderMoved is emits when the handle is moved in any direction.
       
   228 
       
   229 
       
   230     sample code showing how this can be connected. If the Application has different use case based on 
       
   231     Slider press and slider release they can customize the behaviour.
       
   232 
       
   233     \code
       
   234     HbProgressSlider *object = new HbProgressSlider(parent);
       
   235     connect(mySlider,SIGNAL(sliderMoved(int)), mySlider ,SLOT(setSliderValue(int)));
       
   236     \endcode
       
   237     
       
   238 */
       
   239 
       
   240 /*!
       
   241     @beta
       
   242     Constructs a progressslider with a  parent.
       
   243 */
       
   244 
   189 HbProgressSlider::HbProgressSlider(QGraphicsItem *parent) :
   245 HbProgressSlider::HbProgressSlider(QGraphicsItem *parent) :
   190     HbProgressBar(*new HbProgressSliderPrivate,HbProgressBar::SimpleProgressBar,parent)
   246     HbProgressBar(*new HbProgressSliderPrivate,HbProgressBar::SimpleProgressBar,parent)
   191 {
   247 {
   192     Q_D( HbProgressSlider );
   248     Q_D( HbProgressSlider );
   193     d->q_ptr = this;
   249     d->q_ptr = this;
   194     d->init();
   250     d->init();
   195 
   251     setMinMaxTextVisible(true);
   196 
   252 
   197     setFocusPolicy(Qt::FocusPolicy(qApp->style()->styleHint(QStyle::SH_Button_FocusPolicy)));
   253     setFocusPolicy(Qt::FocusPolicy(qApp->style()->styleHint(QStyle::SH_Button_FocusPolicy)));
   198     d->handle =new HbProgressSliderHandle(d);
   254     d->handle =new HbProgressSliderHandle(d);
   199     if(!flags().testFlag(ItemIsFocusable)) {
   255     if(!flags().testFlag(ItemIsFocusable)) {
   200         d->handle->setVisible(false);
   256         d->handle->setVisible(false);
   201     }
   257     }
   202     if(d->mOrientation == Qt::Horizontal){
   258     if(d->mOrientation == Qt::Horizontal){
   203 		qreal x = boundingRect().height();
   259         qreal x = boundingRect().height();
   204 		qreal y = d->handle->size().height();
   260         qreal y = d->handle->size().height();
   205 		qreal a = qreal (x-y)/2;
   261         qreal a = qreal (x-y)/2;
   206         d->handle->setPos(0,a);
   262         d->handle->setPos(0,a);
   207 
   263 
   208     }
   264     }
   209     else{
   265     else{
   210         d->handle->setPos(0,boundingRect().height());
   266         d->handle->setPos(0,boundingRect().height());
   212 }
   268 }
   213 
   269 
   214 
   270 
   215 /*!
   271 /*!
   216     @beta
   272     @beta
   217     Constructs a progressslider  of a given \a parent.
   273     Constructs a progressslider with a  parent.
   218 */
   274 */
   219 HbProgressSlider::HbProgressSlider(HbProgressSliderPrivate &dd,QGraphicsItem *parent) : 
   275 HbProgressSlider::HbProgressSlider(HbProgressSliderPrivate &dd,QGraphicsItem *parent) : 
   220     HbProgressBar( dd,HbProgressBar::SimpleProgressBar,parent)
   276     HbProgressBar( dd,HbProgressBar::SimpleProgressBar,parent)
   221 {
   277 {
   222     Q_D( HbProgressSlider );
   278     Q_D( HbProgressSlider );
   223     d->init();
   279     d->init();
   224 
   280 
   225 	setFocusPolicy(Qt::FocusPolicy(qApp->style()->styleHint(QStyle::SH_Button_FocusPolicy)));
   281     setFocusPolicy(Qt::FocusPolicy(qApp->style()->styleHint(QStyle::SH_Button_FocusPolicy)));
   226     d->handle =new HbProgressSliderHandle(d);
   282     d->handle =new HbProgressSliderHandle(d);
   227 	d->handle->setZValue(1010);
   283     d->handle->setZValue(1010);
   228     if(d->mOrientation == Qt::Horizontal){
   284     if(d->mOrientation == Qt::Horizontal){
   229 		qreal posY = qreal (boundingRect().height()-d->handle->size().height())/2;
   285         qreal posY = qreal (boundingRect().height()-d->handle->size().height())/2;
   230         d->handle->setPos(0,posY);
   286         d->handle->setPos(0,posY);
   231     }
   287     }
   232     else{
   288     else{
   233         d->handle->setPos(0,boundingRect().height());
   289         d->handle->setPos(0,boundingRect().height());
   234     }
   290     }
   248     Sets the current value of the progress slider.
   304     Sets the current value of the progress slider.
   249 
   305 
   250     The progress slider forces the value to be within the legal range: \b
   306     The progress slider forces the value to be within the legal range: \b
   251     minimum <= \c value <= \b maximum.
   307     minimum <= \c value <= \b maximum.
   252 
   308 
   253     \sa value()
   309     \param value slider value.
       
   310 
       
   311     \sa sliderValue()
   254 */
   312 */
   255 void HbProgressSlider::setSliderValue(int value)
   313 void HbProgressSlider::setSliderValue(int value)
   256 {
   314 {
   257     Q_D( HbProgressSlider );
   315     Q_D( HbProgressSlider );
   258 
   316 
   266     if (value<minimum()) {
   324     if (value<minimum()) {
   267         value = minimum();
   325         value = minimum();
   268     }
   326     }
   269     d->mSliderValue = value;
   327     d->mSliderValue = value;
   270 
   328 
   271     HbStyleOptionProgressBar progressBarOption;
   329     HbStyleOptionProgressSlider option;
   272     initStyleOption(&progressBarOption);
   330     initStyleOption(&option);
       
   331 
   273     if (d->mSliderGraphicItem) {
   332     if (d->mSliderGraphicItem) {
   274         style()->updatePrimitive(d->mSliderGraphicItem, HbStyle::P_ProgressBar_slidertrack, &progressBarOption);
   333         style()->updatePrimitive(d->mSliderGraphicItem, HbStyle::P_ProgressSlider_slidertrack, &option);
   275        /* if( value == d->mMaximum ) {
       
   276             d->handle->changeIcon();
       
   277         }*/
       
   278     }
   334     }
   279     d->handle->setHandlePosForValue(sliderValue());
   335     d->handle->setHandlePosForValue(sliderValue());
   280 }
   336 }
   281 
   337 
   282 /*!
   338 /*!
   294 }
   350 }
   295 
   351 
   296 
   352 
   297 /*!
   353 /*!
   298     @beta
   354     @beta
   299     Returns \c true whether the slider is pressed down.
   355     Returns true of false depending on whether the slider is pressed down or not.
   300 */
   356 */
   301 
   357 
   302 bool HbProgressSlider::isSliderDown() const
   358 bool HbProgressSlider::isSliderDown() const
   303 {
   359 {
   304     Q_D( const HbProgressSlider );
   360     Q_D( const HbProgressSlider );
   306 }
   362 }
   307 
   363 
   308 
   364 
   309 /*!
   365 /*!
   310     @beta
   366     @beta
   311     Sets the inverted appearance flag. 
   367     Sets the inverted appearence of the slider.
       
   368     If inverted the slider increases from right to left.
       
   369 
       
   370     \param inverted true or false
       
   371 
       
   372     \sa invertedAppearance()
   312 */
   373 */
   313 void HbProgressSlider::setInvertedAppearance(bool inverted)
   374 void HbProgressSlider::setInvertedAppearance(bool inverted)
   314 {
   375 {
   315     Q_D( HbProgressSlider );
   376     Q_D( HbProgressSlider );
   316     if(d->mInvertedAppearance != inverted) {
   377     if(d->mInvertedAppearance != inverted) {
   319         updatePrimitives();
   380         updatePrimitives();
   320     }
   381     }
   321 }
   382 }
   322 
   383 
   323 
   384 
   324 /*!
   385 /*!    
       
   386     \deprecated HbProgressSlider::setThumbIcon(const HbIcon&)
       
   387         is deprecated. Use setHandleIcon instead of this
       
   388 
   325     Sets the Icon for the progressslider thumb.
   389     Sets the Icon for the progressslider thumb.
   326 
       
   327     \deprecated HbProgressSlider::setThumbIcon(const HbIcon&)
       
   328         is deprecated. 
       
   329 */
   390 */
   330 void HbProgressSlider::setThumbIcon(const HbIcon &icon)
   391 void HbProgressSlider::setThumbIcon(const HbIcon &icon)
   331 {
   392 {
       
   393     HB_DEPRECATED("HbProgressSlider::setThumbIcon is deprecated.");
       
   394 
   332     Q_D( HbProgressSlider );
   395     Q_D( HbProgressSlider );
   333     d->handle->setThumbIcon(icon);
   396     d->handle->setHandleIcon(icon);
   334 }
   397 }
   335 
   398 
   336 /*!
   399 /*!
   337     Returns the Icon for the progressslider thumb.
       
   338 
       
   339     \deprecated HbProgressSlider::thumbIcon() const
   400     \deprecated HbProgressSlider::thumbIcon() const
   340         is deprecated. 
   401         is deprecated. 
       
   402 
       
   403     Returns the Icon for the progressslider thumb.
   341 */
   404 */
   342 HbIcon HbProgressSlider::thumbIcon() const
   405 HbIcon HbProgressSlider::thumbIcon() const
   343 {
   406 {
       
   407     HB_DEPRECATED("HbProgressSlider::thumbIcon is deprecated.");
       
   408 
   344     Q_D( const HbProgressSlider );
   409     Q_D( const HbProgressSlider );
   345     return d->handle->thumbIcon();
   410     return d->handle->thumbIcon();
   346 }
   411 }
   347 
   412 
   348 void HbProgressSlider::mousePressEvent(QGraphicsSceneMouseEvent *event) 
   413 void HbProgressSlider::mousePressEvent(QGraphicsSceneMouseEvent *event) 
   349 {
   414 {
   350     Q_D(HbProgressSlider);
   415     Q_D(HbProgressSlider);
   351     if(flags().testFlag(ItemIsFocusable)) {
   416     if(flags().testFlag(ItemIsFocusable)) {
       
   417         d->mDownState = true;
       
   418         HbStyleOptionProgressSlider option;
       
   419         initStyleOption(&option);
       
   420         if (d->mFrame) {
       
   421             style()->updatePrimitive(d->mFrame, HbStyle::P_ProgressSlider_frame, &option);          
       
   422         }
   352         qreal temp = event->scenePos().x();
   423         qreal temp = event->scenePos().x();
   353         if((d->mMinMaxTextVisible) && (d->mMinMaxTextAlignment== Qt::AlignCenter)) {
   424         if((d->mMinMaxTextVisible) && (d->mMinMaxTextAlignment== Qt::AlignCenter)) {
   354 		    temp -=  d->mMinTextItem->boundingRect().width();
   425             temp -=  d->mMinTextItem->boundingRect().width();
   355         }
   426         }
   356         if( (temp > d->handle->pos().x()) && (temp < (d->handle->boundingRect().width()+d->handle->pos().x())) ) {
   427         if( (temp > d->handle->pos().x()) && (temp < (d->handle->boundingRect().width()+d->handle->pos().x())) ) {
   357             event->ignore();
   428             event->ignore();
   358             return;
   429             return;
   359         }
   430         }
   360         
   431         
   361         HbWidgetFeedback::triggered(this, Hb::InstantPressed);
   432         HbWidgetFeedback::triggered(this, Hb::InstantPressed);
   362         d->handle->handleTrackPress(event);
   433         d->handle->handleTrackPress(event);
   363         event->accept();
   434         event->accept();
   364 		#ifdef HB_EFFECTS
   435         #ifdef HB_EFFECTS
   365 	        HbEffect::start(this, HB_PRGRESSSLIDER_ITEM_TYPE, "progressslider_trackpress");
   436             HbEffect::start(this, HB_PRGRESSSLIDER_ITEM_TYPE, "progressslider_trackpress");
   366         #endif
   437         #endif
   367     } else {
   438     } else {
   368         event->ignore();
   439         event->ignore();
   369     }
   440     }
   370 }
   441 }
   371 
   442 
   372 
       
   373 void HbProgressSlider::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) 
   443 void HbProgressSlider::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) 
   374 {
   444 {
   375     Q_D(HbProgressSlider);
   445     Q_D(HbProgressSlider);
   376     if(flags().testFlag(ItemIsFocusable)) {
   446     if(flags().testFlag(ItemIsFocusable)) {
       
   447         d->mDownState = false;
       
   448 
       
   449         HbStyleOptionProgressSlider option;
       
   450         initStyleOption(&option);
       
   451         if (d->mFrame) {
       
   452             style()->updatePrimitive(d->mFrame, HbStyle::P_ProgressSlider_frame, &option);          
       
   453         }
       
   454 
   377         HbWidgetFeedback::triggered(this, Hb::InstantReleased);
   455         HbWidgetFeedback::triggered(this, Hb::InstantReleased);
   378         d->handle->handleTrackRelease(event);
   456         d->handle->handleTrackRelease(event);
   379         event->accept();
   457         event->accept();
   380 #ifdef HB_EFFECTS
   458 #ifdef HB_EFFECTS
   381         HbEffect::start(this, HB_PRGRESSSLIDER_ITEM_TYPE, "progressslider_trackrelease");
   459         HbEffect::start(this, HB_PRGRESSSLIDER_ITEM_TYPE, "progressslider_trackrelease");
   382 #endif
   460 #endif
   383     } else {
   461     } else {
   384         event->ignore();
   462         event->ignore();
   385     }
   463     }
   386   
       
   387 }
   464 }
   388 
   465 
   389 void HbProgressSlider::setGeometry(const QRectF & rect)
   466 void HbProgressSlider::setGeometry(const QRectF & rect)
   390 {
   467 {
   391     Q_D(HbProgressSlider);
   468     Q_D(HbProgressSlider);
   392     HbProgressBar::setGeometry(rect);
   469     HbProgressBar::setGeometry(rect);
   393     d->handle->setHandlePosForValue(sliderValue());
   470     d->handle->setHandlePosForValue(sliderValue());
   394     updatePrimitives();
   471     updatePrimitives();
   395 }
   472 }
   396 
   473 
   397 
   474 /*!
   398 void HbProgressSlider::initStyleOption(HbStyleOption *hboption) const
   475     Initializes \a option with the values from this HbProgressSlider. 
   399 {
   476     This method is useful for subclasses when they need a HbStyleOptionProgressSlider,
   400     Q_ASSERT(hboption);
   477     but don't want to fill in all the information themselves.
       
   478  */
       
   479 void HbProgressSlider::initStyleOption( HbStyleOptionProgressSlider *option ) const
       
   480 {
   401     Q_D(const HbProgressSlider);
   481     Q_D(const HbProgressSlider);
   402     HbProgressBar::initStyleOption(hboption);
   482     HbProgressBar::initStyleOption(option);
   403     HbStyleOptionProgressBar *option = 0;
   483 
   404     if ((option = qstyleoption_cast< HbStyleOptionProgressBar *>(hboption)) != 0){
   484     option->secondaryType = true;
   405         option->secondoryType = true;
   485     option->progressSliderValue = d->mSliderValue;  
   406         option->sliderValue = d->mSliderValue;
   486     option->pressedState = d->mDownState;
   407         option->inverted = d->mInvertedAppearance;
   487 }
   408         option->maximum = d->mMaximum;
       
   409         option->minimum = d->mMinimum;        
       
   410     }
       
   411 }
       
   412 
       
   413 
   488 
   414 void HbProgressSlider::updatePrimitives()
   489 void HbProgressSlider::updatePrimitives()
   415 {
   490 {
   416     HbProgressBar::updatePrimitives();
       
   417 
       
   418     Q_D(HbProgressSlider);
   491     Q_D(HbProgressSlider);
   419     if(isVisible()){
   492     if(isVisible()){
   420         d->mWaitTrack->setVisible(false);
   493         d->mWaitTrack->setVisible(false);
   421         d->mTrack->setVisible(true);
   494         d->mTrack->setVisible(true);
   422         HbStyleOptionProgressBar progressBarOption;
   495 
   423         initStyleOption(&progressBarOption);
   496         HbStyleOptionProgressSlider option;
       
   497         initStyleOption(&option);
       
   498 
   424         if (d->mSliderGraphicItem) {
   499         if (d->mSliderGraphicItem) {
   425             style()->updatePrimitive(d->mSliderGraphicItem, HbStyle::P_ProgressBar_slidertrack, &progressBarOption);
   500             style()->updatePrimitive(d->mSliderGraphicItem, HbStyle::P_ProgressSlider_slidertrack, &option);
   426         }
   501         }
   427 
   502 
   428         if(d->handle)
   503         if(d->handle)
   429               d->handle->setHandlePosForValue(sliderValue());
   504               d->handle->setHandlePosForValue(sliderValue());
   430     }
       
   431     
   505     
       
   506         if (d->mFrame) {
       
   507             style()->updatePrimitive(d->mFrame, HbStyle::P_ProgressSlider_frame, &option);          
       
   508         }
       
   509      
       
   510         if (d->mTrack) {
       
   511                 style()->updatePrimitive(d->mTrack, HbStyle::P_ProgressSlider_track, &option);
       
   512         }
       
   513                 
       
   514         if(d->mMinTextItem && d->mMinMaxTextVisible) {
       
   515             style()->updatePrimitive(d->mMinTextItem,HbStyle::P_ProgressBar_mintext,&option);    
       
   516         }
       
   517 
       
   518         if(d->mMaxTextItem && d->mMinMaxTextVisible) {
       
   519             style()->updatePrimitive(d->mMaxTextItem,HbStyle::P_ProgressBar_maxtext,&option);    
       
   520         }
       
   521     }
   432 }
   522 }
   433 
   523 
   434 void HbProgressSlider::showEvent( QShowEvent * event )
   524 void HbProgressSlider::showEvent( QShowEvent * event )
   435 {
   525 {
   436 	Q_D(const HbProgressSlider);
   526     Q_D(const HbProgressSlider);
   437 	if(d->mTouchAreaItem && scene()) {
   527     if(d->mTouchAreaItem && scene()) {
   438         d->mTouchAreaItem->removeSceneEventFilter(this);
   528         d->mTouchAreaItem->removeSceneEventFilter(this);
   439         d->mTouchAreaItem->installSceneEventFilter(this);
   529         d->mTouchAreaItem->installSceneEventFilter(this);
   440     }
   530     }
   441 
   531 
   442     HbProgressBar::showEvent(event);
   532     HbProgressBar::showEvent(event);
   446     Q_D(HbProgressSlider);
   536     Q_D(HbProgressSlider);
   447     if (change == ItemFlagsChange) {
   537     if (change == ItemFlagsChange) {
   448         if(value.toInt() & ItemIsFocusable) {
   538         if(value.toInt() & ItemIsFocusable) {
   449             if(!flags().testFlag(ItemIsFocusable) && d->handle) {
   539             if(!flags().testFlag(ItemIsFocusable) && d->handle) {
   450                 d->handle->setVisible(true);
   540                 d->handle->setVisible(true);
   451 
       
   452             }
   541             }
   453         } else {
   542         } else {
   454             if(flags().testFlag(ItemIsFocusable) && d->handle) {
   543             if(flags().testFlag(ItemIsFocusable) && d->handle) {
   455                 d->handle->setVisible(false);
   544                 d->handle->setVisible(false);
   456             }
   545             }
   461 }
   550 }
   462 
   551 
   463 bool HbProgressSlider::sceneEventFilter(QGraphicsItem *obj,QEvent *event)
   552 bool HbProgressSlider::sceneEventFilter(QGraphicsItem *obj,QEvent *event)
   464 {
   553 {
   465     Q_D(HbProgressSlider);
   554     Q_D(HbProgressSlider);
   466 	if( obj == d->mTouchAreaItem) {
   555     if( obj == d->mTouchAreaItem) {
   467        if (!isEnabled() ) {
   556        if (!isEnabled() ) {
   468             return false;
   557             return false;
   469         }
   558         }
   470 		if (event->type() == QEvent::GraphicsSceneMousePress){
   559         if (event->type() == QEvent::GraphicsSceneMousePress){
   471 			mousePressEvent((QGraphicsSceneMouseEvent *) event);
   560             mousePressEvent((QGraphicsSceneMouseEvent *) event);
   472              return true;
   561              return true;
   473 		}
   562         }
   474 		else if (event->type() == QEvent::GraphicsSceneMouseRelease){
   563         else if (event->type() == QEvent::GraphicsSceneMouseRelease){
   475 			mouseReleaseEvent((QGraphicsSceneMouseEvent *) event);
   564             mouseReleaseEvent((QGraphicsSceneMouseEvent *) event);
   476             return true;
   565             return true;
   477 		}
   566         }
   478 	} 
   567     } 
   479 	return false;
   568     return false;
   480 }
   569 }
   481 
   570 
   482 /*!
   571 /*!
       
   572     \deprecated HbProgressSlider::setHandleToolTip(const QString&)
       
   573         is deprecated. Please use HbProgressSlider::setSliderToolTip(const QString &text) instead.
       
   574 
   483     set the tooltip text . 
   575     set the tooltip text . 
   484     
   576     
   485     \deprecated HbProgressSlider::setHandleToolTip(const QString&)
       
   486         is deprecated. Please use HbProgressSlider::setSliderToolTip(const QString &text) instead.
       
   487 
       
   488     \sa handleToolTip()
   577     \sa handleToolTip()
   489 */
   578 */
   490 void HbProgressSlider::setHandleToolTip(const QString &text)
   579 void HbProgressSlider::setHandleToolTip(const QString &text)
   491 {
   580 {
       
   581     HB_DEPRECATED("HbProgressSlider::setHandleToolTip is deprecated. Use HbProgressSlider::setSliderToolTip(const QString &text) instead.");
       
   582 
   492     setSliderToolTip(text);
   583     setSliderToolTip(text);
   493 }
   584 }
   494 
   585 
   495 
   586 
   496 /*!
   587 /*!
       
   588     \deprecated HbProgressSlider::handleToolTip() const
       
   589         is deprecated. Please use HbProgressSlider::sliderToolTip() const instead.
       
   590 
   497     Returns the current tooltip text value.
   591     Returns the current tooltip text value.
   498     
   592     
   499     \deprecated HbProgressSlider::handleToolTip() const
       
   500         is deprecated. Please use HbProgressSlider::sliderToolTip() const instead.
       
   501 
       
   502     \sa setHandleToolTip()
   593     \sa setHandleToolTip()
   503 */
   594 */
   504 QString HbProgressSlider::handleToolTip() const
   595 QString HbProgressSlider::handleToolTip() const
   505 {
   596 {
       
   597     HB_DEPRECATED("HbProgressSlider::handleToolTip is deprecated. Use HbProgressSlider::sliderToolTip() instead.");
       
   598 
   506     return sliderToolTip();
   599     return sliderToolTip();
   507 }
   600 }
   508 
   601 
   509 /*!
   602 /*!
   510     Sets the state of the handle as normal play,pressed play,normal pause,pressed pause etc. 
       
   511 
       
   512     \deprecated HbProgressSlider::setHandleState(HbProgressSlider::HandleState)
   603     \deprecated HbProgressSlider::setHandleState(HbProgressSlider::HandleState)
   513         is deprecated. Please use HbProgressSlider::setSliderState(HbProgressSlider::SliderState state) instead.
   604         is deprecated. Please use HbProgressSlider::setSliderState(HbProgressSlider::SliderState state) instead.
   514 
   605 
       
   606     Sets the state of the handle as normal play,pressed play,normal pause,pressed pause etc. 
   515 */
   607 */
   516 void HbProgressSlider::setHandleState(HbProgressSlider::HandleState state)
   608 void HbProgressSlider::setHandleState(HbProgressSlider::HandleState state)
   517 {
   609 {
       
   610     HB_DEPRECATED("HbProgressSlider::setHandleState is deprecated. Use HbProgressSlider::setSliderState instead.");
       
   611 
   518     setSliderState((HbProgressSlider::SliderState)state);
   612     setSliderState((HbProgressSlider::SliderState)state);
   519 }
   613 }
   520 /*!
   614 
   521     Returns the state of the handle. 
   615 /*!
   522 
   616 
   523     \deprecated HbProgressSlider::handleState() const
   617     \deprecated HbProgressSlider::handleState() const
   524         is deprecated. Please use HbProgressSlider::sliderState() const instead.
   618         is deprecated. Please use HbProgressSlider::sliderState() const instead.
       
   619 
       
   620     Returns the state of the handle. 
   525 */
   621 */
   526 HbProgressSlider::HandleState HbProgressSlider::handleState() const
   622 HbProgressSlider::HandleState HbProgressSlider::handleState() const
   527 {
   623 {
       
   624     HB_DEPRECATED("HbProgressSlider::handleState is deprecated. Use HbProgressSlider::handleState() instead.");
       
   625 
   528     return (HbProgressSlider::HandleState)sliderState();
   626     return (HbProgressSlider::HandleState)sliderState();
   529 }
   627 }
   530 
   628 
   531 
   629 
   532 /*!
   630 /*!
   533     @beta
   631     @beta
   534 
   632     Sets the tooltip for the handle. By default it shows the slider value.
   535     Sets the tooltip text . 
   633     If the Application wants to configure this they use setSliderToolTip for 
       
   634     setting the new tooltip text.
       
   635 
       
   636     \param text tooltip text
       
   637 
   536     \sa sliderToolTip()
   638     \sa sliderToolTip()
   537 */
   639 */
   538 void HbProgressSlider::setSliderToolTip(const QString &text)
   640 void HbProgressSlider::setSliderToolTip(const QString &text)
   539 {
   641 {
   540     Q_D(HbProgressSlider);
   642     Q_D(HbProgressSlider);
   553     Q_D(const HbProgressSlider);
   655     Q_D(const HbProgressSlider);
   554     return d->mTooltipText;
   656     return d->mTooltipText;
   555 }
   657 }
   556 
   658 
   557 /*!
   659 /*!
   558     @beta
   660     \deprecated HbProgressSlider::setSliderState(HbProgressSlider::SliderState)
   559     
   661         is deprecated.
   560     Sets the state of the handle as SliderStatePlayNormal, SliderStatePlayPressed,
   662 
   561     SliderStatePauseNormal, SliderStatePausePressed.
   663     Sets the state of the handle as normal play,pressed play,normal pause,pressed pause etc. 
   562 
       
   563     \sa sliderState()
       
   564 
       
   565 */
   664 */
   566 void HbProgressSlider::setSliderState(HbProgressSlider::SliderState state)
   665 void HbProgressSlider::setSliderState(HbProgressSlider::SliderState state)
   567 {
   666 {
   568 	Q_D(HbProgressSlider);
   667     Q_D(HbProgressSlider);
   569 	if(d->state != state) {
   668     if(d->state != state) {
   570 		d->state = state;
   669         d->state = state;
   571 		if (d->handle) {
   670         if (d->handle) {
   572 			d->handle->mSliderState = state;
   671             d->handle->mSliderHandleState = state;
   573 
   672 
   574             switch(d->handle->mSliderState) {
   673             switch(d->handle->mSliderHandleState) {
   575                
       
   576                case HbProgressSlider::SliderStatePlayNormal:
   674                case HbProgressSlider::SliderStatePlayNormal:
   577                    d->handle->setProperty("state","normal");
   675                    d->handle->setProperty("state","normal");
   578                    break;
   676                    break;
   579                
       
   580                case HbProgressSlider::SliderStatePlayPressed:
   677                case HbProgressSlider::SliderStatePlayPressed:
   581                    d->handle->setProperty("state","pressed");
   678                    d->handle->setProperty("state","pressed");
   582                    break;
   679                    break;
   583                
       
   584                case HbProgressSlider::SliderStatePauseNormal:
   680                case HbProgressSlider::SliderStatePauseNormal:
   585                     d->handle->setProperty("state","normal");
   681                     d->handle->setProperty("state","normal");
   586                    break;
   682                    break;
   587                
       
   588                case HbProgressSlider::SliderStatePausePressed:
   683                case HbProgressSlider::SliderStatePausePressed:
   589                     d->handle->setProperty("state","pressed");
   684                     d->handle->setProperty("state","pressed");
   590                    break;
   685                    break;
       
   686                default:
       
   687                     break;
   591             }
   688             }
   592 
   689 
   593 			d->handle->updatePrimitives();
   690             d->handle->updatePrimitives();
   594 			
   691             
   595 		}
   692         }
   596 	}
   693     }
   597 }
   694 }
   598 /*!
   695 /*!
   599     @beta
   696     \deprecated HbProgressSlider::sliderState() const
   600 
   697         is deprecated.
   601     Returns the state of the handle. 
   698 
   602 
   699     Sets the state of the handle as normal play,pressed play,normal pause,pressed pause etc. 
   603     \sa setSliderState()
       
   604 */
   700 */
   605 HbProgressSlider::SliderState HbProgressSlider::sliderState() const
   701 HbProgressSlider::SliderState HbProgressSlider::sliderState() const
   606 {
   702 {
   607 	Q_D(const HbProgressSlider);
   703     Q_D(const HbProgressSlider);
   608 	return d->state;
   704     return d->state;
   609 
   705 }
   610 }
   706 
   611 
   707 /*!
   612 
   708     @beta
   613 /*!
   709     Sets the icon for handle. By default it has theme based icon. Application 
       
   710     can configure this icon via this API
       
   711 
       
   712     \param handlePath path of the graphics
       
   713 
       
   714     \sa handleIcon()
       
   715 */
       
   716 void HbProgressSlider::setHandleIcon(const QString& handlePath )
       
   717 {
       
   718     
       
   719     Q_D( HbProgressSlider );
       
   720     if(handlePath != d->mHandlePath) {
       
   721         d->mHandlePath =handlePath;
       
   722         d->handle->setHandleIcon(HbIcon(handlePath));
       
   723     }
       
   724 }
       
   725 
       
   726 /*!
       
   727     @beta
       
   728 
       
   729     Returns the icon  handle path
       
   730 
       
   731     \sa setHandleIcon()
       
   732 */
       
   733 QString HbProgressSlider::handleIcon() const
       
   734 {
       
   735     Q_D(const HbProgressSlider);
       
   736     return d->mHandlePath;
       
   737 }
       
   738 
       
   739 /*!
       
   740 
       
   741     \deprecated HbProgressSlider::primitive(HbStyle::Primitive)
       
   742         is deprecated.
       
   743 
   614     Returns the pointer for \a primitive passed.
   744     Returns the pointer for \a primitive passed.
   615     Will return NULL if \a primitive passed is invalid
   745     Will return NULL if \a primitive passed is invalid
   616 */
   746 */
   617 QGraphicsItem* HbProgressSlider::primitive(HbStyle::Primitive primitive) const
   747 QGraphicsItem* HbProgressSlider::primitive(HbStyle::Primitive primitive) const
   618 {
   748 {
   619     Q_D(const HbProgressSlider);
   749     Q_D(const HbProgressSlider);
   620 
   750 
   621     switch (primitive) {
   751     switch (primitive) {
   622         case HbStyle::P_ProgressBar_slidertrack:
   752         case HbStyle::P_ProgressSlider_frame:
       
   753             return d->mFrame;
       
   754         case HbStyle::P_ProgressSlider_track:
       
   755             return d->mTrack;
       
   756         case HbStyle::P_ProgressSlider_slidertrack:
   623             return d->mSliderGraphicItem;
   757             return d->mSliderGraphicItem;
   624         case HbStyle::P_ProgressBar_toucharea:
   758         case HbStyle::P_ProgressSlider_toucharea:
   625             return d->mTouchAreaItem;  
   759             return d->mTouchAreaItem; 
       
   760         case HbStyle::P_ProgressSliderHandle_icon:
       
   761         case HbStyle::P_ProgressSliderHandle_toucharea:
       
   762             return d->handle->primitive(primitive);
   626         default:
   763         default:
   627             return 0;
   764             return 0;
   628     }
   765     }
   629 }
   766 }
       
   767