312 } |
312 } |
313 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(obj); |
313 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(obj); |
314 |
314 |
315 qreal leftVal=0, topVal=0, rightVal=0, bottomVal=0; |
315 qreal leftVal=0, topVal=0, rightVal=0, bottomVal=0; |
316 bool ok = true; |
316 bool ok = true; |
317 if (left.mType != HbXmlLengthValue::None) { |
317 if (left.mValues.count()) { |
318 ok &= toPixels(left, leftVal); |
318 ok &= toPixels(left, leftVal); |
319 } |
319 } |
320 if (top.mType != HbXmlLengthValue::None) { |
320 if (top.mValues.count()) { |
321 ok &= toPixels(top, topVal); |
321 ok &= toPixels(top, topVal); |
322 } |
322 } |
323 if (right.mType != HbXmlLengthValue::None) { |
323 if (right.mValues.count()) { |
324 ok &= toPixels(right, rightVal); |
324 ok &= toPixels(right, rightVal); |
325 } |
325 } |
326 if (bottom.mType != HbXmlLengthValue::None) { |
326 if (bottom.mValues.count()) { |
327 ok &= toPixels(bottom, bottomVal); |
327 ok &= toPixels(bottom, bottomVal); |
328 } |
328 } |
329 if ( ok ) { |
329 if ( ok ) { |
330 widget->setContentsMargins( leftVal, topVal, rightVal, bottomVal ); |
330 widget->setContentsMargins( leftVal, topVal, rightVal, bottomVal ); |
331 } |
331 } |
344 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(obj); |
344 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(obj); |
345 |
345 |
346 qreal hintWidthVal, hintHeightVal; |
346 qreal hintWidthVal, hintHeightVal; |
347 |
347 |
348 bool ok = true; |
348 bool ok = true; |
349 if ( hintWidth.mType != HbXmlLengthValue::None ) { |
349 if ( hintWidth.mValues.count() ) { |
350 ok &= toPixels(hintWidth, hintWidthVal); |
350 ok &= toPixels(hintWidth, hintWidthVal); |
351 } |
351 } |
352 if ( hintHeight.mType != HbXmlLengthValue::None ) { |
352 if ( hintHeight.mValues.count() ) { |
353 ok &= toPixels(hintHeight, hintHeightVal); |
353 ok &= toPixels(hintHeight, hintHeightVal); |
354 } |
354 } |
355 if (!ok) { |
355 if (!ok) { |
356 return false; |
356 return false; |
357 } |
357 } |
358 |
358 |
359 // TODO: Use set <Min/Pref/Max> Size if both declared. It's more efficient. |
359 // TODO: Use set <Min/Pref/Max> Size if both declared. It's more efficient. |
360 switch (hint) { |
360 switch (hint) { |
361 case Qt::MinimumSize: |
361 case Qt::MinimumSize: |
362 if ( hintWidth.mType != HbXmlLengthValue::None ) { |
362 if ( hintWidth.mValues.count() ) { |
363 |
363 |
364 widget->setMinimumWidth(hintWidthVal); |
364 widget->setMinimumWidth(hintWidthVal); |
365 } |
365 } |
366 if ( hintHeight.mType != HbXmlLengthValue::None ) { |
366 if ( hintHeight.mValues.count() ) { |
367 widget->setMinimumHeight(hintHeightVal); |
367 widget->setMinimumHeight(hintHeightVal); |
368 } |
368 } |
369 break; |
369 break; |
370 |
370 |
371 case Qt::PreferredSize: |
371 case Qt::PreferredSize: |
372 if ( hintWidth.mType != HbXmlLengthValue::None ) { |
372 if ( hintWidth.mValues.count() ) { |
373 widget->setPreferredWidth(hintWidthVal); |
373 widget->setPreferredWidth(hintWidthVal); |
374 } |
374 } |
375 if ( hintHeight.mType != HbXmlLengthValue::None ) { |
375 if ( hintHeight.mValues.count() ) { |
376 widget->setPreferredHeight(hintHeightVal); |
376 widget->setPreferredHeight(hintHeightVal); |
377 } |
377 } |
378 break; |
378 break; |
379 |
379 |
380 case Qt::MaximumSize: |
380 case Qt::MaximumSize: |
381 if ( hintWidth.mType != HbXmlLengthValue::None ) { |
381 if ( hintWidth.mValues.count() ) { |
382 widget->setMaximumWidth(hintWidthVal); |
382 widget->setMaximumWidth(hintWidthVal); |
383 } |
383 } |
384 if ( hintHeight.mType != HbXmlLengthValue::None ) { |
384 if ( hintHeight.mValues.count() ) { |
385 widget->setMaximumHeight(hintHeightVal); |
385 widget->setMaximumHeight(hintHeightVal); |
386 } |
386 } |
387 break; |
387 break; |
388 |
388 |
389 default: |
389 default: |
390 break; |
390 break; |
391 } |
391 } |
392 |
392 |
393 if (fixed) { |
393 if (fixed) { |
394 QSizePolicy policy = widget->sizePolicy(); |
394 QSizePolicy policy = widget->sizePolicy(); |
395 if ( hintWidth.mType != HbXmlLengthValue::None && hintWidthVal >= 0) { |
395 if ( hintWidth.mValues.count() && hintWidthVal >= 0) { |
396 policy.setHorizontalPolicy(QSizePolicy::Fixed); |
396 policy.setHorizontalPolicy(QSizePolicy::Fixed); |
397 } |
397 } |
398 if ( hintHeight.mType != HbXmlLengthValue::None && hintHeightVal >= 0) { |
398 if ( hintHeight.mValues.count() && hintHeightVal >= 0) { |
399 policy.setVerticalPolicy(QSizePolicy::Fixed); |
399 policy.setVerticalPolicy(QSizePolicy::Fixed); |
400 } |
400 } |
401 widget->setSizePolicy(policy); |
401 widget->setSizePolicy(policy); |
402 } |
402 } |
403 |
403 |
418 bool result = variableToQVariant( tooltip, variant ); |
418 bool result = variableToQVariant( tooltip, variant ); |
419 if ( result ) { |
419 if ( result ) { |
420 widget->setToolTip( variant.toString() ); |
420 widget->setToolTip( variant.toString() ); |
421 } |
421 } |
422 return result; |
422 return result; |
|
423 } |
|
424 |
|
425 bool HbDocumentLoaderActions::setBackground( const QString &name, HbFrameDrawer::FrameType type ) |
|
426 { |
|
427 HbWidget *widget = qobject_cast<HbWidget*>(findFromStack()); |
|
428 if (!widget) { |
|
429 HB_DOCUMENTLOADER_PRINT( QString( "Cannot set background for non-HbWidget" ) ); |
|
430 return false; |
|
431 } |
|
432 HbFrameItem *frame = new HbFrameItem(name, type, widget); |
|
433 widget->setBackgroundItem(frame); |
|
434 |
|
435 return true; |
423 } |
436 } |
424 |
437 |
425 bool HbDocumentLoaderActions::setSizePolicy( |
438 bool HbDocumentLoaderActions::setSizePolicy( |
426 QSizePolicy::Policy *horizontalPolicy, |
439 QSizePolicy::Policy *horizontalPolicy, |
427 QSizePolicy::Policy *verticalPolicy, |
440 QSizePolicy::Policy *verticalPolicy, |
544 anchor = new HbAnchor( srcId, srcEdge, item2, dstEdge ); |
557 anchor = new HbAnchor( srcId, srcEdge, item2, dstEdge ); |
545 } else { |
558 } else { |
546 anchor = new HbAnchor( srcId, srcEdge, dstId, dstEdge ); |
559 anchor = new HbAnchor( srcId, srcEdge, dstId, dstEdge ); |
547 } |
560 } |
548 |
561 |
549 if ( minLength.mType != HbXmlLengthValue::None ) { |
562 if ( minLength.mValues.count() ) { |
550 qreal minVal(0); |
563 qreal minVal(0); |
551 if ( !toPixels(minLength, minVal) ) { |
564 if ( !toPixels(minLength, minVal) ) { |
552 delete anchor; |
565 delete anchor; |
553 return false; |
566 return false; |
554 } else { |
567 } else { |
555 anchor->setMinimumLength( minVal ); |
568 anchor->setMinimumLength( minVal ); |
556 } |
569 } |
557 } |
570 } |
558 |
571 |
559 if ( prefLength.mType != HbXmlLengthValue::None ) { |
572 if ( prefLength.mValues.count() ) { |
560 qreal prefVal(0); |
573 qreal prefVal(0); |
561 if ( !toPixels(prefLength, prefVal) ) { |
574 if ( !toPixels(prefLength, prefVal) ) { |
562 delete anchor; |
575 delete anchor; |
563 return false; |
576 return false; |
564 } else { |
577 } else { |
565 // if the expression resulted a negative result, we must reverse the direction |
578 // if the expression resulted a negative result, we must reverse the direction |
566 if ( prefLength.mType == HbXmlLengthValue::Expression && prefVal < 0 && dir ) { |
579 if ( prefVal < 0 && dir ) { |
567 *dir = (*dir==HbAnchor::Positive) ? HbAnchor::Negative : HbAnchor::Positive; |
580 *dir = (*dir==HbAnchor::Positive) ? HbAnchor::Negative : HbAnchor::Positive; |
568 } |
581 } |
569 anchor->setPreferredLength( qAbs(prefVal) ); |
582 anchor->setPreferredLength( qAbs(prefVal) ); |
570 } |
583 } |
571 } |
584 } |
572 |
585 |
573 if ( maxLength.mType != HbXmlLengthValue::None ) { |
586 if ( maxLength.mValues.count() ) { |
574 qreal maxVal(0); |
587 qreal maxVal(0); |
575 if ( !toPixels(maxLength, maxVal) ) { |
588 if ( !toPixels(maxLength, maxVal) ) { |
576 delete anchor; |
589 delete anchor; |
577 return false; |
590 return false; |
578 } else { |
591 } else { |
769 if( !layout ) { |
782 if( !layout ) { |
770 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
783 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
771 return false; |
784 return false; |
772 } |
785 } |
773 |
786 |
774 if ( minHeight.mType != HbXmlLengthValue::None ) { |
787 if ( minHeight.mValues.count() ) { |
775 qreal minHeightVal; |
788 qreal minHeightVal; |
776 if ( !toPixels(minHeight, minHeightVal) ) { |
789 if ( !toPixels(minHeight, minHeightVal) ) { |
777 return false; |
790 return false; |
778 } |
791 } |
779 layout->setRowMinimumHeight( row, minHeightVal ); |
792 layout->setRowMinimumHeight( row, minHeightVal ); |
780 } |
793 } |
781 |
794 |
782 if ( maxHeight.mType != HbXmlLengthValue::None ) { |
795 if ( maxHeight.mValues.count() ) { |
783 qreal maxHeightVal; |
796 qreal maxHeightVal; |
784 if ( !toPixels(maxHeight, maxHeightVal) ) { |
797 if ( !toPixels(maxHeight, maxHeightVal) ) { |
785 return false; |
798 return false; |
786 } |
799 } |
787 layout->setRowMaximumHeight( row, maxHeightVal ); |
800 layout->setRowMaximumHeight( row, maxHeightVal ); |
788 } |
801 } |
789 |
802 |
790 if ( prefHeight.mType != HbXmlLengthValue::None ) { |
803 if ( prefHeight.mValues.count() ) { |
791 qreal prefHeightVal; |
804 qreal prefHeightVal; |
792 if ( !toPixels(prefHeight, prefHeightVal) ) { |
805 if ( !toPixels(prefHeight, prefHeightVal) ) { |
793 return false; |
806 return false; |
794 } |
807 } |
795 layout->setRowPreferredHeight( row, prefHeightVal ); |
808 layout->setRowPreferredHeight( row, prefHeightVal ); |
796 } |
809 } |
797 |
810 |
798 if ( fixedHeight.mType != HbXmlLengthValue::None ) { |
811 if ( fixedHeight.mValues.count() ) { |
799 qreal fixedHeightVal; |
812 qreal fixedHeightVal; |
800 if ( !toPixels(fixedHeight, fixedHeightVal) ) { |
813 if ( !toPixels(fixedHeight, fixedHeightVal) ) { |
801 return false; |
814 return false; |
802 } |
815 } |
803 layout->setRowFixedHeight( row, fixedHeightVal ); |
816 layout->setRowFixedHeight( row, fixedHeightVal ); |
804 } |
817 } |
805 |
818 |
806 if ( rowSpacing.mType != HbXmlLengthValue::None ) { |
819 if ( rowSpacing.mValues.count() ) { |
807 qreal rowSpacingVal; |
820 qreal rowSpacingVal; |
808 if ( !toPixels(rowSpacing, rowSpacingVal) ) { |
821 if ( !toPixels(rowSpacing, rowSpacingVal) ) { |
809 return false; |
822 return false; |
810 } |
823 } |
811 layout->setRowSpacing( row, rowSpacingVal ); |
824 layout->setRowSpacing( row, rowSpacingVal ); |
827 if( !layout ) { |
840 if( !layout ) { |
828 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
841 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
829 return false; |
842 return false; |
830 } |
843 } |
831 |
844 |
832 if ( minWidth.mType != HbXmlLengthValue::None ) { |
845 if ( minWidth.mValues.count() ) { |
833 qreal minWidthVal; |
846 qreal minWidthVal; |
834 if ( !toPixels(minWidth, minWidthVal) ) { |
847 if ( !toPixels(minWidth, minWidthVal) ) { |
835 return false; |
848 return false; |
836 } |
849 } |
837 layout->setColumnMinimumWidth( column, minWidthVal ); |
850 layout->setColumnMinimumWidth( column, minWidthVal ); |
838 } |
851 } |
839 |
852 |
840 if ( maxWidth.mType != HbXmlLengthValue::None ) { |
853 if ( maxWidth.mValues.count() ) { |
841 qreal maxWidthVal; |
854 qreal maxWidthVal; |
842 if ( !toPixels(maxWidth, maxWidthVal) ) { |
855 if ( !toPixels(maxWidth, maxWidthVal) ) { |
843 return false; |
856 return false; |
844 } |
857 } |
845 layout->setColumnMaximumWidth( column, maxWidthVal ); |
858 layout->setColumnMaximumWidth( column, maxWidthVal ); |
846 } |
859 } |
847 |
860 |
848 if ( prefWidth.mType != HbXmlLengthValue::None ) { |
861 if ( prefWidth.mValues.count() ) { |
849 qreal prefWidthVal; |
862 qreal prefWidthVal; |
850 if ( !toPixels(prefWidth, prefWidthVal) ) { |
863 if ( !toPixels(prefWidth, prefWidthVal) ) { |
851 return false; |
864 return false; |
852 } |
865 } |
853 layout->setColumnPreferredWidth( column, prefWidthVal ); |
866 layout->setColumnPreferredWidth( column, prefWidthVal ); |
854 } |
867 } |
855 |
868 |
856 if ( fixedWidth.mType != HbXmlLengthValue::None ) { |
869 if ( fixedWidth.mValues.count() ) { |
857 qreal fixedWidthVal; |
870 qreal fixedWidthVal; |
858 if ( !toPixels(fixedWidth, fixedWidthVal) ) { |
871 if ( !toPixels(fixedWidth, fixedWidthVal) ) { |
859 return false; |
872 return false; |
860 } |
873 } |
861 layout->setColumnFixedWidth( column, fixedWidthVal ); |
874 layout->setColumnFixedWidth( column, fixedWidthVal ); |
862 } |
875 } |
863 |
876 |
864 if ( columnSpacing.mType != HbXmlLengthValue::None ) { |
877 if ( columnSpacing.mValues.count() ) { |
865 qreal columnSpacingVal; |
878 qreal columnSpacingVal; |
866 if ( !toPixels(columnSpacing, columnSpacingVal) ) { |
879 if ( !toPixels(columnSpacing, columnSpacingVal) ) { |
867 return false; |
880 return false; |
868 } |
881 } |
869 layout->setColumnSpacing( column, columnSpacingVal ); |
882 layout->setColumnSpacing( column, columnSpacingVal ); |
1014 return false; |
1027 return false; |
1015 } |
1028 } |
1016 |
1029 |
1017 qreal leftVal=0, topVal=0, rightVal=0, bottomVal=0; |
1030 qreal leftVal=0, topVal=0, rightVal=0, bottomVal=0; |
1018 bool ok = true; |
1031 bool ok = true; |
1019 if (left.mType != HbXmlLengthValue::None) { |
1032 if (left.mValues.count()) { |
1020 ok &= toPixels(left, leftVal); |
1033 ok &= toPixels(left, leftVal); |
1021 } |
1034 } |
1022 if (top.mType != HbXmlLengthValue::None) { |
1035 if (top.mValues.count()) { |
1023 ok &= toPixels(top, topVal); |
1036 ok &= toPixels(top, topVal); |
1024 } |
1037 } |
1025 if (right.mType != HbXmlLengthValue::None) { |
1038 if (right.mValues.count()) { |
1026 ok &= toPixels(right, rightVal); |
1039 ok &= toPixels(right, rightVal); |
1027 } |
1040 } |
1028 if (bottom.mType != HbXmlLengthValue::None) { |
1041 if (bottom.mValues.count()) { |
1029 ok &= toPixels(bottom, bottomVal); |
1042 ok &= toPixels(bottom, bottomVal); |
1030 } |
1043 } |
1031 if ( ok ) { |
1044 if ( ok ) { |
1032 mCurrentLayout->setContentsMargins( leftVal, topVal, rightVal, bottomVal ); |
1045 mCurrentLayout->setContentsMargins( leftVal, topVal, rightVal, bottomVal ); |
1033 } |
1046 } |
1198 HbXmlLengthValue* widthVal = (HbXmlLengthValue*)variable.mParameters.at(1); |
1211 HbXmlLengthValue* widthVal = (HbXmlLengthValue*)variable.mParameters.at(1); |
1199 HbXmlLengthValue* heightVal = (HbXmlLengthValue*)variable.mParameters.at(2); |
1212 HbXmlLengthValue* heightVal = (HbXmlLengthValue*)variable.mParameters.at(2); |
1200 |
1213 |
1201 HbIcon icon(*iconName); |
1214 HbIcon icon(*iconName); |
1202 qreal width, height; |
1215 qreal width, height; |
1203 if ( widthVal->mType != HbXmlLengthValue::None ) { |
1216 if ( widthVal->mValues.count() ) { |
1204 result = toPixels(*widthVal, width); |
1217 result = toPixels(*widthVal, width); |
1205 } |
1218 } |
1206 if ( result && heightVal->mType != HbXmlLengthValue::None ) { |
1219 if ( result && heightVal->mValues.count() ) { |
1207 result = toPixels(*heightVal, height); |
1220 result = toPixels(*heightVal, height); |
1208 } |
1221 } |
1209 if ( result ) { |
1222 if ( result ) { |
1210 if ( widthVal->mType != HbXmlLengthValue::None && |
1223 if ( widthVal->mValues.count() && |
1211 heightVal->mType != HbXmlLengthValue::None ) { |
1224 heightVal->mValues.count() ) { |
1212 icon.setSize(QSizeF(width, height)); |
1225 icon.setSize(QSizeF(width, height)); |
1213 } else if ( widthVal->mType != HbXmlLengthValue::None ) { |
1226 } else if ( widthVal->mValues.count() ) { |
1214 icon.setWidth(width); |
1227 icon.setWidth(width); |
1215 } else if ( heightVal->mType != HbXmlLengthValue::None ) { |
1228 } else if ( heightVal->mValues.count() ) { |
1216 icon.setHeight(height); |
1229 icon.setHeight(height); |
1217 } |
1230 } |
1218 variant.setValue( icon ); |
1231 variant.setValue( icon ); |
1219 } |
1232 } |
1220 break; |
1233 break; |
1281 case HbXmlVariable::FONTSPEC: |
1294 case HbXmlVariable::FONTSPEC: |
1282 { |
1295 { |
1283 quint8* role_b = (quint8*)variable.mParameters.at(0); |
1296 quint8* role_b = (quint8*)variable.mParameters.at(0); |
1284 HbXmlLengthValue* textHeightVal = (HbXmlLengthValue*)variable.mParameters.at(1); |
1297 HbXmlLengthValue* textHeightVal = (HbXmlLengthValue*)variable.mParameters.at(1); |
1285 qreal textHeight; |
1298 qreal textHeight; |
1286 if ( textHeightVal->mType != HbXmlLengthValue::None ) { |
1299 if ( textHeightVal->mValues.count() ) { |
1287 result = toPixels(*textHeightVal, textHeight); |
1300 result = toPixels(*textHeightVal, textHeight); |
1288 } |
1301 } |
1289 if (result) { |
1302 if (result) { |
1290 HbFontSpec fontSpec((HbFontSpec::Role)(*role_b)); |
1303 HbFontSpec fontSpec((HbFontSpec::Role)(*role_b)); |
1291 if ( textHeightVal->mType != HbXmlLengthValue::None ) { |
1304 if ( textHeightVal->mValues.count() ) { |
1292 fontSpec.setTextHeight(textHeight); |
1305 fontSpec.setTextHeight(textHeight); |
1293 } |
1306 } |
1294 variant.setValue(fontSpec); |
1307 variant.setValue(fontSpec); |
1295 } |
1308 } |
1296 break; |
1309 break; |