src/hbwidgets/sliders/hbslidertickmarkslabel.cpp
changeset 3 11d3954df52a
parent 2 06ff229162e9
child 6 c3690ec91ef8
equal deleted inserted replaced
2:06ff229162e9 3:11d3954df52a
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
    26 #include "hbslidertickmarkslabel_p.h"
    26 #include "hbslidertickmarkslabel_p.h"
    27 #include "hbslidercontrol_p.h"
    27 #include "hbslidercontrol_p.h"
    28 #include "hbsliderhandle_p.h"
    28 #include "hbslider_p.h"
    29 #include "hbwidget_p.h"
    29 #include "hbwidget_p.h"
    30 #include <hbinstance.h>
    30 #include <hbinstance.h>
    31 #include <hbstyle.h>
    31 #include <hbstyle.h>
    32 #include <hbstyleoptionslider_p.h>
    32 #include <hbstyleoptionslider_p.h>
    33 #include <hbapplication.h>
    33 #include <hbapplication.h>
    34 #include <hbtextitem.h>
    34 #include <hbtextitem.h>
       
    35 #include <hbslider.h>
    35 #include <QList>
    36 #include <QList>
    36 #include <QStringList>
    37 #include <QStringList>
       
    38 #include <QEvent>
       
    39 #include <QGraphicsItem>
    37 
    40 
    38 
    41 
    39 class HbSliderTickmarksLabelPrivate : public HbWidgetPrivate
    42 class HbSliderTickmarksLabelPrivate : public HbWidgetPrivate
    40 {
    43 {
    41     Q_DECLARE_PUBLIC( HbSliderTickmarksLabel )
    44     Q_DECLARE_PUBLIC( HbSliderTickmarksLabel )
    44     HbSliderTickmarksLabelPrivate();
    47     HbSliderTickmarksLabelPrivate();
    45     void createTickLabels( );
    48     void createTickLabels( );
    46     HbStyleOptionSlider sliderOption;
    49     HbStyleOptionSlider sliderOption;
    47     QList<QGraphicsWidget *> tickmarkmajorIconItemsLabel;
    50     QList<QGraphicsWidget *> tickmarkmajorIconItemsLabel;
    48     QList<QGraphicsWidget *> tickmarkminorIconItemsLabel;
    51     QList<QGraphicsWidget *> tickmarkminorIconItemsLabel;
    49     HbSliderControl *sliderControl;
    52     HbSlider *slider;
    50     Hb::SliderTickPositions tickPosition;
    53     Hb::SliderTickPositions tickPosition;
    51     bool createText;
    54     bool createText;
    52 
    55 
    53 };
    56 };
    54 
    57 
    55 
    58 
    56  HbSliderTickmarksLabelPrivate::HbSliderTickmarksLabelPrivate() :HbWidgetPrivate(){
    59  HbSliderTickmarksLabelPrivate::HbSliderTickmarksLabelPrivate() :HbWidgetPrivate(){
    57     tickmarkmajorIconItemsLabel.clear();
    60     tickmarkmajorIconItemsLabel.clear();
    58     tickmarkminorIconItemsLabel.clear();
    61     tickmarkminorIconItemsLabel.clear();
    59     sliderControl = 0;
    62     slider = 0;
    60     tickPosition = Hb::NoSliderTicks;
    63     tickPosition = Hb::NoSliderTicks;
    61     createText = true;
    64     createText = true;
    62 
    65 
    63 
    66 
    64 }
    67 }
    68 {
    71 {
    69     Q_Q ( HbSliderTickmarksLabel );
    72     Q_Q ( HbSliderTickmarksLabel );
    70     if (!createText) {
    73     if (!createText) {
    71         return;
    74         return;
    72     }
    75     }
       
    76     bool textItemCreated = false;
    73     
    77     
    74     int minimum = sliderControl->minimum();
    78     int minimum = slider->minimum();
    75     int maximum = sliderControl->maximum();
    79     int maximum = slider->maximum();
    76     QStringList majorLabelList = sliderControl->majorTickLabels( );
    80     QStringList majorLabelList = slider->majorTickLabels( );
    77     QStringList minorLabelList = sliderControl->minorTickLabels( );
    81     QStringList minorLabelList = slider->minorTickLabels( );
    78     int majorTickInterval = sliderControl->majorTickInterval ( );
    82     int majorTickInterval = slider->majorTickInterval ( );
    79     int minorTickInterval = sliderControl->minorTickInterval ( );
    83     int minorTickInterval = slider->minorTickInterval ( );
    80     if (majorTickInterval) {
    84     if (majorTickInterval) {
    81         int totalMajorTicksLabel = ((maximum-minimum)/majorTickInterval)+1;
    85         int totalMajorTicksLabel = ((maximum-minimum)/majorTickInterval)+1;
    82         if (majorLabelList.length( ) < totalMajorTicksLabel ) {
    86         if (majorLabelList.length( ) < totalMajorTicksLabel ) {
    83             totalMajorTicksLabel = majorLabelList.length( );
    87             totalMajorTicksLabel = majorLabelList.length( );
    84         }
    88         }
    85         int majorLabelListLength =  tickmarkmajorIconItemsLabel.length();
    89         int majorLabelListLength =  tickmarkmajorIconItemsLabel.length();
    86         for (int i=majorLabelListLength;i<totalMajorTicksLabel;i++) {
    90         for (int i=majorLabelListLength;i<totalMajorTicksLabel;i++) {
    87             QGraphicsItem *textItem = q->style()->createPrimitive(HbStyle::P_SliderTickMark_majorlabel, q);
    91             QGraphicsItem *textItem = q->style()->createPrimitive(HbStyle::P_SliderTickMark_majorlabel, q);
       
    92             textItemCreated = true;
    88             Q_ASSERT(textItem->isWidget());
    93             Q_ASSERT(textItem->isWidget());
    89             tickmarkmajorIconItemsLabel.append(static_cast<QGraphicsWidget *>(textItem));//add newly defind primitive
    94             tickmarkmajorIconItemsLabel.append(static_cast<QGraphicsWidget *>(textItem));//add newly defind primitive
    90         }
    95         }
    91         while ( totalMajorTicksLabel < tickmarkmajorIconItemsLabel.length() ) {
    96         while ( totalMajorTicksLabel < tickmarkmajorIconItemsLabel.length() ) {
    92             QGraphicsWidget *textItem = tickmarkmajorIconItemsLabel.at(totalMajorTicksLabel);
    97             QGraphicsWidget *textItem = tickmarkmajorIconItemsLabel.at(totalMajorTicksLabel);
   109         }
   114         }
   110 
   115 
   111         int minorIconLabelListLength =  tickmarkminorIconItemsLabel.length();
   116         int minorIconLabelListLength =  tickmarkminorIconItemsLabel.length();
   112         for (int i=minorIconLabelListLength;i<totalMinorTicksLabel;i++) {
   117         for (int i=minorIconLabelListLength;i<totalMinorTicksLabel;i++) {
   113             QGraphicsItem *textItem = q->style()->createPrimitive(HbStyle::P_SliderTickMark_minorlabel, q);
   118             QGraphicsItem *textItem = q->style()->createPrimitive(HbStyle::P_SliderTickMark_minorlabel, q);
       
   119             textItemCreated = true;
   114             Q_ASSERT(textItem->isWidget());
   120             Q_ASSERT(textItem->isWidget());
   115             tickmarkminorIconItemsLabel.append(static_cast<QGraphicsWidget *>(textItem));//add newly defind primitive
   121             tickmarkminorIconItemsLabel.append(static_cast<QGraphicsWidget *>(textItem));//add newly defind primitive
   116         }
   122         }
   117         while (totalMinorTicksLabel < tickmarkminorIconItemsLabel.length() ){
   123         while (totalMinorTicksLabel < tickmarkminorIconItemsLabel.length() ){
   118             QGraphicsWidget *textItem = tickmarkminorIconItemsLabel.at(totalMinorTicksLabel);
   124             QGraphicsWidget *textItem = tickmarkminorIconItemsLabel.at(totalMinorTicksLabel);
   125             tickmarkminorIconItemsLabel.removeAll(textItem);
   131             tickmarkminorIconItemsLabel.removeAll(textItem);
   126             delete textItem;
   132             delete textItem;
   127         }
   133         }
   128     }
   134     }
   129     q->setProperty("state","normal");
   135     q->setProperty("state","normal");
       
   136     if( textItemCreated ) {
       
   137        q->repolish();
       
   138 }
   130 }
   139 }
   131 
   140 
   132 void HbSliderTickmarksLabel::resizeEvent(QGraphicsSceneResizeEvent *event)
   141 void HbSliderTickmarksLabel::resizeEvent(QGraphicsSceneResizeEvent *event)
   133 {
   142 {
   134     Q_UNUSED (event);
   143     Q_UNUSED (event);
   143     if (!d->createText) {
   152     if (!d->createText) {
   144         return;
   153         return;
   145     }
   154     }
   146     d->createTickLabels();
   155     d->createTickLabels();
   147     setLabelSize( );
   156     setLabelSize( );
   148     int minimum = d->sliderControl->minimum();
   157     int minimum = d->slider->minimum();
   149     int maximum = d->sliderControl->maximum();
   158     int maximum = d->slider->maximum();
   150     int majorTickInterval = d->sliderControl->majorTickInterval ( );
   159     int majorTickInterval = d->slider->majorTickInterval ( );
   151     int minorTickInterval = d->sliderControl->minorTickInterval ( );
   160     int minorTickInterval = d->slider->minorTickInterval ( );
   152     qreal span = 0;
   161     qreal span = 0;
   153     bool rtlLayout = (((d->sliderControl->orientation( ) != Qt::Vertical)
   162     bool rtlLayout = (((d->slider->orientation( ) != Qt::Vertical)
   154         &&(HbApplication::layoutDirection() == Qt::LeftToRight))?false:true);
   163         &&(HbApplication::layoutDirection() == Qt::LeftToRight))?false:true);
   155     HbSliderHandle *handle = dynamic_cast <HbSliderHandle *> (d->sliderControl->primitive (HbStyle::P_Slider_thumb));
   164     HbSliderPrivate *sliderPrivate = dynamic_cast<HbSliderPrivate*>(HbSliderPrivate::d_ptr(d->slider));
   156     if ( d->sliderControl->orientation() == Qt::Horizontal) {
   165     QSizeF handleSize(0.0,0.0);
   157         span = d->sliderControl->size().width();
   166     if( sliderPrivate) {
   158         span-=handle->size().width();
   167         handleSize = sliderPrivate->getHandleSize( );
   159     }
   168     } else {
   160     if ( d->sliderControl->orientation() == Qt::Vertical) {
   169         return;
   161         span = d->sliderControl->size().height();
   170     }
   162         span-=handle->size().height();
   171     if ( d->slider->orientation() == Qt::Horizontal) {
   163     }
   172         span = boundingRect().width();
       
   173         span-=handleSize.width();
       
   174     }
       
   175     if ( d->slider->orientation() == Qt::Vertical) {
       
   176         span = boundingRect().height();
       
   177         span-=handleSize.height();
       
   178     }
       
   179     int minPos = QStyle::sliderPositionFromValue( minimum, maximum,
       
   180                 minimum,static_cast<int>( span ), rtlLayout );
       
   181     int firstMajorIntervalPos = QStyle::sliderPositionFromValue( minimum, maximum,
       
   182                 minimum+majorTickInterval,static_cast<int>( span ), rtlLayout );
       
   183 
       
   184     int firstMinorIntervalPos = QStyle::sliderPositionFromValue( minimum, maximum,
       
   185                 minimum+minorTickInterval,static_cast<int>( span ), rtlLayout );
       
   186 
       
   187     qreal totalMajorTextWidth = abs(firstMajorIntervalPos-minPos);
       
   188     qreal totalMinorTextWidth = abs(firstMinorIntervalPos-minPos);
       
   189 
   164     if (majorTickInterval) {
   190     if (majorTickInterval) {
   165         int totalMajorTicksLabel = d->tickmarkmajorIconItemsLabel.length();
   191         int totalMajorTicksLabel = d->tickmarkmajorIconItemsLabel.length();
   166         for (int i=0;i<totalMajorTicksLabel;i++) {
   192         for (int i=0;i<totalMajorTicksLabel;i++) {
   167              QGraphicsWidget *textItem = d->tickmarkmajorIconItemsLabel.at ( i);
   193              QGraphicsWidget *textItem = d->tickmarkmajorIconItemsLabel.at ( i);
   168              int pos = QStyle::sliderPositionFromValue( minimum, maximum,
   194              int pos = QStyle::sliderPositionFromValue( minimum, maximum,
   169                 minimum+majorTickInterval*i,static_cast<int>( span ), rtlLayout );
   195                 minimum+majorTickInterval*i,static_cast<int>( span ), rtlLayout );
   170 
   196 
   171              if ( d->sliderControl->orientation() == Qt::Horizontal) {
   197              if ( d->slider->orientation() == Qt::Horizontal) {
   172                 textItem->setPreferredHeight(boundingRect().height());
       
   173                 textItem->update();
   198                 textItem->update();
   174                 qreal correctedPosX = handle->size().width()/2+pos;
   199                 qreal correctedPosX = handleSize.width()/2+pos;
   175                 qreal tickWidth = textItem->boundingRect().size().width();
   200                 qreal tickWidth = totalMajorTextWidth;
   176                 correctedPosX -= tickWidth/2;
   201                 correctedPosX -= tickWidth/2;
   177                 qreal correctedPosY = 0;
   202                 qreal correctedPosY = 0;
   178                 textItem->setPos( correctedPosX,correctedPosY );
   203                 qreal tickHeight = textItem->boundingRect().size().height();
       
   204                 textItem->setGeometry( QRectF(correctedPosX,correctedPosY,tickWidth,tickHeight));
   179             } else {
   205             } else {
   180                 qreal correctedPosY = handle->size().height()/2+pos;
   206                 qreal correctedPosY = handleSize.height()/2+pos;
   181                 qreal tickHeight = textItem->boundingRect().size().height();
   207                 qreal tickHeight = textItem->boundingRect().size().height();
   182                 correctedPosY-=tickHeight/2;
   208                 correctedPosY-=tickHeight/2;
   183                 qreal correctedPosX =0;
   209                 qreal correctedPosX =0;
   184                 textItem->setPos ( correctedPosX,correctedPosY );
   210                 qreal tickWidth = boundingRect().width();
       
   211                 textItem->setGeometry ( QRectF(correctedPosX,correctedPosY,tickWidth,tickHeight ));
   185                 textItem->setLayoutDirection (layoutDirection());
   212                 textItem->setLayoutDirection (layoutDirection());
   186             }
   213             }
   187         }
   214         }
   188     }
   215     }
   189     if (minorTickInterval) {
   216     if (minorTickInterval) {
   199                 continue;
   226                 continue;
   200             } else {
   227             } else {
   201                 QGraphicsWidget *textItem = d->tickmarkminorIconItemsLabel.at ( minorIndex);
   228                 QGraphicsWidget *textItem = d->tickmarkminorIconItemsLabel.at ( minorIndex);
   202                 HbStyleOptionSlider opt;
   229                 HbStyleOptionSlider opt;
   203                 initStyleOption(&opt);
   230                 initStyleOption(&opt);
   204                 opt.orientation = d->sliderControl->orientation();
   231                 opt.orientation = d->slider->orientation();
   205                 opt.text = (d->sliderControl->minorTickLabels( )).at(minorIndex);
   232                 opt.text = (d->slider->minorTickLabels( )).at(minorIndex);
   206                 style()->updatePrimitive(textItem,HbStyle::P_SliderTickMark_minorlabel,&opt);
   233                 style()->updatePrimitive(textItem,HbStyle::P_SliderTickMark_minorlabel,&opt);
   207                 minorIndex++;
   234                 minorIndex++;
   208                 int pos = QStyle::sliderPositionFromValue( minimum, maximum,
   235                 int pos = QStyle::sliderPositionFromValue( minimum, maximum,
   209                     minimum+minorTickInterval*i,static_cast<int>( span ), rtlLayout );
   236                     minimum+minorTickInterval*i,static_cast<int>( span ), rtlLayout );
   210                  if ( d->sliderControl->orientation() == Qt::Horizontal) {
   237                  if ( d->slider->orientation() == Qt::Horizontal) {
   211                     qreal correctedPosX = handle->size().width()/2+pos; 
   238                     qreal correctedPosX = handleSize.width()/2+pos; 
   212                     qreal tickWidth = textItem->boundingRect().size().width();
   239                     correctedPosX -= totalMinorTextWidth/2;
   213                     correctedPosX -= tickWidth/2;
       
   214                     qreal correctedPosY = 0;
   240                     qreal correctedPosY = 0;
   215                     textItem->setPos ( correctedPosX,correctedPosY );
   241                     qreal tickHeight = textItem->boundingRect().size().height();
       
   242                     textItem->setGeometry( QRectF(correctedPosX,correctedPosY,totalMinorTextWidth,tickHeight));
       
   243  
   216                 } else {
   244                 } else {
   217                     qreal correctedPosY = handle->size().height()/2+pos;
   245                     qreal correctedPosY = handleSize.height()/2+pos;
   218                     qreal tickHeight = textItem->boundingRect().size().height();
   246                     qreal tickHeight = textItem->boundingRect().size().height();
   219                     correctedPosY-=tickHeight/2;
   247                     correctedPosY-=tickHeight/2;
   220                     textItem->setLayoutDirection (layoutDirection());
   248                     textItem->setLayoutDirection (layoutDirection());
   221                     qreal correctedPosX =0;
   249                     qreal correctedPosX =0;
   222                     textItem->setPos ( correctedPosX,correctedPosY );
   250                     qreal tickWidth = boundingRect().width();
       
   251                     textItem->setGeometry ( QRectF(correctedPosX,correctedPosY,tickWidth,tickHeight ));
       
   252 
       
   253   
   223                 }
   254                 }
   224             }
   255             }
   225         }
   256         }
   226     }
   257     }
   227  }
   258  }
   254 HbSliderTickmarksLabel::HbSliderTickmarksLabel( QGraphicsItem *parent )
   285 HbSliderTickmarksLabel::HbSliderTickmarksLabel( QGraphicsItem *parent )
   255     : HbWidget( *new HbSliderTickmarksLabelPrivate, parent )
   286     : HbWidget( *new HbSliderTickmarksLabelPrivate, parent )
   256 {
   287 {
   257     Q_D( HbSliderTickmarksLabel );
   288     Q_D( HbSliderTickmarksLabel );
   258     d->q_ptr = this;
   289     d->q_ptr = this;
   259     d->sliderControl=dynamic_cast<HbSliderControl*>( parentItem() );
   290     d->slider=dynamic_cast<HbSlider*>( parentItem() );
   260     d->createTickLabels();
   291     d->createTickLabels();
   261 }
   292 }
   262 
   293 
   263 /*!
   294 /*!
   264     destructor
   295     destructor
   269 
   300 
   270 void HbSliderTickmarksLabel::setLabelSize()
   301 void HbSliderTickmarksLabel::setLabelSize()
   271 {
   302 {
   272     Q_D (HbSliderTickmarksLabel);
   303     Q_D (HbSliderTickmarksLabel);
   273 
   304 
   274     int minimum = d->sliderControl->minimum();
   305     int minimum = d->slider->minimum();
   275     int maximum = d->sliderControl->maximum();
   306     int maximum = d->slider->maximum();
   276     int majorTickInterval = d->sliderControl->majorTickInterval ( );
   307     int majorTickInterval = d->slider->majorTickInterval ( );
   277     int minorTickInterval = d->sliderControl->minorTickInterval ( );
   308     int minorTickInterval = d->slider->minorTickInterval ( );
   278     qreal span = 0;
   309     qreal span = 0;
   279     bool rtlLayout = (((d->sliderControl->orientation( ) != Qt::Vertical)
   310     bool rtlLayout = (((d->slider->orientation( ) != Qt::Vertical)
   280         &&(HbApplication::layoutDirection() == Qt::LeftToRight))?false:true);
   311         &&(HbApplication::layoutDirection() == Qt::LeftToRight))?false:true);
   281     HbSliderHandle *handle = dynamic_cast <HbSliderHandle *> (d->sliderControl->primitive (HbStyle::P_Slider_thumb));
   312     HbSliderPrivate *sliderPrivate = dynamic_cast<HbSliderPrivate*>(HbSliderPrivate::d_ptr(d->slider));
   282     if ( d->sliderControl->orientation() == Qt::Horizontal) {
   313     QSizeF handleSize(0.0,0.0);
   283         span = d->sliderControl->size().width();
   314     if( sliderPrivate) {
   284         span-=handle->size().width();
   315         handleSize = sliderPrivate->getHandleSize( );
   285     }
   316     } else {
   286     if ( d->sliderControl->orientation() == Qt::Vertical) {
   317         return;
   287         span = d->sliderControl->size().height();
   318     }
   288         span-=handle->size().height();
   319     if ( d->slider->orientation() == Qt::Horizontal) {
       
   320         span = d->slider->size().width();
       
   321         span-=handleSize.width();
       
   322     }
       
   323     if ( d->slider->orientation() == Qt::Vertical) {
       
   324         span = d->slider->size().height();
       
   325         span-=handleSize.height();
   289     }
   326     }
   290     int minPos = QStyle::sliderPositionFromValue( minimum, maximum,
   327     int minPos = QStyle::sliderPositionFromValue( minimum, maximum,
   291                 minimum,static_cast<int>( span ), rtlLayout );
   328                 minimum,static_cast<int>( span ), rtlLayout );
   292     int firstMajorIntervalPos = QStyle::sliderPositionFromValue( minimum, maximum,
   329     int firstMajorIntervalPos = QStyle::sliderPositionFromValue( minimum, maximum,
   293                 minimum+majorTickInterval,static_cast<int>( span ), rtlLayout );
   330                 minimum+majorTickInterval,static_cast<int>( span ), rtlLayout );
   295     int firstMinorIntervalPos = QStyle::sliderPositionFromValue( minimum, maximum,
   332     int firstMinorIntervalPos = QStyle::sliderPositionFromValue( minimum, maximum,
   296                 minimum+minorTickInterval,static_cast<int>( span ), rtlLayout );
   333                 minimum+minorTickInterval,static_cast<int>( span ), rtlLayout );
   297 
   334 
   298     qreal totalMajorTextWidth = abs(firstMajorIntervalPos-minPos);
   335     qreal totalMajorTextWidth = abs(firstMajorIntervalPos-minPos);
   299     qreal totalMinorTextWidth = abs(firstMinorIntervalPos-minPos);
   336     qreal totalMinorTextWidth = abs(firstMinorIntervalPos-minPos);
       
   337     Q_UNUSED(totalMajorTextWidth)
       
   338     Q_UNUSED(totalMinorTextWidth)
   300 
   339 
   301     if (majorTickInterval) {
   340     if (majorTickInterval) {
   302         int totalMajorTicksLabel = d->tickmarkmajorIconItemsLabel.length();
   341         int totalMajorTicksLabel = d->tickmarkmajorIconItemsLabel.length();
   303         for (int i=0;i<totalMajorTicksLabel;i++) {
   342         for (int i=0;i<totalMajorTicksLabel;i++) {
   304              QGraphicsWidget *textItem = d->tickmarkmajorIconItemsLabel.at ( i);
   343              QGraphicsWidget *textItem = d->tickmarkmajorIconItemsLabel.at ( i);
   305              HbStyleOptionSlider opt;
   344              HbStyleOptionSlider opt;
   306              initStyleOption(&opt);
   345              initStyleOption(&opt);
   307              opt.orientation = d->sliderControl->orientation();
   346              opt.orientation = d->slider->orientation();
   308              opt.text = (d->sliderControl->majorTickLabels( )).at(i);
   347              opt.text = (d->slider->majorTickLabels( )).at(i);
   309              style()->updatePrimitive(textItem,HbStyle::P_SliderTickMark_majorlabel,&opt);
   348              style()->updatePrimitive(textItem,HbStyle::P_SliderTickMark_majorlabel,&opt);
   310              if ( d->sliderControl->orientation() == Qt::Horizontal) {
   349              if ( d->slider->orientation() == Qt::Horizontal) {
   311                 textItem->setMaximumHeight (boundingRect().height());
   350              /*   textItem->setMaximumHeight (boundingRect().height());
   312                 textItem->setMinimumHeight (boundingRect().height());
   351                 textItem->setMinimumHeight (boundingRect().height());
   313                 textItem->setMinimumWidth(totalMajorTextWidth);
   352                 textItem->setMinimumWidth(totalMajorTextWidth);
   314                 textItem->setMaximumWidth(totalMajorTextWidth);
   353                 textItem->setMaximumWidth(totalMajorTextWidth);*/
   315                 textItem->update();
   354                 textItem->update();
   316              } else {
   355              } else {
   317                 textItem->setMinimumWidth(boundingRect().width());
   356              /*   textItem->setMinimumWidth(boundingRect().width());
   318                 textItem->setMaximumWidth(boundingRect().width());
   357                 textItem->setMaximumWidth(boundingRect().width());*/
   319                 textItem->update( );
   358                 textItem->update( );
   320              }
   359              }
   321         }
   360         }
   322     }
   361     }
   323     if (minorTickInterval) {
   362     if (minorTickInterval) {
   330                 }
   369                 }
   331             }
   370             }
   332             if ( minorIndex < d->tickmarkminorIconItemsLabel.length() ) {
   371             if ( minorIndex < d->tickmarkminorIconItemsLabel.length() ) {
   333                 QGraphicsWidget *textItem = d->tickmarkminorIconItemsLabel.at ( minorIndex);
   372                 QGraphicsWidget *textItem = d->tickmarkminorIconItemsLabel.at ( minorIndex);
   334                 minorIndex++;
   373                 minorIndex++;
   335                  if ( d->sliderControl->orientation() == Qt::Horizontal) {
   374                  if ( d->slider->orientation() == Qt::Horizontal) {
   336                     textItem->setMaximumHeight (boundingRect().height());
   375                   /*  textItem->setMaximumHeight (boundingRect().height());
   337                     textItem->setMinimumHeight (boundingRect().height());
   376                     textItem->setMinimumHeight (boundingRect().height());
   338                     textItem->setMinimumWidth(totalMinorTextWidth);
   377                     textItem->setMinimumWidth(totalMinorTextWidth);
   339                     textItem->setMaximumWidth(totalMinorTextWidth);
   378                     textItem->setMaximumWidth(totalMinorTextWidth);*/
   340                     textItem->update();
   379                     textItem->update();
   341                  } else {
   380                  } else {
   342                     textItem->setMinimumWidth(boundingRect().width());
   381                  /*   textItem->setMinimumWidth(boundingRect().width());
   343                     textItem->setMaximumWidth(boundingRect().width());
   382                     textItem->setMaximumWidth(boundingRect().width());*/
   344                     textItem->update( );
   383                     textItem->update( );
   345                  }
   384                  }
   346             }
   385             }
   347         }
   386         }
   348     }
   387     }
   349 }
   388  }
   350 
       
   351 void HbSliderTickmarksLabel::createText(bool create)
       
   352 {
       
   353     Q_D(HbSliderTickmarksLabel);
       
   354     d->createText = create;
       
   355     if (!create) {
       
   356         while ( d->tickmarkmajorIconItemsLabel.length() > 0) {
       
   357             QGraphicsWidget *textItem = d->tickmarkmajorIconItemsLabel.at(0);
       
   358             d->tickmarkmajorIconItemsLabel.removeAll(textItem);
       
   359             delete textItem;
       
   360         }
       
   361         while ( d->tickmarkminorIconItemsLabel.length() > 0) {
       
   362             QGraphicsWidget *textItem = d->tickmarkminorIconItemsLabel.at(0);
       
   363             d->tickmarkminorIconItemsLabel.removeAll(textItem);
       
   364             delete textItem;
       
   365         } 
       
   366     } else {
       
   367         d->createTickLabels();
       
   368     }
       
   369 
       
   370 
       
   371 }
       
   372 
   389 
   373 
   390 
   374 
   391 
   375 void HbSliderTickmarksLabel::polish( HbStyleParameters& params )
   392 void HbSliderTickmarksLabel::polish( HbStyleParameters& params )
   376 {
   393 {
   377     Q_D (HbSliderTickmarksLabel);
   394     Q_D (HbSliderTickmarksLabel);
   378     d->createTickLabels();
   395     d->createTickLabels();
   379     if( d->sliderControl->orientation( ) == Qt::Horizontal ) {
   396     if( d->slider->orientation( ) == Qt::Horizontal ) {
   380         setProperty("orientation",(Qt::Orientation)1);
   397         setProperty("orientation",(Qt::Orientation)1);
   381     } else {
   398     } else {
   382         setProperty("orientation",(Qt::Orientation)2);
   399         setProperty("orientation",(Qt::Orientation)2);
   383     }
   400     }
   384     HbWidget::polish(params);
   401     HbWidget::polish(params);
   407             break;
   424             break;
   408     }
   425     }
   409     return HbWidget::itemChange( change, value );
   426     return HbWidget::itemChange( change, value );
   410 }
   427 }
   411 
   428 
       
   429 bool  HbSliderTickmarksLabel::event(QEvent *e)
       
   430 {
       
   431     if(e->type( ) == QEvent::LayoutDirectionChange) {
       
   432         updateTickLabels( );
       
   433     }
       
   434     return HbWidget::event(e);
       
   435 }
       
   436 
   412 
   437 
   413 void HbSliderTickmarksLabel::initStyleOption( HbStyleOptionSlider *option ) const
   438 void HbSliderTickmarksLabel::initStyleOption( HbStyleOptionSlider *option ) const
   414 {
   439 {
   415     Q_D( const HbSliderTickmarksLabel );
   440     Q_D( const HbSliderTickmarksLabel );
   416     if ( !option ) {
   441     if ( !option ) {
   417         return;
   442         return;
   418     }
   443     }
   419     HbWidget::initStyleOption( option );
   444     HbWidget::initStyleOption( option );
   420     option->orientation = d->sliderControl->orientation( );
   445     option->orientation = d->slider->orientation( );
   421     option->tickPosition =  d->sliderControl->tickPosition( );
   446     option->tickPosition =  d->slider->tickPosition( );
   422     option->upsideDown = ( d->sliderControl->orientation( ) == Qt::Horizontal ) 
   447     option->upsideDown = ( d->slider->orientation( ) == Qt::Horizontal ) 
   423         ? ( d->sliderControl->invertedAppearance( ) != ( option->direction == Qt::RightToLeft ) )
   448         ? ( d->slider->invertedAppearance( ) != ( option->direction == Qt::RightToLeft ) )
   424             : ( !d->sliderControl->invertedAppearance( ) );
   449             : ( !d->slider->invertedAppearance( ) );
   425     // we use the upsideDown option instead
   450     // we use the upsideDown option instead
   426 }
   451 }
   427 
   452 
   428  //end of file
   453  //end of file
   429 
   454