27 #include "hbindexfeedback_p.h" |
27 #include "hbindexfeedback_p.h" |
28 |
28 |
29 #include "hbabstractitemview.h" |
29 #include "hbabstractitemview.h" |
30 |
30 |
31 #include <hbscrollbar.h> |
31 #include <hbscrollbar.h> |
32 #include <hbstyleoptionindexfeedback_p.h> |
32 #include <hbframeitem.h> |
|
33 #include <hbtextitem.h> |
33 #include <hbstyleparameters.h> |
34 #include <hbstyleparameters.h> |
34 #include <hbstyle.h> |
35 #include <hbstyle.h> |
35 #include <hbdeviceprofile.h> |
36 #include <hbdeviceprofile.h> |
|
37 #include <hbstyletextprimitivedata.h> |
|
38 #include <hbstyleframeprimitivedata.h> |
36 |
39 |
37 #include <QEvent> |
40 #include <QEvent> |
38 #include <QObject> |
41 #include <QObject> |
39 #include <QGraphicsScene> |
42 #include <QGraphicsScene> |
|
43 #include <QGraphicsObject> |
40 |
44 |
41 /*! |
45 /*! |
42 @alpha |
46 @alpha |
43 @hbwidgets |
47 @hbwidgets |
44 \class HbIndexFeedback |
48 \class HbIndexFeedback |
302 } |
306 } |
303 |
307 |
304 return QObject::eventFilter(obj, ev); |
308 return QObject::eventFilter(obj, ev); |
305 } |
309 } |
306 |
310 |
307 /* |
311 /*! |
308 For use with HbStyle. |
312 Initializes the HbIndexFeedback primitive data. |
309 |
313 |
310 Provide the correct data to use in the 'model.' |
314 This function calls HbWidgetBase::initPrimitiveData(). |
311 */ |
315 \a primitiveData is data object, which is populated with data. \a primitive is the primitive. |
312 void HbIndexFeedback::initStyleOption(HbStyleOptionIndexFeedback *option) const |
316 */ |
313 { |
317 void HbIndexFeedback::initPrimitiveData(HbStylePrimitiveData *primitiveData, |
314 Q_D( const HbIndexFeedback ); |
318 const QGraphicsObject *primitive) |
315 |
319 { |
316 HbWidget::initStyleOption(option); |
320 Q_ASSERT_X(primitive && primitiveData, "HbIndexFeedback::initPrimitiveData" , "NULL data not permitted"); |
317 |
321 Q_D(HbIndexFeedback); |
318 if (!d->mItemView) { |
322 |
319 return; |
323 HbWidgetBase::initPrimitiveData(primitiveData, primitive); |
320 } |
324 |
321 |
325 if (primitiveData->type == HbStylePrimitiveData::SPD_Text) { |
322 HbFontSpec fontSpec; |
326 HbStyleTextPrimitiveData *textPrimitiveData = hbstyleprimitivedata_cast<HbStyleTextPrimitiveData*>(primitiveData); |
323 qreal margin = 0; |
327 |
324 |
328 HbFontSpec fontSpec; |
325 style()->parameter(QLatin1String("hb-param-margin-gene-popup"), margin); |
329 switch (d->mIndexFeedbackPolicy) { |
326 |
330 case IndexFeedbackSingleCharacter: { |
327 switch (d->mIndexFeedbackPolicy) { |
|
328 case IndexFeedbackSingleCharacter: |
|
329 { |
|
330 fontSpec = HbFontSpec(HbFontSpec::Primary); |
331 fontSpec = HbFontSpec(HbFontSpec::Primary); |
331 fontSpec.setTextHeight(d->textHeight()); |
332 fontSpec.setTextHeight(d->textHeight()); |
332 } |
333 } |
333 break; |
334 break; |
334 |
335 case IndexFeedbackThreeCharacter: { |
335 case IndexFeedbackThreeCharacter: |
|
336 { |
|
337 fontSpec = HbFontSpec(HbFontSpec::Primary); |
336 fontSpec = HbFontSpec(HbFontSpec::Primary); |
338 fontSpec.setTextHeight(d->textHeight()); |
337 fontSpec.setTextHeight(d->textHeight()); |
339 } |
338 } |
340 break; |
339 break; |
341 |
340 case IndexFeedbackString: { |
342 case IndexFeedbackString: |
|
343 { |
|
344 fontSpec = HbFontSpec(HbFontSpec::Primary); |
341 fontSpec = HbFontSpec(HbFontSpec::Primary); |
345 qreal textHeight = 0; |
342 qreal textHeight = 0; |
346 style()->parameter(QLatin1String("hb-param-text-height-primary"), textHeight); |
343 style()->parameter(QLatin1String("hb-param-text-height-primary"), textHeight); |
347 fontSpec.setTextHeight( textHeight ); |
344 fontSpec.setTextHeight( textHeight ); |
348 } |
345 } |
349 break; |
346 break; |
350 |
347 case IndexFeedbackNone: |
351 case IndexFeedbackNone: |
348 // no initialisation |
352 // leave the HbStyleOption uninitialized |
349 return; |
353 return; |
350 } |
354 } |
351 textPrimitiveData->fontSpec = fontSpec; |
355 |
352 |
356 option->text = d->mPopupContent; |
353 textPrimitiveData->text = d->mPopupContent; |
357 option->fontSpec = fontSpec; |
354 textPrimitiveData->geometry = d->mPopupTextRect; |
358 option->textRect = d->mPopupTextRect; |
355 |
359 option->popupRect = d->mPopupBackgroundRect; |
356 } else if (primitiveData->type == HbStylePrimitiveData::SPD_Frame) { |
|
357 HbStyleFramePrimitiveData *framePrimitiveData = hbstyleprimitivedata_cast<HbStyleFramePrimitiveData*>(primitiveData); |
|
358 framePrimitiveData->geometry = d->mPopupBackgroundRect; |
|
359 } |
|
360 } |
|
361 |
|
362 |
|
363 |
|
364 /* |
|
365 Update the primitives for the index feedback. |
|
366 */ |
|
367 void HbIndexFeedback::updatePrimitives() |
|
368 { |
|
369 Q_D( HbIndexFeedback ); |
|
370 |
|
371 if (d->mTextItem) { |
|
372 HbStyleTextPrimitiveData textPrimitiveData; |
|
373 initPrimitiveData(&textPrimitiveData, d->mTextItem); |
|
374 style()->updatePrimitive(d->mTextItem, &textPrimitiveData, this); |
|
375 } |
|
376 if (d->mPopupItem) { |
|
377 HbStyleFramePrimitiveData framePrimitiveData; |
|
378 initPrimitiveData(&framePrimitiveData, d->mPopupItem); |
|
379 style()->updatePrimitive(d->mPopupItem, &framePrimitiveData, this); |
|
380 } |
360 } |
381 } |
361 |
382 |
362 void HbIndexFeedback::polish(HbStyleParameters& params) |
383 void HbIndexFeedback::polish(HbStyleParameters& params) |
363 { |
384 { |
364 Q_D( HbIndexFeedback ); |
385 Q_D( HbIndexFeedback ); |