38 |
38 |
39 #ifdef HB_EFFECTS |
39 #ifdef HB_EFFECTS |
40 #include <hbeffect.h> |
40 #include <hbeffect.h> |
41 #include "hbeffectinternal_p.h" |
41 #include "hbeffectinternal_p.h" |
42 #define HB_RATINGSLIDER_ITEM_TYPE "HB_RATINGSLIDER" |
42 #define HB_RATINGSLIDER_ITEM_TYPE "HB_RATINGSLIDER" |
43 |
|
44 #endif |
43 #endif |
|
44 |
|
45 #include <QGraphicsSceneMouseEvent> |
|
46 |
45 #define MAX_NUMBER_OF_ICONS 10 |
47 #define MAX_NUMBER_OF_ICONS 10 |
46 |
48 |
47 HbRatingSliderPrivate::HbRatingSliderPrivate(): |
49 HbRatingSliderPrivate::HbRatingSliderPrivate(): |
48 mMousePressed(false), |
50 mMousePressed(false), |
49 mLookupValues(0), |
51 mLookupValues(0), |
50 mReadOnly(false), |
52 mReadOnly(false), |
51 mNumberOfIcons(5), |
53 mNumberOfIcons(5), |
52 mStepCount(5), |
54 mStepCount(5), |
53 mCurrentValue(0), |
55 mCurrentValue(0), |
54 mFrame(0), |
56 mUnRatedItem(0), |
55 mTrack(0), |
57 mRatedItem(0), |
56 mLayoutItem(0), |
58 mBackGroundItem(0), |
57 mUnratedIconName(""), |
|
58 mTouchArea(0), |
59 mTouchArea(0), |
59 mRatedIconName("") |
60 mToolTipArea(0) |
60 { |
61 { |
61 } |
62 } |
62 |
63 |
63 HbRatingSliderPrivate::~HbRatingSliderPrivate() |
64 HbRatingSliderPrivate::~HbRatingSliderPrivate() |
64 { |
65 { |
65 if(mLookupValues) { |
66 if(mLookupValues) { |
66 delete [] mLookupValues; |
67 delete [] mLookupValues; |
67 } |
68 } |
68 } |
69 } |
69 |
70 |
70 |
71 /* |
|
72 Initializes widget primitives |
|
73 */ |
71 void HbRatingSliderPrivate::init() |
74 void HbRatingSliderPrivate::init() |
72 { |
75 { |
73 Q_Q(HbRatingSlider); |
76 Q_Q(HbRatingSlider); |
74 mLayoutItem = q->style()->createPrimitive(HbStyle::P_RatingSlider_layout,q); |
77 |
75 mFrame = q->style()->createPrimitive(HbStyle::P_RatingSlider_frame,mLayoutItem); |
78 mBackGroundItem = new HbWidgetBase(q); |
76 mTrack = q->style()->createPrimitive(HbStyle::P_RatingSlider_track,mFrame); |
79 HbStyle::setItemName(mBackGroundItem, "background"); |
77 mTouchArea = q->style()->createPrimitive(HbStyle::P_RatingSlider_toucharea, q); |
80 |
78 |
81 mUnRatedItem = new HbRepeatItem(mBackGroundItem); |
79 q->updatePrimitives(); |
82 HbStyle::setItemName(mUnRatedItem, "unrated-item"); |
|
83 |
|
84 mRatedItem = new HbRepeatMaskItem(mUnRatedItem); |
|
85 HbStyle::setItemName(mRatedItem, "rated-item"); |
|
86 |
|
87 mTouchArea = q->style()->createPrimitive(HbStyle::PT_TouchArea, "toucharea",q); |
|
88 mTouchArea->setFlag(QGraphicsItem::ItemIsFocusable); |
|
89 q->setHandlesChildEvents(true); |
|
90 |
|
91 //q->updatePrimitives(); |
80 |
92 |
81 #ifdef HB_EFFECTS |
93 #ifdef HB_EFFECTS |
82 HbEffectInternal::add(HB_RATINGSLIDER_ITEM_TYPE,"ratingslider_appear", "ratingslider_appear"); |
94 HbEffectInternal::add(HB_RATINGSLIDER_ITEM_TYPE,"ratingslider_appear", "ratingslider_appear"); |
83 HbEffectInternal::add(HB_RATINGSLIDER_ITEM_TYPE,"ratingslider_disappear", "ratingslider_disappear"); |
95 HbEffectInternal::add(HB_RATINGSLIDER_ITEM_TYPE,"ratingslider_disappear", "ratingslider_disappear"); |
84 #endif |
96 #endif |
85 |
97 |
86 #ifdef HB_GESTURE_FW |
98 #ifdef HB_GESTURE_FW |
87 q->grabGesture(Qt::TapGesture); |
99 q->grabGesture(Qt::TapGesture); |
88 q->grabGesture(Qt::PanGesture); |
100 q->grabGesture(Qt::PanGesture); |
89 |
101 |
90 if(QGraphicsObject *touchArea = mTouchArea->toGraphicsObject()) { |
102 mTouchArea->grabGesture(Qt::TapGesture); |
91 touchArea->grabGesture(Qt::TapGesture); |
103 mTouchArea->grabGesture(Qt::PanGesture); |
92 touchArea->grabGesture(Qt::PanGesture); |
|
93 } |
|
94 #endif |
104 #endif |
95 |
105 |
96 } |
106 } |
97 |
107 |
|
108 /* |
|
109 Creates a lookup table which stores the bandwidth calculation for each star. |
|
110 |
|
111 Decision will be made based on this LookupTable values for touch |
|
112 point/position identification. |
|
113 */ |
98 void HbRatingSliderPrivate::createLookupTable() |
114 void HbRatingSliderPrivate::createLookupTable() |
99 { |
115 { |
100 if(mLookupValues) { |
116 if(mLookupValues) { |
101 delete [] mLookupValues; |
117 delete [] mLookupValues; |
102 mLookupValues=0; |
118 mLookupValues=0; |
103 } |
119 } |
104 |
120 |
105 mLookupValues = new int[mStepCount]; |
121 mLookupValues = new int[mStepCount]; |
106 qreal width = mFrame->boundingRect().width(); |
122 qreal width = mUnRatedItem->boundingRect().width(); |
107 int bandWidth =(int) (width/mStepCount); |
123 int bandWidth =(int) (width/mStepCount); |
108 |
124 |
109 for(int i=0;i < mStepCount;i++) { |
125 for(int i=0;i < mStepCount;i++) { |
110 mLookupValues[i] = bandWidth*(i+1); |
126 mLookupValues[i] = bandWidth*(i+1); |
111 } |
127 } |
112 } |
128 } |
113 |
129 |
|
130 /* |
|
131 Returns the exact count for the touch position based |
|
132 on the LookupTable array values. |
|
133 */ |
114 int HbRatingSliderPrivate::calculateProgressValue(qreal pos) |
134 int HbRatingSliderPrivate::calculateProgressValue(qreal pos) |
115 { |
135 { |
116 Q_Q(HbRatingSlider); |
136 Q_Q(HbRatingSlider); |
117 |
137 |
118 int count=0; |
|
119 for(count=0;count< mStepCount ;count++) { |
|
120 if(pos <= mLookupValues[count]) |
|
121 break; |
|
122 } |
|
123 if(q->layoutDirection() == Qt::RightToLeft) { |
|
124 |
|
125 count = mStepCount -count; |
|
126 } |
|
127 else { |
|
128 |
|
129 count++; |
|
130 } |
|
131 |
|
132 if (pos > mLookupValues[mStepCount-1]) { |
138 if (pos > mLookupValues[mStepCount-1]) { |
133 return -1; |
139 return -1; |
134 } |
140 } |
135 |
141 |
136 return count; |
142 int count=0; |
137 |
143 for(;count< mStepCount ;count++) { |
|
144 if(pos <= mLookupValues[count]) |
|
145 break; |
|
146 } |
|
147 |
|
148 if(q->layoutDirection() == Qt::RightToLeft) { |
|
149 count = mStepCount -count; |
|
150 } |
|
151 else { |
|
152 count++; |
|
153 } |
|
154 |
|
155 return count; |
|
156 } |
|
157 |
|
158 /* |
|
159 updates rated icon item |
|
160 */ |
|
161 void HbRatingSliderPrivate::updateRatedIconItem() |
|
162 { |
|
163 Q_Q(HbRatingSlider); |
|
164 |
|
165 if (mRatedItem) { |
|
166 HbRepeatMaskItem *repeatItem = static_cast<HbRepeatMaskItem*>(mRatedItem); |
|
167 repeatItem->setMaskValue(mCurrentValue); |
|
168 repeatItem->setMaximum(mStepCount); |
|
169 repeatItem->setInverted((q->layoutDirection() == Qt::RightToLeft)); |
|
170 repeatItem->setRepeatingNumber(mNumberOfIcons); |
|
171 if (!mRatedIconName.isEmpty()) { |
|
172 repeatItem->setName(mRatedIconName); |
|
173 } |
|
174 else { |
|
175 if(!q->isEnabled()) { |
|
176 repeatItem->setName(QLatin1String("qtg_graf_ratingslider_rated_disabled")); |
|
177 } |
|
178 else { |
|
179 if(mMousePressed) { |
|
180 repeatItem->setName(QLatin1String("qtg_graf_ratingslider_rated_pressed")); |
|
181 } |
|
182 else { |
|
183 repeatItem->setName(QLatin1String("qtg_graf_ratingslider_rated")); |
|
184 } |
|
185 } |
|
186 } |
|
187 repeatItem->setGeometry(q->boundingRect()); |
|
188 repeatItem->update(); |
|
189 } |
|
190 } |
|
191 |
|
192 /* |
|
193 updates unrated icon item |
|
194 */ |
|
195 void HbRatingSliderPrivate::updateUnRatedIconItem() |
|
196 { |
|
197 Q_Q(HbRatingSlider); |
|
198 |
|
199 if (mUnRatedItem) { |
|
200 HbRepeatItem *repeatItem = static_cast<HbRepeatItem*>(mUnRatedItem); |
|
201 repeatItem->setRepeatingNumber(mNumberOfIcons); |
|
202 if (!mUnratedIconName.isEmpty()) { |
|
203 repeatItem->setName(mUnratedIconName); |
|
204 } |
|
205 else { |
|
206 if(!q->isEnabled()) { |
|
207 repeatItem->setName(QLatin1String("qtg_graf_ratingslider_unrated_disabled")); |
|
208 } |
|
209 else { |
|
210 if(mMousePressed) { |
|
211 repeatItem->setName(QLatin1String("qtg_graf_ratingslider_unrated_pressed")); |
|
212 } |
|
213 else { |
|
214 repeatItem->setName(QLatin1String("qtg_graf_ratingslider_unrated")); |
|
215 } |
|
216 } |
|
217 } |
|
218 repeatItem->setGeometry(q->boundingRect()); |
|
219 repeatItem->update(); |
|
220 } |
138 } |
221 } |
139 |
222 |
140 /*! |
223 /*! |
141 \class HbRatingSlider |
224 \class HbRatingSlider |
142 \brief This is a widget that enables a user to rate contents like videos , music etc. |
225 \brief This is a widget that enables a user to rate contents like videos , music etc. |
143 \image html ratingslider.png "A Rating Slider with rating done" |
226 \image html ratingslider.png "A Rating Slider with rating done" |
144 |
227 |
145 The default version of Rating Slider contains 5 repeated icons drawn side by side, using a single themed graphics. |
228 The default version of HbRatingSlider contains 5 repeated icons drawn side by side, using a single themed graphics. |
146 The application can replace the themed graphic with a custom graphic. |
229 The application can replace the themed graphic with a custom graphic. |
147 The custom graphics should contain only one icon (eg one star) which will be multipled by the API \a setNumberOfIcons(). |
230 The custom graphics should contain only one icon (eg one star) which will be multipled by the API \a setNumberOfIcons(). |
148 By default it is 5 and maximum number of icons are 10. |
231 By default it is 5 and maximum number of icons are 10. |
149 |
232 |
150 Along with the rating Rating Slider can be used to show the cumulative rating also. |
233 Along with the rating HbRatingSlider can be used to show the cumulative rating also. |
151 |
234 |
152 To use HbRatingSlider with default settings it just needs to be created. |
235 To use HbRatingSlider with default settings it just needs to be created. |
153 example code: |
236 example code: |
154 \code |
237 \code |
155 HbRatingSlider *object = new HbRatingSlider(parent); |
238 HbRatingSlider *object = new HbRatingSlider(parent); |
541 { |
614 { |
542 Q_UNUSED(event) |
615 Q_UNUSED(event) |
543 } |
616 } |
544 #endif |
617 #endif |
545 |
618 |
|
619 |
546 #ifdef HB_GESTURE_FW |
620 #ifdef HB_GESTURE_FW |
547 /*! |
621 /*! |
548 \reimp |
622 \reimp |
549 */ |
623 */ |
550 void HbRatingSlider::gestureEvent(QGestureEvent *event) |
624 void HbRatingSlider::gestureEvent(QGestureEvent *event) |
551 { |
625 { |
552 Q_D (HbRatingSlider); |
626 Q_D (HbRatingSlider); |
553 if(event->gesture(Qt::TapGesture)) { |
627 |
554 HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture)); |
628 if ( (!isEnabled()) || (d->mReadOnly)) { |
555 switch(tap->state()) { |
629 event->ignore(); |
|
630 return; |
|
631 } |
|
632 |
|
633 if(HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))){ |
|
634 switch(tap->state()) { |
556 case Qt::GestureStarted: |
635 case Qt::GestureStarted: |
557 { |
636 { |
558 qreal xVal = mapFromScene(event->mapToGraphicsScene(tap->position( ))).x(); |
637 qreal xVal = mapFromScene(event->mapToGraphicsScene(tap->position( ))).x(); |
559 int rating = d->calculateProgressValue(xVal); |
638 int rating = d->calculateProgressValue(xVal); |
560 if(rating == -1) { |
639 if(rating == -1) { |
561 return; |
|
562 } |
|
563 if(d->mReadOnly) { |
|
564 event->ignore(); |
640 event->ignore(); |
565 return; |
641 return; |
566 } |
642 } |
|
643 |
567 QRectF rect = d->mTouchArea->boundingRect(); |
644 QRectF rect = d->mTouchArea->boundingRect(); |
568 if(rect.contains(xVal,0 )) { |
645 if(rect.contains(xVal,0 )) { |
569 HbWidgetFeedback::triggered(this, Hb::InstantPressed); |
646 HbWidgetFeedback::triggered(this, Hb::InstantPressed); |
570 d->mMousePressed = true; |
647 d->mMousePressed = true; |
571 updatePrimitives(); |
648 updatePrimitives(); |
572 rating = d->calculateProgressValue(xVal); |
649 rating = d->calculateProgressValue(xVal); |
573 setCurrentRating(rating); |
650 setCurrentRating(rating); |
|
651 emit ratingChanged (d->mCurrentValue); |
|
652 if(!d->mToolTipArea) |
|
653 d->mToolTipArea = new HbTouchArea(d->mUnRatedItem); |
|
654 d->mToolTipArea->setPos(xVal,0); |
|
655 d->mToolTipArea->setSize(QSize(1,1)); |
|
656 if(!d->mToolTipText.isNull()) { |
|
657 HbToolTip::showText(d->mToolTipText,d->mToolTipArea); |
|
658 } |
574 event->accept(); |
659 event->accept(); |
575 } |
660 } |
576 else { |
661 else { |
577 event->ignore(); |
662 event->ignore(); |
578 } |
663 } |
579 |
664 } |
580 } |
665 break; |
581 break; |
|
582 |
666 |
583 case Qt::GestureFinished: // Reset state |
667 case Qt::GestureFinished: // Reset state |
584 { |
668 { |
585 qreal xVal = mapFromScene(event->mapToGraphicsScene(tap->position( ))).x(); |
669 qreal xVal = mapFromScene(event->mapToGraphicsScene(tap->position( ))).x(); |
586 QRectF rect = d->mTouchArea->boundingRect(); |
670 QRectF rect = d->mTouchArea->boundingRect(); |
587 int rating=0; |
671 int rating=0; |
588 if(rect.contains(xVal,0 )) { |
672 if(rect.contains(xVal,0 )) { |
589 if(d->mReadOnly) { |
673 if(!d->mMousePressed){ |
590 event->ignore(); |
674 event->ignore(); |
591 return; |
675 return; |
592 } |
676 } |
593 |
677 if(xVal <0) { |
594 if(!d->mMousePressed){ |
678 setCurrentRating(0); |
595 return; |
679 emit ratingDone (d->mCurrentValue); |
596 } |
680 return; |
597 |
681 } |
598 if(xVal <0) { |
682 rating = d->calculateProgressValue(xVal); |
599 setCurrentRating(0); |
683 setCurrentRating(rating); |
600 emit ratingDone (d->mCurrentValue); |
684 HbWidgetFeedback::triggered(this, Hb::InstantReleased); |
601 return; |
685 if(d->mCurrentValue) { |
602 } |
686 emit ratingDone (d->mCurrentValue); |
603 |
687 } |
604 rating = d->calculateProgressValue(xVal); |
688 event->accept(); |
605 |
689 d->mMousePressed = false; |
606 if(!toolTip().isNull()) { |
690 updatePrimitives(); |
607 HbToolTip::showText(toolTip(),this); |
691 } |
608 } |
692 else { |
609 setCurrentRating(rating); |
693 d->mMousePressed = false; |
610 HbWidgetFeedback::triggered(this, Hb::InstantReleased); |
694 updatePrimitives(); |
611 if(d->mCurrentValue) { |
695 if(xVal <rect.x() ) { |
612 emit ratingDone (d->mCurrentValue); |
696 setCurrentRating(0); |
613 } |
697 emit ratingDone (d->mCurrentValue); |
614 |
698 } |
615 event->accept(); |
|
616 d->mMousePressed = false; |
|
617 updatePrimitives(); |
|
618 } |
|
619 else { |
|
620 |
|
621 d->mMousePressed = false; |
|
622 updatePrimitives(); |
|
623 |
|
624 if(xVal <rect.x() ) { |
|
625 |
|
626 setCurrentRating(0); |
|
627 emit ratingDone (d->mCurrentValue); |
|
628 } |
|
629 |
699 |
630 } |
700 } |
631 |
|
632 |
|
633 |
|
634 |
|
635 } |
701 } |
636 break; |
702 break; |
637 default: break; |
703 default: break; |
638 } |
704 } |
639 }else if(event->gesture(Qt::PanGesture)) { |
705 } |
640 HbPanGesture *pan = qobject_cast<HbPanGesture *>(event->gesture(Qt::PanGesture)); |
706 else if(HbPanGesture *pan = qobject_cast<HbPanGesture *>(event->gesture(Qt::PanGesture))){ |
641 switch(pan->state()) { |
707 switch(pan->state()) { |
642 case Qt::GestureUpdated: |
708 case Qt::GestureUpdated: |
643 { |
709 { |
644 if(!d->mMousePressed) { |
710 if(!d->mMousePressed) { |
645 return; |
711 return; |
|
712 } |
|
713 qreal xVal = mapFromScene(event->mapToGraphicsScene( pan->startPos()+pan->offset())).x(); |
|
714 QRectF rect = d->mTouchArea->boundingRect(); |
|
715 int rating=0; |
|
716 if(rect.contains(xVal,0 )) { |
|
717 if(xVal <0) { |
|
718 setCurrentRating(0); |
|
719 return; |
|
720 } |
|
721 |
|
722 rating = d->calculateProgressValue(xVal); |
|
723 if(!d->mToolTipArea) |
|
724 d->mToolTipArea = new HbTouchArea(d->mUnRatedItem); //Need to show the tooltip at the touch point |
|
725 if(rating!=-1) { |
|
726 d->mToolTipArea->setPos(xVal,0); |
|
727 d->mToolTipArea->setSize(QSize(1,1)); |
|
728 if(!d->mToolTipText.isNull()) { |
|
729 HbToolTip::showText(d->mToolTipText,d->mToolTipArea); |
646 } |
730 } |
647 qreal xVal = mapFromScene(event->mapToGraphicsScene( pan->startPos()+pan->offset())).x(); |
731 } |
648 QRectF rect = d->mTouchArea->boundingRect(); |
732 setCurrentRating(rating); |
649 int rating=0; |
733 HbWidgetFeedback::continuousTriggered(this, Hb::ContinuousDragged); |
650 if(rect.contains(xVal,0 )) { |
734 emit ratingChanged (d->mCurrentValue); |
651 if(d->mReadOnly) { |
735 event->accept(); |
652 event->ignore(); |
736 } |
653 return; |
737 else { |
654 } |
738 setCurrentRating(0); |
655 |
739 } |
656 if(xVal <0) { |
740 } |
657 setCurrentRating(0); |
741 break; |
658 return; |
742 case Qt::GestureFinished: // Reset state |
659 } |
743 { |
660 |
744 qreal xVal = mapFromScene(event->mapToGraphicsScene( pan->startPos()+pan->offset())).x(); |
661 rating = d->calculateProgressValue(xVal); |
745 QRectF rect = d->mTouchArea->boundingRect(); |
662 |
746 d->mMousePressed = false; |
663 if(!toolTip().isNull()) { |
747 updatePrimitives(); |
664 HbToolTip::showText(toolTip(),this); |
748 int rating=0; |
665 } |
749 if(rect.contains(xVal,0 )) { |
666 setCurrentRating(rating); |
750 if(xVal <0) { |
667 HbWidgetFeedback::continuousTriggered(this, Hb::ContinuousDragged); |
751 setCurrentRating(0); |
668 emit ratingChanged (d->mCurrentValue); |
752 emit ratingDone (d->mCurrentValue); |
669 event->accept(); |
753 return; |
670 } |
754 } |
671 else { |
755 rating = d->calculateProgressValue(xVal); |
672 setCurrentRating(0); |
756 setCurrentRating(rating); |
673 } |
757 HbWidgetFeedback::triggered(this, Hb::InstantReleased); |
674 } |
758 if(d->mCurrentValue) { |
675 break; |
759 emit ratingDone (d->mCurrentValue); |
676 case Qt::GestureFinished: // Reset state |
760 } |
677 { |
761 event->accept(); |
678 qreal xVal = mapFromScene(event->mapToGraphicsScene( pan->startPos()+pan->offset())).x(); |
762 } |
679 QRectF rect = d->mTouchArea->boundingRect(); |
|
680 d->mMousePressed = false; |
|
681 updatePrimitives(); |
|
682 int rating=0; |
|
683 if(rect.contains(xVal,0 )) { |
|
684 if(d->mReadOnly) { |
|
685 event->ignore(); |
|
686 return; |
|
687 } |
|
688 } |
|
689 |
|
690 if(xVal <0) { |
|
691 setCurrentRating(0); |
|
692 emit ratingDone (d->mCurrentValue); |
|
693 return; |
|
694 } |
|
695 |
|
696 rating = d->calculateProgressValue(xVal); |
|
697 setCurrentRating(rating); |
|
698 HbWidgetFeedback::triggered(this, Hb::InstantReleased); |
|
699 if(d->mCurrentValue) { |
|
700 emit ratingDone (d->mCurrentValue); |
|
701 } |
|
702 event->accept(); |
|
703 |
763 |
704 } |
764 } |
705 |
765 break; |
706 |
766 default: |
707 default: |
767 break; |
708 break; |
768 } |
709 } |
|
710 } |
769 } |
711 } |
770 } |
712 #endif |
771 #endif |
713 |
772 |
714 /*! |
773 /*! |
715 \reimp |
774 \reimp |
716 */ |
775 */ |
717 void HbRatingSlider::setGeometry(const QRectF & rect) |
776 void HbRatingSlider::setGeometry(const QRectF & rect) |
718 { |
777 { |
719 Q_D(HbRatingSlider); |
778 Q_D(HbRatingSlider); |
|
779 |
720 HbWidget::setGeometry(rect); |
780 HbWidget::setGeometry(rect); |
721 updatePrimitives(); |
781 updatePrimitives(); |
722 d->createLookupTable(); |
782 d->createLookupTable(); |
723 } |
783 } |
724 /*! |
784 |
725 \reimp |
785 /*! |
726 */ |
786 @beta |
|
787 Sets the tooltip for the rating slider. |
|
788 |
|
789 By default it shows nothing. |
|
790 |
|
791 The application can customize the tooltip text using this API. |
|
792 Setting NULL string will disable the tooltip. |
|
793 |
|
794 \param tooltip tooltip text |
|
795 |
|
796 \sa toolTipText() |
|
797 */ |
|
798 void HbRatingSlider::setToolTipText(const QString tooltip) |
|
799 { |
|
800 Q_D(HbRatingSlider); |
|
801 |
|
802 d->mToolTipText = tooltip; |
|
803 } |
|
804 |
|
805 /*! |
|
806 @beta |
|
807 |
|
808 Returns the current tooltip text value. |
|
809 |
|
810 \sa setToolTipText() |
|
811 */ |
|
812 QString HbRatingSlider::toolTipText() const |
|
813 { |
|
814 Q_D(const HbRatingSlider); |
|
815 |
|
816 return d->mToolTipText; |
|
817 } |
|
818 |
|
819 /*! |
|
820 \reimp |
|
821 */ |
727 void HbRatingSlider::initStyleOption(HbStyleOption *hboption) const |
822 void HbRatingSlider::initStyleOption(HbStyleOption *hboption) const |
728 { |
823 { |
729 Q_D( const HbRatingSlider ); |
824 Q_D( const HbRatingSlider ); |
730 HbWidget::initStyleOption(hboption); |
825 HbWidget::initStyleOption(hboption); |
731 HbStyleOptionRatingSlider *option = 0; |
826 HbStyleOptionRatingSlider *option = 0; |
732 if ((option = qstyleoption_cast< HbStyleOptionRatingSlider *>(hboption)) != 0) { |
827 if ((option = qstyleoption_cast< HbStyleOptionRatingSlider *>(hboption)) != 0) { |
733 option->noOfStars = d->mNumberOfIcons; |
828 option->noOfStars = d->mNumberOfIcons; |
734 option->noOfIntervals = d->mStepCount; |
829 option->noOfIntervals = d->mStepCount; |
735 option->unRatedGraphicsName = d->mUnratedIconName; |
830 option->unRatedGraphicsName = d->mUnratedIconName; |
736 option->ratedGraphicsName = d->mRatedIconName; |
831 option->ratedGraphicsName = d->mRatedIconName; |
737 option->progressValue = d->mCurrentValue; |
832 option->progressValue = d->mCurrentValue; |
738 option->disableState = !isEnabled(); |
833 option->disableState = !isEnabled(); |
739 option->pressedState = d->mMousePressed; |
834 option->pressedState = d->mMousePressed; |
740 } |
835 if(layoutDirection() == Qt::RightToLeft) { |
741 } |
836 option->inverted = true; |
742 |
837 } |
743 /*! |
838 else { |
744 |
839 option->inverted = false; |
745 \deprecated HbRatingSlider::primitive(HbStyle::Primitive) |
840 } |
746 is deprecated. |
841 } |
747 |
842 } |
748 Provides access to primitives of HbRatingSlider. |
843 |
749 \param primitive is the type of the requested primitive. The available |
|
750 primitives are P_RatingSlider_frame,P_RatingSlider_track and P_RatingSlider_layout. |
|
751 |
|
752 */ |
|
753 QGraphicsItem* HbRatingSlider::primitive(HbStyle::Primitive primitive) const |
|
754 { |
|
755 Q_D(const HbRatingSlider); |
|
756 switch (primitive) { |
|
757 case HbStyle::P_RatingSlider_frame: |
|
758 return d->mFrame; |
|
759 case HbStyle::P_RatingSlider_track: |
|
760 return d->mTrack; |
|
761 case HbStyle::P_RatingSlider_layout: |
|
762 return d->mLayoutItem; |
|
763 default: |
|
764 return 0; |
|
765 } |
|
766 } |
|
767 /*! |
844 /*! |
768 \reimp |
845 \reimp |
769 */ |
846 */ |
770 void HbRatingSlider::changeEvent(QEvent *event) |
847 void HbRatingSlider::changeEvent(QEvent *event) |
771 { |
848 { |
772 HbWidget::changeEvent(event); |
849 HbWidget::changeEvent(event); |
|
850 |
773 switch (event->type()) { |
851 switch (event->type()) { |
774 case QEvent::LayoutDirectionChange: |
852 case QEvent::LayoutDirectionChange: |
775 updatePrimitives(); |
853 { |
|
854 updatePrimitives(); |
|
855 } |
776 break; |
856 break; |
777 case QEvent::EnabledChange: |
857 case QEvent::EnabledChange: |
778 updatePrimitives(); |
858 updatePrimitives(); |
779 break; |
859 break; |
780 default: |
860 default: |
781 break; |
861 break; |
782 } |
862 } |
783 } |
863 } |
|
864 |
784 /*! |
865 /*! |
785 \reimp |
866 \reimp |
786 */ |
867 */ |
787 void HbRatingSlider::updatePrimitives() |
868 void HbRatingSlider::updatePrimitives() |
788 { |
869 { |
789 Q_D(HbRatingSlider); |
870 Q_D(HbRatingSlider); |
790 HbStyleOptionRatingSlider option; |
871 |
791 initStyleOption(&option); |
872 // update unrated icon item |
792 if (d->mFrame) { |
873 d->updateUnRatedIconItem(); |
793 style()->updatePrimitive(d->mFrame, HbStyle::P_RatingSlider_frame, &option); |
874 |
794 } |
875 // update rated icon item |
795 |
876 d->updateRatedIconItem(); |
796 if (d->mTrack) { |
877 } |
797 style()->updatePrimitive(d->mTrack, HbStyle::P_RatingSlider_track, &option); |
878 |
798 } |
|
799 |
|
800 if (d->mTouchArea) { |
|
801 style()->updatePrimitive(d->mTouchArea, HbStyle::P_CheckBox_toucharea, &option); |
|
802 } |
|
803 |
|
804 } |
|
805 /*! |
879 /*! |
806 \reimp |
880 \reimp |
807 */ |
881 */ |
808 QVariant HbRatingSlider::itemChange(GraphicsItemChange change, const QVariant &value) |
882 QVariant HbRatingSlider::itemChange(GraphicsItemChange change, const QVariant &value) |
809 { |
883 { |