src/hbwidgets/sliders/hbratingslider.cpp
changeset 34 ed14f46c0e55
parent 7 923ff622b8b9
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    20 **
    20 **
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
       
    25 
    25 #include "hbratingslider_p.h"
    26 #include "hbratingslider_p.h"
       
    27 #include "hbrepeatitem_p.h"
    26 #include <hbratingslider.h>
    28 #include <hbratingslider.h>
    27 #include <hbtooltip.h>
    29 #include <hbtooltip.h>
    28 #include <hbstyleoptionratingslider_p.h>
    30 #include <hbstyleoptionratingslider_p.h>
    29 #include <QGraphicsItem>
       
    30 #include <QGraphicsSceneMouseEvent>
       
    31 #include <hbtoucharea.h>
    31 #include <hbtoucharea.h>
    32 #include <hbwidgetfeedback.h>
    32 #include <hbwidgetfeedback.h>
    33 
    33 
    34 #ifdef HB_GESTURE_FW
    34 #ifdef HB_GESTURE_FW
    35 #include <hbtapgesture.h>
    35 #include <hbtapgesture.h>
    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);
   180     HbRatingSlider *slider = new HbRatingSlider();
   263     HbRatingSlider *slider = new HbRatingSlider();
   181     slider->setStepCount(50); //5 *10//
   264     slider->setStepCount(50); //5 *10//
   182     slider->setCurrentRating(25); //2.5*10 it shows 25/50 which is same as 2.5/5
   265     slider->setCurrentRating(25); //2.5*10 it shows 25/50 which is same as 2.5/5
   183     \endcode
   266     \endcode
   184     
   267     
   185     This will show as 2.5/5. Now if on the same ratingslider 
   268     This will show as 2.5/5. Now if on the same HbRatingSlider 
   186     the Application wants to configure a Rating Slider with range 1-5
   269     the Application wants to configure a Rating Slider with range 1-5
   187     on emitting the signal rating changed it can set to 5.
   270     on emitting the signal rating changed it can set to 5.
   188  */
   271  */
   189 
   272 
   190 
   273 
   192     @beta
   275     @beta
   193      Constructs a Rating Slider bar with the given parent.
   276      Constructs a Rating Slider bar with the given parent.
   194     \param parent Parent Item.
   277     \param parent Parent Item.
   195 
   278 
   196 */
   279 */
   197 
       
   198 
       
   199 
       
   200 
       
   201 HbRatingSlider::HbRatingSlider(QGraphicsItem *parent) :
   280 HbRatingSlider::HbRatingSlider(QGraphicsItem *parent) :
   202 HbWidget(*new HbRatingSliderPrivate,parent)
   281 HbWidget(*new HbRatingSliderPrivate,parent)
   203 {
   282 {
   204     Q_D( HbRatingSlider );
   283     Q_D( HbRatingSlider );
   205     d->q_ptr = this;
   284     d->q_ptr = this;
   206     d->init();
   285     d->init();
   207 }
   286 }
   208 
   287 
   209 
       
   210 /*!
   288 /*!
   211     @beta
   289     @beta
   212     Protected constructor
   290     Protected constructor
   213 */
   291 */
   214 HbRatingSlider::HbRatingSlider(HbRatingSliderPrivate &dd,QGraphicsItem *parent) : 
   292 HbRatingSlider::HbRatingSlider(HbRatingSliderPrivate &dd,QGraphicsItem *parent) : 
   216 {
   294 {
   217     Q_D( HbRatingSlider );
   295     Q_D( HbRatingSlider );
   218     d->init();
   296     d->init();
   219 }
   297 }
   220 
   298 
   221 
       
   222 /*!
   299 /*!
   223     Destructor
   300     Destructor
   224 */
   301 */
   225 
       
   226 HbRatingSlider::~HbRatingSlider()
   302 HbRatingSlider::~HbRatingSlider()
   227 {
   303 {
   228 }
   304 }
   229 
   305 
   230 /*!
   306 /*!
   233 
   309 
   234     \param value true or false.
   310     \param value true or false.
   235 
   311 
   236     \sa readOnly()
   312     \sa readOnly()
   237 */
   313 */
   238 
       
   239 void HbRatingSlider::setReadOnly(bool value)
   314 void HbRatingSlider::setReadOnly(bool value)
   240 {
   315 {
   241     Q_D(HbRatingSlider);
   316     Q_D(HbRatingSlider);
   242     d->mReadOnly = value;
   317     d->mReadOnly = value;
   243 }
   318 }
   250 
   325 
   251     \param number. A value between 1 and 10 
   326     \param number. A value between 1 and 10 
   252 
   327 
   253     \sa numberOfIcons()
   328     \sa numberOfIcons()
   254 */
   329 */
   255 
       
   256 void HbRatingSlider::setNumberOfIcons(int number)
   330 void HbRatingSlider::setNumberOfIcons(int number)
   257 {
   331 {
   258     Q_D(HbRatingSlider);
   332     Q_D(HbRatingSlider);
   259     if ( (number <= 0) || (number > MAX_NUMBER_OF_ICONS) ){
   333 
   260         return;
   334     if(number != d->mNumberOfIcons){
   261     }
   335         if ( (number <= 0) || (number > MAX_NUMBER_OF_ICONS) ){
   262     d->mNumberOfIcons = number;
   336             return;
   263     updatePrimitives();
   337         }
   264     d->createLookupTable();
   338         d->mNumberOfIcons = number;
   265 }
   339         updatePrimitives();
   266 
   340 
       
   341         d->createLookupTable();
       
   342     }
       
   343 }
   267 
   344 
   268 /*!        
   345 /*!        
   269     @beta  
   346     @beta  
   270     Returns the number of icons set.
   347     Returns the number of icons set.
   271 
   348 
   272     \sa setNumberOfIcons()
   349     \sa setNumberOfIcons()
   273 */
   350 */
   274 
       
   275 int HbRatingSlider::numberOfIcons() const
   351 int HbRatingSlider::numberOfIcons() const
   276 {
   352 {
   277     Q_D(const HbRatingSlider);
   353     Q_D(const HbRatingSlider);
       
   354 
   278     return d->mNumberOfIcons;
   355     return d->mNumberOfIcons;
   279 }
   356 }
   280 
   357 
   281 /*!
   358 /*!
   282     @beta
   359     @beta
   289 
   366 
   290 */
   367 */
   291 void HbRatingSlider::setStepCount(int count)
   368 void HbRatingSlider::setStepCount(int count)
   292 {
   369 {
   293     Q_D(HbRatingSlider);
   370     Q_D(HbRatingSlider);
   294     if( (count <= 0) || (count > 100) ) {
   371 
   295         return;
   372     if(count != d->mStepCount){
   296     }
   373         if( (count <= 0) || (count > 100) ) {
   297     d->mStepCount = count;
   374             return;
   298     d->createLookupTable();    
   375         }
   299     
   376         d->mStepCount = count;
   300     HbStyleOptionRatingSlider option;
   377         d->createLookupTable();    
   301     initStyleOption(&option);
   378 
   302     if (d->mTrack) {
   379         d->updateRatedIconItem();
   303            style()->updatePrimitive(d->mTrack, HbStyle::P_RatingSlider_track, &option);
   380     }
   304     }
       
   305 
       
   306 }
   381 }
   307 
   382 
   308 /*!
   383 /*!
   309     @beta
   384     @beta
   310     Returns the step count.
   385     Returns the step count.
   311 
   386 
   312 */    
   387 */    
   313 int HbRatingSlider::stepCount() const
   388 int HbRatingSlider::stepCount() const
   314 {
   389 {
   315     Q_D(const HbRatingSlider);
   390     Q_D(const HbRatingSlider);
       
   391 
   316     return d->mStepCount;
   392     return d->mStepCount;
   317 }
   393 }
   318 
   394 
   319 /*!
   395 /*!
   320     @beta
   396     @beta
   321     Returns the read only flag of the Rating slider
   397     Returns the read only flag of the Rating slider
   322 */
   398 */
   323 bool HbRatingSlider::isReadOnly() const
   399 bool HbRatingSlider::isReadOnly() const
   324 {
   400 {
   325     Q_D(const HbRatingSlider);
   401     Q_D(const HbRatingSlider);
       
   402 
   326     return d->mReadOnly;
   403     return d->mReadOnly;
   327 }
   404 }
   328 
   405 
   329 /*!
   406 /*!
   330     @beta
   407     @beta
   334 
   411 
   335 */
   412 */
   336 void  HbRatingSlider::setCurrentRating(int rating)
   413 void  HbRatingSlider::setCurrentRating(int rating)
   337 {
   414 {
   338     Q_D(HbRatingSlider);
   415     Q_D(HbRatingSlider);
   339     if( rating >d->mStepCount ) {
   416 
   340         rating = d->mStepCount;
       
   341     }
       
   342     if( (rating == d->mCurrentValue) || (rating < 0) ) {
   417     if( (rating == d->mCurrentValue) || (rating < 0) ) {
   343         return;
   418         return;
   344     }
   419     }
   345 
   420 
       
   421     if( rating > d->mStepCount ) {
       
   422         rating = d->mStepCount;
       
   423     }
       
   424 
   346     d->mCurrentValue = rating;
   425     d->mCurrentValue = rating;
   347     
   426 
   348     HbStyleOptionRatingSlider option;
   427     d->updateRatedIconItem();
   349     initStyleOption(&option);
       
   350     if (d->mTrack) {
       
   351            style()->updatePrimitive(d->mTrack, HbStyle::P_RatingSlider_track, &option);
       
   352     }
       
   353 }
   428 }
   354 
   429 
   355 /*!
   430 /*!
   356     @beta
   431     @beta
   357     Returns the the current rating value.
   432     Returns the the current rating value.
   358 */
   433 */
   359 int HbRatingSlider::currentRating() const
   434 int HbRatingSlider::currentRating() const
   360 {
   435 {
   361     Q_D(const HbRatingSlider);
   436     Q_D(const HbRatingSlider);
       
   437 
   362     return d->mCurrentValue;
   438     return d->mCurrentValue;
   363 }
   439 }
   364 
   440 
   365 /*!
   441 /*!
   366     @beta
   442     @beta
   373     \sa unRatedIconName()
   449     \sa unRatedIconName()
   374 */
   450 */
   375 void HbRatingSlider::setUnRatedIconName(const QString name)
   451 void HbRatingSlider::setUnRatedIconName(const QString name)
   376 {
   452 {
   377     Q_D(HbRatingSlider);
   453     Q_D(HbRatingSlider);
   378     if(d->mUnratedIconName != name) {
   454 
       
   455     if(name != d->mUnratedIconName) {
   379         d->mUnratedIconName =name;
   456         d->mUnratedIconName =name;
   380 
       
   381         HbStyleOptionRatingSlider option;
       
   382         initStyleOption(&option);
       
   383         updatePrimitives();
   457         updatePrimitives();
   384     }
   458     }    
   385     
       
   386 }
   459 }
   387 
   460 
   388 /*!
   461 /*!
   389     @beta
   462     @beta
   390     Returns the unrated graphics name .
   463     Returns the unrated graphics name .
   391 */
   464 */
   392 QString HbRatingSlider::unRatedIconName() const
   465 QString HbRatingSlider::unRatedIconName() const
   393 {
   466 {
   394     Q_D(const HbRatingSlider);
   467     Q_D(const HbRatingSlider);
       
   468 
   395     return d->mUnratedIconName;
   469     return d->mUnratedIconName;
   396 
       
   397 }
   470 }
   398 
   471 
   399 /*!
   472 /*!
   400     @beta
   473     @beta
   401     
   474     
   407     \sa unRatedIconName()
   480     \sa unRatedIconName()
   408 */
   481 */
   409 void HbRatingSlider::setRatedIconName(const QString name)
   482 void HbRatingSlider::setRatedIconName(const QString name)
   410 {
   483 {
   411     Q_D(HbRatingSlider);
   484     Q_D(HbRatingSlider);
   412     if(d->mRatedIconName != name) {
   485 
       
   486     if(name != d->mRatedIconName) {
   413         d->mRatedIconName = name;
   487         d->mRatedIconName = name;
   414         HbStyleOptionRatingSlider option;
       
   415         initStyleOption(&option);
       
   416         updatePrimitives();
   488         updatePrimitives();
   417     }
   489     }
   418 }
   490 }
   419 
   491 
   420 /*!
   492 /*!
   422     Returns the rated graphics name .
   494     Returns the rated graphics name .
   423 */
   495 */
   424 QString HbRatingSlider::ratedIconName() const 
   496 QString HbRatingSlider::ratedIconName() const 
   425 {
   497 {
   426     Q_D(const HbRatingSlider);
   498     Q_D(const HbRatingSlider);
       
   499 
   427     return d->mRatedIconName;
   500     return d->mRatedIconName;
   428 }
   501 }
   429 
   502 
   430 #ifndef HB_GESTURE_FW
   503 #ifndef HB_GESTURE_FW
   431 /*!
   504 /*!
   456     Q_D(HbRatingSlider);
   529     Q_D(HbRatingSlider);
   457 
   530 
   458     if(!d->mMousePressed) {
   531     if(!d->mMousePressed) {
   459         return;
   532         return;
   460     }
   533     }
   461     QPointF layoutItemPos = d->mLayoutItem->pos();
   534     QPointF layoutItemPos = d->mBackGroundItem->pos();
   462     QPointF frameItemPos = d->mFrame->pos();   
   535     QPointF frameItemPos = d->mUnRatedItem->pos();   
   463     qreal xVal = event->pos().x() - layoutItemPos.x()+ frameItemPos.x();
   536     qreal xVal = event->pos().x() - layoutItemPos.x()+ frameItemPos.x();
   464     if(d->mTouchArea->isUnderMouse()) {
   537     if(d->mTouchArea->isUnderMouse()) {
   465             
   538             
   466         if(d->mReadOnly) {
   539         if(d->mReadOnly) {
   467             event->ignore();
   540             event->ignore();
   475         
   548         
   476         QRectF rect = d->mTouchArea->boundingRect();
   549         QRectF rect = d->mTouchArea->boundingRect();
   477         int rating=0;
   550         int rating=0;
   478         if(rect.contains(xVal,0 )) {
   551         if(rect.contains(xVal,0 )) {
   479             rating = d->calculateProgressValue(xVal);
   552             rating = d->calculateProgressValue(xVal);
   480             if(!toolTip().isNull()) {
   553             if(!mToolTipText.isNull()) {
   481                 HbToolTip::showText(toolTip(),this);
   554                 HbToolTip::showText(mToolTipText,this);
   482             }    
   555             }    
   483             setCurrentRating(rating);
   556             setCurrentRating(rating);
   484             emit ratingChanged (d->mCurrentValue);
   557             emit ratingChanged (d->mCurrentValue);
   485             event->accept();
   558             event->accept();
   486         }
   559         }
   497 */
   570 */
   498 void HbRatingSlider::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) 
   571 void HbRatingSlider::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) 
   499 {
   572 {
   500     Q_D(HbRatingSlider);
   573     Q_D(HbRatingSlider);
   501    
   574    
   502     QPointF layoutItemPos = d->mLayoutItem->pos();
   575     QPointF layoutItemPos = d->mBackGroundItem->pos();
   503     QPointF frameItemPos = d->mFrame->pos();
   576     QPointF frameItemPos = d->mUnRatedItem->pos();
   504 
   577 
   505     qreal xVal = event->pos().x() - layoutItemPos.x()+ frameItemPos.x();
   578     qreal xVal = event->pos().x() - layoutItemPos.x()+ frameItemPos.x();
   506     if(d->mTouchArea->isUnderMouse()) {
   579     if(d->mTouchArea->isUnderMouse()) {
   507             
   580             
   508         if(d->mReadOnly) {
   581         if(d->mReadOnly) {
   517         
   590         
   518         QRectF rect = d->mTouchArea->boundingRect();
   591         QRectF rect = d->mTouchArea->boundingRect();
   519         int rating=0;
   592         int rating=0;
   520         if(rect.contains(xVal,0 )) {
   593         if(rect.contains(xVal,0 )) {
   521             rating = d->calculateProgressValue(xVal);
   594             rating = d->calculateProgressValue(xVal);
   522             if(!toolTip().isNull()) {
   595             if(!mToolTipText.isNull()) {
   523                 HbToolTip::showText(toolTip(),this);
   596                 HbToolTip::showText(mToolTipText,this);
   524             }    
   597             }    
   525             setCurrentRating(rating);
   598             setCurrentRating(rating);
   526             if(d->mCurrentValue) {
   599             if(d->mCurrentValue) {
   527                 emit ratingDone (d->mCurrentValue);
   600                 emit ratingDone (d->mCurrentValue);
   528             }
   601             }
   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 {
   811         updatePrimitives();
   885         updatePrimitives();
   812     }
   886     }
   813 #ifdef HB_EFFECTS
   887 #ifdef HB_EFFECTS
   814     if(change == QGraphicsItem::ItemVisibleChange){
   888     if(change == QGraphicsItem::ItemVisibleChange){
   815         if(value.toBool()) {
   889         if(value.toBool()) {
   816 
       
   817             HbEffect::start(this, HB_RATINGSLIDER_ITEM_TYPE, "ratingslider_appear");
   890             HbEffect::start(this, HB_RATINGSLIDER_ITEM_TYPE, "ratingslider_appear");
   818         }
   891         }
   819         else
   892         else {
   820         {
   893             HbEffect::start(this, HB_RATINGSLIDER_ITEM_TYPE, "ratingslider_disappear");
   821              HbEffect::start(this, HB_RATINGSLIDER_ITEM_TYPE, "ratingslider_disappear");
   894         }
   822         }
   895     }
   823     }
       
   824 
       
   825 #endif//HB_EFFECTS
   896 #endif//HB_EFFECTS
   826 
   897 
   827    return HbWidget::itemChange(change,value);
   898    return HbWidget::itemChange(change,value);
   828 }
   899 }
   829 
   900 
       
   901 /*!
       
   902     \reimp
       
   903  */
       
   904 QGraphicsItem *HbRatingSlider::primitive(const QString &itemName) const
       
   905 {
       
   906     Q_D(const HbRatingSlider);
       
   907 
       
   908     if(!itemName.compare(QString("background"))){
       
   909         return d->mBackGroundItem;
       
   910     }
       
   911     if(!itemName.compare(QString("unrated-item"))){
       
   912         return d->mUnRatedItem;
       
   913     }
       
   914     if(!itemName.compare(QString("rated-item"))){
       
   915         return d->mRatedItem;
       
   916     }
       
   917     if(!itemName.compare(QString("toucharea"))){
       
   918         return d->mTouchArea;
       
   919     }
       
   920 
       
   921     return HbWidget::primitive(itemName);
       
   922 }
       
   923