src/hbwidgets/itemviews/hbtreeitemcontainer_p.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 6 c3690ec91ef8
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
    26 #include "hbtreeitemcontainer_p.h"
    26 #include "hbtreeitemcontainer_p.h"
    27 #include "hbtreeitemcontainer_p_p.h"
    27 #include "hbtreeitemcontainer_p_p.h"
    28 #include "hbtreelayout_p.h"
    28 #include "hbtreelayout_p.h"
    29 #include "hbabstractitemcontainer_p.h"
    29 #include "hbabstractitemcontainer_p_p.h"
    30 #include "hbabstractitemview.h"
    30 #include "hbabstractitemview.h"
    31 #include "hbtreeviewitem.h"
    31 #include "hbtreeviewitem.h"
    32 #include "hbapplication.h"
    32 #include "hbapplication.h"
    33 #include "hbmodeliterator.h"
    33 #include "hbmodeliterator.h"
    34 
       
    35 // For QMAP_INT__ITEM_STATE_DEPRECATED's sake. Removed when QMap<int,QVariant> based state item system is removed
       
    36 #include <hbabstractviewitem_p.h>
       
    37 
    34 
    38 #include <qmath.h>
    35 #include <qmath.h>
    39 
    36 
    40 #include <QDebug>
    37 #include <QDebug>
    41 
    38 
   166 */
   163 */
   167 qreal HbTreeItemContainerPrivate::itemHeight() const
   164 qreal HbTreeItemContainerPrivate::itemHeight() const
   168 {
   165 {
   169     qreal minHeight = 0.0;
   166     qreal minHeight = 0.0;
   170     if (mItems.count() > 0) {
   167     if (mItems.count() > 0) {
   171         minHeight = mLayout->sizeHint(Qt::PreferredSize).height() / mItems.count();
   168         minHeight = mLayout->effectiveSizeHint(Qt::PreferredSize).height() / mItems.count();
   172     }
   169     }
   173 
   170 
   174     if (minHeight == 0.0) {
   171     if (minHeight == 0.0) {
   175         minHeight = getSmallestItemHeight();
   172         minHeight = getSmallestItemHeight();
   176     }
   173     }
   572     } else {
   569     } else {
   573         item->deleteLater();
   570         item->deleteLater();
   574     }
   571     }
   575 }
   572 }
   576 
   573 
       
   574 /*!
       
   575     \reimp
       
   576 
       
   577     All other sizehints are taken from list layout except preferred sizehint. List container preferred sizeHint 
       
   578     width is maximum width and height is average item height times index count.
       
   579 */
       
   580 QSizeF HbTreeItemContainer::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
       
   581 {
       
   582     Q_D(const HbTreeItemContainer);
       
   583 
       
   584     if (which == Qt::PreferredSize) {
       
   585         HbModelIterator *modelIterator = d->modelIterator();
       
   586         if (modelIterator) {
       
   587             return QSizeF(QWIDGETSIZE_MAX, d->itemHeight() * modelIterator->indexCount());
       
   588         }
       
   589     }
       
   590 
       
   591     return HbAbstractItemContainer::sizeHint(which, constraint);
       
   592 }
       
   593 
       
   594 /*!
       
   595     \reimp
       
   596 
       
   597     Resizes the container to use layout preferred size.
       
   598 */
       
   599 void HbTreeItemContainer::resizeContainer()
       
   600 {      
       
   601     resize(layout()->preferredSize());
       
   602 }
       
   603 
   577 #include "moc_hbtreeitemcontainer_p.cpp"
   604 #include "moc_hbtreeitemcontainer_p.cpp"
   578 
   605