191 if ( !current ) { |
207 if ( !current ) { |
192 current = static_cast<HbWidgetPrivate*>(HbWidgetBasePrivate::d_ptr(parent))->createSpacerItem(name); |
208 current = static_cast<HbWidgetPrivate*>(HbWidgetBasePrivate::d_ptr(parent))->createSpacerItem(name); |
193 } |
209 } |
194 |
210 |
195 // add it onto stack for further processing |
211 // add it onto stack for further processing |
196 Element e; |
212 HbXml::Element e; |
197 e.type = SPACERITEM; |
213 e.type = HbXml::SPACERITEM; |
198 e.data = current; |
214 e.data = current; |
199 mStack.append( e ); |
215 mStack.append( e ); |
200 HB_DOCUMENTLOADER_PRINT( QString( "ADD ELEMENT " ) + name ); |
216 HB_DOCUMENTLOADER_PRINT( QString( "ADD ELEMENT " ) + name ); |
201 |
217 |
202 return true; |
218 return true; |
203 |
219 |
204 } |
220 } |
205 |
221 |
206 bool HbDocumentLoaderActions::pushConnect( const QString &srcName, const QString &signalName, |
222 bool HbDocumentLoaderActions::pushConnect( const QString &srcName, const QString &signalName, |
207 const QString &dstName, const QString &slotName ) |
223 const QString &dstName, const QString &slotName ) |
208 { |
224 { |
209 if( srcName.isEmpty() || signalName.isEmpty() || dstName.isEmpty() || slotName.isEmpty() ) { |
225 if( srcName.isEmpty() || signalName.isEmpty() || dstName.isEmpty() || slotName.isEmpty() ) { |
210 HB_DOCUMENTLOADER_PRINT( QString( "Wrong parameters for signal/slot connection" ) ); |
226 HB_DOCUMENTLOADER_PRINT( QString( "Wrong parameters for signal/slot connection" ) ); |
211 return false; |
227 return false; |
212 } |
228 } |
213 |
229 |
214 if( ! mObjectMap.contains( srcName ) ) { |
230 if( ! mObjectMap.contains( srcName ) ) { |
215 HB_DOCUMENTLOADER_PRINT( QString( "Unable to establish signal/slot connection, no instance with name " ) + srcName ); |
231 HB_DOCUMENTLOADER_PRINT( QString( "Unable to establish signal/slot connection, no instance with name " ) + srcName ); |
216 return false; |
232 return false; |
217 } |
233 } |
218 if( ! mObjectMap.contains( dstName ) ) { |
234 if( ! mObjectMap.contains( dstName ) ) { |
219 HB_DOCUMENTLOADER_PRINT( QString( "Unable to establish signal/slot connection, no instance with name " ) + dstName ); |
235 HB_DOCUMENTLOADER_PRINT( QString( "Unable to establish signal/slot connection, no instance with name " ) + dstName ); |
220 return false; |
236 return false; |
221 } |
237 } |
222 |
238 |
223 QObject *src = mObjectMap[ srcName ]; |
239 QObject *src = mObjectMap[ srcName ].first; |
224 |
240 |
225 if( !src ) { |
241 if( !src ) { |
226 HB_DOCUMENTLOADER_PRINT( QString( "Unable to establish signal/slot connection, already destroyed " ) + srcName ); |
242 HB_DOCUMENTLOADER_PRINT( QString( "Unable to establish signal/slot connection, already destroyed " ) + srcName ); |
227 return false; |
243 return false; |
228 } |
244 } |
229 |
245 |
230 QObject *dst = mObjectMap[ dstName ]; |
246 QObject *dst = mObjectMap[ dstName ].first; |
231 |
247 |
232 if( !dst ) { |
248 if( !dst ) { |
233 HB_DOCUMENTLOADER_PRINT( QString( "Unable to establish signal/slot connection, already destroyed " ) + dstName ); |
249 HB_DOCUMENTLOADER_PRINT( QString( "Unable to establish signal/slot connection, already destroyed " ) + dstName ); |
234 return false; |
250 return false; |
235 } |
251 } |
236 |
252 |
237 const QMetaObject *msrc = src->metaObject(); |
253 const QMetaObject *msrc = src->metaObject(); |
238 const QMetaObject *mdst = dst->metaObject(); |
254 const QMetaObject *mdst = dst->metaObject(); |
239 |
255 |
240 int signalIndex = msrc->indexOfSignal( QMetaObject::normalizedSignature( signalName.toLatin1() ) ); |
256 int signalIndex = msrc->indexOfSignal( QMetaObject::normalizedSignature( signalName.toLatin1() ) ); |
241 int slotIndex = mdst->indexOfSlot( QMetaObject::normalizedSignature( slotName.toLatin1() ) ); |
257 int slotIndex = mdst->indexOfSlot( QMetaObject::normalizedSignature( slotName.toLatin1() ) ); |
242 |
258 |
243 if( signalIndex == -1 ) { |
259 if( signalIndex == -1 ) { |
244 HB_DOCUMENTLOADER_PRINT( QString( "Unable to establish signal/slot connection, no such signal " ) + signalName ); |
260 HB_DOCUMENTLOADER_PRINT( QString( "Unable to establish signal/slot connection, no such signal " ) + signalName ); |
245 return false; |
261 return false; |
246 } |
262 } |
247 |
263 |
248 if( slotIndex == -1 ) { |
264 if( slotIndex == -1 ) { |
249 HB_DOCUMENTLOADER_PRINT( QString( "Unable to establish signal/slot connection, no such slot " ) + slotName ); |
265 HB_DOCUMENTLOADER_PRINT( QString( "Unable to establish signal/slot connection, no such slot " ) + slotName ); |
250 return false; |
266 return false; |
251 } |
267 } |
252 |
268 |
253 QMetaObject::connect(src, signalIndex, dst, slotIndex ); |
269 QMetaObject::connect(src, signalIndex, dst, slotIndex ); |
254 |
270 |
255 return true; |
271 return true; |
256 } |
272 } |
257 |
273 |
258 bool HbDocumentLoaderActions::pushProperty( const QString &propertyName, const QVariant &value ) |
274 bool HbDocumentLoaderActions::pushProperty( const char *propertyName, const HbXmlVariable &variable ) |
259 { |
275 { |
260 QObject *current = findFromStack(); |
276 QObject *current = findFromStack(); |
261 |
277 |
262 if( current == 0 ) { |
278 if( current == 0 ) { |
263 HB_DOCUMENTLOADER_PRINT( QString( "Unable to set property " ) + propertyName ); |
279 HB_DOCUMENTLOADER_PRINT( QString( "Unable to set property " ) + propertyName ); |
264 return false; |
280 return false; |
265 } |
281 } |
266 |
282 |
267 |
283 QVariant value; |
268 if( propertyName.isEmpty() ) { |
284 bool ok = variableToQVariant(variable, value); |
269 HB_DOCUMENTLOADER_PRINT( QString( "No property name for " ) + propertyName ); |
285 if (ok) { |
270 return false; |
286 current->setProperty( propertyName, value ); |
271 } |
287 } |
272 |
288 return ok; |
273 QByteArray asLatin1 = propertyName.toLatin1(); |
|
274 current->setProperty( asLatin1, value ); |
|
275 return true; |
|
276 } |
289 } |
277 |
290 |
278 bool HbDocumentLoaderActions::pushRef( const QString &name, const QString &role ) |
291 bool HbDocumentLoaderActions::pushRef( const QString &name, const QString &role ) |
279 { |
292 { |
280 QObject *current = findFromStack(); |
293 QObject *current = findFromStack(); |
281 QObject *ref = mObjectMap[ name ].data(); |
294 QObject *ref = mObjectMap[ name ].first.data(); |
282 |
295 |
283 if( ( current == 0 ) || ( ref == 0 ) ) { |
296 if( ( current == 0 ) || ( ref == 0 ) ) { |
284 HB_DOCUMENTLOADER_PRINT( QString( "Wrong role name or role context" ) ); |
297 HB_DOCUMENTLOADER_PRINT( QString( "Wrong role name or role context" ) ); |
285 return false; |
298 return false; |
286 } |
299 } |
287 |
300 |
288 if ( !setObjectRole(current, ref, role)) { |
301 if ( !setObjectRole(current, ref, role)) { |
289 HB_DOCUMENTLOADER_PRINT( QString( "Unable to set role" ) ); |
302 HB_DOCUMENTLOADER_PRINT( QString( "Unable to set role" ) ); |
290 return false; |
303 return false; |
291 } |
304 } |
292 return true; |
305 return true; |
293 } |
306 } |
294 |
307 |
295 bool HbDocumentLoaderActions::setContentsMargins( qreal left, qreal top, qreal right, qreal bottom ) |
308 bool HbDocumentLoaderActions::pushContainer( const char *propertyName, |
|
309 HbXmlLoaderAbstractSyntax::DocumentLexems type, |
|
310 const QList<HbXmlVariable*> &container ) |
|
311 { |
|
312 bool result = true; |
|
313 if ( type == HbXmlLoaderAbstractSyntax::CONTAINER_STRINGLIST ) { |
|
314 QStringList list; |
|
315 for ( int i=0; i<container.count(); i++ ) { |
|
316 QVariant variant; |
|
317 result = variableToQVariant(*(container.value(i)), variant); |
|
318 if ( result ) { |
|
319 list.append( variant.toString() ); |
|
320 } |
|
321 } |
|
322 if ( result ) { |
|
323 QObject *current = findFromStack(); |
|
324 |
|
325 if (current == 0) { |
|
326 HB_DOCUMENTLOADER_PRINT( QString( "Unable to set property " ) + propertyName ); |
|
327 result = false; |
|
328 } |
|
329 |
|
330 if (result) { |
|
331 current->setProperty( propertyName, list ); |
|
332 } |
|
333 } |
|
334 } else { |
|
335 result = false; |
|
336 } |
|
337 |
|
338 return result; |
|
339 } |
|
340 |
|
341 bool HbDocumentLoaderActions::setContentsMargins( const HbXmlLengthValue &left, |
|
342 const HbXmlLengthValue &top, |
|
343 const HbXmlLengthValue &right, |
|
344 const HbXmlLengthValue &bottom ) |
296 { |
345 { |
297 bool isWidget = false; |
346 bool isWidget = false; |
298 QGraphicsWidget *widget = qobject_cast<QGraphicsWidget *>(findFromStack(&isWidget)); |
347 QObject* obj = findFromStack(&isWidget); |
299 if( !isWidget || !widget ) { |
348 if( !obj || !isWidget ) { |
300 HB_DOCUMENTLOADER_PRINT( QString( "Cannot set contentsmargins for non-QGraphicsWidget" ) ); |
349 HB_DOCUMENTLOADER_PRINT( QString( "Cannot set contentsmargins for non-QGraphicsWidget" ) ); |
301 return false; |
350 return false; |
302 } |
351 } |
303 widget->setContentsMargins( left, top, right, bottom ); |
352 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(obj); |
304 return true; |
353 |
305 } |
354 qreal leftVal=0, topVal=0, rightVal=0, bottomVal=0; |
306 |
355 bool ok = true; |
307 |
356 if (left.mType != HbXmlLengthValue::None) { |
308 bool HbDocumentLoaderActions::setSizeHint(Qt::SizeHint hint, qreal *hintWidth, qreal *hintHeight, bool fixed) |
357 ok &= toPixels(left, leftVal); |
|
358 } |
|
359 if (top.mType != HbXmlLengthValue::None) { |
|
360 ok &= toPixels(top, topVal); |
|
361 } |
|
362 if (right.mType != HbXmlLengthValue::None) { |
|
363 ok &= toPixels(right, rightVal); |
|
364 } |
|
365 if (bottom.mType != HbXmlLengthValue::None) { |
|
366 ok &= toPixels(bottom, bottomVal); |
|
367 } |
|
368 if ( ok ) { |
|
369 widget->setContentsMargins( leftVal, topVal, rightVal, bottomVal ); |
|
370 } |
|
371 return ok; |
|
372 } |
|
373 |
|
374 |
|
375 bool HbDocumentLoaderActions::setSizeHint(Qt::SizeHint hint, const HbXmlLengthValue &hintWidth, const HbXmlLengthValue &hintHeight, bool fixed) |
309 { |
376 { |
310 QGraphicsLayoutItem *current = findSpacerItemFromStackTop(); |
377 QGraphicsLayoutItem *current = findSpacerItemFromStackTop(); |
311 if (!current) { |
378 if (!current) { |
312 bool isWidget = false; |
379 bool isWidget = false; |
313 QGraphicsWidget *widget = qobject_cast<QGraphicsWidget *>(findFromStack(&isWidget)); |
380 QObject* obj = findFromStack(&isWidget); |
314 if( !isWidget || !widget ) { |
381 if( !obj || !isWidget ) { |
315 HB_DOCUMENTLOADER_PRINT( QString( "Cannot set sizehint for non-QGraphicsWidget" ) ); |
382 HB_DOCUMENTLOADER_PRINT( QString( "Cannot set sizehint for non-QGraphicsWidget" ) ); |
316 return false; |
383 return false; |
317 } |
384 } |
|
385 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(obj); |
318 current = widget; |
386 current = widget; |
319 } |
387 } |
320 |
388 qreal hintWidthVal, hintHeightVal; |
|
389 |
|
390 bool ok = true; |
|
391 if ( hintWidth.mType != HbXmlLengthValue::None ) { |
|
392 ok &= toPixels(hintWidth, hintWidthVal); |
|
393 } |
|
394 if ( hintHeight.mType != HbXmlLengthValue::None ) { |
|
395 ok &= toPixels(hintHeight, hintHeightVal); |
|
396 } |
|
397 if (!ok) { |
|
398 return false; |
|
399 } |
|
400 |
|
401 // TODO: Use set <Min/Pref/Max> Size if both declared. It's more efficient. |
321 switch (hint) { |
402 switch (hint) { |
322 case Qt::MinimumSize: |
403 case Qt::MinimumSize: |
323 if ( hintWidth ) { |
404 if ( hintWidth.mType != HbXmlLengthValue::None ) { |
324 current->setMinimumWidth(*hintWidth); |
405 |
325 } |
406 current->setMinimumWidth(hintWidthVal); |
326 if ( hintHeight ) { |
407 } |
327 current->setMinimumHeight(*hintHeight); |
408 if ( hintHeight.mType != HbXmlLengthValue::None ) { |
328 } |
409 current->setMinimumHeight(hintHeightVal); |
329 break; |
410 } |
330 |
411 break; |
331 case Qt::PreferredSize: |
412 |
332 if ( hintWidth ) { |
413 case Qt::PreferredSize: |
333 current->setPreferredWidth(*hintWidth); |
414 if ( hintWidth.mType != HbXmlLengthValue::None ) { |
334 } |
415 current->setPreferredWidth(hintWidthVal); |
335 if ( hintHeight ) { |
416 } |
336 current->setPreferredHeight(*hintHeight); |
417 if ( hintHeight.mType != HbXmlLengthValue::None ) { |
337 } |
418 current->setPreferredHeight(hintHeightVal); |
338 break; |
419 } |
339 |
420 break; |
340 case Qt::MaximumSize: |
421 |
341 if ( hintWidth ) { |
422 case Qt::MaximumSize: |
342 current->setMaximumWidth(*hintWidth); |
423 if ( hintWidth.mType != HbXmlLengthValue::None ) { |
343 } |
424 current->setMaximumWidth(hintWidthVal); |
344 if ( hintHeight ) { |
425 } |
345 current->setMaximumHeight(*hintHeight); |
426 if ( hintHeight.mType != HbXmlLengthValue::None ) { |
|
427 current->setMaximumHeight(hintHeightVal); |
346 } |
428 } |
347 break; |
429 break; |
348 |
430 |
349 default: |
431 default: |
350 break; |
432 break; |
351 } |
433 } |
352 |
434 |
353 if (fixed) { |
435 if (fixed) { |
354 QSizePolicy policy = current->sizePolicy(); |
436 QSizePolicy policy = current->sizePolicy(); |
355 if ( hintWidth && *hintWidth >= 0) { |
437 if ( hintWidth.mType != HbXmlLengthValue::None && hintWidthVal >= 0) { |
356 policy.setHorizontalPolicy(QSizePolicy::Fixed); |
438 policy.setHorizontalPolicy(QSizePolicy::Fixed); |
357 } |
439 } |
358 if ( hintHeight && *hintHeight >= 0) { |
440 if ( hintHeight.mType != HbXmlLengthValue::None && hintHeightVal >= 0) { |
359 policy.setVerticalPolicy(QSizePolicy::Fixed); |
441 policy.setVerticalPolicy(QSizePolicy::Fixed); |
360 } |
442 } |
361 current->setSizePolicy(policy); |
443 current->setSizePolicy(policy); |
362 } |
444 } |
363 |
445 |
364 return true; |
446 return true; |
365 } |
447 } |
366 |
448 |
367 bool HbDocumentLoaderActions::setZValue( qreal zValue ) |
449 bool HbDocumentLoaderActions::setToolTip( const HbXmlVariable &tooltip ) |
368 { |
450 { |
369 bool isWidget = false; |
451 bool isWidget; |
370 QGraphicsWidget *widget = qobject_cast<QGraphicsWidget *>(findFromStack(&isWidget)); |
452 QObject* obj = findFromStack(&isWidget); |
371 if( !isWidget || !widget ) { |
453 if( !obj || !isWidget ) { |
372 HB_DOCUMENTLOADER_PRINT( QString( "Cannot set z value for non-QGraphicsWidget" ) ); |
|
373 return false; |
|
374 } |
|
375 |
|
376 widget->setZValue( zValue ); |
|
377 return true; |
|
378 } |
|
379 |
|
380 bool HbDocumentLoaderActions::setToolTip( const QString &tooltip ) |
|
381 { |
|
382 bool isWidget = false; |
|
383 QGraphicsWidget *widget = qobject_cast<QGraphicsWidget *>(findFromStack(&isWidget)); |
|
384 if( !isWidget || !widget ) { |
|
385 HB_DOCUMENTLOADER_PRINT( QString( "Cannot set tooltip for non-QGraphicsWidget" ) ); |
454 HB_DOCUMENTLOADER_PRINT( QString( "Cannot set tooltip for non-QGraphicsWidget" ) ); |
386 return false; |
455 return false; |
387 } |
456 } |
388 |
457 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(obj); |
389 widget->setToolTip( tooltip ); |
458 |
390 return true; |
459 QVariant variant; |
391 } |
460 bool result = variableToQVariant( tooltip, variant ); |
392 |
461 if ( result ) { |
393 bool HbDocumentLoaderActions::setSizePolicy( |
462 widget->setToolTip( variant.toString() ); |
394 const QSizePolicy::Policy *horizontalPolicy, |
463 } |
395 const QSizePolicy::Policy *verticalPolicy, |
464 return result; |
396 const int *horizontalStretch, |
465 } |
397 const int *verticalStretch ) |
466 |
|
467 bool HbDocumentLoaderActions::setSizePolicy( |
|
468 QSizePolicy::Policy *horizontalPolicy, |
|
469 QSizePolicy::Policy *verticalPolicy, |
|
470 int *horizontalStretch, |
|
471 int *verticalStretch ) |
398 { |
472 { |
399 QGraphicsLayoutItem *current = findSpacerItemFromStackTop(); |
473 QGraphicsLayoutItem *current = findSpacerItemFromStackTop(); |
400 if (!current) { |
474 if (!current) { |
401 bool isWidget = false; |
475 bool isWidget = false; |
402 QGraphicsWidget *widget = qobject_cast<QGraphicsWidget *>(findFromStack(&isWidget)); |
476 QObject* obj = findFromStack(&isWidget); |
403 if( !isWidget || !widget ) { |
477 if( !obj || !isWidget ) { |
404 HB_DOCUMENTLOADER_PRINT( QString( "Cannot set size policy for non-QGraphicsWidget" ) ); |
478 HB_DOCUMENTLOADER_PRINT( QString( "Cannot set size policy for non-QGraphicsWidget" ) ); |
405 return false; |
479 return false; |
406 } |
480 } |
|
481 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(obj); |
407 current = widget; |
482 current = widget; |
408 } |
483 } |
409 |
484 |
410 bool changed = false; |
485 bool changed = false; |
411 QSizePolicy sizePolicy = current->sizePolicy(); |
486 QSizePolicy sizePolicy = current->sizePolicy(); |
475 } |
550 } |
476 } |
551 } |
477 return result; |
552 return result; |
478 } |
553 } |
479 |
554 |
480 bool HbDocumentLoaderActions::addAnchorLayoutEdge( const QString &src, const QString &srcEdge, |
555 bool HbDocumentLoaderActions::addAnchorLayoutEdge( const QString &src, Hb::Edge srcEdge, |
481 const QString &dst, const QString &dstEdge, qreal spacing, const QString &spacer ) |
556 const QString &dst, Hb::Edge dstEdge, |
|
557 const HbXmlLengthValue &spacing, const QString &spacer ) |
482 { |
558 { |
483 if ( !spacer.isEmpty() ) { |
559 if ( !spacer.isEmpty() ) { |
484 // spacer is added |
560 // spacer is added |
485 // divide original anchor definition into two. src->dst becomes src->spacer->dst |
561 // divide original anchor definition into two. src->dst becomes src->spacer->dst |
486 bool ok = true; |
562 bool ok = true; |
487 if ( src.isEmpty() ) { |
563 if ( src.isEmpty() ) { |
488 // if the starting item is layout |
564 // if the starting item is layout |
489 // "layout --(spacing)--> item" |
565 // "layout --(spacing)--> item" |
490 // becomes |
566 // becomes |
491 // "layout --(spacing)--> spacer --(0)--> item" |
567 // "layout --(spacing)--> spacer --(0)--> item" |
492 ok &= addAnchorLayoutEdge( src, srcEdge, spacer, srcEdge, spacing ); |
568 ok &= addAnchorLayoutEdge( src, srcEdge, spacer, srcEdge, spacing ); |
493 ok &= addAnchorLayoutEdge( spacer, getAnchorOppositeEdge(srcEdge), dst, dstEdge, 0 ); |
569 HbXmlLengthValue val(0, HbXmlLengthValue::Pixel); |
|
570 ok &= addAnchorLayoutEdge( spacer, getAnchorOppositeEdge(srcEdge), dst, dstEdge, val ); |
494 } else { |
571 } else { |
495 // if the starting item is not layout |
572 // if the starting item is not layout |
496 // "item1 --(spacing)--> item2" |
573 // "item1 --(spacing)--> item2" |
497 // becomes |
574 // becomes |
498 // "item1 --(spacing)--> spacer --(0)--> item2" |
575 // "item1 --(spacing)--> spacer --(0)--> item2" |
499 ok &= addAnchorLayoutEdge( src, srcEdge, spacer, getAnchorOppositeEdge(srcEdge), spacing ); |
576 ok &= addAnchorLayoutEdge( src, srcEdge, spacer, getAnchorOppositeEdge(srcEdge), spacing ); |
500 ok &= addAnchorLayoutEdge( spacer, srcEdge, dst, dstEdge, 0 ); |
577 HbXmlLengthValue val(0, HbXmlLengthValue::Pixel); |
|
578 ok &= addAnchorLayoutEdge( spacer, srcEdge, dst, dstEdge, val ); |
501 } |
579 } |
502 return ok; |
580 return ok; |
503 } |
581 } |
504 |
582 |
505 QGraphicsLayoutItem *item1 = 0; |
583 QGraphicsLayoutItem *item1 = 0; |
506 QGraphicsLayoutItem *item2 = 0; |
584 QGraphicsLayoutItem *item2 = 0; |
507 |
585 |
508 HbAnchorLayout *layout = static_cast<HbAnchorLayout *>( mCurrentLayout ); |
586 HbAnchorLayout *layout = static_cast<HbAnchorLayout *>( mCurrentLayout ); |
509 |
587 |
510 if( src.isEmpty() ) { |
588 if ( src.isEmpty() ) { |
511 item1 = layout; |
589 item1 = layout; |
512 } else if( !( mObjectMap.contains( src ) ) ) { |
590 } else if ( !( mObjectMap.contains( src ) ) ) { |
513 item1 = findLayoutItem( *layout, src ); |
591 item1 = findLayoutItem( *layout, src ); |
514 if ( !item1 ) { |
|
515 HB_DOCUMENTLOADER_PRINT( QString( "ANCHORLAYOUT: NO SUCH ITEM " ) + src ); |
|
516 return false; |
|
517 } |
|
518 } else { |
592 } else { |
519 item1 = qobject_cast<QGraphicsWidget *>( mObjectMap[ src ].data() ); |
593 if (mObjectMap[ src ].second == HbXml::WIDGET) { |
520 } |
594 item1 = static_cast<QGraphicsWidget *>( mObjectMap[ src ].first.data() ); |
521 |
595 } |
522 if( dst.isEmpty() ) { |
596 } |
|
597 if ( !item1 ) { |
|
598 HB_DOCUMENTLOADER_PRINT( QString( "ANCHORLAYOUT: NO SUCH ITEM " ) + src ); |
|
599 return false; |
|
600 } |
|
601 |
|
602 if ( dst.isEmpty() ) { |
523 item2 = layout; |
603 item2 = layout; |
524 } else if( !( mObjectMap.contains( dst ) ) ) { |
604 } else if( !( mObjectMap.contains( dst ) ) ) { |
525 item2 = findLayoutItem( *layout, dst ); |
605 item2 = findLayoutItem( *layout, dst ); |
526 if ( !item2 ) { |
|
527 HB_DOCUMENTLOADER_PRINT( QString( "ANCHORLAYOUT: NO SUCH ITEM " ) + dst ); |
|
528 return false; |
|
529 } |
|
530 } else { |
606 } else { |
531 item2 = qobject_cast<QGraphicsWidget *>( mObjectMap[ dst ].data() ); |
607 if (mObjectMap[ dst ].second == HbXml::WIDGET) { |
532 } |
608 item2 = static_cast<QGraphicsWidget *>( mObjectMap[ dst ].first.data() ); |
533 |
609 } |
534 int edge1 = getAnchorEdge( srcEdge ); |
610 } |
535 int edge2 = getAnchorEdge( dstEdge ); |
611 if ( !item2 ) { |
536 |
612 HB_DOCUMENTLOADER_PRINT( QString( "ANCHORLAYOUT: NO SUCH ITEM " ) + dst ); |
537 if( edge1 < 0 ) { |
613 return false; |
538 HB_DOCUMENTLOADER_PRINT( QString( "ANCHORLAYOUT: UNKNOWN EDGE " ) + srcEdge ); |
614 } |
539 return false; |
615 |
540 } |
616 qreal spacingVal(0); |
541 |
617 if ( spacing.mType != HbXmlLengthValue::None && !toPixels(spacing, spacingVal) ) { |
542 if( edge2 < 0 ) { |
618 return false; |
543 HB_DOCUMENTLOADER_PRINT( QString( "ANCHORLAYOUT: UNKNOWN EDGE " ) + dstEdge ); |
619 } |
544 return false; |
620 layout->setAnchor( item1, srcEdge, item2, dstEdge, spacingVal ); |
545 } |
621 return true; |
546 |
622 } |
547 layout->setAnchor( item1, ( HbAnchorLayout::Edge )edge1, item2, ( HbAnchorLayout::Edge )edge2, spacing ); |
623 |
548 return true; |
624 |
549 } |
625 bool HbDocumentLoaderActions::createGridLayout( const QString &widget, const HbXmlLengthValue &spacing ) |
550 |
626 { |
551 |
|
552 bool HbDocumentLoaderActions::createGridLayout( const QString &widget, qreal *spacing ) |
|
553 { |
|
554 QGraphicsWidget *parent = 0; |
627 QGraphicsWidget *parent = 0; |
555 |
628 |
556 if( widget.isEmpty() ) { |
629 if( widget.isEmpty() ) { |
557 bool isWidget = false; |
630 bool isWidget = false; |
558 parent = qobject_cast<QGraphicsWidget *>( findFromStack( &isWidget ) ); |
631 QObject *parentObj = findFromStack( &isWidget ); |
559 if( !isWidget ) { |
632 if( isWidget ) { |
560 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: CANNOT SET LAYOUT TO NON-QGRAPHICSWIDGET " ) ); |
633 parent = static_cast<QGraphicsWidget *>( parentObj ); |
561 return false; |
634 } |
562 } |
635 } else if ( mObjectMap.contains( widget ) && mObjectMap[ widget ].second == HbXml::WIDGET ) { |
563 } else if( !( mObjectMap.contains( widget ) ) ) { |
636 parent = static_cast<QGraphicsWidget *>( mObjectMap[ widget ].first.data() ); |
564 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO SUCH ITEM " ) + widget ); |
637 } |
565 return false; |
638 if ( !parent ) { |
566 } else { |
639 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: PARENT NOT FOUND" ) ); |
567 parent = qobject_cast<QGraphicsWidget *>( mObjectMap[ widget ].data() ); |
640 return false; |
568 } |
641 } |
569 |
642 |
570 QGraphicsGridLayout* layout = new QGraphicsGridLayout(); |
643 QGraphicsGridLayout* layout = new QGraphicsGridLayout(); |
571 if (spacing) { |
644 if (spacing.mType != HbXmlLengthValue::None) { |
572 layout->setSpacing(*spacing); |
645 qreal spacingVal; |
573 } |
646 if ( toPixels(spacing, spacingVal) ) { |
574 |
647 layout->setSpacing(spacingVal); |
575 mCurrentLayout = layout; |
648 } else { |
|
649 delete layout; |
|
650 return false; |
|
651 } |
|
652 } |
|
653 |
|
654 mCurrentLayout = layout; |
576 parent->setLayout( mCurrentLayout ); |
655 parent->setLayout( mCurrentLayout ); |
577 |
656 |
578 return true; |
657 return true; |
579 } |
658 } |
580 |
659 |
581 bool HbDocumentLoaderActions::addGridLayoutCell( const QString &src, const QString &row, |
660 bool HbDocumentLoaderActions::addGridLayoutCell( |
582 const QString &column, const QString &rowspan, const QString &columnspan, |
661 const QString &src, |
583 const QString &alignment ) |
662 int row, |
|
663 int column, |
|
664 int *rowspan, |
|
665 int *columnspan, |
|
666 Qt::Alignment *alignment ) |
584 { |
667 { |
585 QGraphicsLayoutItem *item = 0; |
668 QGraphicsLayoutItem *item = 0; |
586 |
669 |
587 QGraphicsGridLayout *layout = static_cast<QGraphicsGridLayout *>( mCurrentLayout ); |
670 QGraphicsGridLayout *layout = static_cast<QGraphicsGridLayout *>( mCurrentLayout ); |
588 |
671 |
589 if( !layout ) { |
672 if( !layout ) { |
590 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) + src ); |
673 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) + src ); |
591 return false; |
674 return false; |
592 } |
675 } |
593 |
676 |
594 if( src.isEmpty() ) { |
677 if( src.isEmpty() ) { |
595 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: TRY TO ADD EMPTY ITEM " ) + src ); |
678 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: TRY TO ADD EMPTY ITEM " ) + src ); |
596 return false; |
679 return false; |
597 } else if( !( mObjectMap.contains( src ) ) ) { |
680 } else if ( mObjectMap.contains( src ) && mObjectMap[ src ].second == HbXml::WIDGET ) { |
|
681 item = static_cast<QGraphicsWidget *>( mObjectMap[ src ].first.data() ); |
|
682 } else { |
598 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO SUCH ITEM " ) + src ); |
683 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO SUCH ITEM " ) + src ); |
599 return false; |
684 return false; |
600 } else { |
685 } |
601 item = qobject_cast<QGraphicsWidget *>( mObjectMap[ src ].data() ); |
686 |
602 } |
687 int rowspannum = rowspan ? *rowspan : 1; |
603 |
688 int columnspannum = columnspan ? *columnspan : 1; |
604 bool ok = false; |
689 Qt::Alignment align = alignment ? *alignment : (Qt::Alignment)0; |
605 int rownum = row.toInt( &ok ); |
690 |
606 if( !ok ) { |
691 layout->addItem( item, row, column, rowspannum, columnspannum, align ); |
607 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO ROW SPECIFIED" ) ); |
692 |
608 return false; |
693 return true; |
609 } |
694 } |
610 |
695 |
611 int columnnum = column.toInt( &ok ); |
696 bool HbDocumentLoaderActions::setGridLayoutRowProperties( |
612 if( !ok ) { |
697 int row, |
613 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO COLUMN SPECIFIED" ) ); |
698 int *rowStretchFactor, |
614 return false; |
699 Qt::Alignment *alignment ) |
615 } |
|
616 |
|
617 int rowspannum = rowspan.toInt( &ok ); |
|
618 if( !ok ) { |
|
619 rowspannum = 1; |
|
620 } |
|
621 |
|
622 int columnspannum = columnspan.toInt( &ok ); |
|
623 if( !ok ) { |
|
624 columnspannum = 1; |
|
625 } |
|
626 |
|
627 Qt::Alignment align = 0; |
|
628 if( !alignment.isEmpty() ) { |
|
629 AccessToMetadata myAccess; |
|
630 |
|
631 int value = myAccess.getEnumValue( "Alignment", alignment.toLatin1().data() ); |
|
632 if( value == -1 ) { |
|
633 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO SUCH ALIGNMENT " ) + alignment ); |
|
634 return false; |
|
635 } |
|
636 align = ( Qt::Alignment )value; |
|
637 } |
|
638 |
|
639 layout->addItem( item, rownum, columnnum, rowspannum, columnspannum, align ); |
|
640 |
|
641 return true; |
|
642 } |
|
643 |
|
644 bool HbDocumentLoaderActions::setGridLayoutRowProperties( const QString &row, const QString &rowStretchFactor, |
|
645 const QString &alignment ) |
|
646 { |
700 { |
647 QGraphicsGridLayout *layout = static_cast<QGraphicsGridLayout *>( mCurrentLayout ); |
701 QGraphicsGridLayout *layout = static_cast<QGraphicsGridLayout *>( mCurrentLayout ); |
648 |
702 |
|
703 if (!layout) { |
|
704 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
|
705 return false; |
|
706 } |
|
707 |
|
708 if (rowStretchFactor) { |
|
709 layout->setRowStretchFactor( row, *rowStretchFactor ); |
|
710 } |
|
711 |
|
712 if (alignment) { |
|
713 layout->setRowAlignment( row, *alignment ); |
|
714 } |
|
715 |
|
716 return true; |
|
717 } |
|
718 |
|
719 bool HbDocumentLoaderActions::setGridLayoutColumnProperties( |
|
720 int column, |
|
721 int *columnStretchFactor, |
|
722 Qt::Alignment *alignment ) |
|
723 { |
|
724 QGraphicsGridLayout *layout = static_cast<QGraphicsGridLayout *>( mCurrentLayout ); |
|
725 |
649 if( !layout ) { |
726 if( !layout ) { |
650 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
727 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
651 return false; |
728 return false; |
652 } |
729 } |
653 |
730 |
654 bool ok = false; |
731 if (columnStretchFactor) { |
655 const int rownum = row.toInt( &ok ); |
732 layout->setColumnStretchFactor( column, *columnStretchFactor ); |
656 if( !ok ) { |
733 } |
657 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO ROW NUMBER SPECIFIED FOR STRETCH FACTOR" ) ); |
734 |
658 return false; |
735 if (alignment) { |
659 } |
736 layout->setColumnAlignment( column, *alignment ); |
660 |
737 } |
661 if( !rowStretchFactor.isEmpty() ) { |
738 |
662 bool ok = false; |
739 return true; |
663 int rowStretch = rowStretchFactor.toInt( &ok ); |
740 } |
664 if( !ok ) { |
741 |
665 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: UNABLE TO PARSE ROW STRETCH FACTOR VALUE" ) ); |
742 bool HbDocumentLoaderActions::setGridLayoutRowHeights( int row, |
666 return false; |
743 const HbXmlLengthValue &minHeight, |
667 } |
744 const HbXmlLengthValue &maxHeight, |
668 layout->setRowStretchFactor( rownum, rowStretch ); |
745 const HbXmlLengthValue &prefHeight, |
669 } |
746 const HbXmlLengthValue &fixedHeight, |
670 |
747 const HbXmlLengthValue &rowSpacing ) |
671 if( !alignment.isEmpty() ) { |
|
672 AccessToMetadata myAccess; |
|
673 |
|
674 int value = myAccess.getEnumValue( "Alignment", alignment.toLatin1().data() ); |
|
675 if( value == -1 ) { |
|
676 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO SUCH ROW ALIGNMENT " ) + alignment ); |
|
677 return false; |
|
678 } |
|
679 layout->setRowAlignment(rownum, ( Qt::Alignment )value ); |
|
680 } |
|
681 |
|
682 return true; |
|
683 } |
|
684 |
|
685 bool HbDocumentLoaderActions::setGridLayoutColumnProperties( const QString &column, const QString &columnStretchFactor, |
|
686 const QString &alignment ) |
|
687 { |
748 { |
688 QGraphicsGridLayout *layout = static_cast<QGraphicsGridLayout *>( mCurrentLayout ); |
749 QGraphicsGridLayout *layout = static_cast<QGraphicsGridLayout *>( mCurrentLayout ); |
689 |
750 |
690 if( !layout ) { |
751 if( !layout ) { |
691 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
752 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
692 return false; |
753 return false; |
693 } |
754 } |
694 |
755 |
695 bool ok = false; |
756 if ( minHeight.mType != HbXmlLengthValue::None ) { |
696 const int columnnum = column.toInt( &ok ); |
757 qreal minHeightVal; |
697 if( !ok ) { |
758 if ( !toPixels(minHeight, minHeightVal) ) { |
698 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO COLUMN NUMBER SPECIFIED FOR STRETCH FACTOR" ) ); |
759 return false; |
699 return false; |
760 } |
700 } |
761 layout->setRowMinimumHeight( row, minHeightVal ); |
701 |
762 } |
702 if( !columnStretchFactor.isEmpty() ) { |
763 |
703 bool ok = false; |
764 if ( maxHeight.mType != HbXmlLengthValue::None ) { |
704 int columnStretch = columnStretchFactor.toInt( &ok ); |
765 qreal maxHeightVal; |
705 if( !ok ) { |
766 if ( !toPixels(maxHeight, maxHeightVal) ) { |
706 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: UNABLE TO PARSE COLUMN STRETCH FACTOR VALUE" ) ); |
767 return false; |
707 return false; |
768 } |
708 } |
769 layout->setRowMaximumHeight( row, maxHeightVal ); |
709 layout->setColumnStretchFactor( columnnum, columnStretch ); |
770 } |
710 } |
771 |
711 |
772 if ( prefHeight.mType != HbXmlLengthValue::None ) { |
712 if( !alignment.isEmpty() ) { |
773 qreal prefHeightVal; |
713 AccessToMetadata myAccess; |
774 if ( !toPixels(prefHeight, prefHeightVal) ) { |
714 |
775 return false; |
715 int value = myAccess.getEnumValue( "Alignment", alignment.toLatin1().data() ); |
776 } |
716 if( value == -1 ) { |
777 layout->setRowPreferredHeight( row, prefHeightVal ); |
717 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO SUCH COLUMN ALIGNMENT " ) + alignment ); |
778 } |
718 return false; |
779 |
719 } |
780 if ( fixedHeight.mType != HbXmlLengthValue::None ) { |
720 layout->setColumnAlignment( columnnum, ( Qt::Alignment )value ); |
781 qreal fixedHeightVal; |
721 } |
782 if ( !toPixels(fixedHeight, fixedHeightVal) ) { |
722 |
783 return false; |
723 return true; |
784 } |
724 } |
785 layout->setRowFixedHeight( row, fixedHeightVal ); |
725 |
786 } |
726 bool HbDocumentLoaderActions::setGridLayoutRowHeights( const QString &row, const qreal minHeight, |
787 |
727 const qreal maxHeight, const qreal prefHeight, |
788 if ( rowSpacing.mType != HbXmlLengthValue::None ) { |
728 const qreal fixedHeight, const qreal rowSpacing, |
789 qreal rowSpacingVal; |
729 const int flagsPropertyAvailable ) |
790 if ( !toPixels(rowSpacing, rowSpacingVal) ) { |
|
791 return false; |
|
792 } |
|
793 layout->setRowSpacing( row, rowSpacingVal ); |
|
794 } |
|
795 |
|
796 return true; |
|
797 |
|
798 } |
|
799 |
|
800 bool HbDocumentLoaderActions::setGridLayoutColumnWidths( int column, |
|
801 const HbXmlLengthValue &minWidth, |
|
802 const HbXmlLengthValue &maxWidth, |
|
803 const HbXmlLengthValue &prefWidth, |
|
804 const HbXmlLengthValue &fixedWidth, |
|
805 const HbXmlLengthValue &columnSpacing ) |
730 { |
806 { |
731 QGraphicsGridLayout *layout = static_cast<QGraphicsGridLayout *>( mCurrentLayout ); |
807 QGraphicsGridLayout *layout = static_cast<QGraphicsGridLayout *>( mCurrentLayout ); |
732 |
808 |
733 if( !layout ) { |
809 if( !layout ) { |
734 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
810 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
735 return false; |
811 return false; |
736 } |
812 } |
737 |
813 |
738 bool ok = false; |
814 if ( minWidth.mType != HbXmlLengthValue::None ) { |
739 const int rownum = row.toInt( &ok ); |
815 qreal minWidthVal; |
740 if( !ok ) { |
816 if ( !toPixels(minWidth, minWidthVal) ) { |
741 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO ROW NUMBER SPECIFIED FOR ROW HEIGHTS" ) ); |
817 return false; |
742 return false; |
818 } |
743 } |
819 layout->setColumnMinimumWidth( column, minWidthVal ); |
744 |
820 } |
745 if ( flagsPropertyAvailable & HbDocumentLoaderActions::propertyMin ) { |
821 |
746 layout->setRowMinimumHeight( rownum, minHeight ); |
822 if ( maxWidth.mType != HbXmlLengthValue::None ) { |
747 } |
823 qreal maxWidthVal; |
748 |
824 if ( !toPixels(maxWidth, maxWidthVal) ) { |
749 if ( flagsPropertyAvailable & HbDocumentLoaderActions::propertyMax ) { |
825 return false; |
750 layout->setRowMaximumHeight( rownum, maxHeight ); |
826 } |
751 } |
827 layout->setColumnMaximumWidth( column, maxWidthVal ); |
752 |
828 } |
753 if ( flagsPropertyAvailable & HbDocumentLoaderActions::propertyPref ) { |
829 |
754 layout->setRowPreferredHeight( rownum, prefHeight ); |
830 if ( prefWidth.mType != HbXmlLengthValue::None ) { |
755 } |
831 qreal prefWidthVal; |
756 |
832 if ( !toPixels(prefWidth, prefWidthVal) ) { |
757 if ( flagsPropertyAvailable & HbDocumentLoaderActions::propertyFixed ) { |
833 return false; |
758 layout->setRowFixedHeight( rownum, fixedHeight ); |
834 } |
759 } |
835 layout->setColumnPreferredWidth( column, prefWidthVal ); |
760 |
836 } |
761 if ( flagsPropertyAvailable & HbDocumentLoaderActions::propertySpacing ) { |
837 |
762 layout->setRowSpacing( rownum, rowSpacing ); |
838 if ( fixedWidth.mType != HbXmlLengthValue::None ) { |
763 } |
839 qreal fixedWidthVal; |
764 |
840 if ( !toPixels(fixedWidth, fixedWidthVal) ) { |
765 return true; |
841 return false; |
766 |
842 } |
767 } |
843 layout->setColumnFixedWidth( column, fixedWidthVal ); |
768 |
844 } |
769 bool HbDocumentLoaderActions::setGridLayoutColumnWidths( const QString &column, const qreal minWidth, |
845 |
770 const qreal maxWidth, const qreal prefWidth, |
846 if ( columnSpacing.mType != HbXmlLengthValue::None ) { |
771 const qreal fixedWidth, const qreal columnSpacing, |
847 qreal columnSpacingVal; |
772 const int flagsPropertyAvailable ) |
848 if ( !toPixels(columnSpacing, columnSpacingVal) ) { |
773 { |
849 return false; |
774 QGraphicsGridLayout *layout = static_cast<QGraphicsGridLayout *>( mCurrentLayout ); |
850 } |
775 |
851 layout->setColumnSpacing( column, columnSpacingVal ); |
776 if( !layout ) { |
852 } |
777 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
853 |
778 return false; |
854 return true; |
779 } |
855 } |
780 |
856 |
781 bool ok = false; |
857 bool HbDocumentLoaderActions::createLinearLayout( |
782 const int columnnum = column.toInt( &ok ); |
858 const QString &widget, |
783 if( !ok ) { |
859 Qt::Orientation *orientation, |
784 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO COLUMN NUMBER SPECIFIED FOR COLUMN WIDTHS" ) ); |
860 const HbXmlLengthValue &spacing ) |
785 return false; |
|
786 } |
|
787 |
|
788 if ( flagsPropertyAvailable & HbDocumentLoaderActions::propertyMin ) { |
|
789 layout->setColumnMinimumWidth( columnnum, minWidth ); |
|
790 } |
|
791 |
|
792 if ( flagsPropertyAvailable & HbDocumentLoaderActions::propertyMax ) { |
|
793 layout->setColumnMaximumWidth( columnnum, maxWidth ); |
|
794 } |
|
795 |
|
796 if ( flagsPropertyAvailable & HbDocumentLoaderActions::propertyPref ) { |
|
797 layout->setColumnPreferredWidth( columnnum, prefWidth ); |
|
798 } |
|
799 |
|
800 if ( flagsPropertyAvailable & HbDocumentLoaderActions::propertyFixed ) { |
|
801 layout->setColumnFixedWidth( columnnum, fixedWidth ); |
|
802 } |
|
803 |
|
804 if ( flagsPropertyAvailable & HbDocumentLoaderActions::propertySpacing ) { |
|
805 layout->setColumnSpacing( columnnum, columnSpacing ); |
|
806 } |
|
807 |
|
808 return true; |
|
809 } |
|
810 |
|
811 bool HbDocumentLoaderActions::createLinearLayout( const QString &widget, const QString &orientation, qreal *spacing ) |
|
812 { |
861 { |
813 QGraphicsWidget *parent = 0; |
862 QGraphicsWidget *parent = 0; |
814 QGraphicsLinearLayout *layout = 0; |
863 QGraphicsLinearLayout *layout = 0; |
815 |
864 |
816 if( widget.isEmpty() ) { |
865 if( widget.isEmpty() ) { |
817 bool isWidget = false; |
866 bool isWidget = false; |
818 parent = qobject_cast<QGraphicsWidget *>( findFromStack( &isWidget ) ); |
867 QObject *parentObj = findFromStack( &isWidget ); |
819 if( !isWidget ) { |
868 if ( isWidget ) { |
820 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: CANNOT SET LAYOUT TO NON-QGRAPHICSWIDGET " ) ); |
869 parent = static_cast<QGraphicsWidget *>( parentObj ); |
821 return false; |
870 } |
822 } |
871 } else if ( mObjectMap.contains( widget ) && mObjectMap[ widget ].second == HbXml::WIDGET ) { |
823 } else if( !( mObjectMap.contains( widget ) ) ) { |
872 parent = static_cast<QGraphicsWidget *>( mObjectMap[ widget ].first.data() ); |
824 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: NO SUCH ITEM " ) + widget ); |
873 } |
825 return false; |
874 if ( !parent ) { |
826 } else { |
875 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: PARENT NOT FOUND" ) ); |
827 parent = qobject_cast<QGraphicsWidget *>( mObjectMap[ widget ].data() ); |
876 return false; |
828 } |
877 } |
829 |
878 |
830 Qt::Orientation orient = Qt::Horizontal; |
879 if( orientation ) { |
831 |
880 layout = new QGraphicsLinearLayout( *orientation ); |
832 if( ! orientation.isEmpty() ) { |
|
833 AccessToMetadata myAccess; |
|
834 |
|
835 int value = myAccess.getEnumValue( "Orientation", orientation.toLatin1().data() ); |
|
836 if( value == -1 ) { |
|
837 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: NO SUCH ORIENTATION " ) + orientation ); |
|
838 return false; |
|
839 } |
|
840 orient = ( Qt::Orientation )value; |
|
841 layout = new QGraphicsLinearLayout( orient ); |
|
842 } else { |
881 } else { |
843 layout = new QGraphicsLinearLayout(); |
882 layout = new QGraphicsLinearLayout(); |
844 } |
883 } |
845 |
884 |
846 if ( spacing ) { |
885 if ( spacing.mType != HbXmlLengthValue::None ) { |
847 layout->setSpacing(*spacing); |
886 qreal spacingVal; |
|
887 if ( !toPixels(spacing, spacingVal) ) { |
|
888 return false; |
|
889 } |
|
890 layout->setSpacing(spacingVal); |
848 } |
891 } |
849 |
892 |
850 mCurrentLayout = layout; |
893 mCurrentLayout = layout; |
851 parent->setLayout( mCurrentLayout ); |
894 parent->setLayout( mCurrentLayout ); |
852 |
895 |
853 return true; |
896 return true; |
854 } |
897 } |
855 |
898 |
856 bool HbDocumentLoaderActions::addLinearLayoutItem( const QString &itemname, const QString &index, |
899 bool HbDocumentLoaderActions::addLinearLayoutItem( |
857 const QString &stretchfactor, const QString &alignment, |
900 const QString &itemname, |
858 qreal *spacing ) |
901 int *index, |
|
902 int *stretchfactor, |
|
903 Qt::Alignment *alignment, |
|
904 const HbXmlLengthValue &spacing ) |
859 { |
905 { |
860 QGraphicsLayoutItem *item = 0; |
906 QGraphicsLayoutItem *item = 0; |
861 |
907 |
862 QGraphicsLinearLayout *layout = static_cast<QGraphicsLinearLayout *>( mCurrentLayout ); |
908 QGraphicsLinearLayout *layout = static_cast<QGraphicsLinearLayout *>( mCurrentLayout ); |
863 |
909 |
864 if( !layout ) { |
910 if ( !layout ) { |
865 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: INTERNAL ERROR " ) ); |
911 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: INTERNAL ERROR " ) ); |
866 return false; |
912 return false; |
867 } |
913 } |
868 |
914 |
869 if( itemname.isEmpty() ) { |
915 if ( itemname.isEmpty() ) { |
870 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: TRY TO ADD EMPTY ITEM " ) + itemname ); |
916 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: TRY TO ADD EMPTY ITEM " ) + itemname ); |
871 return false; |
917 return false; |
872 } else if( !( mObjectMap.contains( itemname ) ) ) { |
918 } else if ( mObjectMap.contains( itemname ) && mObjectMap[ itemname ].second == HbXml::WIDGET ) { |
|
919 item = static_cast<QGraphicsWidget *>( mObjectMap[ itemname ].first.data() ); |
|
920 } else { |
873 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: NO SUCH ITEM " ) + itemname ); |
921 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: NO SUCH ITEM " ) + itemname ); |
874 return false; |
922 return false; |
875 } else { |
923 } |
876 item = qobject_cast<QGraphicsWidget *>( mObjectMap[ itemname ].data() ); |
924 |
877 } |
925 int indexValue = index ? *index : -1; |
878 |
|
879 int indexValue = -1; |
|
880 |
|
881 if( ! index.isEmpty() ) { |
|
882 bool ok = false; |
|
883 indexValue = index.toInt( &ok ); |
|
884 if( !ok ) { |
|
885 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: UNABLE TO PARSE ITEM INDEX" ) ); |
|
886 return false; |
|
887 } |
|
888 } |
|
889 |
|
890 layout->insertItem( indexValue, item ); |
926 layout->insertItem( indexValue, item ); |
891 if ( spacing ) { |
927 |
|
928 if ( spacing.mType != HbXmlLengthValue::None ) { |
|
929 qreal spacingVal; |
|
930 if ( !toPixels(spacing, spacingVal) ) { |
|
931 return false; |
|
932 } |
|
933 |
892 // Need to resolve the item index for spacing |
934 // Need to resolve the item index for spacing |
893 int i = layout->count(); |
935 int i = layout->count(); |
894 while (i--) { |
936 while (i--) { |
895 if ( layout->itemAt(i) == item ) { |
937 if ( layout->itemAt(i) == item ) { |
896 layout->setItemSpacing(i, *spacing); |
938 layout->setItemSpacing(i, spacingVal); |
897 break; |
939 break; |
898 } |
940 } |
899 } |
941 } |
900 } |
942 } |
901 |
943 |
902 if( !stretchfactor.isEmpty() ) { |
944 if ( stretchfactor ) { |
903 bool ok = false; |
945 layout->setStretchFactor( item, *stretchfactor ); |
904 int stretch = stretchfactor.toInt( &ok ); |
946 } |
905 if( !ok ) { |
947 |
906 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: UNABLE TO PARSE STRETCH VALUE" ) ); |
948 if( alignment ) { |
907 return false; |
949 layout->setAlignment( item, *alignment ); |
908 } |
950 } |
909 layout->setStretchFactor( item, stretch ); |
951 |
910 } |
952 return true; |
911 |
953 } |
912 if( !alignment.isEmpty() ) { |
954 |
913 AccessToMetadata myAccess; |
955 bool HbDocumentLoaderActions::addLinearLayoutStretch( |
914 |
956 int *index, |
915 int value = myAccess.getEnumValue( "Alignment", alignment.toLatin1().data() ); |
957 int *stretchfactor ) |
916 if( value == -1 ) { |
|
917 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: NO SUCH ITEM ALIGNMENT " ) + alignment ); |
|
918 return false; |
|
919 } |
|
920 layout->setAlignment( item, ( Qt::Alignment )value ); |
|
921 } |
|
922 |
|
923 return true; |
|
924 } |
|
925 |
|
926 bool HbDocumentLoaderActions::addLinearLayoutStretch( const QString &index, const QString &stretchfactor ) |
|
927 { |
958 { |
928 QGraphicsLinearLayout *layout = static_cast<QGraphicsLinearLayout *>( mCurrentLayout ); |
959 QGraphicsLinearLayout *layout = static_cast<QGraphicsLinearLayout *>( mCurrentLayout ); |
929 |
960 |
930 if( !layout ) { |
961 if( !layout ) { |
931 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: INTERNAL ERROR " ) ); |
962 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: INTERNAL ERROR " ) ); |
932 return false; |
963 return false; |
933 } |
964 } |
934 |
965 |
935 int indexValue = -1; |
966 int indexValue = index ? *index : -1; |
936 int stretch = 1; |
967 int stretch = stretchfactor ? * stretchfactor : 1; |
937 |
968 |
938 if( ! index.isEmpty() ) { |
|
939 bool ok = false; |
|
940 indexValue = index.toInt( &ok ); |
|
941 if( !ok ) { |
|
942 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: UNABLE TO PARSE STRETCH INDEX" ) ); |
|
943 return false; |
|
944 } |
|
945 } |
|
946 |
|
947 if( ! stretchfactor.isEmpty() ) { |
|
948 bool ok = false; |
|
949 stretch = stretchfactor.toInt( &ok ); |
|
950 if( !ok ) { |
|
951 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: UNABLE TO PARSE STRETCH VALUE" ) ); |
|
952 return false; |
|
953 } |
|
954 } |
|
955 |
|
956 layout->insertStretch( indexValue, stretch ); |
969 layout->insertStretch( indexValue, stretch ); |
957 |
970 |
958 return true; |
971 return true; |
959 } |
972 } |
960 |
973 |
961 bool HbDocumentLoaderActions::setLayoutContentsMargins( qreal left, qreal top, qreal right, qreal bottom ) |
974 bool HbDocumentLoaderActions::setLayoutContentsMargins( const HbXmlLengthValue &left, |
|
975 const HbXmlLengthValue &top, |
|
976 const HbXmlLengthValue &right, |
|
977 const HbXmlLengthValue &bottom ) |
962 { |
978 { |
963 if( !mCurrentLayout ) { |
979 if( !mCurrentLayout ) { |
964 HB_DOCUMENTLOADER_PRINT( QString( "LAYOUT: INTERNAL ERROR " ) ); |
980 HB_DOCUMENTLOADER_PRINT( QString( "LAYOUT: INTERNAL ERROR " ) ); |
965 return false; |
981 return false; |
966 } |
982 } |
967 mCurrentLayout->setContentsMargins( left, top, right, bottom ); |
983 |
968 return true; |
984 qreal leftVal=0, topVal=0, rightVal=0, bottomVal=0; |
|
985 bool ok = true; |
|
986 if (left.mType != HbXmlLengthValue::None) { |
|
987 ok &= toPixels(left, leftVal); |
|
988 } |
|
989 if (top.mType != HbXmlLengthValue::None) { |
|
990 ok &= toPixels(top, topVal); |
|
991 } |
|
992 if (right.mType != HbXmlLengthValue::None) { |
|
993 ok &= toPixels(right, rightVal); |
|
994 } |
|
995 if (bottom.mType != HbXmlLengthValue::None) { |
|
996 ok &= toPixels(bottom, bottomVal); |
|
997 } |
|
998 if ( ok ) { |
|
999 mCurrentLayout->setContentsMargins( leftVal, topVal, rightVal, bottomVal ); |
|
1000 } |
|
1001 return ok; |
969 } |
1002 } |
970 |
1003 |
971 bool HbDocumentLoaderActions::createStackedLayout( const QString &widget ) |
1004 bool HbDocumentLoaderActions::createStackedLayout( const QString &widget ) |
972 { |
1005 { |
973 QGraphicsWidget *parent = 0; |
1006 QGraphicsWidget *parent = 0; |
974 |
1007 |
975 if( widget.isEmpty() ) { |
1008 if( widget.isEmpty() ) { |
976 bool isWidget = false; |
1009 bool isWidget = false; |
977 parent = qobject_cast<QGraphicsWidget *>( findFromStack( &isWidget ) ); |
1010 QObject *parentObj = findFromStack( &isWidget ); |
978 if( !isWidget ) { |
1011 if( isWidget ) { |
979 HB_DOCUMENTLOADER_PRINT( QString( "STACKEDLAYOUT: CANNOT SET LAYOUT TO NON-QGRAPHICSWIDGET " ) ); |
1012 parent = static_cast<QGraphicsWidget *>( parentObj ); |
980 return false; |
1013 } |
981 } |
1014 } else if ( mObjectMap.contains( widget ) && mObjectMap[ widget ].second == HbXml::WIDGET ) { |
982 } else if( !( mObjectMap.contains( widget ) ) ) { |
1015 parent = static_cast<QGraphicsWidget *>( mObjectMap[ widget ].first.data() ); |
983 HB_DOCUMENTLOADER_PRINT( QString( "STACKEDLAYOUT: NO SUCH ITEM " ) + widget ); |
1016 } |
984 return false; |
1017 if ( !parent ) { |
985 } else { |
1018 HB_DOCUMENTLOADER_PRINT( QString( "STACKEDLAYOUT: PARENT NOT FOUND" ) ); |
986 parent = qobject_cast<QGraphicsWidget *>( mObjectMap[ widget ].data() ); |
1019 return false; |
987 } |
1020 } |
988 |
1021 |
989 mCurrentLayout = new HbStackedLayout(); |
1022 mCurrentLayout = new HbStackedLayout(); |
990 |
1023 |
991 parent->setLayout( mCurrentLayout ); |
1024 parent->setLayout( mCurrentLayout ); |
992 |
1025 |
993 return true; |
1026 return true; |
994 } |
1027 } |
995 |
1028 |
996 bool HbDocumentLoaderActions::addStackedLayoutItem( const QString &itemname, const QString &index ) |
1029 bool HbDocumentLoaderActions::addStackedLayoutItem( const QString &itemname, int *index ) |
997 { |
1030 { |
998 QGraphicsLayoutItem *item = 0; |
1031 QGraphicsLayoutItem *item = 0; |
999 |
1032 |
1000 HbStackedLayout *layout = static_cast<HbStackedLayout *>( mCurrentLayout ); |
1033 HbStackedLayout *layout = static_cast<HbStackedLayout *>( mCurrentLayout ); |
1001 |
1034 |
1002 if( !layout ) { |
1035 if( !layout ) { |
1003 HB_DOCUMENTLOADER_PRINT( QString( "STACKEDLAYOUT: INTERNAL ERROR " ) ); |
1036 HB_DOCUMENTLOADER_PRINT( QString( "STACKEDLAYOUT: INTERNAL ERROR " ) ); |
1004 return false; |
1037 return false; |
1005 } |
1038 } |
1006 |
1039 |
1007 if( itemname.isEmpty() ) { |
1040 if( itemname.isEmpty() ) { |
1008 HB_DOCUMENTLOADER_PRINT( QString( "STACKEDLAYOUT: TRY TO ADD EMPTY ITEM " ) + itemname ); |
1041 HB_DOCUMENTLOADER_PRINT( QString( "STACKEDLAYOUT: TRY TO ADD EMPTY ITEM " ) + itemname ); |
1009 return false; |
1042 return false; |
1010 } else if( !( mObjectMap.contains( itemname ) ) ) { |
1043 } else if ( mObjectMap.contains( itemname ) && mObjectMap[ itemname ].second == HbXml::WIDGET ) { |
|
1044 item = static_cast<QGraphicsWidget *>( mObjectMap[ itemname ].first.data() ); |
|
1045 } else { |
1011 HB_DOCUMENTLOADER_PRINT( QString( "STACKEDLAYOUT: NO SUCH ITEM " ) + itemname ); |
1046 HB_DOCUMENTLOADER_PRINT( QString( "STACKEDLAYOUT: NO SUCH ITEM " ) + itemname ); |
1012 return false; |
1047 return false; |
1013 } else { |
1048 } |
1014 item = qobject_cast<QGraphicsWidget *>( mObjectMap[ itemname ].data() ); |
1049 |
1015 } |
1050 int indexValue = index ? *index : -1; |
1016 |
|
1017 int indexValue = -1; |
|
1018 |
|
1019 if( ! index.isEmpty() ) { |
|
1020 bool ok = false; |
|
1021 indexValue = index.toInt( &ok ); |
|
1022 if( !ok ) { |
|
1023 HB_DOCUMENTLOADER_PRINT( QString( "STACKEDLAYOUT: UNABLE TO PARSE ITEM INDEX" ) ); |
|
1024 return false; |
|
1025 } |
|
1026 } |
|
1027 |
|
1028 layout->insertItem( indexValue, item ); |
1051 layout->insertItem( indexValue, item ); |
1029 |
1052 |
1030 return true; |
1053 return true; |
1031 } |
1054 } |
1032 |
1055 |
1033 |
1056 |
1034 bool HbDocumentLoaderActions::createNullLayout( const QString &widget ) |
1057 bool HbDocumentLoaderActions::createNullLayout( const QString &widget ) |
1035 { |
1058 { |
1036 QGraphicsWidget *parent = 0; |
1059 QGraphicsWidget *parent = 0; |
1037 |
1060 |
1038 if( widget.isEmpty() ) { |
1061 if( widget.isEmpty() ) { |
1039 bool isWidget = false; |
1062 bool isWidget = false; |
1040 parent = qobject_cast<QGraphicsWidget *>( findFromStack( &isWidget ) ); |
1063 QObject *parentObj = findFromStack( &isWidget ); |
1041 if( !isWidget ) { |
1064 if( isWidget ) { |
1042 HB_DOCUMENTLOADER_PRINT( QString( "NULL LAYOUT: CANNOT UNSET LAYOUT FROM NON-QGRAPHICSWIDGET " ) ); |
1065 parent = static_cast<QGraphicsWidget *>( parentObj ); |
1043 return false; |
1066 } |
1044 } |
1067 } else if ( mObjectMap.contains( widget ) && mObjectMap[ widget ].second == HbXml::WIDGET ) { |
1045 } else if( !( mObjectMap.contains( widget ) ) ) { |
1068 parent = static_cast<QGraphicsWidget *>( mObjectMap[ widget ].first.data() ); |
1046 HB_DOCUMENTLOADER_PRINT( QString( "NULL LAYOUT: NO SUCH ITEM " ) + widget ); |
1069 } |
1047 return false; |
1070 if ( !parent ) { |
1048 } else { |
1071 HB_DOCUMENTLOADER_PRINT( QString( "NULL LAYOUT: PARENT NOT FOUND" ) ); |
1049 parent = qobject_cast<QGraphicsWidget *>( mObjectMap[ widget ].data() ); |
1072 return false; |
1050 } |
1073 } |
1051 |
1074 |
1052 mCurrentLayout = 0; |
1075 mCurrentLayout = 0; |
1053 |
1076 |
1054 parent->setLayout( mCurrentLayout ); |
1077 parent->setLayout( mCurrentLayout ); |
1055 |
1078 |
1056 return true; |
1079 return true; |
1057 |
1080 |
1058 } |
|
1059 |
|
1060 bool HbDocumentLoaderActions::createContainer() |
|
1061 { |
|
1062 if (mCurrentContainer) { |
|
1063 delete mCurrentContainer; |
|
1064 } |
|
1065 mCurrentContainer = new QList<QVariant>(); |
|
1066 return true; |
|
1067 } |
|
1068 |
|
1069 bool HbDocumentLoaderActions::appendPropertyToContainer( const QVariant &value ) |
|
1070 { |
|
1071 bool result(false); |
|
1072 if (!mCurrentContainer) { |
|
1073 result = false; |
|
1074 } else { |
|
1075 // note that for a successful conversion later on, all of the appended items need |
|
1076 // to be of the same (appropriate type) e.g. String |
|
1077 mCurrentContainer->append(value); |
|
1078 result = true; |
|
1079 } |
|
1080 return result; |
|
1081 } |
1081 } |
1082 |
1082 |
1083 bool HbDocumentLoaderActions::setWidgetRole( |
1083 bool HbDocumentLoaderActions::setWidgetRole( |
1084 QGraphicsWidget *parent, QGraphicsWidget *child, const QString &role) |
1084 QGraphicsWidget *parent, QGraphicsWidget *child, const QString &role) |
1085 { |
1085 { |
1086 return factory.setWidgetRole(parent, child, role); |
1086 return mFactory.setWidgetRole(parent, child, role); |
1087 } |
1087 } |
1088 |
1088 |
1089 bool HbDocumentLoaderActions::setObjectRole( |
1089 bool HbDocumentLoaderActions::setObjectRole( |
1090 QObject *parent, QObject *child, const QString &role) |
1090 QObject *parent, QObject *child, const QString &role) |
1091 { |
1091 { |
1092 return factory.setObjectRole(parent, child, role); |
1092 return mFactory.setObjectRole(parent, child, role); |
1093 } |
1093 } |
1094 |
1094 |
1095 |
1095 bool HbDocumentLoaderActions::variableToQVariant( const HbXmlVariable& variable, QVariant &variant ) |
|
1096 { |
|
1097 Q_UNUSED(variable); |
|
1098 Q_UNUSED(variant); |
|
1099 bool result(true); |
|
1100 |
|
1101 switch (variable.mType) { |
|
1102 case HbXmlVariable::INT: |
|
1103 { |
|
1104 qint16* int_b =(qint16*)variable.mParameters.at(0); |
|
1105 variant.setValue((int)(*int_b)); |
|
1106 break; |
|
1107 } |
|
1108 |
|
1109 case HbXmlVariable::REAL: |
|
1110 { |
|
1111 HbXmlLengthValue* realVal = (HbXmlLengthValue*)variable.mParameters.at(0); |
|
1112 qreal realNum; |
|
1113 result = toPixels(*realVal, realNum ); |
|
1114 if (result) { |
|
1115 variant.setValue(realNum); |
|
1116 } |
|
1117 break; |
|
1118 } |
|
1119 |
|
1120 case HbXmlVariable::LOCALIZED_STRING: |
|
1121 { |
|
1122 QString *value = (QString*)variable.mParameters.at(0); |
|
1123 QString *comment = (QString*)variable.mParameters.at(1); |
|
1124 const QString text = translate( *value, *comment ); |
|
1125 variant.setValue( text ); |
|
1126 break; |
|
1127 } |
|
1128 |
|
1129 case HbXmlVariable::STRING: |
|
1130 { |
|
1131 QString *value = (QString*)variable.mParameters.at(0); |
|
1132 QString *locId = (QString*)variable.mParameters.at(1); |
|
1133 variant.setValue( locId->isEmpty() ? *value : hbTrId(locId->toUtf8()) ); |
|
1134 break; |
|
1135 } |
|
1136 |
|
1137 case HbXmlVariable::BOOL: |
|
1138 { |
|
1139 bool *bool_b = (bool*)variable.mParameters.at(0); |
|
1140 variant.setValue( *bool_b ); |
|
1141 break; |
|
1142 } |
|
1143 |
|
1144 case HbXmlVariable::ICON: |
|
1145 { |
|
1146 QString *iconName = (QString*)variable.mParameters.at(0); |
|
1147 HbXmlLengthValue* widthVal = (HbXmlLengthValue*)variable.mParameters.at(1); |
|
1148 HbXmlLengthValue* heightVal = (HbXmlLengthValue*)variable.mParameters.at(2); |
|
1149 |
|
1150 HbIcon icon(*iconName); |
|
1151 qreal width, height; |
|
1152 if ( widthVal->mType != HbXmlLengthValue::None ) { |
|
1153 result = toPixels(*widthVal, width); |
|
1154 } |
|
1155 if ( result && heightVal->mType != HbXmlLengthValue::None ) { |
|
1156 result = toPixels(*heightVal, height); |
|
1157 } |
|
1158 if ( result ) { |
|
1159 if ( widthVal->mType != HbXmlLengthValue::None && |
|
1160 heightVal->mType != HbXmlLengthValue::None ) { |
|
1161 icon.setSize(QSizeF(width, height)); |
|
1162 } else if ( widthVal->mType != HbXmlLengthValue::None ) { |
|
1163 icon.setWidth(width); |
|
1164 } else if ( heightVal->mType != HbXmlLengthValue::None ) { |
|
1165 icon.setHeight(height); |
|
1166 } |
|
1167 variant.setValue( icon ); |
|
1168 } |
|
1169 break; |
|
1170 } |
|
1171 |
|
1172 case HbXmlVariable::SIZE: |
|
1173 { |
|
1174 HbXmlLengthValue* widthVal = (HbXmlLengthValue*)variable.mParameters.at(0); |
|
1175 HbXmlLengthValue* heightVal = (HbXmlLengthValue*)variable.mParameters.at(1); |
|
1176 qreal width, height; |
|
1177 result &= toPixels(*widthVal, width); |
|
1178 result &= toPixels(*heightVal, height); |
|
1179 if ( result ) { |
|
1180 variant.setValue( QSizeF( width, height ) ); |
|
1181 } |
|
1182 break; |
|
1183 } |
|
1184 |
|
1185 case HbXmlVariable::RECT: |
|
1186 { |
|
1187 HbXmlLengthValue* widthVal = (HbXmlLengthValue*)variable.mParameters.at(0); |
|
1188 HbXmlLengthValue* heightVal = (HbXmlLengthValue*)variable.mParameters.at(1); |
|
1189 HbXmlLengthValue* posxVal = (HbXmlLengthValue*)variable.mParameters.at(2); |
|
1190 HbXmlLengthValue* posyVal = (HbXmlLengthValue*)variable.mParameters.at(3); |
|
1191 qreal width, height, posx, posy; |
|
1192 result &= toPixels(*widthVal, width); |
|
1193 result &= toPixels(*heightVal, height); |
|
1194 result &= toPixels(*posxVal, posx); |
|
1195 result &= toPixels(*posyVal, posy); |
|
1196 if ( result ) { |
|
1197 variant.setValue(QRectF(QPointF(posx, posy), QSizeF(width, height))); |
|
1198 } |
|
1199 break; |
|
1200 } |
|
1201 |
|
1202 case HbXmlVariable::POINT: |
|
1203 { |
|
1204 HbXmlLengthValue* posxVal = (HbXmlLengthValue*)variable.mParameters.at(0); |
|
1205 HbXmlLengthValue* posyVal = (HbXmlLengthValue*)variable.mParameters.at(1); |
|
1206 qreal posx, posy; |
|
1207 result &= toPixels(*posxVal, posx); |
|
1208 result &= toPixels(*posyVal, posy); |
|
1209 if ( result ) { |
|
1210 variant.setValue(QPointF(posx, posy)); |
|
1211 } |
|
1212 break; |
|
1213 } |
|
1214 |
|
1215 case HbXmlVariable::ENUMS: |
|
1216 { |
|
1217 // Relies on implicit conversion. |
|
1218 QString *string = (QString*)variable.mParameters.at(0); |
|
1219 variant.setValue(*string); |
|
1220 break; |
|
1221 } |
|
1222 |
|
1223 case HbXmlVariable::COLOR: |
|
1224 { |
|
1225 QColor *color = (QColor*)variable.mParameters.at(0); |
|
1226 variant.setValue(*color); |
|
1227 break; |
|
1228 } |
|
1229 |
|
1230 case HbXmlVariable::FONTSPEC: |
|
1231 { |
|
1232 quint8* role_b = (quint8*)variable.mParameters.at(0); |
|
1233 HbXmlLengthValue* textHeightVal = (HbXmlLengthValue*)variable.mParameters.at(1); |
|
1234 qreal textHeight; |
|
1235 if ( textHeightVal->mType != HbXmlLengthValue::None ) { |
|
1236 result = toPixels(*textHeightVal, textHeight); |
|
1237 } |
|
1238 if (result) { |
|
1239 HbFontSpec fontSpec((HbFontSpec::Role)(*role_b)); |
|
1240 if ( textHeightVal->mType != HbXmlLengthValue::None ) { |
|
1241 fontSpec.setTextHeight(textHeight); |
|
1242 } |
|
1243 variant.setValue(fontSpec); |
|
1244 } |
|
1245 break; |
|
1246 } |
|
1247 |
|
1248 default: |
|
1249 { |
|
1250 result = false; |
|
1251 break; |
|
1252 } |
|
1253 } |
|
1254 |
|
1255 return result; |
|
1256 } |
|
1257 |
|
1258 |