src/hbwidgets/widgets/hblabel.cpp
branchGCC_SURGE
changeset 15 f378acbc9cfb
parent 7 923ff622b8b9
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
9:730c025d4b77 15:f378acbc9cfb
    28 #include <QStyle>
    28 #include <QStyle>
    29 #include <QDebug>
    29 #include <QDebug>
    30 #include <QTextDocument>
    30 #include <QTextDocument>
    31 #include <QGraphicsSceneResizeEvent>
    31 #include <QGraphicsSceneResizeEvent>
    32 
    32 
    33 #include "hblabel.h"
       
    34 #include "hbiconitem.h"
    33 #include "hbiconitem.h"
    35 #include "hbinstance.h"
    34 #include "hbinstance.h"
    36 #include "hbcolorscheme.h"
    35 #include "hbcolorscheme.h"
    37 #include "hbwidget_p.h"
    36 #include "hbwidget_p.h"
    38 #include "hbstyleoptionlabel_p.h"
    37 #include "hbstyleoptionlabel_p.h"
    39 #include "hbwidgetbase.h"
    38 #include "hbwidgetbase.h"
       
    39 #include "hblabel.h"
    40 
    40 
    41 /*!
    41 /*!
    42     @alpha
    42     @alpha
    43     @hbcore
    43     @hbcore
    44 
    44 
   123         mAlignment(Qt::AlignLeft | Qt::AlignVCenter),
   123         mAlignment(Qt::AlignLeft | Qt::AlignVCenter),
   124         mText(QString()),
   124         mText(QString()),
   125         mElideMode(Qt::ElideRight),
   125         mElideMode(Qt::ElideRight),
   126         mTextWrapping(Hb::TextNoWrap),
   126         mTextWrapping(Hb::TextNoWrap),
   127         mAspectRatioMode(Qt::KeepAspectRatio),
   127         mAspectRatioMode(Qt::KeepAspectRatio),
   128         mPrimitiveItem(NULL),
   128         mPrimitiveItem(0),
   129         mActivePrimitive(HbStyle::P_None)
   129         mActivePrimitive(HbStyle::P_None)
   130 {
   130 {
   131 }
   131 }
   132 
   132 
   133 void HbLabelPrivate::clearAll()
   133 void HbLabelPrivate::clearAll()
   134 {
   134 {
   135     if (mPrimitiveItem) {
   135     if (mPrimitiveItem) {
   136         delete mPrimitiveItem;
   136         delete mPrimitiveItem;
   137         mPrimitiveItem = NULL;
   137         mPrimitiveItem = 0;
   138         mActivePrimitive = HbStyle::P_None;
   138         mActivePrimitive = HbStyle::P_None;
   139     }
   139     }
   140 
   140 
   141     mText.clear();
   141     mText.clear();
   142     mIcon.clear();
   142     mIcon.clear();
   158     if (mText != text || mText.isNull()) {
   158     if (mText != text || mText.isNull()) {
   159         mText = text;
   159         mText = text;
   160         if (mActivePrimitive != primitiveId) {
   160         if (mActivePrimitive != primitiveId) {
   161             mActivePrimitive = primitiveId;
   161             mActivePrimitive = primitiveId;
   162             createPrimitives();
   162             createPrimitives();
   163             q->repolish(); // reconecting new primitive to HbMeshLayout so it is really needed!
   163             q->repolish(); // reconecting new primitive to HbAnchorLayout so it is really needed!
   164         }
   164         }
   165         q->updatePrimitives();
   165         q->updatePrimitives();
   166     }
   166     }
   167 }
   167 }
   168 
   168 
   183         mIcon = icon;
   183         mIcon = icon;
   184 
   184 
   185         if (mActivePrimitive != HbStyle::P_Label_icon) {
   185         if (mActivePrimitive != HbStyle::P_Label_icon) {
   186             mActivePrimitive = HbStyle::P_Label_icon;
   186             mActivePrimitive = HbStyle::P_Label_icon;
   187             createPrimitives();
   187             createPrimitives();
   188             q->repolish(); // reconecting new primitive to HbMeshLayout so it is really needed!
   188             q->repolish(); // reconecting new primitive to HbAnchorLayout so it is really needed!
   189         }
   189         }
   190         q->updatePrimitives();
   190         q->updatePrimitives();
   191     }
   191     }
   192 }
   192 }
   193 
   193 
   197 
   197 
   198 void HbLabelPrivate::createPrimitives()
   198 void HbLabelPrivate::createPrimitives()
   199 {
   199 {
   200     Q_Q(HbLabel);
   200     Q_Q(HbLabel);
   201 
   201 
   202     Q_ASSERT(mPrimitiveItem==NULL);
   202     Q_ASSERT(mPrimitiveItem==0);
   203 
   203 
   204     if (mActivePrimitive != HbStyle::P_None) {
   204     if (mActivePrimitive != HbStyle::P_None) {
   205         mPrimitiveItem = q->style()->createPrimitive(mActivePrimitive, q);
   205         mPrimitiveItem = q->style()->createPrimitive(mActivePrimitive, q);
   206     }
   206     }
   207 }
   207 }
   542         option->icon = d->mIcon;
   542         option->icon = d->mIcon;
   543         option->aspectRatioMode = d->mAspectRatioMode;
   543         option->aspectRatioMode = d->mAspectRatioMode;
   544     }
   544     }
   545 }
   545 }
   546 
   546 
       
   547 QSizeF HbLabel::sizeHint ( Qt::SizeHint which, const QSizeF & constraint ) const
       
   548 {
       
   549     if (isEmpty()) {
       
   550         return QSizeF(0,0);
       
   551     }
       
   552     return HbWidget::sizeHint(which,constraint);
       
   553 }
       
   554 
   547 /*!
   555 /*!
   548     Slot to be called when the style primitives need to be updated.
   556     Slot to be called when the style primitives need to be updated.
   549     This function does not initiate redrawing this widget.
   557     This function does not initiate redrawing this widget.
   550 
   558 
   551     \reimp
   559     \reimp