src/hbcore/primitives/hbiconitem.cpp
changeset 5 627c4a0fd0e7
parent 3 11d3954df52a
child 6 c3690ec91ef8
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    34 
    34 
    35 /*!
    35 /*!
    36   @stable
    36   @stable
    37   @hbcore
    37   @hbcore
    38   \class HbIconItem
    38   \class HbIconItem
    39   \brief HbIconItem displays an HbIcon instance.
    39   \brief HbIconItem displays an icon provided in form of an HbIcon
    40 
    40 
    41 
    41 
    42   HbIconItem derives from HbWidgetBase and so can be added to a layout.
    42   HbIconItem derives from HbWidgetBase and so can be added to a layout.
    43   Use HbIconItem when you need your icon's position and size to be managed by a layout.
    43   Use HbIconItem when you need your icon's position and size to be managed by a layout.
    44 
    44 
    59   //Create new icon, set position and size for it
    59   //Create new icon, set position and size for it
    60   HbIconItem *icon = new HbIconItem("qtg_large_phonebook", this);
    60   HbIconItem *icon = new HbIconItem("qtg_large_phonebook", this);
    61   icon->setPos(10,150);
    61   icon->setPos(10,150);
    62   icon->setSize(icon->defaultSize());
    62   icon->setSize(icon->defaultSize());
    63   \endcode
    63   \endcode
    64   
    64 
    65   Example of how to add HbIconItem to a layout.
    65   Example of how to add HbIconItem to a layout.
    66   \code
    66   \code
    67   HbButton *button = new HbButton("Button 1");
    67   HbButton *button = new HbButton("Button 1");
    68   HbIconItem *icon = new HbIconItem("qtg_large_phonebook");
    68   HbIconItem *icon = new HbIconItem("qtg_large_phonebook");
    69   QGraphicsGridLayout *layout = new QGraphicsGridLayout();
    69   QGraphicsGridLayout *layout = new QGraphicsGridLayout();
   100 
   100 
   101 //Initialize the default values
   101 //Initialize the default values
   102 const QIcon::Mode HbIconItem::defaultMode = QIcon::Normal;
   102 const QIcon::Mode HbIconItem::defaultMode = QIcon::Normal;
   103 const QIcon::State HbIconItem::defaultState = QIcon::Off;
   103 const QIcon::State HbIconItem::defaultState = QIcon::Off;
   104 const Qt::AspectRatioMode HbIconItem::defaultAspectRatioMode = Qt::KeepAspectRatio;
   104 const Qt::AspectRatioMode HbIconItem::defaultAspectRatioMode = Qt::KeepAspectRatio;
   105 const Qt::Alignment HbIconItem::defaultAlignment = Qt::AlignCenter;
   105     
       
   106 // Note: No center aligning by default to prevent interesting rounding issues
       
   107 // in certain cases (e.g. 50.25x50.25 sized icon item would lead to having an
       
   108 // icon sized 50x50 drawn at (0.12499, 0.12499) which may or may not fit visually
       
   109 // the other primitives of the same widget).
       
   110 const Qt::Alignment HbIconItem::defaultAlignment = 0;
   106 
   111 
   107 bool HbIconItemPrivate::outlinesEnabled = false;
   112 bool HbIconItemPrivate::outlinesEnabled = false;
   108 
   113 
   109 HbIconItemPrivate::HbIconItemPrivate(const HbIcon &icon) :
   114 HbIconItemPrivate::HbIconItemPrivate(const HbIcon &icon) :
   110         mIcon(icon),
   115     mIcon(icon),
   111         mAnimator(),
   116     mAnimator(),
   112         mAlignment(HbIconItem::defaultAlignment),
   117     mAlignment(HbIconItem::defaultAlignment),
   113         mAspectRatioMode(HbIconItem::defaultAspectRatioMode),
   118     mAspectRatioMode(HbIconItem::defaultAspectRatioMode),
   114         mState(HbIconItem::defaultState),
   119     mState(HbIconItem::defaultState),
   115         mMode(HbIconItem::defaultMode)
   120     mMode(HbIconItem::defaultMode)
   116 {
   121 {
   117     q_ptr = 0;
   122     q_ptr = 0;
   118 }
   123 }
   119 
   124 
   120 HbIconItemPrivate::~HbIconItemPrivate ()
   125 HbIconItemPrivate::~HbIconItemPrivate()
   121 {
   126 {
   122 }
   127 }
   123 
   128 
   124 void HbIconItemPrivate::updateIconItem()
   129 void HbIconItemPrivate::updateIconItem()
   125 {
   130 {
   126     Q_Q(HbIconItem);
   131     Q_Q(HbIconItem);
       
   132     if (!mIcon.isNull()) {
       
   133         // This must be done before the setIcon() call below due to the
       
   134         // possibility of detaching. Doing it afterwards would lead to
       
   135         // colorization errors as the themed color might potentially be set for
       
   136         // a different icon engine, not for the one that is used in painting.
       
   137         HbIconPrivate::d_ptr_detached(&mIcon)->setThemedColor(mThemedColor);
       
   138     }
   127     const QRectF boundingRect = q->rect();
   139     const QRectF boundingRect = q->rect();
   128     if (!boundingRect.size().isEmpty()) {
   140     if (!boundingRect.size().isEmpty()) {
   129         mIconRect = boundingRect;
   141         mIconRect = boundingRect;
   130         mIcon.setSize(mIconRect.size());
   142         mIcon.setSize(mIconRect.size());
   131         mAnimator.setIcon(mIcon);
   143         mAnimator.setIcon(mIcon);
   132         q->update();
   144         q->update();
   133     }
   145     }
   134     if (!mIcon.isNull() && HbIconPrivate::d_ptr(&mIcon)->themedColor() != mThemedColor) {
   146 }
   135         HbIconPrivate::d_ptr_detached(&mIcon)->setThemedColor(mThemedColor);
   147 
   136     }
   148 void HbIconItemPrivate::updateIconParams()
       
   149 {
       
   150     Q_Q(HbIconItem);
       
   151     if (mIconRect.isValid()) {
       
   152         if (!mIcon.isNull()) {
       
   153             HbIconPrivate::d_ptr_detached(&mIcon)->setThemedColor(mThemedColor);
       
   154         }
       
   155         mAnimator.setIcon(mIcon);
       
   156     }
       
   157     q->update();
   137 }
   158 }
   138 
   159 
   139 void HbIconItemPrivate::setThemedColor(const QColor &color)
   160 void HbIconItemPrivate::setThemedColor(const QColor &color)
   140 {
   161 {
   141     mThemedColor = color;
   162     mThemedColor = color;
   142     updateIconItem();
   163     updateIconItem();
   143 }
   164 }
   144     
   165 
   145 /*!
   166 /*!
   146  Constructs a new HbIconItem with \a iconName and \a parent.
   167  Constructs a new HbIconItem with \a iconName and \a parent.
   147  \param iconName the name of the icon.
   168  \param iconName the name of the icon.
   148  See HbIcon for a description of how the icon name and the icon image filename are related.
   169  See HbIcon for a description of how the icon name and the icon image filename are related.
   149  \param parent the graphics item parent of this icon.
   170  \param parent the graphics item parent of this icon.
   150  */
   171  */
   151 HbIconItem::HbIconItem(const QString &iconName, QGraphicsItem *parent) :
   172 HbIconItem::HbIconItem(const QString &iconName, QGraphicsItem *parent) :
   152     HbWidgetBase(*new HbIconItemPrivate(iconName), parent)
   173     HbWidgetBase(*new HbIconItemPrivate(iconName), parent)
   153 {
   174 {
   154     Q_D( HbIconItem );
   175     Q_D(HbIconItem);
   155     d->q_ptr = this;
   176     d->q_ptr = this;
   156     // Set this graphics item to be updated on icon animations
   177     // Set this graphics item to be updated on icon animations
   157     d->mAnimator.setGraphicsItem(this);
   178     d->mAnimator.setGraphicsItem(this);
   158     HbOogmWatcher::instance()->registerIconItem(this);
   179     HbOogmWatcher::instance()->registerIconItem(this);
   159 }
   180 }
   164  \param parent the graphics item parent of this icon.
   185  \param parent the graphics item parent of this icon.
   165  */
   186  */
   166 HbIconItem::HbIconItem(const HbIcon &icon, QGraphicsItem *parent) :
   187 HbIconItem::HbIconItem(const HbIcon &icon, QGraphicsItem *parent) :
   167     HbWidgetBase(*new HbIconItemPrivate(icon), parent)
   188     HbWidgetBase(*new HbIconItemPrivate(icon), parent)
   168 {
   189 {
   169     Q_D( HbIconItem );
   190     Q_D(HbIconItem);
   170     d->q_ptr = this;
   191     d->q_ptr = this;
   171     // Set this graphics item to be updated on icon animations
   192     // Set this graphics item to be updated on icon animations
   172     d->mAnimator.setGraphicsItem(this);
   193     d->mAnimator.setGraphicsItem(this);
   173     HbOogmWatcher::instance()->registerIconItem(this);
   194     HbOogmWatcher::instance()->registerIconItem(this);
   174 }
   195 }
   178  \param parent the graphics item parent of this HbIconItem.
   199  \param parent the graphics item parent of this HbIconItem.
   179  */
   200  */
   180 HbIconItem::HbIconItem(QGraphicsItem *parent) :
   201 HbIconItem::HbIconItem(QGraphicsItem *parent) :
   181     HbWidgetBase(*new HbIconItemPrivate(QString()), parent)
   202     HbWidgetBase(*new HbIconItemPrivate(QString()), parent)
   182 {
   203 {
   183     Q_D( HbIconItem );
   204     Q_D(HbIconItem);
   184     d->q_ptr = this;
   205     d->q_ptr = this;
   185     // Set this graphics item to be updated on icon animations
   206     // Set this graphics item to be updated on icon animations
   186     d->mAnimator.setGraphicsItem(this);
   207     d->mAnimator.setGraphicsItem(this);
   187     HbOogmWatcher::instance()->registerIconItem(this);
   208     HbOogmWatcher::instance()->registerIconItem(this);
   188 }
   209 }
   189 
   210 
   190 
   211 
   191 /*!
   212 /*!
   192  \internal
   213  \internal
   193  */
   214  */
   194 HbIconItem::HbIconItem(HbIconItemPrivate &dd, QGraphicsItem * parent) :
   215 HbIconItem::HbIconItem(HbIconItemPrivate &dd, QGraphicsItem *parent) :
   195     HbWidgetBase(dd, parent)
   216     HbWidgetBase(dd, parent)
   196 {
   217 {
   197     // Set this graphics item to be updated on icon animations
   218     // Set this graphics item to be updated on icon animations
   198     dd.mAnimator.setGraphicsItem(this);
   219     dd.mAnimator.setGraphicsItem(this);
   199     HbOogmWatcher::instance()->registerIconItem(this);
   220     HbOogmWatcher::instance()->registerIconItem(this);
   215 
   236 
   216  \sa setIcon
   237  \sa setIcon
   217  */
   238  */
   218 HbIcon HbIconItem::icon() const
   239 HbIcon HbIconItem::icon() const
   219 {
   240 {
   220     Q_D(const HbIconItem );
   241     Q_D(const HbIconItem);
   221     return d->mIcon;
   242     return d->mIcon;
   222 }
   243 }
   223 
   244 
   224 /*!
   245 /*!
   225  Sets the HbIcon instance associated with this HbIconItem.
   246  Sets the HbIcon instance associated with this HbIconItem.
       
   247 
       
   248  Calling any function on \a icon after this one may not have any effect on the
       
   249  icon displayed by the HbIconItem. Use the setters in HbIconItem instead. Of course
       
   250  the settings set on \a icon before calling setIcon() will all be taken into account.
   226 
   251 
   227  \param icon the HbIcon instance that this HbIconItem displays.
   252  \param icon the HbIcon instance that this HbIconItem displays.
   228 
   253 
   229  \sa icon()
   254  \sa icon()
   230 */
   255 */
   263 
   288 
   264  \sa alignment
   289  \sa alignment
   265  */
   290  */
   266 void HbIconItem::setAlignment(Qt::Alignment alignment)
   291 void HbIconItem::setAlignment(Qt::Alignment alignment)
   267 {
   292 {
   268     Q_D(HbIconItem );
   293     Q_D(HbIconItem);
   269     if (d->mAlignment != alignment) {
   294     if (d->mAlignment != alignment) {
   270         d->mAlignment = alignment;
   295         d->mAlignment = alignment;
   271         update();
   296         update();
   272     }
   297     }
   273 }
   298 }
   281 
   306 
   282  \sa aspectRatioMode
   307  \sa aspectRatioMode
   283  */
   308  */
   284 void HbIconItem::setAspectRatioMode(Qt::AspectRatioMode aspectRatioMode)
   309 void HbIconItem::setAspectRatioMode(Qt::AspectRatioMode aspectRatioMode)
   285 {
   310 {
   286     Q_D(HbIconItem );
   311     Q_D(HbIconItem);
   287     d->setApiProtectionFlag(HbWidgetBasePrivate::AC_IconAspectRatioMode, true);
   312     d->setApiProtectionFlag(HbWidgetBasePrivate::AC_IconAspectRatioMode, true);
   288     if (d->mAspectRatioMode != aspectRatioMode) {
   313     if (d->mAspectRatioMode != aspectRatioMode) {
   289         d->mAspectRatioMode = aspectRatioMode;
   314         d->mAspectRatioMode = aspectRatioMode;
   290         update();
   315         update();
   291     }
   316     }
   294 /*!
   319 /*!
   295  Sets the QIcon mode for the icon. An icon can show different images for different modes.
   320  Sets the QIcon mode for the icon. An icon can show different images for different modes.
   296  If this method is not called, the icon uses the default mode which is QIcon::Normal.
   321  If this method is not called, the icon uses the default mode which is QIcon::Normal.
   297 
   322 
   298  \param mode the new icon mode.
   323  \param mode the new icon mode.
   299  \warning Currently this method makes use of pixmap() routine in case of NVG icons. 
   324  \warning Currently this method makes use of pixmap() routine in case of NVG icons.
   300  pixmap() slows down the hardware accelerated rendering.
   325  pixmap() slows down the hardware accelerated rendering.
   301  \sa mode
   326  \sa mode
   302  */
   327  */
   303 void HbIconItem::setMode(QIcon::Mode mode)
   328 void HbIconItem::setMode(QIcon::Mode mode)
   304 {
   329 {
   305     Q_D(HbIconItem );
   330     Q_D(HbIconItem);
   306     if (d->mMode != mode) {
   331     if (d->mMode != mode) {
   307         d->mMode = mode;
   332         d->mMode = mode;
   308         update();
   333         update();
   309     }
   334     }
   310 }
   335 }
   317 
   342 
   318  \sa state
   343  \sa state
   319  */
   344  */
   320 void HbIconItem::setState(QIcon::State state)
   345 void HbIconItem::setState(QIcon::State state)
   321 {
   346 {
   322     Q_D(HbIconItem );
   347     Q_D(HbIconItem);
   323     if (d->mState != state) {
   348     if (d->mState != state) {
   324         d->mState = state;
   349         d->mState = state;
   325         update();
   350         update();
   326     }
   351     }
   327 }
   352 }
   334  \sa HbIcon::setIconName()
   359  \sa HbIcon::setIconName()
   335  \sa iconName
   360  \sa iconName
   336  */
   361  */
   337 void HbIconItem::setIconName(const QString &iconName)
   362 void HbIconItem::setIconName(const QString &iconName)
   338 {
   363 {
   339     Q_D(HbIconItem );
   364     Q_D(HbIconItem);
   340     if (d->mIcon.iconName() != iconName) {
   365     if (d->mIcon.iconName() != iconName) {
   341         d->mIcon.setIconName(iconName);
   366         d->mIcon.setIconName(iconName);
   342         d->updateIconItem();
   367         d->updateIconItem();
   343     }
   368     }
   344 }
   369 }
   353 void HbIconItem::setFlags(HbIcon::Flags flags)
   378 void HbIconItem::setFlags(HbIcon::Flags flags)
   354 {
   379 {
   355     Q_D(HbIconItem);
   380     Q_D(HbIconItem);
   356     if (d->mIcon.flags() != flags) {
   381     if (d->mIcon.flags() != flags) {
   357         d->mIcon.setFlags(flags);
   382         d->mIcon.setFlags(flags);
   358         if (d->mIconRect.isValid())
   383         d->updateIconParams();
   359             d->mAnimator.setIcon(d->mIcon);
       
   360         update();
       
   361     }
   384     }
   362 }
   385 }
   363 
   386 
   364 /*!
   387 /*!
   365  Sets the mirroring \a mode for the icon item.
   388  Sets the mirroring \a mode for the icon item.
   372 void HbIconItem::setMirroringMode(HbIcon::MirroringMode mode)
   395 void HbIconItem::setMirroringMode(HbIcon::MirroringMode mode)
   373 {
   396 {
   374     Q_D(HbIconItem);
   397     Q_D(HbIconItem);
   375     if (d->mIcon.mirroringMode() != mode) {
   398     if (d->mIcon.mirroringMode() != mode) {
   376         d->mIcon.setMirroringMode(mode);
   399         d->mIcon.setMirroringMode(mode);
   377         if (d->mIconRect.isValid())
   400         d->updateIconParams();
   378             d->mAnimator.setIcon(d->mIcon);
       
   379         update();
       
   380     }
   401     }
   381 }
   402 }
   382 
   403 
   383 /*!
   404 /*!
   384  Sets the \a brush for the icon item.
   405  Sets the \a brush for the icon item.
   407  \sa HbIcon::setIconName()
   428  \sa HbIcon::setIconName()
   408  \sa iconName
   429  \sa iconName
   409  */
   430  */
   410 void HbIconItem::setIconName(const QString &iconName, QIcon::Mode mode, QIcon::State state)
   431 void HbIconItem::setIconName(const QString &iconName, QIcon::Mode mode, QIcon::State state)
   411 {
   432 {
   412     Q_D( HbIconItem );
   433     Q_D(HbIconItem);
   413     d->mIcon.setIconName(iconName, mode, state);
   434     d->mIcon.setIconName(iconName, mode, state);
   414     d->updateIconItem();
   435     d->updateIconItem();
   415 }
   436 }
   416 
   437 
   417 /*!
   438 /*!
   425   \param  color to be set.
   446   \param  color to be set.
   426   \sa HbIconItem::color(), HbIcon::setColor()
   447   \sa HbIconItem::color(), HbIcon::setColor()
   427 */
   448 */
   428 void HbIconItem::setColor(const QColor &color)
   449 void HbIconItem::setColor(const QColor &color)
   429 {
   450 {
   430     Q_D( HbIconItem );
   451     Q_D(HbIconItem);
   431     if (d->mIcon.color() != color) {
   452     if (d->mIcon.color() != color) {
   432         d->mIcon.setColor(color);
   453         d->mIcon.setColor(color);
   433         if (d->mIconRect.isValid())
   454         d->updateIconParams();
   434             d->mAnimator.setIcon(d->mIcon);
       
   435         update();
       
   436     }
   455     }
   437 }
   456 }
   438 
   457 
   439 /*!
   458 /*!
   440 * Returns the color of the HbIconItem.
   459 * Returns the color of the HbIconItem.
   441 * \sa HbIconItem::setColor()
   460 * \sa HbIconItem::setColor()
   442 */
   461 */
   443 QColor HbIconItem::color() const
   462 QColor HbIconItem::color() const
   444 {
   463 {
   445     Q_D(const  HbIconItem );
   464     Q_D(const  HbIconItem);
   446     return d->mIcon.color();
   465     return d->mIcon.color();
   447 }
   466 }
   448 
   467 
   449 /*!
   468 /*!
   450  Returns the default size of the icon.
   469  Returns the default size of the icon.
   451  
   470 
   452  For raster images this is the original size of the image.
   471  For raster images this is the original size of the image.
   453 
   472 
   454  \sa HbIcon::defaultSize()
   473  \sa HbIcon::defaultSize()
   455  */
   474  */
   456 QSizeF HbIconItem::defaultSize() const
   475 QSizeF HbIconItem::defaultSize() const
   457 {
   476 {
   458     Q_D(const HbIconItem );
   477     Q_D(const HbIconItem);
   459     return d->mIcon.defaultSize();
   478     return d->mIcon.defaultSize();
   460 }
   479 }
   461 
   480 
   462 /*!
   481 /*!
   463  \return the size of this HbIconItem
   482  \return the size of this HbIconItem
   474 
   493 
   475  \sa setAspectRatioMode
   494  \sa setAspectRatioMode
   476  */
   495  */
   477 Qt::AspectRatioMode HbIconItem::aspectRatioMode() const
   496 Qt::AspectRatioMode HbIconItem::aspectRatioMode() const
   478 {
   497 {
   479     Q_D(const HbIconItem );
   498     Q_D(const HbIconItem);
   480     return d->mAspectRatioMode;
   499     return d->mAspectRatioMode;
   481 }
   500 }
   482 
   501 
   483 /*!
   502 /*!
   484  \return the icon's alignment.
   503  \return the icon's alignment.
   485 
   504 
   486  \sa setAlignment
   505  \sa setAlignment
   487  */
   506  */
   488 Qt::Alignment HbIconItem::alignment() const
   507 Qt::Alignment HbIconItem::alignment() const
   489 {
   508 {
   490     Q_D(const HbIconItem );
   509     Q_D(const HbIconItem);
   491     return d->mAlignment;
   510     return d->mAlignment;
   492 }
   511 }
   493 
   512 
   494 /*!
   513 /*!
   495  \return the icon's mode.
   514  \return the icon's mode.
   496 
   515 
   497  \sa setMode
   516  \sa setMode
   498  */
   517  */
   499 QIcon::Mode HbIconItem::mode() const
   518 QIcon::Mode HbIconItem::mode() const
   500 {
   519 {
   501     Q_D(const HbIconItem );
   520     Q_D(const HbIconItem);
   502     return d->mMode;
   521     return d->mMode;
   503 }
   522 }
   504 
   523 
   505 /*!
   524 /*!
   506  \return the icon's state.
   525  \return the icon's state.
   507 
   526 
   508  \sa setState
   527  \sa setState
   509  */
   528  */
   510 QIcon::State HbIconItem::state() const
   529 QIcon::State HbIconItem::state() const
   511 {
   530 {
   512     Q_D(const HbIconItem );
   531     Q_D(const HbIconItem);
   513     return d->mState;
   532     return d->mState;
   514 }
   533 }
   515 
   534 
   516 /*!
   535 /*!
   517  \return the icon's name.
   536  \return the icon's name.
   519  \sa HbIcon::iconName()
   538  \sa HbIcon::iconName()
   520  \sa setIconName
   539  \sa setIconName
   521  */
   540  */
   522 QString HbIconItem::iconName() const
   541 QString HbIconItem::iconName() const
   523 {
   542 {
   524     Q_D(const HbIconItem );
   543     Q_D(const HbIconItem);
   525     return d->mIcon.iconName();
   544     return d->mIcon.iconName();
   526 }
   545 }
   527 
   546 
   528 /*!
   547 /*!
   529  \return the icon name for a specific mode and state.
   548  \return the icon name for a specific mode and state.
   533  \sa HbIcon::iconName()
   552  \sa HbIcon::iconName()
   534  \sa setIconName
   553  \sa setIconName
   535  */
   554  */
   536 QString HbIconItem::iconName(QIcon::Mode mode, QIcon::State state) const
   555 QString HbIconItem::iconName(QIcon::Mode mode, QIcon::State state) const
   537 {
   556 {
   538     Q_D(const HbIconItem );
   557     Q_D(const HbIconItem);
   539     return d->mIcon.iconName(mode, state);
   558     return d->mIcon.iconName(mode, state);
   540 }
   559 }
   541 
   560 
   542 /*!
   561 /*!
   543  \return the HbIcon flags for the icon displayed by this HbIconItem.
   562  \return the HbIcon flags for the icon displayed by this HbIconItem.
   577 /*!
   596 /*!
   578  * Refer HbIcon::isNull()
   597  * Refer HbIcon::isNull()
   579  */
   598  */
   580 bool HbIconItem::isNull() const
   599 bool HbIconItem::isNull() const
   581 {
   600 {
   582     Q_D(const HbIconItem );
   601     Q_D(const HbIconItem);
   583     return d->mIcon.isNull();
   602     return d->mIcon.isNull();
   584 }
   603 }
   585 
   604 
   586 /*!
   605 /*!
   587  Paints the graphics item.
   606  Paints the graphics item.
   592 {
   611 {
   593     Q_UNUSED(widget)
   612     Q_UNUSED(widget)
   594     Q_UNUSED(option)
   613     Q_UNUSED(option)
   595     Q_D(HbIconItem);
   614     Q_D(HbIconItem);
   596     const QRectF rect(boundingRect());
   615     const QRectF rect(boundingRect());
   597     if (!rect.isEmpty()){
   616     if (!rect.isEmpty()) {
   598         if (d->mIconRect != rect) {
   617         if (d->mIconRect != rect) {
   599             d->mIconRect = rect;
   618             d->mIconRect = rect;
       
   619             if (!d->mIcon.isNull()) {
       
   620                 HbIconPrivate::d_ptr_detached(&d->mIcon)->setThemedColor(d->mThemedColor);
       
   621             }
   600             d->mIcon.setSize(d->mIconRect.size());
   622             d->mIcon.setSize(d->mIconRect.size());
   601             d->mAnimator.setIcon(d->mIcon);
   623             d->mAnimator.setIcon(d->mIcon);
   602         }
   624         }
   603         painter->fillRect(rect, d->mBrush);
   625         painter->fillRect(rect, d->mBrush);
   604         d->mAnimator.paint(painter, rect,
   626         d->mAnimator.paint(painter, rect,
   605                            d->mAspectRatioMode, d->mAlignment,
   627                            d->mAspectRatioMode, d->mAlignment,
   606                            d->mMode, d->mState);
   628                            d->mMode, d->mState);
   607     }
   629     }
   608     if (HbIconItemPrivate::outlinesEnabled) {
   630     if (HbIconItemPrivate::outlinesEnabled) {
   609         painter->setBrush(QBrush(QColor(0, 255, 0, 50)));
   631         painter->setBrush(QBrush(QColor(0, 255, 0, 50)));
   610         painter->drawRect(contentsRect()); 
   632         painter->drawRect(contentsRect());
   611     }
   633     }
   612 }
   634 }
   613 
   635 
   614 /*!
   636 /*!
   615     \reimp
   637     \reimp
   627         HbWidgetBase::changeEvent(event);
   649         HbWidgetBase::changeEvent(event);
   628         break;
   650         break;
   629     }
   651     }
   630 }
   652 }
   631 
   653 
   632  /*!
   654 /*!
   633     \reimp
   655    \reimp
   634  */
   656 */
   635 QVariant HbIconItem::itemChange(GraphicsItemChange change, const QVariant &value)
   657 QVariant HbIconItem::itemChange(GraphicsItemChange change, const QVariant &value)
   636 {
   658 {
   637     Q_D(HbIconItem);
   659     Q_D(HbIconItem);
   638     if (QGraphicsItem::ItemEnabledHasChanged==change) {
   660     if (QGraphicsItem::ItemEnabledHasChanged == change) {
   639         d->mMode = value.toBool() ? QIcon::Normal : QIcon::Disabled;
   661         d->mMode = value.toBool() ? QIcon::Normal : QIcon::Disabled;
   640     }
   662     }
   641 
   663 
   642     return HbWidgetBase::itemChange(change, value);
   664     return HbWidgetBase::itemChange(change, value);
   643 }
   665 }