--- a/src/hbutils/document/hbdocumentloaderactions_p.cpp Fri Sep 17 08:32:10 2010 +0300
+++ b/src/hbutils/document/hbdocumentloaderactions_p.cpp Mon Oct 04 00:38:12 2010 +0300
@@ -46,7 +46,7 @@
#include <hbmenu.h>
#include <hbtoolbar.h>
#include <hbaction.h>
-
+#include <hbframeitem.h>
class AccessToMetadata : public QObject
{
@@ -314,16 +314,16 @@
qreal leftVal=0, topVal=0, rightVal=0, bottomVal=0;
bool ok = true;
- if (left.mType != HbXmlLengthValue::None) {
+ if (left.mValues.count()) {
ok &= toPixels(left, leftVal);
}
- if (top.mType != HbXmlLengthValue::None) {
+ if (top.mValues.count()) {
ok &= toPixels(top, topVal);
}
- if (right.mType != HbXmlLengthValue::None) {
+ if (right.mValues.count()) {
ok &= toPixels(right, rightVal);
}
- if (bottom.mType != HbXmlLengthValue::None) {
+ if (bottom.mValues.count()) {
ok &= toPixels(bottom, bottomVal);
}
if ( ok ) {
@@ -346,10 +346,10 @@
qreal hintWidthVal, hintHeightVal;
bool ok = true;
- if ( hintWidth.mType != HbXmlLengthValue::None ) {
+ if ( hintWidth.mValues.count() ) {
ok &= toPixels(hintWidth, hintWidthVal);
}
- if ( hintHeight.mType != HbXmlLengthValue::None ) {
+ if ( hintHeight.mValues.count() ) {
ok &= toPixels(hintHeight, hintHeightVal);
}
if (!ok) {
@@ -359,29 +359,29 @@
// TODO: Use set <Min/Pref/Max> Size if both declared. It's more efficient.
switch (hint) {
case Qt::MinimumSize:
- if ( hintWidth.mType != HbXmlLengthValue::None ) {
+ if ( hintWidth.mValues.count() ) {
widget->setMinimumWidth(hintWidthVal);
}
- if ( hintHeight.mType != HbXmlLengthValue::None ) {
+ if ( hintHeight.mValues.count() ) {
widget->setMinimumHeight(hintHeightVal);
}
break;
case Qt::PreferredSize:
- if ( hintWidth.mType != HbXmlLengthValue::None ) {
+ if ( hintWidth.mValues.count() ) {
widget->setPreferredWidth(hintWidthVal);
}
- if ( hintHeight.mType != HbXmlLengthValue::None ) {
+ if ( hintHeight.mValues.count() ) {
widget->setPreferredHeight(hintHeightVal);
}
break;
case Qt::MaximumSize:
- if ( hintWidth.mType != HbXmlLengthValue::None ) {
+ if ( hintWidth.mValues.count() ) {
widget->setMaximumWidth(hintWidthVal);
}
- if ( hintHeight.mType != HbXmlLengthValue::None ) {
+ if ( hintHeight.mValues.count() ) {
widget->setMaximumHeight(hintHeightVal);
}
break;
@@ -392,10 +392,10 @@
if (fixed) {
QSizePolicy policy = widget->sizePolicy();
- if ( hintWidth.mType != HbXmlLengthValue::None && hintWidthVal >= 0) {
+ if ( hintWidth.mValues.count() && hintWidthVal >= 0) {
policy.setHorizontalPolicy(QSizePolicy::Fixed);
}
- if ( hintHeight.mType != HbXmlLengthValue::None && hintHeightVal >= 0) {
+ if ( hintHeight.mValues.count() && hintHeightVal >= 0) {
policy.setVerticalPolicy(QSizePolicy::Fixed);
}
widget->setSizePolicy(policy);
@@ -422,6 +422,19 @@
return result;
}
+bool HbDocumentLoaderActions::setBackground( const QString &name, HbFrameDrawer::FrameType type )
+{
+ HbWidget *widget = qobject_cast<HbWidget*>(findFromStack());
+ if (!widget) {
+ HB_DOCUMENTLOADER_PRINT( QString( "Cannot set background for non-HbWidget" ) );
+ return false;
+ }
+ HbFrameItem *frame = new HbFrameItem(name, type, widget);
+ widget->setBackgroundItem(frame);
+
+ return true;
+}
+
bool HbDocumentLoaderActions::setSizePolicy(
QSizePolicy::Policy *horizontalPolicy,
QSizePolicy::Policy *verticalPolicy,
@@ -546,7 +559,7 @@
anchor = new HbAnchor( srcId, srcEdge, dstId, dstEdge );
}
- if ( minLength.mType != HbXmlLengthValue::None ) {
+ if ( minLength.mValues.count() ) {
qreal minVal(0);
if ( !toPixels(minLength, minVal) ) {
delete anchor;
@@ -556,21 +569,21 @@
}
}
- if ( prefLength.mType != HbXmlLengthValue::None ) {
+ if ( prefLength.mValues.count() ) {
qreal prefVal(0);
if ( !toPixels(prefLength, prefVal) ) {
delete anchor;
return false;
} else {
// if the expression resulted a negative result, we must reverse the direction
- if ( prefLength.mType == HbXmlLengthValue::Expression && prefVal < 0 && dir ) {
+ if ( prefVal < 0 && dir ) {
*dir = (*dir==HbAnchor::Positive) ? HbAnchor::Negative : HbAnchor::Positive;
}
anchor->setPreferredLength( qAbs(prefVal) );
}
}
- if ( maxLength.mType != HbXmlLengthValue::None ) {
+ if ( maxLength.mValues.count() ) {
qreal maxVal(0);
if ( !toPixels(maxLength, maxVal) ) {
delete anchor;
@@ -652,7 +665,7 @@
qreal spacingVal;
bool setSpacing(false);
- if (spacing.mType != HbXmlLengthValue::None) {
+ if (spacing.mValues.count()) {
if ( toPixels(spacing, spacingVal) ) {
setSpacing = true;
} else {
@@ -771,7 +784,7 @@
return false;
}
- if ( minHeight.mType != HbXmlLengthValue::None ) {
+ if ( minHeight.mValues.count() ) {
qreal minHeightVal;
if ( !toPixels(minHeight, minHeightVal) ) {
return false;
@@ -779,7 +792,7 @@
layout->setRowMinimumHeight( row, minHeightVal );
}
- if ( maxHeight.mType != HbXmlLengthValue::None ) {
+ if ( maxHeight.mValues.count() ) {
qreal maxHeightVal;
if ( !toPixels(maxHeight, maxHeightVal) ) {
return false;
@@ -787,7 +800,7 @@
layout->setRowMaximumHeight( row, maxHeightVal );
}
- if ( prefHeight.mType != HbXmlLengthValue::None ) {
+ if ( prefHeight.mValues.count() ) {
qreal prefHeightVal;
if ( !toPixels(prefHeight, prefHeightVal) ) {
return false;
@@ -795,7 +808,7 @@
layout->setRowPreferredHeight( row, prefHeightVal );
}
- if ( fixedHeight.mType != HbXmlLengthValue::None ) {
+ if ( fixedHeight.mValues.count() ) {
qreal fixedHeightVal;
if ( !toPixels(fixedHeight, fixedHeightVal) ) {
return false;
@@ -803,7 +816,7 @@
layout->setRowFixedHeight( row, fixedHeightVal );
}
- if ( rowSpacing.mType != HbXmlLengthValue::None ) {
+ if ( rowSpacing.mValues.count() ) {
qreal rowSpacingVal;
if ( !toPixels(rowSpacing, rowSpacingVal) ) {
return false;
@@ -829,7 +842,7 @@
return false;
}
- if ( minWidth.mType != HbXmlLengthValue::None ) {
+ if ( minWidth.mValues.count() ) {
qreal minWidthVal;
if ( !toPixels(minWidth, minWidthVal) ) {
return false;
@@ -837,7 +850,7 @@
layout->setColumnMinimumWidth( column, minWidthVal );
}
- if ( maxWidth.mType != HbXmlLengthValue::None ) {
+ if ( maxWidth.mValues.count() ) {
qreal maxWidthVal;
if ( !toPixels(maxWidth, maxWidthVal) ) {
return false;
@@ -845,7 +858,7 @@
layout->setColumnMaximumWidth( column, maxWidthVal );
}
- if ( prefWidth.mType != HbXmlLengthValue::None ) {
+ if ( prefWidth.mValues.count() ) {
qreal prefWidthVal;
if ( !toPixels(prefWidth, prefWidthVal) ) {
return false;
@@ -853,7 +866,7 @@
layout->setColumnPreferredWidth( column, prefWidthVal );
}
- if ( fixedWidth.mType != HbXmlLengthValue::None ) {
+ if ( fixedWidth.mValues.count() ) {
qreal fixedWidthVal;
if ( !toPixels(fixedWidth, fixedWidthVal) ) {
return false;
@@ -861,7 +874,7 @@
layout->setColumnFixedWidth( column, fixedWidthVal );
}
- if ( columnSpacing.mType != HbXmlLengthValue::None ) {
+ if ( columnSpacing.mValues.count() ) {
qreal columnSpacingVal;
if ( !toPixels(columnSpacing, columnSpacingVal) ) {
return false;
@@ -897,7 +910,7 @@
qreal spacingVal;
bool setSpacing(false);
- if (spacing.mType != HbXmlLengthValue::None) {
+ if (spacing.mValues.count()) {
if ( toPixels(spacing, spacingVal) ) {
setSpacing = true;
} else {
@@ -958,7 +971,7 @@
int indexValue = index ? *index : -1;
layout->insertItem( indexValue, item );
- if ( spacing.mType != HbXmlLengthValue::None ) {
+ if ( spacing.mValues.count() ) {
qreal spacingVal;
if ( !toPixels(spacing, spacingVal) ) {
return false;
@@ -1016,16 +1029,16 @@
qreal leftVal=0, topVal=0, rightVal=0, bottomVal=0;
bool ok = true;
- if (left.mType != HbXmlLengthValue::None) {
+ if (left.mValues.count()) {
ok &= toPixels(left, leftVal);
}
- if (top.mType != HbXmlLengthValue::None) {
+ if (top.mValues.count()) {
ok &= toPixels(top, topVal);
}
- if (right.mType != HbXmlLengthValue::None) {
+ if (right.mValues.count()) {
ok &= toPixels(right, rightVal);
}
- if (bottom.mType != HbXmlLengthValue::None) {
+ if (bottom.mValues.count()) {
ok &= toPixels(bottom, bottomVal);
}
if ( ok ) {
@@ -1200,19 +1213,19 @@
HbIcon icon(*iconName);
qreal width, height;
- if ( widthVal->mType != HbXmlLengthValue::None ) {
+ if ( widthVal->mValues.count() ) {
result = toPixels(*widthVal, width);
}
- if ( result && heightVal->mType != HbXmlLengthValue::None ) {
+ if ( result && heightVal->mValues.count() ) {
result = toPixels(*heightVal, height);
}
if ( result ) {
- if ( widthVal->mType != HbXmlLengthValue::None &&
- heightVal->mType != HbXmlLengthValue::None ) {
+ if ( widthVal->mValues.count() &&
+ heightVal->mValues.count() ) {
icon.setSize(QSizeF(width, height));
- } else if ( widthVal->mType != HbXmlLengthValue::None ) {
+ } else if ( widthVal->mValues.count() ) {
icon.setWidth(width);
- } else if ( heightVal->mType != HbXmlLengthValue::None ) {
+ } else if ( heightVal->mValues.count() ) {
icon.setHeight(height);
}
variant.setValue( icon );
@@ -1283,12 +1296,12 @@
quint8* role_b = (quint8*)variable.mParameters.at(0);
HbXmlLengthValue* textHeightVal = (HbXmlLengthValue*)variable.mParameters.at(1);
qreal textHeight;
- if ( textHeightVal->mType != HbXmlLengthValue::None ) {
+ if ( textHeightVal->mValues.count() ) {
result = toPixels(*textHeightVal, textHeight);
}
if (result) {
HbFontSpec fontSpec((HbFontSpec::Role)(*role_b));
- if ( textHeightVal->mType != HbXmlLengthValue::None ) {
+ if ( textHeightVal->mValues.count() ) {
fontSpec.setTextHeight(textHeight);
}
variant.setValue(fontSpec);