src/hbwidgets/itemviews/hbtreeview_p.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 2 06ff229162e9
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    24 ****************************************************************************/
    24 ****************************************************************************/
    25     
    25     
    26 #include "hbtreeview_p.h"
    26 #include "hbtreeview_p.h"
    27 #include "hbtreeview.h"
    27 #include "hbtreeview.h"
    28 
    28 
    29 #include "hbtreeviewitem.h"
    29 #include "hbabstractitemcontainer.h"
    30 #include "hbtreeitemselectionmodel_p.h"
       
    31 #include "hbtreemodeliterator_p.h"
       
    32 
    30 
    33 const QString KDefaultLayoutOption = "default";
    31 const QString KDefaultLayoutOption = "default";
    34 
    32 
    35 HbTreeViewPrivate::HbTreeViewPrivate() :
    33 HbTreeViewPrivate::HbTreeViewPrivate() :
    36     HbAbstractItemViewPrivate(),
    34     HbAbstractItemViewPrivate(),
    37     mSelectionStarted(false)
    35     mSelectionStarted(false),
       
    36     mInSetExpanded(false)
    38 {
    37 {
    39 }
    38 }
    40 
    39 
    41 HbTreeViewPrivate::~HbTreeViewPrivate()
    40 HbTreeViewPrivate::~HbTreeViewPrivate()
    42 {
    41 {
    43 }
    42 }
    44 
    43 
    45 void HbTreeViewPrivate::init()
    44 void HbTreeViewPrivate::init()
    46 {
    45 {
    47     Q_Q(HbTreeView);
    46     Q_Q(HbTreeView);
    48 
       
    49     q->setClampingStyle(HbScrollArea::StrictClamping);
       
    50     q->setFrictionEnabled(0);
       
    51     q->setItemRecycling(true);
    47     q->setItemRecycling(true);
    52     q->setScrollDirections(Qt::Horizontal | Qt::Vertical);
    48     q->setScrollDirections(Qt::Horizontal | Qt::Vertical);
    53     mLayoutOptionName = KDefaultLayoutOption;
    49     mLayoutOptionName = KDefaultLayoutOption;
    54     treeModelIterator()->setItemContainer(mContainer, HbTreeViewItem::ExpansionKey);
    50     treeModelIterator()->setItemContainer(mContainer);
    55 }
    51 }
    56 
    52 
    57 bool HbTreeViewPrivate::isParentValid(const QModelIndex &parent) const
    53 bool HbTreeViewPrivate::isParentValid(const QModelIndex &parent) const
    58 {
    54 {
    59     bool valid = false;
    55     bool valid = false;
   105             previousIndex = previousIndexTemp;
   101             previousIndex = previousIndexTemp;
   106         }
   102         }
   107     }
   103     }
   108     return previousIndex;
   104     return previousIndex;
   109 }
   105 }
       
   106 
       
   107 /*!
       
   108     \reimp
       
   109 */
       
   110 bool HbTreeViewPrivate::handleScrollBar(Qt::Orientation orientation)
       
   111 {
       
   112     if (!mContainer->itemRecycling()
       
   113         || orientation == Qt::Horizontal
       
   114         || mContainer->itemPrototypes().count() != 1
       
   115         || mContainer->items().isEmpty()
       
   116         || !mVerticalScrollBar) {
       
   117         return false;
       
   118     } else {
       
   119         return true;
       
   120     }
       
   121 }
       
   122 
       
   123 bool HbTreeViewPrivate::animationEnabled(bool insertOperation)
       
   124 {
       
   125     if (mInSetExpanded) {
       
   126         if (insertOperation) {
       
   127             if (mEnabledAnimations & HbAbstractItemView::Expand) {
       
   128                 return true;
       
   129             }
       
   130         } else {
       
   131             if (mEnabledAnimations & HbAbstractItemView::Collapse) {
       
   132                 return true;
       
   133             }
       
   134         }
       
   135         return false;
       
   136     } else {
       
   137         return HbAbstractItemViewPrivate::animationEnabled(insertOperation);
       
   138 
       
   139     }
       
   140 }
       
   141