diff -r f7ac710697a9 -r 06ff229162e9 src/hbwidgets/itemviews/hbtreeitemcontainer_p.cpp --- a/src/hbwidgets/itemviews/hbtreeitemcontainer_p.cpp Mon May 03 12:48:33 2010 +0300 +++ b/src/hbwidgets/itemviews/hbtreeitemcontainer_p.cpp Fri May 14 16:09:54 2010 +0300 @@ -26,15 +26,12 @@ #include "hbtreeitemcontainer_p.h" #include "hbtreeitemcontainer_p_p.h" #include "hbtreelayout_p.h" -#include "hbabstractitemcontainer_p.h" +#include "hbabstractitemcontainer_p_p.h" #include "hbabstractitemview.h" #include "hbtreeviewitem.h" #include "hbapplication.h" #include "hbmodeliterator.h" -// For QMAP_INT__ITEM_STATE_DEPRECATED's sake. Removed when QMap based state item system is removed -#include - #include #include @@ -168,7 +165,7 @@ { qreal minHeight = 0.0; if (mItems.count() > 0) { - minHeight = mLayout->sizeHint(Qt::PreferredSize).height() / mItems.count(); + minHeight = mLayout->effectiveSizeHint(Qt::PreferredSize).height() / mItems.count(); } if (minHeight == 0.0) { @@ -574,5 +571,35 @@ } } +/*! + \reimp + + All other sizehints are taken from list layout except preferred sizehint. List container preferred sizeHint + width is maximum width and height is average item height times index count. +*/ +QSizeF HbTreeItemContainer::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const +{ + Q_D(const HbTreeItemContainer); + + if (which == Qt::PreferredSize) { + HbModelIterator *modelIterator = d->modelIterator(); + if (modelIterator) { + return QSizeF(QWIDGETSIZE_MAX, d->itemHeight() * modelIterator->indexCount()); + } + } + + return HbAbstractItemContainer::sizeHint(which, constraint); +} + +/*! + \reimp + + Resizes the container to use layout preferred size. +*/ +void HbTreeItemContainer::resizeContainer() +{ + resize(layout()->preferredSize()); +} + #include "moc_hbtreeitemcontainer_p.cpp"