28 #include "hbstyleoptionsliderelement_p.h" |
28 #include "hbstyleoptionsliderelement_p.h" |
29 #include "hbstyleoptionpushbutton_p.h" |
29 #include "hbstyleoptionpushbutton_p.h" |
30 #include "hbstyleoptiontoolbutton_p.h" |
30 #include "hbstyleoptiontoolbutton_p.h" |
31 #include "hbstyleoptiontooltip_p.h" |
31 #include "hbstyleoptiontooltip_p.h" |
32 #include "hbstyleoptionprogressbar_p.h" |
32 #include "hbstyleoptionprogressbar_p.h" |
33 #include "hbstyleoptionabstractviewitem_p.h" |
|
34 #include "hbstyleoptionlistviewitem_p.h" |
|
35 #include "hbstyleoptionmenuitem_p.h" |
33 #include "hbstyleoptionmenuitem_p.h" |
36 #include "hbstyleoptionlabel_p.h" |
34 #include "hbstyleoptionlabel_p.h" |
37 #include "hbstyleoptionscrollbar_p.h" |
35 #include "hbstyleoptionscrollbar_p.h" |
38 #include "hbstyleoptiongridviewitem_p.h" |
|
39 #include "hbstyleoptioncheckbox_p.h" |
36 #include "hbstyleoptioncheckbox_p.h" |
40 #include "hbiconloader_p.h" |
37 #include "hbiconloader_p.h" |
41 #include "hbstyleoptiontitlepane_p.h" |
38 #include "hbstyleoptiontitlepane_p.h" |
42 #include "hbstyleoptionstatusbar_p.h" |
39 #include "hbstyleoptionstatusbar_p.h" |
43 #include "hbstyleoptionindicatorgroup_p.h" |
40 #include "hbstyleoptionindicatorgroup_p.h" |
44 #include "hbstyleoptionprogressdialog_p.h" |
41 #include "hbstyleoptionprogressdialog_p.h" |
45 #include "hbstyleoptionnotificationdialog_p.h" |
42 #include "hbstyleoptionnotificationdialog_p.h" |
46 #include "hbstyleoptiontreeviewitem_p.h" |
|
47 #include "hbstyleoptioncolorgridviewitem_p.h" |
43 #include "hbstyleoptioncolorgridviewitem_p.h" |
48 #include "hbstyleoptionmessagebox_p.h" |
44 #include "hbstyleoptionmessagebox_p.h" |
49 #include "hbstyleoptionnavigationbutton_p.h" |
45 #include "hbstyleoptionnavigationbutton_p.h" |
50 #include "hbstyleoptionindicatorbutton_p.h" |
46 #include "hbstyleoptionindicatorbutton_p.h" |
51 #include "hbstyleoptionsignalindicator_p.h" |
47 #include "hbstyleoptionsignalindicator_p.h" |
217 instantiated by the createPrimitive() method. This enables customizing the painting of the UI without touching the widget code. |
212 instantiated by the createPrimitive() method. This enables customizing the painting of the UI without touching the widget code. |
218 |
213 |
219 Updating of a primitive's state is done by using HbStyle::updatePrimitive() method which uses the style primitive data classes (comparable to |
214 Updating of a primitive's state is done by using HbStyle::updatePrimitive() method which uses the style primitive data classes (comparable to |
220 Qt styleoptions) to get the state information needed for the primitive updating. |
215 Qt styleoptions) to get the state information needed for the primitive updating. |
221 |
216 |
222 \param primitiveType, enumeration of the base primitive |
217 \param primitiveType enumeration of the base primitive |
223 \param itemName, string which identifies a primitive in the widget (e.g. "background", or "text"). The item name matches with primitive names in widget's CSS file. |
218 \param itemName string which identifies a primitive in the widget (e.g. "background", or "text"). The item name matches with primitive names in widget's CSS file. |
224 \param parent, parent for the primitive, although the default is 0 usually the widget is given as a parent for the primitive |
219 \param parent parent for the primitive, although the default is 0 usually the widget is given as a parent for the primitive |
225 \return QGraphicsObject, the returned primitive should be stored as a QGraphicsObject on the widget side |
220 \return QGraphicsObject, the returned primitive should be stored as a QGraphicsObject on the widget side |
226 \sa HbStyle::updatePrimitive() |
221 \sa HbStyle::updatePrimitive() |
227 \sa HbStylePrimitiveData |
222 \sa HbStylePrimitiveData |
228 \sa HbStyleTextPrimitiveData |
223 \sa HbStyleTextPrimitiveData |
229 \sa HbStyleFramePrimitiveData |
224 \sa HbStyleFramePrimitiveData |
278 value will be updated to the primitive on the style side. The values on primitive data classes are stored by using HbStyleValue templated class |
273 value will be updated to the primitive on the style side. The values on primitive data classes are stored by using HbStyleValue templated class |
279 which keeps track of whether a primitive data value was assigned or not. On the style side before calling the primitive API the HbStyleValue's |
274 which keeps track of whether a primitive data value was assigned or not. On the style side before calling the primitive API the HbStyleValue's |
280 isSet()-method is called first to check if the widget did assign the primitive data value. |
275 isSet()-method is called first to check if the widget did assign the primitive data value. |
281 |
276 |
282 |
277 |
283 \param primitive, the primitive to be updated |
278 \param primitive the primitive to be updated |
284 \param data, primitive data needed for updating the primitive |
279 \param data primitive data needed for updating the primitive |
285 \param parent, optionally the parent can be given |
280 \param parent optionally the parent can be given |
286 \return bool, true if correct primitive type was found from the style, false if not. |
281 \return bool, true if correct primitive type was found from the style, false if not. |
287 \sa HbStyle::createPrimitive() |
282 \sa HbStyle::createPrimitive() |
288 \sa HbStylePrimitiveData |
283 \sa HbStylePrimitiveData |
289 \sa HbStyleTextPrimitiveData |
284 \sa HbStyleTextPrimitiveData |
290 \sa HbStyleFramePrimitiveData |
285 \sa HbStyleFramePrimitiveData |
383 else |
381 else |
384 marqueeItem->stopAnimation(); |
382 marqueeItem->stopAnimation(); |
385 } |
383 } |
386 if (md->loopCount.isSet()) |
384 if (md->loopCount.isSet()) |
387 marqueeItem->setLoopCount(md->loopCount); |
385 marqueeItem->setLoopCount(md->loopCount); |
388 return true; |
386 ret = true; |
389 |
387 |
390 } else if (HbTouchArea *touchArea = qgraphicsitem_cast<HbTouchArea*>(primitive)) { |
388 } else if (HbTouchArea *touchArea = qgraphicsitem_cast<HbTouchArea*>(primitive)) { |
391 const HbStyleTouchAreaPrimitiveData *td = hbstyleprimitivedata_cast<const HbStyleTouchAreaPrimitiveData*>(data); |
389 const HbStyleTouchAreaPrimitiveData *td = hbstyleprimitivedata_cast<const HbStyleTouchAreaPrimitiveData*>(data); |
392 if (td->size.isSet()) |
390 if (td->size.isSet()) |
393 touchArea->setSize(td->size); |
391 touchArea->setSize(td->size); |
394 if (td->geometry.isSet()) |
392 if (td->geometry.isSet()) |
395 touchArea->setGeometry(td->geometry); |
393 touchArea->setGeometry(td->geometry); |
396 return true; |
394 ret = true; |
397 |
395 |
398 } else if (HbRichTextItem *richTextItem = qgraphicsitem_cast<HbRichTextItem*>(primitive)) { |
396 } else if (HbRichTextItem *richTextItem = qgraphicsitem_cast<HbRichTextItem*>(primitive)) { |
399 const HbStyleRichTextPrimitiveData *rd = hbstyleprimitivedata_cast<const HbStyleRichTextPrimitiveData*>(data); |
397 const HbStyleRichTextPrimitiveData *rd = hbstyleprimitivedata_cast<const HbStyleRichTextPrimitiveData*>(data); |
400 if (rd->text.isSet()) |
398 if (rd->text.isSet()) |
401 richTextItem->setText(rd->text); |
399 richTextItem->setText(rd->text); |
450 return iconItem; |
455 return iconItem; |
451 } |
456 } |
452 |
457 |
453 case P_CheckBox_icon: |
458 case P_CheckBox_icon: |
454 case P_GroupBoxHeading_icon: |
459 case P_GroupBoxHeading_icon: |
455 case P_Label_icon: |
460 case P_Label_icon: { |
456 case P_GridViewItem_icon: { |
|
457 HbIconItem *item = q_check_ptr(new HbIconItem(HbIcon(),parent)); |
461 HbIconItem *item = q_check_ptr(new HbIconItem(HbIcon(),parent)); |
458 HbStyle::setItemName(item, QLatin1String("icon")); |
462 HbStyle::setItemName(item, QLatin1String("icon")); |
459 return item; |
463 return item; |
460 } |
464 } |
|
465 case P_GridViewItem_icon: { |
|
466 Q_ASSERT_X(false, "HbStyle" , "P_GridViewItem_icon no more supported. Use refactored styling"); |
|
467 return 0; |
|
468 } |
461 case P_DataGroup_icon: |
469 case P_DataGroup_icon: |
462 { |
470 { |
463 HbIconItem *item = new HbIconItem(HbIcon(), parent); |
471 HbIconItem *item = new HbIconItem(HbIcon(), parent); |
464 HbStyle::setItemName(item, QLatin1String("dataGroup_Icon")); |
472 HbStyle::setItemName(item, QLatin1String("dataGroup_Icon")); |
465 return item; |
473 return item; |
1019 HbIconItem *n = new HbIconItem(QString(), parent); |
1026 HbIconItem *n = new HbIconItem(QString(), parent); |
1020 return n; |
1027 return n; |
1021 } |
1028 } |
1022 |
1029 |
1023 case P_ItemViewItem_background: { |
1030 case P_ItemViewItem_background: { |
1024 HbIconItem *iconItem = q_check_ptr(new HbIconItem(parent)); |
1031 Q_ASSERT_X(false, "HbStyle" , "P_ItemViewItem_background no more supported. Use refactored styling"); |
1025 iconItem->setZValue(-3.0); |
1032 return 0; |
1026 HbStyle::setItemName(iconItem, QLatin1String("background")); |
|
1027 iconItem->setAspectRatioMode(Qt::IgnoreAspectRatio); |
|
1028 return iconItem; |
|
1029 } |
1033 } |
1030 |
1034 |
1031 case P_ListViewItem_text: { |
1035 case P_ListViewItem_text: { |
1032 HbTextItem *textItem = q_check_ptr(new HbTextItem(parent)); |
1036 Q_ASSERT_X(false, "HbStyle" , "P_ListViewItem_text no more supported. Use refactored styling"); |
1033 |
1037 return 0; |
1034 return textItem; |
|
1035 } |
1038 } |
1036 |
1039 |
1037 case P_ListViewItem_richtext: { |
1040 case P_ListViewItem_richtext: { |
1038 HbRichTextItem *textItem = q_check_ptr(new HbRichTextItem(parent)); |
1041 Q_ASSERT_X(false, "HbStyle" , "P_ListViewItem_richtext no more supported. Use refactored styling"); |
1039 return textItem; |
1042 return 0; |
1040 } |
1043 } |
1041 |
1044 |
1042 case P_GridViewItem_text: { |
1045 case P_GridViewItem_text: { |
1043 HbTextItem *textItem = q_check_ptr(new HbTextItem(parent)); |
1046 Q_ASSERT_X(false, "HbStyle" , "P_GridViewItem_text no more supported. Use refactored styling"); |
1044 // caching do not work properly - text is not refreshed immediatelly |
1047 return 0; |
1045 //textItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache); |
|
1046 HbStyle::setItemName(textItem, QLatin1String("text")); |
|
1047 return textItem; |
|
1048 } |
1048 } |
1049 |
1049 |
1050 case P_ListViewItem_icon: |
1050 case P_ListViewItem_icon: |
1051 return q_check_ptr(new HbIconItem(parent)); |
1051 Q_ASSERT_X(false, "HbStyle" , "P_ListViewItem_icon no more supported. Use refactored styling"); |
|
1052 return 0; |
1052 |
1053 |
1053 case P_ColorGridViewItem_colorIcon: |
1054 case P_ColorGridViewItem_colorIcon: |
1054 return new HbIconItem("qtg_graf_colorpicker_mask", parent); |
1055 return new HbIconItem("qtg_graf_colorpicker_mask", parent); |
1055 case P_ColorGridViewItem_borderIcon: |
1056 case P_ColorGridViewItem_borderIcon: |
1056 return new HbIconItem("qtg_graf_colorpicker_filled", parent); |
1057 return new HbIconItem("qtg_graf_colorpicker_filled", parent); |
1057 case P_ColorGridViewItem_checkIcon: |
1058 case P_ColorGridViewItem_checkIcon: |
1058 return new HbIconItem("qtg_small_tick", parent); |
1059 return new HbIconItem("qtg_small_tick", parent); |
1059 |
1060 |
1060 case P_TreeViewItem_expandicon: { |
1061 case P_TreeViewItem_expandicon: { |
1061 HbIconItem *iconItem = q_check_ptr(new HbIconItem(parent)); |
1062 Q_ASSERT_X(false, "HbStyle" , "P_TreeViewItem_expandicon no more supported. Use refactored styling"); |
1062 HbStyle::setItemName(iconItem, QLatin1String("subitem-indicator")); |
1063 return 0; |
1063 return iconItem; |
|
1064 } |
1064 } |
1065 |
1065 |
1066 case P_SelectionControl_selectionstart://fallthrough |
1066 case P_SelectionControl_selectionstart://fallthrough |
1067 case P_SelectionControl_selectionend://fallthrough |
1067 case P_SelectionControl_selectionend://fallthrough |
1068 { |
1068 { |
1084 case P_ComboBox_button: { |
1084 case P_ComboBox_button: { |
1085 HbIconItem *n = new HbIconItem(QString(), parent); |
1085 HbIconItem *n = new HbIconItem(QString(), parent); |
1086 return n; |
1086 return n; |
1087 } |
1087 } |
1088 case P_ItemViewItem_focus: { |
1088 case P_ItemViewItem_focus: { |
1089 HbFrameItem *frameItem = q_check_ptr(new HbFrameItem(parent)); |
1089 Q_ASSERT_X(false, "HbStyle" , "P_ItemViewItem_focus no more supported. Use refactored styling"); |
1090 frameItem->setZValue(-1.0); |
1090 return 0; |
1091 return frameItem; |
|
1092 } |
1091 } |
1093 case P_ItemHighlight_background: |
1092 case P_ItemHighlight_background: |
1094 return new HbFrameItem(parent); |
1093 return new HbFrameItem(parent); |
1095 |
1094 |
1096 case P_ItemViewItem_frame: { |
1095 case P_ItemViewItem_frame: { |
1097 HbFrameItem *item = q_check_ptr(new HbFrameItem(parent)); |
1096 Q_ASSERT_X(false, "HbStyle" , "P_ItemViewItem_frame no more supported. Use refactored styling"); |
1098 item->setZValue(-4.0); |
1097 return 0; |
1099 HbStyle::setItemName(item,"frame"); |
|
1100 return item; |
|
1101 } |
1098 } |
1102 case P_ScrollArea_continuationbottom: |
1099 case P_ScrollArea_continuationbottom: |
1103 { |
1100 { |
1104 HbFrameItem *n = new HbFrameItem(parent); |
1101 HbFrameItem *n = new HbFrameItem(parent); |
1105 HbStyle::setItemName(n, QLatin1String("continuation-indicator-bottom")); |
1102 HbStyle::setItemName(n, QLatin1String("continuation-indicator-bottom")); |
1127 n->setZValue(-1); |
1124 n->setZValue(-1); |
1128 return n; |
1125 return n; |
1129 } |
1126 } |
1130 case P_ItemViewItem_touchmultiselection: |
1127 case P_ItemViewItem_touchmultiselection: |
1131 { |
1128 { |
1132 HbTouchArea *area = q_check_ptr(new HbTouchArea(parent)); |
1129 Q_ASSERT_X(false, "HbStyle" , "P_ItemViewItem_touchmultiselection no more supported. Use refactored styling"); |
1133 HbStyle::setItemName(area, "multiselection-toucharea"); |
1130 return 0; |
1134 return area; |
|
1135 } |
1131 } |
1136 case P_IndexFeedback_popup_text: |
1132 case P_IndexFeedback_popup_text: |
1137 { |
1133 { |
1138 HbTextItem *textItem = new HbTextItem(parent); |
1134 Q_ASSERT_X(false, "HbStyle" , "P_IndexFeedback_popup_text no more supported. Use refactored styling"); |
1139 textItem->setAlignment(Qt::AlignCenter); |
1135 return 0; |
1140 textItem->setTextWrapping(Hb::TextNoWrap); |
|
1141 HbStyle::setItemName(textItem, QLatin1String("index-text")); |
|
1142 |
|
1143 //TODO:: make this a sane value |
|
1144 textItem->setZValue(4); |
|
1145 return textItem; |
|
1146 } |
1136 } |
1147 case P_IndexFeedback_popup_background: |
1137 case P_IndexFeedback_popup_background: |
1148 { |
1138 { |
1149 |
1139 Q_ASSERT_X(false, "HbStyle" , "P_IndexFeedback_popup_background no more supported. Use refactored styling"); |
1150 HbFrameItem *n = new HbFrameItem(parent); |
1140 return 0; |
1151 n->frameDrawer().setFrameGraphicsName("qtg_fr_popup_preview"); |
|
1152 n->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
1153 qreal cornerPieceSize = 0; |
|
1154 hbInstance->style()->parameter(QLatin1String("hb-param-background-popup-preview"),cornerPieceSize); |
|
1155 n->frameDrawer().setBorderWidths(cornerPieceSize, cornerPieceSize); |
|
1156 HbStyle::setItemName(n, QLatin1String("index-background")); |
|
1157 n->setZValue(3); |
|
1158 return n; |
|
1159 } |
1141 } |
1160 case P_InputDialog_text: |
1142 case P_InputDialog_text: |
1161 { |
1143 { |
1162 HbTextItem *n = new HbTextItem(parent); |
1144 HbTextItem *n = new HbTextItem(parent); |
1163 n->setTextWrapping(Hb::TextWordWrap); |
1145 n->setTextWrapping(Hb::TextWordWrap); |
2255 break; |
2237 break; |
2256 } |
2238 } |
2257 case P_ItemViewItem_radiobutton: |
2239 case P_ItemViewItem_radiobutton: |
2258 case P_ItemViewItem_checkbox: |
2240 case P_ItemViewItem_checkbox: |
2259 case P_ItemViewItem_selection:{ |
2241 case P_ItemViewItem_selection:{ |
2260 if (const HbStyleOptionAbstractViewItem *opt = qstyleoption_cast<const HbStyleOptionAbstractViewItem *>(option)){ |
2242 Q_ASSERT_X(false, "HbStyle" , "P_ItemViewItem_selection no more supported. Use refactored styling"); |
2261 HbIconItem *iconItem = static_cast<HbIconItem *>(item); |
|
2262 iconItem->setAlignment(Qt::AlignCenter); |
|
2263 |
|
2264 if (opt->viewItemType == Hb::ItemType_RadioButtonListViewItem) { |
|
2265 if (opt->checkState == Qt::Checked) { |
|
2266 iconItem->setState(QIcon::On); |
|
2267 iconItem->setIconName(QLatin1String("qtg_small_radio_selected")); |
|
2268 } else { |
|
2269 iconItem->setState(QIcon::Off); |
|
2270 iconItem->setIconName(QLatin1String("qtg_small_radio_unselected")); |
|
2271 } |
|
2272 } else { |
|
2273 if (opt->checkState == Qt::Checked) { |
|
2274 iconItem->setState(QIcon::On); |
|
2275 if (opt->singleSelectionMode) { |
|
2276 iconItem->setIconName(QLatin1String("qtg_small_tick")); |
|
2277 } |
|
2278 else { |
|
2279 iconItem->setIconName(QLatin1String("qtg_small_selected")); |
|
2280 } |
|
2281 } else if (opt->checkState == Qt::PartiallyChecked) { |
|
2282 iconItem->setState(QIcon::On); |
|
2283 iconItem->setIconName(QLatin1String("qtg_small_selected_partial")); |
|
2284 } else { |
|
2285 iconItem->setState(QIcon::Off); |
|
2286 if (opt->singleSelectionMode) { |
|
2287 iconItem->setIconName(QLatin1String("")); |
|
2288 } |
|
2289 else { |
|
2290 iconItem->setIconName(QLatin1String("qtg_small_unselected")); |
|
2291 } |
|
2292 } |
|
2293 } |
|
2294 } |
|
2295 break; |
2243 break; |
2296 } |
2244 } |
2297 |
2245 |
2298 case P_LineEdit_frame_normal:{ |
2246 case P_LineEdit_frame_normal:{ |
2299 if (HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>( item ) ) { |
2247 if (HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>( item ) ) { |
2300 if(frameItem->isEnabled()) { |
2248 if(frameItem->isEnabled()) { |
2301 qDebug() << "Update primitive bagckground enabled"; |
|
2302 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_lineedit_normal")); |
2249 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_lineedit_normal")); |
2303 } else { |
2250 } else { |
2304 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_lineedit_disabled")); |
2251 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_lineedit_disabled")); |
2305 } |
2252 } |
2306 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
2253 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
2669 icon->setIcon(opt->icon); |
2616 icon->setIcon(opt->icon); |
2670 } |
2617 } |
2671 } |
2618 } |
2672 break; |
2619 break; |
2673 case P_ListViewItem_text: |
2620 case P_ListViewItem_text: |
2674 if (const HbStyleOptionListViewItem *opt = qstyleoption_cast<const HbStyleOptionListViewItem *>(option)) { |
2621 Q_ASSERT_X(false, "HbStyle" , "P_ListViewItem_text no more supported. Use refactored styling"); |
2675 HbTextItem *textItem = static_cast<HbTextItem*>(item); |
|
2676 |
|
2677 if (opt->index == 1) { |
|
2678 if (opt->multilineSecondaryTextSupported) { |
|
2679 if (opt->minimumLines != -1) { |
|
2680 // min & max secondary text row counts set by app |
|
2681 Hb::TextWrapping wrapping = Hb::TextNoWrap; |
|
2682 if ( opt->minimumLines != 1 |
|
2683 || opt->maximumLines != 1) { |
|
2684 wrapping = Hb::TextWordWrap; |
|
2685 } |
|
2686 textItem->setTextWrapping(wrapping); |
|
2687 textItem->setMinimumLines(opt->minimumLines); |
|
2688 textItem->setMaximumLines(opt->maximumLines); |
|
2689 } else { |
|
2690 // min & max secondary text row counts not set by app. Allow setting those from .css |
|
2691 // Needed when multilineSecondaryTextSupported changed from FALSE to TRUE and |
|
2692 // min & max secondary text row counts has not bee set by app |
|
2693 HbWidgetBasePrivate *widgetBaseP = widgetBasePrivate(textItem); |
|
2694 widgetBaseP->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode, false); |
|
2695 widgetBaseP->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin, false); |
|
2696 widgetBaseP->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax, false); |
|
2697 } |
|
2698 } else { |
|
2699 // min & max secondary text row counts must always be 1. They cannot be overridden by .css |
|
2700 textItem->setTextWrapping(Hb::TextNoWrap); |
|
2701 textItem->setMinimumLines(1); |
|
2702 textItem->setMaximumLines(1); |
|
2703 } |
|
2704 } // else - default values from .css still in use |
|
2705 |
|
2706 // Below optimizes the most common cases. |
|
2707 if (opt->index == 0) { |
|
2708 HbStyle::setItemName(textItem, QLatin1String("text-1")); |
|
2709 } else if (opt->index == 1) { |
|
2710 HbStyle::setItemName(textItem, QLatin1String("text-2")); |
|
2711 } else if (opt->index == 2) { |
|
2712 HbStyle::setItemName(textItem, QLatin1String("text-3")); |
|
2713 } else { |
|
2714 HbStyle::setItemName(textItem, QLatin1String("text-") + QString::number(opt->index + 1)); |
|
2715 } |
|
2716 |
|
2717 textItem->setText(opt->content.value<QString>()); |
|
2718 } |
|
2719 break; |
2622 break; |
2720 case P_ListViewItem_richtext: |
2623 case P_ListViewItem_richtext: |
2721 if (const HbStyleOptionListViewItem *opt = qstyleoption_cast<const HbStyleOptionListViewItem *>(option)) { |
2624 Q_ASSERT_X(false, "HbStyle" , "P_ListViewItem_richtext no more supported. Use refactored styling"); |
2722 HbRichTextItem *label = static_cast<HbRichTextItem*>(item); |
|
2723 label->setText(opt->content.value<QString>()); |
|
2724 |
|
2725 // Below optimizes the most common cases. |
|
2726 if (opt->index == 0) { |
|
2727 HbStyle::setItemName(label, QLatin1String("text-1")); |
|
2728 } else if (opt->index == 1) { |
|
2729 HbStyle::setItemName(label, QLatin1String("text-2")); |
|
2730 } else if (opt->index == 2) { |
|
2731 HbStyle::setItemName(label, QLatin1String("text-3")); |
|
2732 } else { |
|
2733 HbStyle::setItemName(label, QLatin1String("text-") + QString::number(opt->index + 1)); |
|
2734 } |
|
2735 } |
|
2736 break; |
2625 break; |
2737 case P_ListViewItem_icon: |
2626 case P_ListViewItem_icon: |
2738 if (const HbStyleOptionListViewItem *opt = qstyleoption_cast<const HbStyleOptionListViewItem *>(option)) { |
2627 Q_ASSERT_X(false, "HbStyle" , "P_ListViewItem_icon no more supported. Use refactored styling"); |
2739 HbIconItem *iconItem = static_cast<HbIconItem*>(item); |
|
2740 |
|
2741 // Below optimizes the most common cases. |
|
2742 if (opt->index == 0) { |
|
2743 HbStyle::setItemName(iconItem, QLatin1String("icon-1")); |
|
2744 } else if (opt->index == 1) { |
|
2745 HbStyle::setItemName(iconItem, QLatin1String("icon-2")); |
|
2746 } else { |
|
2747 HbStyle::setItemName(iconItem, QLatin1String("icon-") + QString::number(opt->index + 1)); |
|
2748 } |
|
2749 |
|
2750 if (iconItem->zValue() != opt->index + 1) { |
|
2751 iconItem->setZValue(opt->index + 1); |
|
2752 } |
|
2753 |
|
2754 if (opt->content.canConvert<HbIcon>()){ |
|
2755 iconItem->setIcon(opt->content.value<HbIcon>()); |
|
2756 } if (opt->content.canConvert<QIcon>()){ |
|
2757 iconItem->setIcon(opt->content.value<QIcon>()); |
|
2758 } |
|
2759 } |
|
2760 break; |
2628 break; |
2761 case P_GridViewItem_icon: |
2629 case P_GridViewItem_icon: |
2762 if (const HbStyleOptionGridViewItem*opt = qstyleoption_cast<const HbStyleOptionGridViewItem*>(option)) { |
2630 Q_ASSERT_X(false, "HbStyle" , "P_GridViewItem_icon no more supported. Use refactored styling"); |
2763 HbIconItem *iconItem = static_cast<HbIconItem*>(item); |
|
2764 iconItem->setIcon(opt->icon); |
|
2765 iconItem->setAlignment(Qt::AlignCenter); |
|
2766 iconItem->setAspectRatioMode(Qt::KeepAspectRatio); |
|
2767 } |
|
2768 break; |
2631 break; |
2769 |
2632 |
2770 case P_ColorGridViewItem_colorIcon: |
2633 case P_ColorGridViewItem_colorIcon: |
2771 if (const HbStyleOptionColorGridViewItem* opt = qstyleoption_cast<const HbStyleOptionColorGridViewItem*>(option)) { |
2634 if (const HbStyleOptionColorGridViewItem* opt = qstyleoption_cast<const HbStyleOptionColorGridViewItem*>(option)) { |
2772 HbIconItem *iconItem = static_cast<HbIconItem*>(item); |
2635 HbIconItem *iconItem = static_cast<HbIconItem*>(item); |
3056 iconItem->setPos(opt->editRect.width() - opt->modeIcon->width() - 6,opt->editRect.top()-3); |
2915 iconItem->setPos(opt->editRect.width() - opt->modeIcon->width() - 6,opt->editRect.top()-3); |
3057 } |
2916 } |
3058 }*/ |
2917 }*/ |
3059 break; |
2918 break; |
3060 case P_ItemViewItem_background: |
2919 case P_ItemViewItem_background: |
3061 if (const HbStyleOptionAbstractViewItem *opt = qstyleoption_cast<const HbStyleOptionAbstractViewItem *>(option)) { |
2920 Q_ASSERT_X(false, "HbStyle" , "P_ItemViewItem_background no more supported. Use refactored styling"); |
3062 HbIconItem *iconItem = static_cast<HbIconItem*>(item); |
|
3063 iconItem->setGeometry(opt->boundingRect); |
|
3064 if (opt->background.canConvert<HbIcon>()){ |
|
3065 iconItem->setIcon(opt->background.value<HbIcon>()); |
|
3066 } else if (opt->background.canConvert<QBrush>()){ |
|
3067 iconItem->setBrush(opt->background.value<QBrush>()); |
|
3068 } |
|
3069 } |
|
3070 |
|
3071 break; |
2921 break; |
3072 case P_ItemViewItem_frame: |
2922 case P_ItemViewItem_frame: |
3073 if (const HbStyleOptionAbstractViewItem *opt = qstyleoption_cast<const HbStyleOptionAbstractViewItem *>(option)) { |
2923 Q_ASSERT_X(false, "HbStyle" , "P_ItemViewItem_frame no more supported. Use refactored styling"); |
3074 HbFrameItem *frameItem = static_cast<HbFrameItem*>(item); |
|
3075 frameItem->setGeometry(opt->boundingRect); |
|
3076 |
|
3077 if (opt->background.canConvert<HbFrameBackground>()) { |
|
3078 HbFrameBackground frame = opt->background.value<HbFrameBackground>(); |
|
3079 frameItem->frameDrawer().setFrameType(frame.frameType()); |
|
3080 frameItem->frameDrawer().setFrameGraphicsName(frame.frameGraphicsName()); |
|
3081 } else if (opt->viewItemType == Hb::ItemType_TreeViewItem) { |
|
3082 if (opt->modelItemType == Hb::ParentItem) { |
|
3083 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
3084 frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ? |
|
3085 QLatin1String("qtg_fr_popup_list_parent_normal") : QLatin1String("qtg_fr_list_parent_normal")); |
|
3086 } else if (opt->modelItemType == Hb::SeparatorItem) { |
|
3087 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
3088 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_separator")); |
|
3089 } else { |
|
3090 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
3091 frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ? |
|
3092 QLatin1String("qtg_fr_popup_list_normal") : QLatin1String("qtg_fr_list_normal")); |
|
3093 } |
|
3094 } else if ( opt->viewItemType == Hb::ItemType_ListViewItem |
|
3095 || opt->viewItemType == Hb::ItemType_RadioButtonListViewItem) { |
|
3096 if (opt->modelItemType == Hb::SeparatorItem) { |
|
3097 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
3098 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_separator")); |
|
3099 } else { |
|
3100 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
3101 frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ? |
|
3102 QLatin1String("qtg_fr_popup_list_normal") : QLatin1String("qtg_fr_list_normal")); |
|
3103 } |
|
3104 } else if (opt->viewItemType == Hb::ItemType_GridViewItem |
|
3105 || opt->viewItemType == HbPrivate::ItemType_ColorGridViewItem) { |
|
3106 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
3107 frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ? |
|
3108 QLatin1String("qtg_fr_popup_grid_normal") : QLatin1String("qtg_fr_grid_normal")); |
|
3109 } |
|
3110 else{ |
|
3111 frameItem->frameDrawer().setFrameGraphicsName(QString()); |
|
3112 } |
|
3113 } |
|
3114 break; |
2924 break; |
3115 case P_ItemViewItem_focus: |
2925 case P_ItemViewItem_focus: |
3116 if (const HbStyleOptionAbstractViewItem *opt = qstyleoption_cast<const HbStyleOptionAbstractViewItem *>(option)) { |
2926 Q_ASSERT_X(false, "HbStyle" , "P_ItemViewItem_focus no more supported. Use refactored styling"); |
3117 HbFrameItem *frameItem = static_cast<HbFrameItem*>(item); |
|
3118 frameItem->setGeometry(opt->boundingRect); |
|
3119 |
|
3120 if (opt->viewItemType == Hb::ItemType_TreeViewItem |
|
3121 || opt->viewItemType == Hb::ItemType_ListViewItem |
|
3122 || opt->viewItemType == Hb::ItemType_RadioButtonListViewItem) { |
|
3123 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
3124 frameItem->frameDrawer().setFrameGraphicsName( opt->insidePopup ? |
|
3125 QLatin1String("qtg_fr_popup_list_pressed") : QLatin1String("qtg_fr_list_pressed")); |
|
3126 } else if ( opt->viewItemType == Hb::ItemType_GridViewItem |
|
3127 || opt->viewItemType == HbPrivate::ItemType_ColorGridViewItem) { |
|
3128 frameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
3129 frameItem->frameDrawer().setFrameGraphicsName(opt->insidePopup ? |
|
3130 QLatin1String("qtg_fr_popup_grid_pressed") : QLatin1String("qtg_fr_grid_pressed")); |
|
3131 } else { |
|
3132 HbStyle::setItemName(frameItem,QString()); |
|
3133 frameItem->frameDrawer().setFrameGraphicsName(QString()); |
|
3134 } |
|
3135 } |
|
3136 break; |
2927 break; |
3137 case P_SelectionControl_selectionstart://fallthrough |
2928 case P_SelectionControl_selectionstart://fallthrough |
3138 case P_SelectionControl_selectionend://fallthrough |
2929 case P_SelectionControl_selectionend://fallthrough |
3139 { |
2930 { |
3140 if (HbIconItem *iconItem = qgraphicsitem_cast<HbIconItem*>(item)) { |
2931 if (HbIconItem *iconItem = qgraphicsitem_cast<HbIconItem*>(item)) { |
3141 iconItem->setSize(iconItem->preferredSize()); |
2932 iconItem->setSize(iconItem->preferredSize()); |
3142 } |
2933 } |
3143 break; |
2934 break; |
3144 } |
2935 } |
3145 case P_TreeViewItem_expandicon: |
2936 case P_TreeViewItem_expandicon: |
3146 if (const HbStyleOptionTreeViewItem *opt = qstyleoption_cast<const HbStyleOptionTreeViewItem *>(option)) { |
2937 Q_ASSERT_X(false, "HbStyle" , "P_TreeViewItem_expandicon no more supported. Use refactored styling"); |
3147 HbIconItem *iconItem = static_cast<HbIconItem*>(item); |
|
3148 if (opt->expanded) { |
|
3149 iconItem->setIconName(opt->insidePopup ? QLatin1String("qtg_mono_collapse") : QLatin1String("qtg_small_collapse")); |
|
3150 } else { |
|
3151 iconItem->setIconName(opt->insidePopup ? QLatin1String("qtg_mono_expand") : QLatin1String("qtg_small_expand")); |
|
3152 } |
|
3153 } |
|
3154 break; |
2938 break; |
3155 case P_ScrollArea_continuationbottom: |
2939 case P_ScrollArea_continuationbottom: |
3156 if (HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>( item ) ) { |
2940 if (HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>( item ) ) { |
3157 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_graf_list_mask_b")); |
2941 frameItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_graf_list_mask_b")); |
3158 frameItem->frameDrawer().setFrameType(HbFrameDrawer::OnePiece); |
2942 frameItem->frameDrawer().setFrameType(HbFrameDrawer::OnePiece); |
3237 |
3021 |
3238 }*/ |
3022 }*/ |
3239 break; |
3023 break; |
3240 |
3024 |
3241 case P_IndexFeedback_popup_text: |
3025 case P_IndexFeedback_popup_text: |
3242 if (const HbStyleOptionIndexFeedback *opt = qstyleoption_cast<const HbStyleOptionIndexFeedback *>(option)) { |
3026 Q_ASSERT_X(false, "HbStyle" , "P_IndexFeedback_popup_text no more supported. Use refactored styling"); |
3243 HbTextItem *textItem = static_cast<HbTextItem*>(item); |
|
3244 textItem->setFontSpec(opt->fontSpec); |
|
3245 textItem->setGeometry(opt->textRect); |
|
3246 textItem->setText(opt->text); |
|
3247 } |
|
3248 break; |
3027 break; |
3249 case P_IndexFeedback_popup_background: |
3028 case P_IndexFeedback_popup_background: |
3250 if (const HbStyleOptionIndexFeedback *opt = qstyleoption_cast<const HbStyleOptionIndexFeedback *>(option)) { |
3029 Q_ASSERT_X(false, "HbStyle" , "P_IndexFeedback_popup_background no more supported. Use refactored styling"); |
3251 if (HbFrameItem* frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) { |
|
3252 frameItem->setGeometry(opt->popupRect); |
|
3253 } |
|
3254 } |
|
3255 break; |
3030 break; |
3256 case P_DateTimePicker_background: |
3031 case P_DateTimePicker_background: |
3257 /* if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption*>(option)) { |
3032 /* if (const HbStyleOption *opt = qstyleoption_cast<const HbStyleOption*>(option)) { |
3258 if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) { |
3033 if(HbFrameItem *frameItem = qgraphicsitem_cast<HbFrameItem*>(item)) { |
3259 frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_tumbler_bg"); |
3034 frameItem->frameDrawer().setFrameGraphicsName("qtg_fr_tumbler_bg"); |
3750 with HbStyle::HbStyle::setItemName method before this method is called. |
3525 with HbStyle::HbStyle::setItemName method before this method is called. |
3751 |
3526 |
3752 Note that this method is heavy on the system resources and should be called |
3527 Note that this method is heavy on the system resources and should be called |
3753 absolutely when necessary by the widget. |
3528 absolutely when necessary by the widget. |
3754 |
3529 |
3755 \param widget, HbWidget to be polished |
3530 \param widget HbWidget to be polished |
3756 \param params, style parameters to be returned to the caller |
3531 \param params style parameters to be returned to the caller |
3757 */ |
3532 */ |
3758 void HbStyle::polish(HbWidget *widget, HbStyleParameters ¶ms) |
3533 void HbStyle::polish(HbWidget *widget, HbStyleParameters ¶ms) |
3759 { |
3534 { |
3760 Q_D( HbStyle ); |
3535 Q_D( HbStyle ); |
3761 #ifdef HBSTYLE_DEBUG |
3536 #ifdef HBSTYLE_DEBUG |
3762 qDebug() << "HbStyle::polish : -- -- -- --"; |
3537 qDebug() << "HbStyle::polish : -- -- -- -- ENTER"; |
3763 #endif |
3538 #endif |
3764 if( !widget ) { |
3539 if( !widget ) { |
|
3540 #ifdef HBSTYLE_DEBUG |
|
3541 qDebug() << "HbStyle::polish : -- -- -- -- EXIT"; |
|
3542 #endif |
3765 return; |
3543 return; |
3766 } |
3544 } |
3767 #ifdef HBSTYLE_DEBUG |
3545 #ifdef HBSTYLE_DEBUG |
3768 qDebug() << "HbStyle::polish : Polishing" << widget->metaObject()->className(); |
3546 qDebug() << "HbStyle::polish : Polishing" << widget->metaObject()->className(); |
3769 #endif |
3547 #endif |
3770 |
3548 |
3771 HbLayeredStyleLoader *styleLoader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Layouts); |
3549 HbLayeredStyleLoader *styleLoader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Layouts); |
3772 if(!styleLoader){ |
3550 if(!styleLoader){ |
3773 #ifdef HBSTYLE_DEBUG |
3551 #ifdef HBSTYLE_DEBUG |
3774 qDebug() << "HbStyle::polish : HbLayeredStyleLoader returned a null pointer."; |
3552 qDebug() << "HbStyle::polish : HbLayeredStyleLoader returned a null pointer."; |
|
3553 qDebug() << "HbStyle::polish : -- -- -- -- EXIT"; |
3775 #endif |
3554 #endif |
3776 return; |
3555 return; |
3777 } |
3556 } |
3778 HbDeviceProfile profile(HbDeviceProfile::profile(widget)); |
3557 HbDeviceProfile profile(HbDeviceProfile::profile(widget)); |
3779 NODEPTR_N(widget); |
3558 NODEPTR_N(widget); |
3885 // twice for this item. |
3668 // twice for this item. |
3886 nodeIds.removeAll(name); |
3669 nodeIds.removeAll(name); |
3887 } |
3670 } |
3888 d->polishItem(styleRules, widget, item, name, profile, layoutDefined); |
3671 d->polishItem(styleRules, widget, item, name, profile, layoutDefined); |
3889 } |
3672 } |
3890 foreach (QString nodeId, nodeIds) { |
3673 foreach (const QString &nodeId, nodeIds) { |
3891 // These are the "missing" anchor items. Need to call polishItem |
3674 // These are the "missing" anchor items. Need to call polishItem |
3892 // for them, too, for getting the anchor spacings right. |
3675 // for them, too, for getting the anchor spacings right. |
3893 // if there are anchor node ids, layoutDefined is always true. |
3676 // if there are anchor node ids, layoutDefined is always true. |
3894 if ( !nodeId.isEmpty() ) { |
3677 if ( !nodeId.isEmpty() ) { |
3895 d->polishItem(styleRules, widget, 0, nodeId, profile, true); |
3678 d->polishItem(styleRules, widget, 0, nodeId, profile, true); |
3908 if ( d->mAutomaticTextMeasurementEnabled ) { |
3691 if ( d->mAutomaticTextMeasurementEnabled ) { |
3909 HbInstancePrivate::d_ptr()->startLocalizationMeasurement(); |
3692 HbInstancePrivate::d_ptr()->startLocalizationMeasurement(); |
3910 } |
3693 } |
3911 #endif // HB_TEXT_MEASUREMENT_UTILITY |
3694 #endif // HB_TEXT_MEASUREMENT_UTILITY |
3912 |
3695 |
|
3696 #ifdef HBSTYLE_DEBUG |
|
3697 qDebug() << "HbStyle::polish : -- -- -- -- EXIT"; |
|
3698 #endif |
3913 } |
3699 } |
3914 |
3700 |
3915 /*! |
3701 /*! |
3916 updateThemedItems updates themable children items of widget |
3702 updateThemedItems updates themable children items of widget |
3917 |
3703 |
3918 \param styleRules, style-rules of the widget |
3704 \param styleRules style-rules of the widget |
3919 \param variableRules, variable-rules of the widget |
3705 \param variableRules variable-rules of the widget |
3920 \param widget, widget whose themed parameters are supposed to be updated |
3706 \param widget widget whose themed parameters are supposed to be updated |
3921 \param item, graphics item whose themed parameters are supposed to be updated |
3707 \param item graphics item whose themed parameters are supposed to be updated |
3922 */ |
3708 */ |
3923 void HbStylePrivate::updateThemedItems( |
3709 void HbStylePrivate::updateThemedItems( |
3924 const HbVector<HbCss::StyleRule> &styleRules, |
3710 const HbVector<HbCss::StyleRule> &styleRules, |
3925 QGraphicsItem *item, |
3711 QGraphicsItem *item, |
3926 HbDeviceProfile &profile) const |
3712 HbDeviceProfile &profile) const |
4018 |
3804 |
4019 HbLayeredStyleLoader *styleLoader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors); |
3805 HbLayeredStyleLoader *styleLoader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors); |
4020 if(!styleLoader){ |
3806 if(!styleLoader){ |
4021 #ifdef HBSTYLE_DEBUG |
3807 #ifdef HBSTYLE_DEBUG |
4022 qDebug() << "HbStyle::updateThemedParams : HbLayeredStyleLoader returned a null pointer."; |
3808 qDebug() << "HbStyle::updateThemedParams : HbLayeredStyleLoader returned a null pointer."; |
|
3809 qDebug() << "HbStyle::updateThemedParams : -- -- -- -- EXIT"; |
4023 #endif |
3810 #endif |
4024 return; |
3811 return; |
4025 } |
3812 } |
4026 NODEPTR_N(widget); |
3813 NODEPTR_N(widget); |
4027 HbDeviceProfile profile(HbDeviceProfile::profile(widget)); |
3814 HbDeviceProfile profile(HbDeviceProfile::profile(widget)); |
4028 HbVector<HbCss::StyleRule> styleRules = styleLoader->styleRulesForNode(n, profile.orientation()); |
3815 HbVector<HbCss::StyleRule> styleRules = styleLoader->styleRulesForNode(n, profile.orientation()); |
4029 if (!styleRules.count()) { |
3816 if (!styleRules.count()) { |
4030 #ifdef HBSTYLE_DEBUG |
3817 #ifdef HBSTYLE_DEBUG |
4031 qDebug() << "HbStyle::updateThemedParams : No style rules found."; |
3818 qDebug() << "HbStyle::updateThemedParams : No style rules found."; |
|
3819 qDebug() << "HbStyle::updateThemedParams : -- -- -- -- EXIT"; |
4032 #endif |
3820 #endif |
4033 return; |
3821 return; |
4034 } |
3822 } |
4035 |
3823 |
4036 // update themed items |
3824 // update themed items |
4037 QList<QGraphicsItem*> list = widget->childItems(); |
3825 QList<QGraphicsItem*> list = widget->childItems(); |
4038 foreach (QGraphicsItem* item, list) { |
3826 foreach (QGraphicsItem* item, list) { |
4039 d->updateThemedItems(styleRules, item, profile); |
3827 d->updateThemedItems(styleRules, item, profile); |
4040 } |
3828 } |
|
3829 |
|
3830 #ifdef HBSTYLE_DEBUG |
|
3831 qDebug() << "HbStyle::updateThemedParams : -- -- -- -- EXIT"; |
|
3832 #endif |
4041 } |
3833 } |
4042 |
3834 |
4043 /*! |
3835 /*! |
4044 Checkes whether given widget has orienation specific style |
3836 Checkes whether given widget has orienation specific style |
4045 rules. This can be used for optimizing orientation switch. |
3837 rules. This can be used for optimizing orientation switch. |
4135 } |
3927 } |
4136 Q_D( const HbStyle ); |
3928 Q_D( const HbStyle ); |
4137 d->layoutParameters.init(effectiveProfile); |
3929 d->layoutParameters.init(effectiveProfile); |
4138 HbCss::ValueExtractor valueExtractor(effectiveProfile); |
3930 HbCss::ValueExtractor valueExtractor(effectiveProfile); |
4139 valueExtractor.setLayoutParameters(d->layoutParameters); |
3931 valueExtractor.setLayoutParameters(d->layoutParameters); |
4140 // todo: parsing variable/expression is done here so that there is no need to change API |
3932 |
4141 // also parameters method not changed (this change is done for docml/widgetml parsing) |
3933 if ( param.endsWith(QLatin1String(")")) && |
4142 if (param.startsWith(QLatin1String("var(")) && param.endsWith(QLatin1String(")"))) { |
3934 ( param.startsWith(QLatin1String("var(")) || |
4143 return valueExtractor.extractVariableValue(param.mid(4,param.length()-5), value); |
3935 param.startsWith(QLatin1String("-var(")) || |
4144 } else if (param.startsWith(QLatin1String("-var(")) && param.endsWith(QLatin1String(")"))) { |
3936 param.startsWith(QLatin1String("expr(")) || |
4145 bool retVal = valueExtractor.extractVariableValue(param.mid(5,param.length()-6), value); |
3937 param.startsWith(QLatin1String("-expr(")) ) ) { |
4146 value = -value; |
3938 // Expression parser can deal with "functions" |
4147 return retVal; |
3939 return valueExtractor.extractExpressionValue(param, value); |
4148 } else if (param.startsWith(QLatin1String("expr(")) && param.endsWith(QLatin1String(")"))) { |
3940 } |
4149 QString expressionString = param.mid(5,param.length()-6); |
|
4150 return valueExtractor.extractExpressionValue(expressionString, value); |
|
4151 } else if (param.startsWith(QLatin1String("-expr(")) && param.endsWith(QLatin1String(")"))) { |
|
4152 QString expressionString = param.mid(6,param.length()-7); |
|
4153 bool retVal = valueExtractor.extractExpressionValue(expressionString, value); |
|
4154 value = -value; |
|
4155 return retVal; |
|
4156 } |
|
4157 |
|
4158 return valueExtractor.extractVariableValue(param, value); |
3941 return valueExtractor.extractVariableValue(param, value); |
4159 } |
3942 } |
4160 |
3943 |
4161 bool HbStylePrivate::parameterFromHashValue(quint32 hashValue, qreal &value, const HbDeviceProfile &profile) const |
3944 bool HbStylePrivate::valueFromTokens(const QList<int> &tokens, qreal &value, const HbDeviceProfile &profile) const |
4162 { |
3945 { |
4163 HbDeviceProfile effectiveProfile = profile; |
3946 HbDeviceProfile effectiveProfile = profile; |
4164 if ( effectiveProfile.isNull() ) { |
3947 if ( effectiveProfile.isNull() ) { |
4165 effectiveProfile = HbDeviceProfile::current(); |
3948 effectiveProfile = HbDeviceProfile::current(); |
4166 } |
3949 } |
4167 layoutParameters.init(effectiveProfile); |
3950 layoutParameters.init(effectiveProfile); |
4168 HbCss::ValueExtractor valueExtractor(effectiveProfile); |
3951 HbCss::ValueExtractor valueExtractor(effectiveProfile); |
4169 valueExtractor.setLayoutParameters(layoutParameters); |
3952 valueExtractor.setLayoutParameters(layoutParameters); |
4170 return valueExtractor.extractVariableValue(hashValue, value); |
3953 return valueExtractor.extractExpressionValue(tokens, value); |
4171 } |
3954 } |
4172 |
3955 |
4173 |
3956 |
4174 /*! |
3957 /*! |
4175 Returns copy of all global style parameters. Both names and values |
3958 Returns copy of all global style parameters. Both names and values |