src/hbwidgets/widgets/hblabel.cpp
changeset 28 b7da29130b0e
parent 21 4633027730f5
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
    36 #include "hbwidget_p.h"
    36 #include "hbwidget_p.h"
    37 #include "hbstyleoptionlabel_p.h"
    37 #include "hbstyleoptionlabel_p.h"
    38 #include "hbwidgetbase.h"
    38 #include "hbwidgetbase.h"
    39 #include "hblabel.h"
    39 #include "hblabel.h"
    40 #include "hbstyle_p.h"
    40 #include "hbstyle_p.h"
       
    41 #include "hbstyletextprimitivedata.h"
       
    42 #include "hbstylerichtextprimitivedata.h"
       
    43 #include "hbstyleiconprimitivedata.h"
    41 
    44 
    42 /*!
    45 /*!
    43     @alpha
    46     @alpha
    44     @hbcore
    47     @hbcore
    45 
    48 
    88 
    91 
    89 class HbLabelPrivate: public HbWidgetPrivate {
    92 class HbLabelPrivate: public HbWidgetPrivate {
    90     Q_DECLARE_PUBLIC(HbLabel)
    93     Q_DECLARE_PUBLIC(HbLabel)
    91 
    94 
    92 public:
    95 public:
    93             HbLabelPrivate ();
    96     HbLabelPrivate();
    94     ~HbLabelPrivate ();
    97     ~HbLabelPrivate();
    95 
    98 
    96     void clearAll();
    99     void clearAll();
    97 
   100 
    98     void setText(const QString &text, HbStylePrivate::Primitive primitiveId);
   101     void setText(const QString &text, HbStyle::PrimitiveType primitiveId);
    99     void setIcon(const HbIcon &icon);
   102     void setIcon(const HbIcon &icon);
   100 
   103 
   101     void updatePrimitives ();
   104     void updatePrimitives ();
   102     void createPrimitives ();
   105     void createPrimitives ();
   103 
   106 
   104     //shared between icon and text
   107     //shared between icon and text
   105     Qt::Alignment mAlignment;
   108     HbStyleValue<Qt::Alignment> mAlignment;
   106 
   109 
   107     // text section
   110     // text section
   108     QString mText;
   111     HbStyleValue<QString> mText;
   109     Qt::TextElideMode mElideMode;
   112     HbStyleValue<Qt::TextElideMode> mElideMode;
   110     Hb::TextWrapping mTextWrapping;
   113     HbStyleValue<Hb::TextWrapping> mTextWrapping;
   111     QColor mColor;
   114     HbStyleValue<QColor> mColor;
   112     int mMaxLines;
   115     HbStyleValue<int> mMaxLines;
   113 
   116 
   114     // icon section
   117     // icon section
   115     HbIcon mIcon;
   118     HbStyleValue<HbIcon> mIcon;
   116     Qt::AspectRatioMode mAspectRatioMode;
   119     HbStyleValue<Qt::AspectRatioMode> mAspectRatioMode;
   117 
   120 
   118     // primitive handling
   121     // primitive handling
   119     QGraphicsItem *mPrimitiveItem;
   122     QGraphicsObject *mPrimitiveItem;
   120     HbStylePrivate::Primitive mActivePrimitive;
   123 
       
   124     HbStyle::PrimitiveType mActivePrimitive;
   121 };
   125 };
   122 
   126 
   123 HbLabelPrivate::HbLabelPrivate() :
   127 HbLabelPrivate::HbLabelPrivate() :
   124         HbWidgetPrivate(),
   128         HbWidgetPrivate(),
   125         mAlignment(Qt::AlignLeft | Qt::AlignVCenter),
       
   126         mText(QString()),
       
   127         mElideMode(Qt::ElideRight),
       
   128         mTextWrapping(Hb::TextNoWrap),
       
   129         mMaxLines(0),
       
   130         mAspectRatioMode(Qt::KeepAspectRatio),
       
   131         mPrimitiveItem(0),
   129         mPrimitiveItem(0),
   132         mActivePrimitive(HbStylePrivate::P_None)
   130         mActivePrimitive(HbStyle::PT_None)
   133 {
   131 {
   134 }
   132 }
   135 
   133 
   136 void HbLabelPrivate::clearAll()
   134 void HbLabelPrivate::clearAll()
   137 {
   135 {
   138     if (mPrimitiveItem) {
   136     if (mPrimitiveItem) {
   139         delete mPrimitiveItem;
   137         delete mPrimitiveItem;
   140         mPrimitiveItem = 0;
   138         mPrimitiveItem = 0;
   141         mActivePrimitive = HbStylePrivate::P_None;
   139         mActivePrimitive = HbStyle::PT_None;
   142     }
   140     }
   143 
   141 
   144     mText.clear();
   142     mText.clear();
   145     mIcon.clear();
   143     mIcon.clear();
   146 }
   144 }
   147 
   145 
   148 void HbLabelPrivate::setText(const QString &text, HbStylePrivate::Primitive primitiveId)
   146 void HbLabelPrivate::setText(const QString &text, HbStyle::PrimitiveType primitiveId)
   149 {
   147 {
   150     Q_Q(HbLabel);
   148     Q_Q(HbLabel);
   151 
   149 
   152     if (text.isNull()) {
   150     if (text.isNull()) {
   153         clearAll();
   151         clearAll();
   156 
   154 
   157     if (mActivePrimitive != primitiveId) {
   155     if (mActivePrimitive != primitiveId) {
   158         clearAll();
   156         clearAll();
   159     }
   157     }
   160 
   158 
   161     if (mText != text || mText.isNull()) {
   159     if (mText!=text) {
   162         mText = text;
   160         mText = text;
   163         if (mActivePrimitive != primitiveId) {
   161         if (mActivePrimitive != primitiveId) {
   164             mActivePrimitive = primitiveId;
   162             mActivePrimitive = primitiveId;
   165             createPrimitives();
   163             createPrimitives();
   166             q->repolish(); // reconecting new primitive to HbAnchorLayout so it is really needed!
   164             q->repolish(); // reconecting new primitive to HbAnchorLayout so it is really needed!
   176     if (icon.isNull()) {
   174     if (icon.isNull()) {
   177         clearAll();
   175         clearAll();
   178         return;
   176         return;
   179     }
   177     }
   180 
   178 
   181     if (mActivePrimitive != HbStylePrivate::P_Label_icon) {
   179     if (mActivePrimitive != HbStyle::PT_IconItem) {
   182         clearAll();
   180         clearAll();
   183     }
   181     }
   184 
   182 
   185     if (mIcon != icon) {
   183     if (mIcon != icon) {
   186         mIcon = icon;
   184         mIcon = icon;
   187 
   185 
   188         if (mActivePrimitive != HbStylePrivate::P_Label_icon) {
   186         if (mActivePrimitive != HbStyle::PT_IconItem) {
   189             mActivePrimitive = HbStylePrivate::P_Label_icon;
   187             mActivePrimitive = HbStyle::PT_IconItem;
   190             createPrimitives();
   188             createPrimitives();
   191             q->repolish(); // reconecting new primitive to HbAnchorLayout so it is really needed!
   189             q->repolish(); // reconecting new primitive to HbAnchorLayout so it is really needed!
   192         }
   190         }
   193         q->updatePrimitives();
   191         q->updatePrimitives();
   194     }
   192     }
   202 {
   200 {
   203     Q_Q(HbLabel);
   201     Q_Q(HbLabel);
   204 
   202 
   205     Q_ASSERT(mPrimitiveItem==0);
   203     Q_ASSERT(mPrimitiveItem==0);
   206 
   204 
   207     if (mActivePrimitive != HbStylePrivate::P_None) {
   205     switch (mActivePrimitive) {
   208         mPrimitiveItem = HbStylePrivate::createPrimitive(mActivePrimitive, q);
   206     case HbStyle::PT_None:
       
   207         break;
       
   208 
       
   209     case HbStyle::PT_IconItem:
       
   210         mPrimitiveItem = q->style()->createPrimitive(mActivePrimitive, QString("icon"),q);
       
   211         break;
       
   212 
       
   213     case HbStyle::PT_TextItem: // no break
       
   214     case HbStyle::PT_RichTextItem:
       
   215         mPrimitiveItem = q->style()->createPrimitive(mActivePrimitive, QString("text"),q);
       
   216         break;
       
   217 
       
   218     default:
       
   219         Q_ASSERT(0);
   209     }
   220     }
   210 }
   221 }
   211 
   222 
   212 void HbLabelPrivate::updatePrimitives()
   223 void HbLabelPrivate::updatePrimitives()
   213 {
   224 {
   214     Q_Q(HbLabel);
   225     Q_Q(HbLabel);
   215 
   226 
   216     if (mActivePrimitive != HbStylePrivate::P_None) {
   227     if (mActivePrimitive != HbStyle::PT_None) {
   217         Q_ASSERT(mActivePrimitive == HbStylePrivate::P_Label_icon
   228         Q_ASSERT(mActivePrimitive == HbStyle::PT_IconItem
   218                  || mActivePrimitive == HbStylePrivate::P_Label_richtext
   229                  || mActivePrimitive == HbStyle::PT_RichTextItem
   219                  || mActivePrimitive == HbStylePrivate::P_Label_text);
   230                  || mActivePrimitive == HbStyle::PT_TextItem);
   220 
   231 
   221         HbStyleOptionLabel option;
   232         switch (mActivePrimitive) {
   222         q->initStyleOption(&option);
   233         case HbStyle::PT_IconItem: {
   223         HbStylePrivate::updatePrimitive(mPrimitiveItem, mActivePrimitive, &option);
   234                 HbStyleIconPrimitiveData data;
       
   235                 // set common data:
       
   236                 data.alignment = mAlignment;
       
   237 
       
   238                 // set icon data:
       
   239                 data.aspectRatioMode = mAspectRatioMode;
       
   240                 data.icon = mIcon;
       
   241 
       
   242                 q->style()->updatePrimitive(mPrimitiveItem,
       
   243                                             &data);
       
   244             }
       
   245             break;
       
   246         case HbStyle::PT_TextItem: {
       
   247                 HbStyleTextPrimitiveData data;
       
   248 
       
   249                 // set common data:
       
   250                 data.alignment = mAlignment;
       
   251 
       
   252                 // set text common data:
       
   253                 data.text = mText;
       
   254                 data.textColor = mColor;
       
   255                 data.textWrapping = mTextWrapping;
       
   256 
       
   257                 // plain text specyfic:
       
   258                 data.elideMode = mElideMode;
       
   259                 data.maximumLines = mMaxLines;
       
   260 
       
   261                 q->style()->updatePrimitive(mPrimitiveItem,
       
   262                                             &data);
       
   263             }
       
   264             break;
       
   265 
       
   266         case HbStyle::PT_RichTextItem: {
       
   267                 HbStyleRichTextPrimitiveData data;
       
   268 
       
   269                 // set common data:
       
   270                 data.alignment = mAlignment;
       
   271 
       
   272                 // set text common data:
       
   273                 data.text = mText;
       
   274                 data.defaultColor = mColor;
       
   275                 data.textWrappingMode = mTextWrapping;
       
   276 
       
   277                 q->style()->updatePrimitive(mPrimitiveItem,
       
   278                                             &data);
       
   279             }
       
   280             break;
       
   281 
       
   282         case 0: {
       
   283             }
       
   284             break;
       
   285 
       
   286         default:
       
   287             Q_ASSERT(0);
       
   288         }
   224     }
   289     }
   225 }
   290 }
   226 
   291 
   227 /*!
   292 /*!
   228     Constructs the label with a given \a parent.
   293     Constructs the label with a given \a parent.
   310 void HbLabel::setElideMode (Qt::TextElideMode elideMode)
   375 void HbLabel::setElideMode (Qt::TextElideMode elideMode)
   311 {
   376 {
   312     Q_D(HbLabel);
   377     Q_D(HbLabel);
   313     if (elideMode != d->mElideMode) {
   378     if (elideMode != d->mElideMode) {
   314         d->mElideMode = elideMode;
   379         d->mElideMode = elideMode;
   315         if (!d->mText.isNull()) {
   380         if (d->mText.isSet()) {
   316             updatePrimitives();
   381             updatePrimitives();
   317         }
   382         }
   318     }
   383     }
   319 }
   384 }
   320 
   385 
   325     \sa HbLabel::setElideMode()
   390     \sa HbLabel::setElideMode()
   326  */
   391  */
   327 Qt::TextElideMode HbLabel::elideMode() const
   392 Qt::TextElideMode HbLabel::elideMode() const
   328 {
   393 {
   329     Q_D(const HbLabel);
   394     Q_D(const HbLabel);
   330     return d->mElideMode;
   395     if (d->mElideMode.isSet()) {
       
   396         return d->mElideMode;
       
   397     } else {
       
   398         return Qt::ElideRight;
       
   399     }
   331 }
   400 }
   332 
   401 
   333 /*!
   402 /*!
   334     Sets the text wrapping mode to \a mode.
   403     Sets the text wrapping mode to \a mode.
   335     \param mode - wrapping mode
   404     \param mode - wrapping mode
   339 void HbLabel::setTextWrapping(Hb::TextWrapping mode)
   408 void HbLabel::setTextWrapping(Hb::TextWrapping mode)
   340 {
   409 {
   341     Q_D(HbLabel);
   410     Q_D(HbLabel);
   342     if (d->mTextWrapping != mode) {
   411     if (d->mTextWrapping != mode) {
   343         d->mTextWrapping = mode;
   412         d->mTextWrapping = mode;
   344         if (!d->mText.isNull()) {
   413         if (d->mText.isSet()) {
   345             updatePrimitives();
   414             updatePrimitives();
   346         }
   415         }
   347     }
   416     }
   348 }
   417 }
   349 
   418 
   350 /*!
   419 /*!
   351     \return the label's current text wrapping mode.
   420     \return the label's current text wrapping mode.
   352     Default value is NoWrap.
   421     Default value is Hb::TextNoWrap.
   353 
   422 
   354     \sa setTextWrapping()
   423     \sa setTextWrapping()
   355  */
   424  */
   356 Hb::TextWrapping HbLabel::textWrapping() const
   425 Hb::TextWrapping HbLabel::textWrapping() const
   357 {
   426 {
   358     Q_D(const HbLabel);
   427     Q_D(const HbLabel);
   359     return d->mTextWrapping;
   428 
       
   429     if (d->mTextWrapping.isSet()) {
       
   430         return d->mTextWrapping;
       
   431     } else {
       
   432         return Hb::TextNoWrap;
       
   433     }
   360 }
   434 }
   361 
   435 
   362 /*!
   436 /*!
   363     Sets the icon displayed by this label.
   437     Sets the icon displayed by this label.
   364     Removes any existing text from the label.
   438     Removes any existing text from the label.
   379     \sa setIcon
   453     \sa setIcon
   380  */
   454  */
   381 HbIcon HbLabel::icon() const
   455 HbIcon HbLabel::icon() const
   382 {
   456 {
   383     Q_D(const HbLabel);
   457     Q_D(const HbLabel);
   384     return d->mIcon;
   458 
       
   459     if (d->mIcon.isSet()) {
       
   460         return d->mIcon;
       
   461     } else {
       
   462         return HbIcon();
       
   463     }
   385 }
   464 }
   386 
   465 
   387 /*!
   466 /*!
   388     Clears the content of the label. After this the label is empty.
   467     Clears the content of the label. After this the label is empty.
   389 
   468 
   404 void HbLabel::setAspectRatioMode(Qt::AspectRatioMode aspectRatioMode)
   483 void HbLabel::setAspectRatioMode(Qt::AspectRatioMode aspectRatioMode)
   405 {
   484 {
   406     Q_D(HbLabel);
   485     Q_D(HbLabel);
   407     if (d->mAspectRatioMode != aspectRatioMode) {
   486     if (d->mAspectRatioMode != aspectRatioMode) {
   408         d->mAspectRatioMode = aspectRatioMode;
   487         d->mAspectRatioMode = aspectRatioMode;
   409         if (!d->mIcon.isNull()) {
   488         if (d->mIcon.isSet()) {
   410             updatePrimitives();
   489             updatePrimitives();
   411         }
   490         }
   412     }
   491     }
   413 }
   492 }
   414 
   493 
   419     \sa setAspectRatio()
   498     \sa setAspectRatio()
   420  */
   499  */
   421 Qt::AspectRatioMode HbLabel::aspectRatioMode() const
   500 Qt::AspectRatioMode HbLabel::aspectRatioMode() const
   422 {
   501 {
   423     Q_D(const HbLabel);
   502     Q_D(const HbLabel);
   424     return d->mAspectRatioMode;
   503 
       
   504     if (d->mAspectRatioMode.isSet()) {
       
   505         return d->mAspectRatioMode;
       
   506     } else {
       
   507         return Qt::KeepAspectRatio;
       
   508     }
   425 }
   509 }
   426 
   510 
   427 /*!
   511 /*!
   428     Sets the label contents to plain text containing \a text. Any previous content is cleared.
   512     Sets the label contents to plain text containing \a text. Any previous content is cleared.
   429     Does nothing if the string representation is the same as the current contents of the label.
   513     Does nothing if the string representation is the same as the current contents of the label.
   433     \sa setIcon()
   517     \sa setIcon()
   434  */
   518  */
   435 void HbLabel::setPlainText(const QString &text)
   519 void HbLabel::setPlainText(const QString &text)
   436 {
   520 {
   437     Q_D(HbLabel);
   521     Q_D(HbLabel);
   438     d->setText(text, HbStylePrivate::P_Label_text);
   522     d->setText(text, HbStyle::PT_TextItem);
   439 }
   523 }
   440 
   524 
   441 /*!
   525 /*!
   442     Sets the label contents to html text containing \a text. Any previous content is cleared.
   526     Sets the label contents to html text containing \a text. Any previous content is cleared.
   443     Does nothing if the string representation is the same as the current contents of the label.
   527     Does nothing if the string representation is the same as the current contents of the label.
   447     \sa setIcon()
   531     \sa setIcon()
   448  */
   532  */
   449 void HbLabel::setHtml(const QString &text)
   533 void HbLabel::setHtml(const QString &text)
   450 {
   534 {
   451     Q_D(HbLabel);
   535     Q_D(HbLabel);
   452     d->setText(text, HbStylePrivate::P_Label_richtext);
   536     d->setText(text, HbStyle::PT_RichTextItem);
   453 }
   537 }
   454 
   538 
   455 /*!
   539 /*!
   456     Sets the \a alignment of the label.
   540     Sets the \a alignment of the label.
   457     \param alignment - the new alignment.
   541     \param alignment - the new alignment.
   461 void HbLabel::setAlignment(Qt::Alignment alignment)
   545 void HbLabel::setAlignment(Qt::Alignment alignment)
   462 {
   546 {
   463     Q_D(HbLabel);
   547     Q_D(HbLabel);
   464     if (d->mAlignment != alignment) {
   548     if (d->mAlignment != alignment) {
   465         d->mAlignment = alignment;
   549         d->mAlignment = alignment;
   466         if (d->mActivePrimitive!=HbStylePrivate::P_None) {
   550         if (alignment == 0) {
       
   551             d->mAlignment.clear();
       
   552         }
       
   553         if (d->mActivePrimitive!=HbStyle::PT_None) {
   467             updatePrimitives();
   554             updatePrimitives();
   468         }
   555         }
   469     }
   556     }
   470 }
   557 }
   471 
   558 
   472 /*!
   559 /*!
   473     \return the alignment. Default alignment is 'Qt::AlignLeft | Qt::AlignVCenter'
   560     \return the alignment. Default alignment is '0' indicating that nothing was
       
   561     set (so CSS cotrols alignment).
   474 
   562 
   475     \sa HbLabel::setAlignment()
   563     \sa HbLabel::setAlignment()
   476  */
   564  */
   477 Qt::Alignment HbLabel::alignment() const
   565 Qt::Alignment HbLabel::alignment() const
   478 {
   566 {
   479     Q_D(const HbLabel);
   567     Q_D(const HbLabel);
   480     return d->mAlignment;
   568     if (d->mAlignment.isSet()) {
       
   569         return d->mAlignment;
       
   570     } else {
       
   571         return 0;
       
   572     }
   481 }
   573 }
   482 
   574 
   483 /*!
   575 /*!
   484     \return true if both text and icon are empty; otherwise returns false.
   576     \return true if both text and icon are empty; otherwise returns false.
   485 
   577 
   491     \sa clear()
   583     \sa clear()
   492  */
   584  */
   493 bool HbLabel::isEmpty() const
   585 bool HbLabel::isEmpty() const
   494 {
   586 {
   495     Q_D(const HbLabel);
   587     Q_D(const HbLabel);
   496     return d->mActivePrimitive == HbStylePrivate::P_None;
   588     return d->mActivePrimitive == HbStyle::PT_None;
   497 }
   589 }
   498 
   590 
   499 /*!
   591 /*!
   500 
   592 
   501     \deprecated HbLabel::primitive(HbStyle::Primitive)
   593     \deprecated HbLabel::primitive(HbStyle::Primitive)
   502         is deprecated.
   594         is deprecated.
   503 
   595 
   504     Returns a pointer to the QGraphicsItem primitive used by this label.
   596     Returns a pointer to the QGraphicsItem primitive used by this label.
   505     \param primitive - the type of graphics primitive required.
   597     \param primitive - the type of graphics primitive required.
   506     HbLabel supports HbStylePrivate::P_Label_text and HbStylePrivate::P_Label_icon.
   598     HbLabel supports HbStyle::PT_TextItem and HbStyle::PT_IconItem.
   507     \return the QGraphicsItem used by the label. It is 0 if type \a primitive not currently in use.
   599     \return the QGraphicsItem used by the label. It is 0 if type \a primitive not currently in use.
   508     It is also 0 if the text or icon object is empty.
   600     It is also 0 if the text or icon object is empty.
   509 
   601 
   510     \reimp
   602     \reimp
   511 
   603 
   512     \sa isEmpty()
   604     \sa isEmpty()
   513  */
   605  */
   514 QGraphicsItem * HbLabel::primitive(HbStyle::Primitive primitive) const
   606 QGraphicsItem * HbLabel::primitive(HbStyle::Primitive primitive) const
   515 {
   607 {
   516     Q_D(const HbLabel);
   608     Q_D(const HbLabel);
   517     if ((HbStylePrivate::Primitive)primitive == d->mActivePrimitive) {
   609     switch ((HbStylePrivate::Primitive)primitive) {
       
   610     case HbStylePrivate::P_Label_icon:
       
   611         if (d->mActivePrimitive != HbStyle::PT_IconItem) {
       
   612             break;
       
   613         }
   518         return d->mPrimitiveItem;
   614         return d->mPrimitiveItem;
   519     }
   615 
   520     return HbWidget::primitive(primitive);
   616     case HbStylePrivate::P_Label_text:
       
   617         if (d->mActivePrimitive != HbStyle::PT_TextItem) {
       
   618             break;
       
   619         }
       
   620         return d->mPrimitiveItem;
       
   621 
       
   622     case HbStylePrivate::P_Label_richtext:
       
   623         if (d->mActivePrimitive != HbStyle::PT_RichTextItem) {
       
   624             break;
       
   625         }
       
   626         return d->mPrimitiveItem;
       
   627 
       
   628     default:
       
   629         return HbWidget::primitive(primitive);
       
   630     }
       
   631     return 0;
   521 }
   632 }
   522 
   633 
   523 /*!
   634 /*!
   524     Initializes \a option with the values from this HbLabel.
   635     Initializes \a option with the values from this HbLabel.
   525     HbStyleOptionLabel is used by HbStyle to perform changes in appearance
   636     HbStyleOptionLabel is used by HbStyle to perform changes in appearance
   532 
   643 
   533     HbWidget::initStyleOption(option);
   644     HbWidget::initStyleOption(option);
   534 
   645 
   535     option->alignment = d->mAlignment;
   646     option->alignment = d->mAlignment;
   536 
   647 
   537     if (!d->mText.isNull()) {
   648     if (d->mText.isSet()) {
   538         option->text = d->mText;
   649         option->text = d->mText;
   539         option->elideMode = d->mElideMode;
   650         option->elideMode = d->mElideMode;
   540         option->textWrapMode = d->mTextWrapping;
   651         option->textWrapMode = d->mTextWrapping;
   541         option->color = d->mColor;
   652         option->color = d->mColor;
   542         option->maximumLines = d->mMaxLines;
   653         option->maximumLines = d->mMaxLines;
   543     }
   654     }
   544 
   655 
   545     if (!d->mIcon.isNull()) {
   656     if (d->mIcon.isSet()) {
   546         option->icon = d->mIcon;
   657         option->icon = d->mIcon;
   547         option->aspectRatioMode = d->mAspectRatioMode;
   658         option->aspectRatioMode = d->mAspectRatioMode;
   548     }
   659     }
   549 }
   660 }
   550 
   661 
   578     Plain text accessor. Returns empty string if not set.
   689     Plain text accessor. Returns empty string if not set.
   579  */
   690  */
   580 QString HbLabel::plainText() const
   691 QString HbLabel::plainText() const
   581 {
   692 {
   582     Q_D(const HbLabel);
   693     Q_D(const HbLabel);
   583     if (d->mActivePrimitive == HbStylePrivate::P_Label_text) {
   694     if (d->mActivePrimitive == HbStyle::PT_TextItem) {
   584         return d->mText;
   695         return d->mText;
   585     }
   696     }
   586     return QString();
   697     return QString();
   587 }
   698 }
   588 
   699 
   590     Rich text text accessor. Returns empty string if not set.
   701     Rich text text accessor. Returns empty string if not set.
   591  */
   702  */
   592 QString HbLabel::html() const
   703 QString HbLabel::html() const
   593 {
   704 {
   594     Q_D(const HbLabel);
   705     Q_D(const HbLabel);
   595     if (d->mActivePrimitive == HbStylePrivate::P_Label_richtext) {
   706     if (d->mActivePrimitive == HbStyle::PT_RichTextItem) {
   596         return d->mText;
   707         return d->mText;
   597     }
   708     }
   598     return QString();
   709     return QString();
   599 }
   710 }
   600 
   711 
   604 void HbLabel::setTextColor( const QColor &textColor )
   715 void HbLabel::setTextColor( const QColor &textColor )
   605 {
   716 {
   606     Q_D(HbLabel);
   717     Q_D(HbLabel);
   607     if (d->mColor!=textColor) {
   718     if (d->mColor!=textColor) {
   608         d->mColor=textColor;
   719         d->mColor=textColor;
   609         if (!d->mText.isNull()) {
   720         if (d->mText.isSet()) {
   610             updatePrimitives();
   721             updatePrimitives();
   611         }
   722         }
   612     }
   723     }
   613 }
   724 }
   614 
   725 
   616     Returns color of text or invalid value if theme color is used.
   727     Returns color of text or invalid value if theme color is used.
   617  */
   728  */
   618 QColor HbLabel::textColor() const
   729 QColor HbLabel::textColor() const
   619 {
   730 {
   620     Q_D(const HbLabel);
   731     Q_D(const HbLabel);
   621     return d->mColor;
   732 
       
   733     if (d->mColor.isSet()) {
       
   734         return d->mColor;
       
   735     } else {
       
   736         return QColor();
       
   737     }
   622 }
   738 }
   623 
   739 
   624 /*!
   740 /*!
   625     If plain text is used (\sa setPlainText) this will set maximum number of lines
   741     If plain text is used (\sa setPlainText) this will set maximum number of lines
   626     to be visible in label.
   742     to be visible in label.
   633     Q_D(HbLabel);
   749     Q_D(HbLabel);
   634 
   750 
   635     maxLines = qMax(maxLines, 0);
   751     maxLines = qMax(maxLines, 0);
   636     if (d->mMaxLines != maxLines) {
   752     if (d->mMaxLines != maxLines) {
   637         d->mMaxLines = maxLines;
   753         d->mMaxLines = maxLines;
   638         if (d->mActivePrimitive == HbStylePrivate::P_Label_text) {
   754         if (d->mActivePrimitive == HbStyle::PT_TextItem) {
   639             updatePrimitives();
   755             updatePrimitives();
   640         }
   756         }
   641     }
   757     }
   642 }
   758 }
   643 
   759 
   648 
   764 
   649     \sa setMaximumLines(int)
   765     \sa setMaximumLines(int)
   650  */
   766  */
   651 int HbLabel::maximumLines() const
   767 int HbLabel::maximumLines() const
   652 {
   768 {
   653     return d_func()->mMaxLines;
   769     Q_D(const HbLabel);
       
   770 
       
   771     if (d->mMaxLines.isSet()) {
       
   772         return d->mMaxLines;
       
   773     } else {
       
   774         return 0;
       
   775     }
   654 }
   776 }
   655 
   777 
   656 #include "moc_hblabel.cpp"
   778 #include "moc_hblabel.cpp"