branch | GCC_SURGE |
changeset 15 | f378acbc9cfb |
parent 6 | c3690ec91ef8 |
child 21 | 4633027730f5 |
child 34 | ed14f46c0e55 |
9:730c025d4b77 | 15:f378acbc9cfb |
---|---|
29 #include "hbslidercontrol_p_p.h" |
29 #include "hbslidercontrol_p_p.h" |
30 #include "hbnamespace_p.h" |
30 #include "hbnamespace_p.h" |
31 #include "hbsliderhandle_p.h" |
31 #include "hbsliderhandle_p.h" |
32 |
32 |
33 #include "hbstyleoptionslider_p.h" |
33 #include "hbstyleoptionslider_p.h" |
34 #include "hbslidertickmarks_p.h" |
|
34 #include "hbslidertickmarkslabel_p.h" |
35 #include "hbslidertickmarkslabel_p.h" |
35 #include "hbabstractbutton.h" |
36 #include "hbabstractbutton.h" |
36 #include <hbwidgetfeedback.h> |
37 #include <hbwidgetfeedback.h> |
37 #include <QGraphicsItem> |
38 #include <QGraphicsItem> |
38 #include <QGraphicsSceneEvent> |
39 #include <QGraphicsSceneEvent> |
39 #include <QGraphicsScene> |
40 #include <QGraphicsScene> |
40 #include <QDebug> |
41 #include <QDebug> |
41 |
42 #ifdef HB_GESTURE_FW |
43 #include <hbtapgesture.h> |
|
44 #endif |
|
42 #ifdef HB_EFFECTS |
45 #ifdef HB_EFFECTS |
43 #include "hbeffect.h" |
46 #include "hbeffect.h" |
44 #include "hbeffectinternal_p.h" |
47 #include "hbeffectinternal_p.h" |
45 #define HB_SLIDER_TYPE "HB_SLIDER" |
48 #define HB_SLIDER_TYPE "HB_SLIDER" |
46 #endif |
49 #endif |
86 slider->setElementIcons( map ); |
89 slider->setElementIcons( map ); |
87 \endcode |
90 \endcode |
88 |
91 |
89 \image html verticalslider.png A Custom vertical slider with all elements. |
92 \image html verticalslider.png A Custom vertical slider with all elements. |
90 |
93 |
91 order in which HbSlider::SliderElement are inserted into QList doesnt matter. |
94 order in which HbSlider::SliderElement are inserted into QList does not matter. |
92 |
95 |
93 HbSlider provides methods for controlling tickmarks. You can use |
96 HbSlider provides methods for controlling tickmarks. You can use |
94 setTickPosition( ) to indicate where you want the tickmarks to be, |
97 setTickPosition( ) to indicate where you want the tickmarks to be, |
95 setMajorTickInterval( ) and setMinorTickInterval( ) to indicate how |
98 setMajorTickInterval( ) and setMinorTickInterval( ) to indicate how |
96 many of them you want. The current set tick position and intervals |
99 many of them you want. The current set tick position and intervals |
193 */ |
196 */ |
194 |
197 |
195 /*! |
198 /*! |
196 \var HbSlider::TrackElement |
199 \var HbSlider::TrackElement |
197 |
200 |
198 The slider track that consists of a groove, ticks and handle. |
201 The slider track that consists of a groove and handle. |
199 */ |
202 */ |
200 |
203 |
201 /*! |
204 /*! |
202 \var HbSlider::DecreaseElement |
205 \var HbSlider::DecreaseElement |
203 |
206 |
205 */ |
208 */ |
206 |
209 |
207 /*! |
210 /*! |
208 \var HbSlider::IconElement |
211 \var HbSlider::IconElement |
209 |
212 |
210 An icon element associated to the slider. |
213 An icon element associated to the slider.For example mute icon of volume slider |
211 */ |
214 */ |
212 |
215 |
213 /*! |
216 /*! |
214 \var HbSlider::TextElement |
217 \var HbSlider::TextElement |
215 |
218 |
241 */ |
244 */ |
242 |
245 |
243 HbSliderPrivate::HbSliderPrivate( ) : |
246 HbSliderPrivate::HbSliderPrivate( ) : |
244 sliderControl( 0 ), |
247 sliderControl( 0 ), |
245 orientation( Qt::Vertical ), |
248 orientation( Qt::Vertical ), |
246 pressOnIncrement( false ) |
249 pressOnIncrement( false ), |
250 tickmarksLeft( 0 ), // slider left/top tick mark item |
|
251 tickmarksRight( 0 ),// slider right/bottom tick mark item |
|
252 tickmarkslabelLeft( 0 ),// slider left/above tick mark label |
|
253 tickmarkslabelRight ( 0 )// slider right/bottom tick mark label |
|
254 |
|
247 { |
255 { |
248 elementItemMap.clear(); |
256 elementItemMap.clear(); |
249 |
257 |
250 } |
258 } |
251 |
259 |
268 q->connect( sliderControl, SIGNAL( rangeChanged( int, int ) ), q, SIGNAL( rangeChanged( int, int ) ) ); |
276 q->connect( sliderControl, SIGNAL( rangeChanged( int, int ) ), q, SIGNAL( rangeChanged( int, int ) ) ); |
269 setElements( QList<HbSlider::SliderElement>( ) << HbSlider::TrackElement ); |
277 setElements( QList<HbSlider::SliderElement>( ) << HbSlider::TrackElement ); |
270 HbStyle::setItemName( q,"this" ); |
278 HbStyle::setItemName( q,"this" ); |
271 q->setFlags( QGraphicsItem::ItemIsFocusable ); |
279 q->setFlags( QGraphicsItem::ItemIsFocusable ); |
272 q->setProperty("TickLabelPresent",false); |
280 q->setProperty("TickLabelPresent",false); |
281 #ifdef HB_GESTURE_FW |
|
282 q->grabGesture(Qt::TapGesture); |
|
283 #endif |
|
273 } |
284 } |
274 |
285 |
275 void HbSliderPrivate::setElements( QList<HbSlider::SliderElement> elementList) |
286 void HbSliderPrivate::setElements( QList<HbSlider::SliderElement> elementList) |
276 { |
287 { |
277 Q_Q( HbSlider); |
288 Q_Q( HbSlider); |
278 bool oldElementRemoved = false; |
289 bool oldElementRemoved = false; |
279 foreach(HbSlider::SliderElement element,elements){ |
290 foreach(const HbSlider::SliderElement &element,elements){ |
280 if(!elementList.contains(element)&& elementItemMap.contains(element)) { |
291 if(!elementList.contains(element)&& elementItemMap.contains(element)) { |
281 delete elementItemMap[element].item; |
292 delete elementItemMap[element].item; |
282 delete elementItemMap[element].touchItem; |
293 delete elementItemMap[element].touchItem; |
283 elementItemMap.remove(element); |
294 elementItemMap.remove(element); |
284 oldElementRemoved = true; |
295 oldElementRemoved = true; |
291 // this will delete unwanted element and create new element |
302 // this will delete unwanted element and create new element |
292 updateElements( ); |
303 updateElements( ); |
293 // repolish call is required because new elements might be added |
304 // repolish call is required because new elements might be added |
294 } |
305 } |
295 |
306 |
296 /*! |
307 QSizeF HbSliderPrivate::getHandleSize( ) |
308 { |
|
309 return sliderControl ->getHandleSize(); |
|
310 } |
|
311 |
|
312 /*! |
|
313 \internal |
|
297 This api creates widget for given element |
314 This api creates widget for given element |
298 */ |
315 */ |
299 void HbSliderPrivate::elementWidget( HbSlider::SliderElement element ) |
316 void HbSliderPrivate::elementWidget( HbSlider::SliderElement element ) |
300 { |
317 { |
301 Q_Q( HbSlider ); |
318 Q_Q( HbSlider ); |
389 } //return created; |
406 } //return created; |
390 } |
407 } |
391 |
408 |
392 |
409 |
393 /*! |
410 /*! |
411 \internal |
|
394 update element will first delete element which are not required |
412 update element will first delete element which are not required |
395 and then create new element |
413 and then create new element |
396 */ |
414 */ |
397 void HbSliderPrivate::updateElements( ) |
415 void HbSliderPrivate::updateElements( ) |
398 { |
416 { |
402 elementWidget( element ); |
420 elementWidget( element ); |
403 } |
421 } |
404 } |
422 } |
405 |
423 |
406 /*! |
424 /*! |
425 \internal |
|
407 This Api will start incrementing slider value by step size |
426 This Api will start incrementing slider value by step size |
408 till the time stopReapetAction( ) is not being called or slider |
427 till the time stopReapetAction( ) is not being called or slider |
409 value becomes maximum( ) |
428 value becomes maximum( ) |
410 */ |
429 */ |
411 void HbSliderPrivate::startIncrementing( ) |
430 void HbSliderPrivate::startIncrementing( ) |
419 // start timer to increase slider value by step |
438 // start timer to increase slider value by step |
420 sliderControl->setRepeatAction( HbAbstractSliderControl::SliderSingleStepAdd,sliderControl->maximum( ) ); |
439 sliderControl->setRepeatAction( HbAbstractSliderControl::SliderSingleStepAdd,sliderControl->maximum( ) ); |
421 } |
440 } |
422 |
441 |
423 /*! |
442 /*! |
443 \internal |
|
424 This Api will start decrementing slider value by step size |
444 This Api will start decrementing slider value by step size |
425 till the time stopReapetAction( ) is not being called or slider |
445 till the time stopReapetAction( ) is not being called or slider |
426 value becomes minimum( ) |
446 value becomes minimum( ) |
427 */ |
447 */ |
428 void HbSliderPrivate::startDecrementing( ) |
448 void HbSliderPrivate::startDecrementing( ) |
434 sliderControl->triggerAction( HbAbstractSliderControl::SliderSingleStepSub ); |
454 sliderControl->triggerAction( HbAbstractSliderControl::SliderSingleStepSub ); |
435 sliderControl->setRepeatAction( HbAbstractSliderControl::SliderSingleStepSub,sliderControl->minimum( ) ); |
455 sliderControl->setRepeatAction( HbAbstractSliderControl::SliderSingleStepSub,sliderControl->minimum( ) ); |
436 } |
456 } |
437 |
457 |
438 /*! |
458 /*! |
459 \internal |
|
439 stops the reapeating action |
460 stops the reapeating action |
440 reapeat action can be increase slider value by step or decrease slider value by step |
461 reapeat action can be increase slider value by step or decrease slider value by step |
441 */ |
462 */ |
442 void HbSliderPrivate::stopRepeatAction( ) |
463 void HbSliderPrivate::stopRepeatAction( ) |
443 { |
464 { |
444 sliderControl->setRepeatAction( HbAbstractSliderControl::SliderNoAction ); |
465 sliderControl->setRepeatAction( HbAbstractSliderControl::SliderNoAction ); |
445 } |
466 } |
446 |
467 |
447 |
468 |
448 void HbSliderPrivate::setTickLabelPresentProperty( ) |
469 /*! |
449 { |
470 \internal |
450 Q_Q ( HbSlider ); |
471 creates either left tickmarks or right tickmarks or both based on tickposition of slider |
451 if (q->majorTickInterval( ) > 0 && q->tickPosition( ) !=Hb::NoSliderTicks && |
472 */ |
452 (q->majorTickLabels().length() > 0 || |
473 |
453 (q->minorTickInterval() > 0 && q->minorTickLabels( ).length() > 0))) { |
474 void HbSliderPrivate::createTickMarks( ) |
454 if(!q->property("TickLabelPresent").toBool()){ |
475 { |
455 q->setProperty("TickLabelPresent",true); |
476 Q_Q ( HbSlider); |
456 q->repolish( ); |
477 bool modified = false; |
457 } |
478 if( q->majorTickInterval( ) <= 0) { |
479 return; |
|
480 } |
|
481 if ( q->tickPosition( ) & Hb::SliderTicksLeft) { |
|
482 if (!tickmarksLeft) { |
|
483 tickmarksLeft = new HbSliderTickmarks(q); |
|
484 tickmarksLeft->setZValue(sliderControl->zValue()-1); |
|
485 tickmarksLeft->setTickPosition (Hb::SliderTicksLeft); |
|
486 modified = true; |
|
487 if ( orientation == Qt::Vertical ) { |
|
488 HbStyle::setItemName( tickmarksLeft, "tick-marksleft" ); |
|
489 } else { |
|
490 HbStyle::setItemName( tickmarksLeft, "tick-marksabove" ); |
|
491 } |
|
492 } |
|
493 |
|
494 } else if ( tickmarksLeft ) { |
|
495 delete tickmarksLeft; |
|
496 tickmarksLeft = 0; |
|
497 modified = true; |
|
498 } |
|
499 if ( q->tickPosition( ) & Hb::SliderTicksRight) { |
|
500 if (!tickmarksRight) { |
|
501 tickmarksRight = new HbSliderTickmarks(q); |
|
502 tickmarksRight->setTickPosition (Hb::SliderTicksRight); |
|
503 tickmarksRight->setZValue(sliderControl->zValue()-1); |
|
504 modified = true; |
|
505 |
|
506 if ( orientation == Qt::Vertical ) { |
|
507 HbStyle::setItemName( tickmarksRight, "tick-marksright" ); |
|
508 } else { |
|
509 HbStyle::setItemName( tickmarksRight, "tick-marksbelow" ); |
|
510 } |
|
511 } |
|
512 } else if ( tickmarksRight ) { |
|
513 delete tickmarksRight; |
|
514 tickmarksRight = 0; |
|
515 modified = true; |
|
516 } |
|
517 if ( orientation == Qt::Vertical ) { |
|
518 if ( q->tickPosition( ) & Hb::SliderTicksAbsolute) { |
|
519 q->setLayoutDirection (Qt::LeftToRight ); |
|
520 } else { |
|
521 q->unsetLayoutDirection( ); |
|
522 } |
|
458 } else { |
523 } else { |
459 if( q->property("TickLabelPresent").toBool()){ |
524 q->unsetLayoutDirection( ); |
460 q->setProperty("TickLabelPresent",false); |
525 } |
461 q->repolish( ); |
526 |
527 if ( modified) { |
|
528 q->repolish( ); |
|
529 } |
|
530 } |
|
531 |
|
532 /*! |
|
533 \internal |
|
534 creates either left tickmarks or right tickmarksLabel or both based on tickposition of slider |
|
535 |
|
536 */ |
|
537 void HbSliderPrivate::createTickLabels( ) |
|
538 { |
|
539 Q_Q(HbSlider); |
|
540 bool modified = false; |
|
541 if( q->majorTickInterval( ) <= 0 || q->majorTickLabels( ).isEmpty( ) ) { |
|
542 return; |
|
543 } |
|
544 if ( q->tickPosition( ) & Hb::SliderTicksLeft) { |
|
545 if (!tickmarkslabelLeft) { |
|
546 modified = true; |
|
547 tickmarkslabelLeft = new HbSliderTickmarksLabel(q); |
|
548 tickmarkslabelLeft->setTickPosition (Hb::SliderTicksLeft); |
|
549 if ( orientation == Qt::Vertical ) { |
|
550 HbStyle::setItemName( tickmarkslabelLeft, "tick-textsleft" ); |
|
551 } else { |
|
552 HbStyle::setItemName( tickmarkslabelLeft, "tick-textsabove" ); |
|
462 } |
553 } |
463 } |
554 } |
464 |
555 } else if ( tickmarkslabelLeft ) { |
465 } |
556 modified = true; |
557 delete tickmarkslabelLeft; |
|
558 tickmarkslabelLeft = 0; |
|
559 } |
|
560 if ( q->tickPosition( ) & Hb::SliderTicksRight) { |
|
561 if (!tickmarkslabelRight) { |
|
562 modified = true; |
|
563 tickmarkslabelRight = new HbSliderTickmarksLabel(q); |
|
564 tickmarkslabelRight->setTickPosition (Hb::SliderTicksRight); |
|
565 if ( orientation == Qt::Vertical ) { |
|
566 HbStyle::setItemName( tickmarkslabelRight, "tick-textsright" ); |
|
567 } else { |
|
568 HbStyle::setItemName( tickmarkslabelRight, "tick-textsbelow" ); |
|
569 } |
|
570 } |
|
571 } else if ( tickmarkslabelRight ) { |
|
572 delete tickmarkslabelRight; |
|
573 modified = true; |
|
574 tickmarkslabelRight = 0; |
|
575 } |
|
576 if ( orientation == Qt::Vertical ) { |
|
577 if ( q->tickPosition( ) & Hb::SliderTicksAbsolute) { |
|
578 q->setLayoutDirection (Qt::LeftToRight ); |
|
579 } |
|
580 } |
|
581 if ( modified ) { |
|
582 q->repolish( ); |
|
583 } |
|
584 } |
|
585 |
|
586 /*! |
|
587 \internal |
|
588 changes the orientation of slider tick marks or label based on slider's orientation |
|
589 */ |
|
590 void HbSliderPrivate::setTickOrientation() |
|
591 { |
|
592 Q_Q(HbSlider); |
|
593 if ( orientation == Qt::Vertical ) { |
|
594 if ( tickmarksLeft ) { |
|
595 HbStyle::setItemName( tickmarksLeft, "tick-marksleft" ); |
|
596 } |
|
597 if ( tickmarksRight) { |
|
598 HbStyle::setItemName( tickmarksRight, "tick-marksright" ); |
|
599 } |
|
600 if (tickmarkslabelLeft ) { |
|
601 HbStyle::setItemName( tickmarkslabelLeft, "tick-textsleft" ); |
|
602 } |
|
603 if (tickmarkslabelRight ) { |
|
604 HbStyle::setItemName( tickmarkslabelRight, "tick-textsright" ); |
|
605 } |
|
606 if ( q->tickPosition( )&Hb::SliderTicksAbsolute) { |
|
607 q->setLayoutDirection (Qt::LeftToRight); |
|
608 } |
|
609 } else { |
|
610 if ( tickmarksLeft ) { |
|
611 HbStyle::setItemName( tickmarksLeft, "tick-marksabove" ); |
|
612 } |
|
613 if ( tickmarksRight) { |
|
614 HbStyle::setItemName( tickmarksRight, "tick-marksbelow" ); |
|
615 } |
|
616 if (tickmarkslabelLeft ) { |
|
617 HbStyle::setItemName( tickmarkslabelLeft, "tick-textsabove" ); |
|
618 } |
|
619 if (tickmarkslabelRight ) { |
|
620 HbStyle::setItemName( tickmarkslabelRight, "tick-textsbelow" ); |
|
621 } |
|
622 q->unsetLayoutDirection( ); |
|
623 |
|
624 |
|
625 } |
|
626 |
|
627 } |
|
628 |
|
629 |
|
630 |
|
631 |
|
632 |
|
633 /*! |
|
634 \internal |
|
635 Updates tick and Label. |
|
636 */ |
|
637 void HbSliderPrivate::updateTickMarks( ) |
|
638 { |
|
639 if (tickmarksLeft) { |
|
640 tickmarksLeft->createTicks(); |
|
641 tickmarksLeft->updateTicks(); |
|
642 } |
|
643 if (tickmarksRight) { |
|
644 tickmarksRight->createTicks(); |
|
645 tickmarksRight->updateTicks(); |
|
646 } |
|
647 } |
|
648 |
|
649 |
|
650 /*! |
|
651 \internal |
|
652 Updates tick and Label. |
|
653 */ |
|
654 void HbSliderPrivate::updateTickLabels( ) |
|
655 { |
|
656 if( tickmarkslabelLeft ) { |
|
657 tickmarkslabelLeft->updateTickLabels(); |
|
658 } |
|
659 if( tickmarkslabelRight ) { |
|
660 tickmarkslabelRight->updateTickLabels( ); |
|
661 } |
|
662 } |
|
663 |
|
664 |
|
665 /*! |
|
666 \internal |
|
667 deletes slidertickmarks. |
|
668 */ |
|
669 void HbSliderPrivate::deleteTickMarks( ) |
|
670 { |
|
671 if (tickmarksLeft) { |
|
672 HbStyle::setItemName(tickmarksLeft,QString()); |
|
673 delete tickmarksLeft; |
|
674 tickmarksLeft = 0; |
|
675 } |
|
676 if (tickmarksRight) { |
|
677 HbStyle::setItemName(tickmarksRight,QString()); |
|
678 delete tickmarksRight; |
|
679 tickmarksRight = 0; |
|
680 } |
|
681 } |
|
682 |
|
683 |
|
684 /*! |
|
685 \internal |
|
686 deletes ticklabels. |
|
687 */ |
|
688 void HbSliderPrivate::deleteTickLabels( ) |
|
689 { |
|
690 if (tickmarkslabelLeft) { |
|
691 HbStyle::setItemName(tickmarkslabelLeft,QString()); |
|
692 delete tickmarkslabelLeft; |
|
693 tickmarkslabelLeft = 0; |
|
694 } |
|
695 if (tickmarkslabelRight) { |
|
696 HbStyle::setItemName(tickmarkslabelRight,QString()); |
|
697 delete tickmarkslabelRight; |
|
698 tickmarkslabelRight = 0; |
|
699 } |
|
700 } |
|
466 |
701 |
467 #ifdef HB_EFFECTS |
702 #ifdef HB_EFFECTS |
468 |
703 |
469 /*! |
704 /*! |
705 \internal |
|
470 start effect for on icon press |
706 start effect for on icon press |
471 */ |
707 */ |
472 void HbSliderPrivate::_q_startIconPressedEffect( ) |
708 void HbSliderPrivate::_q_startIconPressedEffect( ) |
473 { |
709 { |
474 HbEffectInternal::add( HB_SLIDER_TYPE,"slidericon_press", "iconpressed" ); |
710 HbEffectInternal::add( HB_SLIDER_TYPE,"slidericon_press", "iconpressed" ); |
475 HbEffect::start( elementItemMap[HbSlider::IconElement].item, HB_SLIDER_TYPE, "iconpressed" ); |
711 HbEffect::start( elementItemMap[HbSlider::IconElement].item, HB_SLIDER_TYPE, "iconpressed" ); |
476 } |
712 } |
477 |
713 |
478 /*! |
714 /*! |
715 \internal |
|
479 start effect on icon release |
716 start effect on icon release |
480 */ |
717 */ |
481 void HbSliderPrivate::_q_startIconReleasedEffect( ) |
718 void HbSliderPrivate::_q_startIconReleasedEffect( ) |
482 { |
719 { |
483 HbEffectInternal::add( HB_SLIDER_TYPE,"slidericon_release", "iconrelease" ); |
720 HbEffectInternal::add( HB_SLIDER_TYPE,"slidericon_release", "iconrelease" ); |
549 HbSlider::~HbSlider( ) |
786 HbSlider::~HbSlider( ) |
550 { |
787 { |
551 } |
788 } |
552 |
789 |
553 /*! |
790 /*! |
554 @proto |
791 @beta |
555 Returns the list of slider elements as QVariant |
792 Returns the list of slider elements as QVariant |
556 |
793 |
557 \note it is safe to type-cast element to HbSlider::SliderElement. |
794 \note it is safe to type-cast element to HbSlider::SliderElement. |
558 |
795 |
559 The slider contains only track element by default. |
796 The slider contains only track element by default. |
562 */ |
799 */ |
563 QList<QVariant> HbSlider::sliderElements() const |
800 QList<QVariant> HbSlider::sliderElements() const |
564 { |
801 { |
565 Q_D( const HbSlider ); |
802 Q_D( const HbSlider ); |
566 QList<QVariant> elementList; |
803 QList<QVariant> elementList; |
567 foreach(HbSlider::SliderElement element,d->elements){ |
804 foreach(const HbSlider::SliderElement &element,d->elements){ |
568 elementList.append ( QVariant ( element ) ); |
805 elementList.append ( QVariant ( element ) ); |
569 } |
806 } |
570 return elementList; |
807 return elementList; |
571 } |
808 } |
572 |
809 |
573 /*! |
810 /*! |
574 @proto |
811 @beta |
575 Sets the elements of the slider. |
812 Sets the elements of the slider. |
576 |
813 |
577 \note Duplicate elements will be ignored. |
814 \note Duplicate elements will be ignored. |
578 |
815 |
579 \note element order cant be changed |
816 \note element order cant be changed |
594 */ |
831 */ |
595 void HbSlider::setSliderElements(const QList<QVariant> &elementlist) |
832 void HbSlider::setSliderElements(const QList<QVariant> &elementlist) |
596 { |
833 { |
597 Q_D( HbSlider ); |
834 Q_D( HbSlider ); |
598 QList<HbSlider::SliderElement> elements; |
835 QList<HbSlider::SliderElement> elements; |
599 foreach ( QVariant elementVar , elementlist ) { |
836 foreach (const QVariant &elementVar , elementlist ) { |
600 elements.append( static_cast<HbSlider::SliderElement>(elementVar.toInt())); |
837 elements.append( static_cast<HbSlider::SliderElement>(elementVar.toInt())); |
601 } |
838 } |
602 d->setElements( elements ); |
839 d->setElements( elements ); |
603 } |
840 } |
604 |
841 |
605 /*! |
842 /*! |
606 @proto |
843 @beta |
607 Sets the icons for elements |
844 Sets the icons for elements |
608 |
845 |
609 key of \a elements is element name and value is icon |
846 key of \a elements is element name and value is icon |
610 name to set on given element |
847 name to set on given element |
611 Use following string for specifying elements |
848 Use following string for specifying elements |
614 "IconElement" for icon element |
851 "IconElement" for icon element |
615 |
852 |
616 Eg Usage: |
853 Eg Usage: |
617 HbSlider slider; |
854 HbSlider slider; |
618 QMap<QString , QVariant> map; |
855 QMap<QString , QVariant> map; |
619 map.insert(QString("IncreaseElement") , QVariant(":/unittest_hbslider/star_on.png")); |
856 map.insert(QString("IncreaseElement") , QVariant("example1.png")); |
620 map.insert(QString("DecreaseElement") , QVariant(":/unittest_hbslider/star_on.png")); |
857 map.insert(QString("DecreaseElement") , QVariant("example2.png")); |
621 slider.setElementIcons( map ); |
858 slider.setElementIcons( map ); |
622 |
859 |
623 \warning Setting icon to a non-existing element has no effect. |
860 \warning Setting icon to a non-existing element has no effect. |
624 |
861 |
625 \sa elementIcons() setSliderElements() setElementIcon() |
862 \sa elementIcons() setSliderElements() setElementIcon() |
656 } |
893 } |
657 } |
894 } |
658 } |
895 } |
659 |
896 |
660 /*! |
897 /*! |
661 @proto |
898 @beta |
662 Returns the map , which consist of element name as key and icon name as value |
899 Returns the map , which consist of element name as key and icon name as value |
663 |
900 |
664 returns NULL map if none of the element has icon |
901 returns NULL map if none of the element has icon |
665 |
902 |
666 \sa setElementIcons() |
903 \sa setElementIcons() |
961 { |
1198 { |
962 Q_D( HbSlider ); |
1199 Q_D( HbSlider ); |
963 if ( d->orientation != orientation ) { |
1200 if ( d->orientation != orientation ) { |
964 d->orientation = orientation; |
1201 d->orientation = orientation; |
965 d->sliderControl->setOrientation( orientation ); |
1202 d->sliderControl->setOrientation( orientation ); |
966 repolish(); |
1203 d->setTickOrientation( ); |
1204 repolish( ); |
|
967 } |
1205 } |
968 } |
1206 } |
969 |
1207 |
970 /*! |
1208 /*! |
971 @beta |
1209 @beta |
1287 */ |
1525 */ |
1288 void HbSlider::setTickPosition( Hb::SliderTickPositions position ) |
1526 void HbSlider::setTickPosition( Hb::SliderTickPositions position ) |
1289 { |
1527 { |
1290 Q_D( HbSlider ); |
1528 Q_D( HbSlider ); |
1291 d->sliderControl->setTickPosition( position ); |
1529 d->sliderControl->setTickPosition( position ); |
1292 d->setTickLabelPresentProperty( ); |
1530 d->createTickMarks( ); |
1531 d->createTickLabels( ); |
|
1532 d->updateTickMarks( ); |
|
1533 d->updateTickLabels( ); |
|
1293 } |
1534 } |
1294 |
1535 |
1295 /*! |
1536 /*! |
1296 @beta |
1537 @beta |
1297 Returns the SnappingMode of the slider. |
1538 Returns the SnappingMode of the slider. |
1344 */ |
1585 */ |
1345 void HbSlider::setMajorTickInterval( int interval ) |
1586 void HbSlider::setMajorTickInterval( int interval ) |
1346 { |
1587 { |
1347 Q_D( HbSlider ); |
1588 Q_D( HbSlider ); |
1348 d->sliderControl->setMajorTickInterval( interval ); |
1589 d->sliderControl->setMajorTickInterval( interval ); |
1349 d->setTickLabelPresentProperty( ); |
1590 if (interval <=0 ) { |
1591 d->deleteTickMarks( ); |
|
1592 d->deleteTickLabels( ); |
|
1593 } |
|
1594 else { |
|
1595 d->createTickMarks( ); |
|
1596 d->createTickLabels( ); |
|
1597 d->updateTickMarks( ); |
|
1598 d->updateTickLabels( ); |
|
1599 } |
|
1350 } |
1600 } |
1351 |
1601 |
1352 /*! |
1602 /*! |
1353 @beta |
1603 @beta |
1354 Returns the interval between minor tickmarks. |
1604 Returns the interval between minor tickmarks. |
1375 */ |
1625 */ |
1376 void HbSlider::setMinorTickInterval( int interval ) |
1626 void HbSlider::setMinorTickInterval( int interval ) |
1377 { |
1627 { |
1378 Q_D( HbSlider ); |
1628 Q_D( HbSlider ); |
1379 d->sliderControl->setMinorTickInterval( interval ); |
1629 d->sliderControl->setMinorTickInterval( interval ); |
1380 d->setTickLabelPresentProperty( ); |
1630 d->updateTickMarks( ); |
1631 d->updateTickLabels( ); |
|
1381 } |
1632 } |
1382 |
1633 |
1383 /*! |
1634 /*! |
1384 @beta |
1635 @beta |
1385 sets the icon path for handle |
1636 sets the icon path for handle |
1406 return d->sliderControl->handleIcon( ); |
1657 return d->sliderControl->handleIcon( ); |
1407 } |
1658 } |
1408 |
1659 |
1409 |
1660 |
1410 /*! |
1661 /*! |
1411 @proto |
1662 @beta |
1412 Sets whether to display progress track or not |
1663 Sets whether to display progress track or not |
1413 |
1664 |
1414 \default value is true |
1665 \default value is true |
1415 |
1666 |
1416 \sa isTrackFilled( ) |
1667 \sa isTrackFilled( ) |
1422 return d->sliderControl->setTrackFilled( trackVisible ); |
1673 return d->sliderControl->setTrackFilled( trackVisible ); |
1423 |
1674 |
1424 } |
1675 } |
1425 |
1676 |
1426 /*! |
1677 /*! |
1427 @proto |
1678 @beta |
1428 returns whether progress track is visible or not |
1679 returns whether progress track is visible or not |
1429 |
1680 |
1430 \sa setTrackFilled( ) |
1681 \sa setTrackFilled( ) |
1431 |
1682 |
1432 */ |
1683 */ |
1470 specify empty string ( "" ) for that item in the string list. |
1721 specify empty string ( "" ) for that item in the string list. |
1471 |
1722 |
1472 case 4: if both major & minor tickinterval are same,then only majortickLabel |
1723 case 4: if both major & minor tickinterval are same,then only majortickLabel |
1473 strings are taken into account for drawing the labelItem |
1724 strings are taken into account for drawing the labelItem |
1474 |
1725 |
1726 case 5: If you want to remove the whole tickLabel then set the empty string as the argument. |
|
1727 |
|
1728 Note:: if the major tickinterval of the slider is very small, the tick labels may overlap, |
|
1729 application needs to take care of this. |
|
1730 |
|
1475 \sa majorTickLabels( ) |
1731 \sa majorTickLabels( ) |
1476 */ |
1732 */ |
1477 void HbSlider::setMajorTickLabels( const QStringList &majorTickLabels ) |
1733 void HbSlider::setMajorTickLabels( const QStringList &majorTickLabels ) |
1478 { |
1734 { |
1479 Q_D( HbSlider ); |
1735 Q_D( HbSlider ); |
1480 d->sliderControl->setMajorTickLabels( majorTickLabels ); |
1736 d->sliderControl->setMajorTickLabels( majorTickLabels ); |
1481 d->setTickLabelPresentProperty( ); |
1737 if(majorTickLabels.isEmpty( )) { |
1738 d->deleteTickLabels( ); |
|
1739 } else { |
|
1740 d->createTickLabels( ); |
|
1741 d->updateTickLabels( ); |
|
1742 } |
|
1482 } |
1743 } |
1483 |
1744 |
1484 /*! |
1745 /*! |
1485 @beta |
1746 @beta |
1486 Returns the minor ticklabels of the slider. |
1747 Returns the minor ticklabels of the slider. |
1494 } |
1755 } |
1495 |
1756 |
1496 /*! |
1757 /*! |
1497 @beta |
1758 @beta |
1498 Sets the minor ticklabels of the slider. |
1759 Sets the minor ticklabels of the slider. |
1499 see setMajorTickLabels for detailed description |
1760 see setMajorTickLabels for detailed description. |
1761 Note:: if the minor tickinterval of the slider is very small, the tick labels may overlap, |
|
1762 application needs to take care of this. |
|
1763 |
|
1500 |
1764 |
1501 \sa minorTickLabels( ),setMajorTickLabels( ) |
1765 \sa minorTickLabels( ),setMajorTickLabels( ) |
1502 */ |
1766 */ |
1503 void HbSlider::setMinorTickLabels( const QStringList &minorTickLabels ) |
1767 void HbSlider::setMinorTickLabels( const QStringList &minorTickLabels ) |
1504 { |
1768 { |
1505 Q_D( HbSlider ); |
1769 Q_D( HbSlider ); |
1506 d->sliderControl->setMinorTickLabels( minorTickLabels ); |
1770 d->sliderControl->setMinorTickLabels( minorTickLabels ); |
1507 d->setTickLabelPresentProperty( ); |
1771 d->updateTickLabels( ); |
1508 } |
1772 } |
1509 |
1773 |
1510 |
1774 |
1511 /*! |
1775 /*! |
1512 |
1776 |
1542 return d->elementItemMap[HbSlider::DecreaseElement].item; |
1806 return d->elementItemMap[HbSlider::DecreaseElement].item; |
1543 } |
1807 } |
1544 break; |
1808 break; |
1545 case HbStyle::P_Slider_groove: |
1809 case HbStyle::P_Slider_groove: |
1546 return HbSliderControlPrivate::d_ptr( d->sliderControl )->groove; |
1810 return HbSliderControlPrivate::d_ptr( d->sliderControl )->groove; |
1811 case HbStyle::P_SliderElement_touchgroove: |
|
1812 return HbSliderControlPrivate::d_ptr( d->sliderControl )->grooveTouchArea; |
|
1547 |
1813 |
1548 case HbStyle::P_SliderElement_touchhandle: |
1814 case HbStyle::P_SliderElement_touchhandle: |
1549 return HbSliderControlPrivate::d_ptr( d->sliderControl )->handle->primitive( |
1815 return HbSliderControlPrivate::d_ptr( d->sliderControl )->handle->primitive( |
1550 HbStyle::P_SliderElement_touchhandle ); |
1816 HbStyle::P_SliderElement_touchhandle ); |
1551 |
1817 |
1653 } |
1919 } |
1654 d->stopRepeatAction( ); |
1920 d->stopRepeatAction( ); |
1655 } |
1921 } |
1656 |
1922 |
1657 /*! |
1923 /*! |
1924 reimp |
|
1925 |
|
1926 */ |
|
1927 |
|
1928 void HbSlider::gestureEvent(QGestureEvent *event) |
|
1929 { |
|
1930 Q_D(HbSlider); |
|
1931 //consume the event if gesture is on increment or decrement,It is being handled in mouse press and mouse release |
|
1932 //If it is on mute/control igonore the gesture as they are handled separately by HbAbstractButton and HbSlidercontrol classes |
|
1933 if (HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) { |
|
1934 QPointF pos = event->mapToGraphicsScene(tap->position()); |
|
1935 bool consumeEvent = false; |
|
1936 if ( d->elementItemMap.contains (HbSlider::IncreaseElement ) ) { |
|
1937 if (d->elementItemMap[HbSlider::IncreaseElement].touchItem ) { |
|
1938 if (d->elementItemMap[HbSlider::IncreaseElement].touchItem->sceneBoundingRect().contains(pos)) { |
|
1939 consumeEvent = true; |
|
1940 } |
|
1941 } |
|
1942 } |
|
1943 if ( d->elementItemMap.contains (HbSlider::DecreaseElement ) ) { |
|
1944 if (d->elementItemMap[HbSlider::DecreaseElement].touchItem ) { |
|
1945 if (d->elementItemMap[HbSlider::DecreaseElement].touchItem->sceneBoundingRect().contains(pos)) { |
|
1946 consumeEvent = true; |
|
1947 } |
|
1948 } |
|
1949 } |
|
1950 |
|
1951 if(!consumeEvent) { |
|
1952 event->ignore(); |
|
1953 HbWidget::gestureEvent(event); |
|
1954 } |
|
1955 } |
|
1956 |
|
1957 } |
|
1958 |
|
1959 /*! |
|
1658 \reimp |
1960 \reimp |
1659 |
1961 |
1660 This api update the primitive when ever item enable has changed |
1962 This api update the primitive when ever item enable has changed |
1661 */ |
1963 */ |
1662 QVariant HbSlider::itemChange( GraphicsItemChange change, const QVariant &value ) |
1964 QVariant HbSlider::itemChange( GraphicsItemChange change, const QVariant &value ) |