src/hbwidgets/itemviews/hbgridview_p.h
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 6 c3690ec91ef8
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    26 #define HBGRIDVIEW_P_H
    26 #define HBGRIDVIEW_P_H
    27 
    27 
    28 #include <hbabstractitemview_p.h>
    28 #include <hbabstractitemview_p.h>
    29 #include <hbgriditemcontainer_p.h>
    29 #include <hbgriditemcontainer_p.h>
    30 #include <hbgridview.h>
    30 #include <hbgridview.h>
       
    31 #include <hbgridviewitem_p.h>
    31 
    32 
    32 class HbGridViewParams;
    33 class HbGridViewParams;
    33 class HbGridViewPrivate: public HbAbstractItemViewPrivate
    34 class HbGridViewPrivate: public HbAbstractItemViewPrivate
    34 {
    35 {
    35     Q_DECLARE_PUBLIC(HbGridView)
    36     Q_DECLARE_PUBLIC(HbGridView)
    41 
    42 
    42     QModelIndex itemIndexUnder(const QPointF& point);
    43     QModelIndex itemIndexUnder(const QPointF& point);
    43 
    44 
    44     bool visible(HbAbstractViewItem* item, bool fullyVisible = true) const;
    45     bool visible(HbAbstractViewItem* item, bool fullyVisible = true) const;
    45 
    46 
    46     inline HbGridItemContainer *itemContainer() const
    47     inline HbGridItemContainer *itemContainer() const;
    47     {
       
    48         return static_cast<HbGridItemContainer *> (mContainer);
       
    49     }
       
    50 
    48 
       
    49     qreal calculateScrollBarPos() const;
       
    50     qreal calculateScrollBarThumbSize() const;
    51     void updateScrollBar(Qt::Orientation orientation);
    51     void updateScrollBar(Qt::Orientation orientation);
    52     void updateVerticalScrollBar();
       
    53     void updateHorizontalScrollBar();
       
    54     void setScrollBarMetrics(Qt::Orientation orientation);
    52     void setScrollBarMetrics(Qt::Orientation orientation);
    55 
    53 
    56     void setContentPosition( qreal value, Qt::Orientation orientation, bool animate );
    54     void setContentPosition(qreal value, Qt::Orientation orientation, bool animate);
       
    55 
       
    56     inline int getScrollDirectionColumnCount() const;
       
    57     inline int getScrollDirectionRowCount() const;
       
    58     inline HbScrollBar *getScrollDirectionScrollBar() const;
       
    59     inline qreal getScrollDirectionContainerPos() const;
       
    60     inline qreal getScrollDirectionItemSize() const;
    57 
    61 
    58     inline QModelIndex indexInTheCenter() const;
    62     inline QModelIndex indexInTheCenter() const;
    59     QModelIndex indexInTheCenter(Qt::Orientations scrollDirection) const;
    63     QModelIndex indexInTheCenter(Qt::Orientations scrollDirection) const;
    60 
    64 
    61 public:
    65 public:
    73         Q_ASSERT(view);
    77         Q_ASSERT(view);
    74         return view->d_func();
    78         return view->d_func();
    75     }
    79     }
    76 
    80 
    77     friend class HbGridViewItem;
    81     friend class HbGridViewItem;
       
    82 };
    78 
    83 
    79 };
    84 inline HbGridItemContainer *HbGridViewPrivate::itemContainer() const
       
    85 {
       
    86     return qobject_cast<HbGridItemContainer *> (mContainer);
       
    87 }
       
    88 
       
    89 inline int HbGridViewPrivate::getScrollDirectionColumnCount() const
       
    90 {
       
    91     return (mScrollDirections == Qt::Vertical) ?
       
    92         itemContainer()->columnCount() : itemContainer()->rowCount();
       
    93 }
       
    94 
       
    95 inline int HbGridViewPrivate::getScrollDirectionRowCount() const
       
    96 {
       
    97     return (mScrollDirections == Qt::Vertical) ?
       
    98         itemContainer()->rowCount() : itemContainer()->columnCount();
       
    99 }
       
   100 
       
   101 inline HbScrollBar *HbGridViewPrivate::getScrollDirectionScrollBar() const
       
   102 {
       
   103     return (mScrollDirections == Qt::Vertical) ?
       
   104         mVerticalScrollBar : mHorizontalScrollBar;
       
   105 }
       
   106 
       
   107 inline qreal HbGridViewPrivate::getScrollDirectionContainerPos() const
       
   108 {
       
   109     return (mScrollDirections == Qt::Vertical) ?
       
   110         mContainer->pos().y() : mContainer->pos().x();
       
   111 }
       
   112 
       
   113 inline qreal HbGridViewPrivate::getScrollDirectionItemSize() const
       
   114 {
       
   115     // caller responsibility to check if container has any item
       
   116     return (mScrollDirections == Qt::Vertical) ?
       
   117         mContainer->items().first()->size().height()
       
   118         : mContainer->items().first()->size().width();
       
   119 }
    80 
   120 
    81 QModelIndex HbGridViewPrivate::indexInTheCenter() const
   121 QModelIndex HbGridViewPrivate::indexInTheCenter() const
    82 {
   122 {
    83     return indexInTheCenter(mScrollDirections);
   123     return indexInTheCenter(mScrollDirections);
    84 }
   124 }