equal
deleted
inserted
replaced
25 |
25 |
26 #include "hblistitemcontainer_p.h" |
26 #include "hblistitemcontainer_p.h" |
27 #include "hblistitemcontainer_p_p.h" |
27 #include "hblistitemcontainer_p_p.h" |
28 #include "hblistlayout_p.h" |
28 #include "hblistlayout_p.h" |
29 |
29 |
30 #include "hbabstractitemcontainer.h" |
30 #include "hbabstractitemcontainer_p.h" |
31 #include "hbabstractitemview.h" |
31 #include "hbabstractitemview.h" |
32 #include "hblistviewitem.h" |
32 #include "hblistviewitem.h" |
33 #include "hbmodeliterator.h" |
33 #include "hbmodeliterator.h" |
34 |
34 |
35 #include <qmath.h> |
35 #include <qmath.h> |
144 |
144 |
145 qreal HbListItemContainerPrivate::itemHeight() const |
145 qreal HbListItemContainerPrivate::itemHeight() const |
146 { |
146 { |
147 qreal minHeight = 0.0; |
147 qreal minHeight = 0.0; |
148 if (mItems.count() > 0) { |
148 if (mItems.count() > 0) { |
149 minHeight = mLayout->sizeHint(Qt::PreferredSize).height() / mItems.count(); |
149 minHeight = mLayout->effectiveSizeHint(Qt::PreferredSize).height() / mItems.count(); |
150 } |
150 } |
151 |
151 |
152 if (minHeight == 0.0) { |
152 if (minHeight == 0.0) { |
153 minHeight = getSmallestItemHeight(); |
153 minHeight = getSmallestItemHeight(); |
154 } |
154 } |
509 } else { |
509 } else { |
510 item->deleteLater(); |
510 item->deleteLater(); |
511 } |
511 } |
512 } |
512 } |
513 |
513 |
|
514 /*! |
|
515 \reimp |
|
516 |
|
517 All other sizehints are taken from list layout except preferred sizehint. List container preferred sizeHint |
|
518 width is maximum width and height is average item height times index count. |
|
519 */ |
|
520 QSizeF HbListItemContainer::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
521 { |
|
522 Q_D(const HbListItemContainer); |
|
523 |
|
524 if (which == Qt::PreferredSize) { |
|
525 HbModelIterator *modelIterator = d->modelIterator(); |
|
526 if (modelIterator) { |
|
527 return QSizeF(QWIDGETSIZE_MAX, d->itemHeight() * modelIterator->indexCount()); |
|
528 } |
|
529 } |
|
530 |
|
531 return HbAbstractItemContainer::sizeHint(which, constraint); |
|
532 } |
|
533 |
|
534 /*! |
|
535 \reimp |
|
536 |
|
537 Resizes the container to use view width (if present; otherwise 0) |
|
538 and layout preferred height. |
|
539 */ |
|
540 void HbListItemContainer::resizeContainer() |
|
541 { |
|
542 Q_D(HbListItemContainer); |
|
543 |
|
544 if (d->mItemView) { |
|
545 resize(d->mItemView->size().width(), layout()->preferredHeight()); |
|
546 } else { |
|
547 resize(0, layout()->preferredHeight()); |
|
548 } |
|
549 } |
|
550 |
514 #include "moc_hblistitemcontainer_p.cpp" |
551 #include "moc_hblistitemcontainer_p.cpp" |
515 |
552 |
516 |
553 |