src/hbcore/primitives/hbslidertrackitem.cpp
changeset 28 b7da29130b0e
parent 7 923ff622b8b9
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
    35     maximum = 0;
    35     maximum = 0;
    36     value = 0;
    36     value = 0;
    37     maskWidth = 0;
    37     maskWidth = 0;
    38     trackSpan = 0;
    38     trackSpan = 0;
    39     setMask   = true;
    39     setMask   = true;
       
    40     handleRect = QRectF();
    40 }
    41 }
    41 
    42 
    42 HbSliderTrackItem::HbSliderTrackItem(HbFrameDrawer *drawer, QGraphicsItem *parent)
    43 HbSliderTrackItem::HbSliderTrackItem(HbFrameDrawer *drawer, QGraphicsItem *parent)
    43     :HbFrameItem(drawer,parent)
    44     :HbFrameItem(drawer,parent)
    44 {
    45 {
    46     maximum = 0;
    47     maximum = 0;
    47     value = 0;
    48     value = 0;
    48     maskWidth = 0;
    49     maskWidth = 0;
    49     trackSpan = 0;
    50     trackSpan = 0;
    50     setMask   = true;
    51     setMask   = true;
       
    52     handleRect = QRectF();
    51 }
    53 }
    52 
    54 
    53 void HbSliderTrackItem::setMinimum(int min)
    55 void HbSliderTrackItem::setMinimum(int min)
    54 {
    56 {
    55     if ( minimum != min ) {
    57     if ( minimum != min ) {
   104         trackSpan = span;
   106         trackSpan = span;
   105         setMask = true;
   107         setMask = true;
   106     }
   108     }
   107 }
   109 }
   108 
   110 
       
   111 void HbSliderTrackItem::setHandleRect( QRectF sliderHandleRect)
       
   112 {
       
   113     handleRect=sliderHandleRect;
       
   114 }
       
   115 
   109 void HbSliderTrackItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
   116 void HbSliderTrackItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
   110 {
   117 {
   111     QSize size = boundingRect().size().toSize();
   118     QSize size = boundingRect().size().toSize();
   112     if (setMask) {
   119     if (setMask) {
   113         QRectF maskRect;
   120         QRectF maskRect;
   120                     }
   127                     }
   121                     if (layoutDirection() == Qt::RightToLeft) {
   128                     if (layoutDirection() == Qt::RightToLeft) {
   122                         maskRect = QRectF(
   129                         maskRect = QRectF(
   123                                        left,
   130                                        left,
   124                                        (qreal)boundingRect().topLeft().y(),
   131                                        (qreal)boundingRect().topLeft().y(),
   125                                        (qreal)boundingRect().width() * ((value -  minimum) / (qreal)(maximum - minimum)),
   132                                        (qreal)boundingRect().width() * ((value -  minimum) / (qreal)(maximum - minimum))-handleRect.width()/2,
   126                                        (qreal)boundingRect().height());
   133                                        (qreal)boundingRect().height());
   127                     } else {
   134                     } else {
   128                         maskRect = QRectF(
   135                         maskRect = QRectF(
   129                                        left,
   136                                        left,
   130                                        (qreal)boundingRect().topLeft().y(),
   137                                        (qreal)boundingRect().topLeft().y(),
   131                                        (qreal)trackSpan * ((value -  minimum) / (qreal)(maximum - minimum)),
   138                                        (qreal)trackSpan * ((value -  minimum) / (qreal)(maximum - minimum))+handleRect.width()/2,
   132                                        (qreal)boundingRect().height());
   139                                        (qreal)boundingRect().height());
   133                     }
   140                     }
   134                 } else {
   141                 } else {
   135                     qreal start = boundingRect().bottom() - (qreal)trackSpan * ((value -  minimum) / (qreal)(maximum - minimum));
   142                     qreal start = boundingRect().bottom() - (qreal)trackSpan * ((value -  minimum) / (qreal)(maximum - minimum))-handleRect.height()/2;
   136                     qreal end = boundingRect().bottom();
   143                     qreal end = boundingRect().bottom();
   137 
   144 
   138                     if (inverted) {
   145                     if (inverted) {
   139                         start = boundingRect().top();
   146                         start = boundingRect().top();
   140                         end = start + (qreal)trackSpan * ((value -  minimum) / (qreal)(maximum - minimum));
   147                         end = start + (qreal)trackSpan * ((value -  minimum) / (qreal)(maximum - minimum))+handleRect.height()/2;
   141                     }
   148                     }
   142                     maskRect = QRectF(
   149                     maskRect = QRectF(
   143                                    (qreal)boundingRect().topLeft().x(),
   150                                    (qreal)boundingRect().topLeft().x(),
   144                                    start,
   151                                    start,
   145                                    (qreal)boundingRect().width(),
   152                                    (qreal)boundingRect().width(),