151 Q_D ( HbSliderTickmarksLabel ); |
151 Q_D ( HbSliderTickmarksLabel ); |
152 if (!d->createText) { |
152 if (!d->createText) { |
153 return; |
153 return; |
154 } |
154 } |
155 d->createTickLabels(); |
155 d->createTickLabels(); |
156 setLabelSize( ); |
156 int totalMajorTicksLabel = d->tickmarkmajorIconItemsLabel.length(); |
|
157 for (int i=0;i<totalMajorTicksLabel;i++) { |
|
158 QGraphicsWidget *textItem = d->tickmarkmajorIconItemsLabel.at ( i); |
|
159 HbStyleOptionSlider opt; |
|
160 initStyleOption(&opt); |
|
161 opt.orientation = d->slider->orientation(); |
|
162 opt.text = (d->slider->majorTickLabels( )).at(i); |
|
163 style()->updatePrimitive(textItem,HbStyle::P_SliderTickMark_majorlabel,&opt); |
|
164 } |
157 int minimum = d->slider->minimum(); |
165 int minimum = d->slider->minimum(); |
158 int maximum = d->slider->maximum(); |
166 int maximum = d->slider->maximum(); |
159 int majorTickInterval = d->slider->majorTickInterval ( ); |
167 int majorTickInterval = d->slider->majorTickInterval ( ); |
160 int minorTickInterval = d->slider->minorTickInterval ( ); |
168 int minorTickInterval = d->slider->minorTickInterval ( ); |
161 qreal span = 0; |
169 qreal span = 0; |
287 { |
295 { |
288 Q_D( HbSliderTickmarksLabel ); |
296 Q_D( HbSliderTickmarksLabel ); |
289 d->q_ptr = this; |
297 d->q_ptr = this; |
290 d->slider=dynamic_cast<HbSlider*>( parentItem() ); |
298 d->slider=dynamic_cast<HbSlider*>( parentItem() ); |
291 d->createTickLabels(); |
299 d->createTickLabels(); |
|
300 setFlag(QGraphicsItem::ItemSendsGeometryChanges,true); |
292 } |
301 } |
293 |
302 |
294 /*! |
303 /*! |
295 destructor |
304 destructor |
296 */ |
305 */ |
297 HbSliderTickmarksLabel::~HbSliderTickmarksLabel() |
306 HbSliderTickmarksLabel::~HbSliderTickmarksLabel() |
298 { |
307 { |
299 } |
308 } |
300 |
309 |
301 void HbSliderTickmarksLabel::setLabelSize() |
|
302 { |
|
303 Q_D (HbSliderTickmarksLabel); |
|
304 |
|
305 int minimum = d->slider->minimum(); |
|
306 int maximum = d->slider->maximum(); |
|
307 int majorTickInterval = d->slider->majorTickInterval ( ); |
|
308 int minorTickInterval = d->slider->minorTickInterval ( ); |
|
309 qreal span = 0; |
|
310 bool rtlLayout = (((d->slider->orientation( ) != Qt::Vertical) |
|
311 &&(HbApplication::layoutDirection() == Qt::LeftToRight))?false:true); |
|
312 HbSliderPrivate *sliderPrivate = dynamic_cast<HbSliderPrivate*>(HbSliderPrivate::d_ptr(d->slider)); |
|
313 QSizeF handleSize(0.0,0.0); |
|
314 if( sliderPrivate) { |
|
315 handleSize = sliderPrivate->getHandleSize( ); |
|
316 } else { |
|
317 return; |
|
318 } |
|
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(); |
|
326 } |
|
327 int minPos = QStyle::sliderPositionFromValue( minimum, maximum, |
|
328 minimum,static_cast<int>( span ), rtlLayout ); |
|
329 int firstMajorIntervalPos = QStyle::sliderPositionFromValue( minimum, maximum, |
|
330 minimum+majorTickInterval,static_cast<int>( span ), rtlLayout ); |
|
331 |
|
332 int firstMinorIntervalPos = QStyle::sliderPositionFromValue( minimum, maximum, |
|
333 minimum+minorTickInterval,static_cast<int>( span ), rtlLayout ); |
|
334 |
|
335 qreal totalMajorTextWidth = abs(firstMajorIntervalPos-minPos); |
|
336 qreal totalMinorTextWidth = abs(firstMinorIntervalPos-minPos); |
|
337 Q_UNUSED(totalMajorTextWidth) |
|
338 Q_UNUSED(totalMinorTextWidth) |
|
339 |
|
340 if (majorTickInterval) { |
|
341 int totalMajorTicksLabel = d->tickmarkmajorIconItemsLabel.length(); |
|
342 for (int i=0;i<totalMajorTicksLabel;i++) { |
|
343 QGraphicsWidget *textItem = d->tickmarkmajorIconItemsLabel.at ( i); |
|
344 HbStyleOptionSlider opt; |
|
345 initStyleOption(&opt); |
|
346 opt.orientation = d->slider->orientation(); |
|
347 opt.text = (d->slider->majorTickLabels( )).at(i); |
|
348 style()->updatePrimitive(textItem,HbStyle::P_SliderTickMark_majorlabel,&opt); |
|
349 if ( d->slider->orientation() == Qt::Horizontal) { |
|
350 /* textItem->setMaximumHeight (boundingRect().height()); |
|
351 textItem->setMinimumHeight (boundingRect().height()); |
|
352 textItem->setMinimumWidth(totalMajorTextWidth); |
|
353 textItem->setMaximumWidth(totalMajorTextWidth);*/ |
|
354 textItem->update(); |
|
355 } else { |
|
356 /* textItem->setMinimumWidth(boundingRect().width()); |
|
357 textItem->setMaximumWidth(boundingRect().width());*/ |
|
358 textItem->update( ); |
|
359 } |
|
360 } |
|
361 } |
|
362 if (minorTickInterval) { |
|
363 int totalminorTicks = ((maximum-minimum)/minorTickInterval)+1; |
|
364 int minorIndex = 0; |
|
365 for (int i=0;i<totalminorTicks;i++) { |
|
366 if (majorTickInterval ) { |
|
367 if (i*minorTickInterval%majorTickInterval== 0) { |
|
368 continue; |
|
369 } |
|
370 } |
|
371 if ( minorIndex < d->tickmarkminorIconItemsLabel.length() ) { |
|
372 QGraphicsWidget *textItem = d->tickmarkminorIconItemsLabel.at ( minorIndex); |
|
373 minorIndex++; |
|
374 if ( d->slider->orientation() == Qt::Horizontal) { |
|
375 /* textItem->setMaximumHeight (boundingRect().height()); |
|
376 textItem->setMinimumHeight (boundingRect().height()); |
|
377 textItem->setMinimumWidth(totalMinorTextWidth); |
|
378 textItem->setMaximumWidth(totalMinorTextWidth);*/ |
|
379 textItem->update(); |
|
380 } else { |
|
381 /* textItem->setMinimumWidth(boundingRect().width()); |
|
382 textItem->setMaximumWidth(boundingRect().width());*/ |
|
383 textItem->update( ); |
|
384 } |
|
385 } |
|
386 } |
|
387 } |
|
388 } |
|
389 |
|
390 |
|
391 |
310 |
392 void HbSliderTickmarksLabel::polish( HbStyleParameters& params ) |
311 void HbSliderTickmarksLabel::polish( HbStyleParameters& params ) |
393 { |
312 { |
394 Q_D (HbSliderTickmarksLabel); |
|
395 d->createTickLabels(); |
|
396 if( d->slider->orientation( ) == Qt::Horizontal ) { |
|
397 setProperty("orientation",(Qt::Orientation)1); |
|
398 } else { |
|
399 setProperty("orientation",(Qt::Orientation)2); |
|
400 } |
|
401 HbWidget::polish(params); |
313 HbWidget::polish(params); |
402 updateTickLabels(); |
314 updateTickLabels(); |
403 } |
315 } |
404 |
316 |
405 /*! |
317 /*! |