|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbWidgets module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 |
|
26 #ifndef HBABSTRACTITEMVIEW_P_H |
|
27 #define HBABSTRACTITEMVIEW_P_H |
|
28 |
|
29 // |
|
30 // W A R N I N G |
|
31 // ------------- |
|
32 // |
|
33 // This file is not part of the Qt API. It exists purely as an |
|
34 // implementation detail. This header file may change from version to |
|
35 // version without notice, or even be removed. |
|
36 // |
|
37 // We mean it. |
|
38 // |
|
39 |
|
40 #include "hbabstractitemview.h" |
|
41 #include "hbscrollarea_p.h" |
|
42 #include <hbeffect.h> |
|
43 |
|
44 #include <QItemSelectionModel> |
|
45 #include <QPointer> |
|
46 #include <QPersistentModelIndex> |
|
47 |
|
48 QT_BEGIN_NAMESPACE |
|
49 class QModelIndex; |
|
50 class QEvent; |
|
51 class QTimer; |
|
52 QT_END_NAMESPACE |
|
53 |
|
54 class HbAbstractItemContainer; |
|
55 class HbAbstractViewItem; |
|
56 class HbModelIterator; |
|
57 |
|
58 class HbAbstractItemViewPrivate : public HbScrollAreaPrivate |
|
59 { |
|
60 Q_DECLARE_PUBLIC(HbAbstractItemView) |
|
61 |
|
62 public: |
|
63 enum ItemViewOption { |
|
64 NoOptions = 0x0000, |
|
65 PanningActive = 0x0001 |
|
66 }; |
|
67 |
|
68 enum SelectionSetting{ |
|
69 None = 0x0000, |
|
70 Selection = 0x0001 |
|
71 }; |
|
72 |
|
73 Q_DECLARE_FLAGS(ItemViewOptions, ItemViewOption) |
|
74 Q_DECLARE_FLAGS(SelectionSettings, SelectionSetting) |
|
75 |
|
76 public: |
|
77 HbAbstractItemViewPrivate(); |
|
78 virtual ~HbAbstractItemViewPrivate(); |
|
79 void init(HbAbstractItemContainer *container, HbModelIterator *modelIterator); |
|
80 |
|
81 void setModel(QAbstractItemModel *model); |
|
82 void initializeNewModel(); |
|
83 void clearCurrentModel(); |
|
84 |
|
85 void setSelectionModel(QItemSelectionModel *selectionModel); |
|
86 |
|
87 // use ItemPosition as position |
|
88 QPointF pixelsToScroll(const HbAbstractViewItem *item, HbAbstractItemView::ScrollHint hint); |
|
89 |
|
90 void saveIndexMadeVisibleAfterMetricsChange(); |
|
91 |
|
92 QItemSelectionModel::SelectionFlags contiguousSelectionCommand( |
|
93 const HbAbstractViewItem *item, const QEvent *event ); |
|
94 QItemSelectionModel::SelectionFlags multiSelectionCommand( |
|
95 const HbAbstractViewItem *item, const QEvent *event ); |
|
96 QItemSelectionModel::SelectionFlags singleSelectionCommand( |
|
97 const HbAbstractViewItem *item, const QEvent *event ); |
|
98 |
|
99 HbAbstractViewItem *itemAt(const QPointF& position) const; |
|
100 |
|
101 virtual bool visible(HbAbstractViewItem* item, bool fullyVisible = true) const; |
|
102 |
|
103 HbAbstractViewItem* currentItem() const; |
|
104 |
|
105 HbAbstractViewItem* viewItem(QGraphicsItem *item) const; |
|
106 |
|
107 void updateScrollBar(Qt::Orientation orientation); |
|
108 |
|
109 void refreshContainerGeometry(); |
|
110 |
|
111 QRectF itemBoundingRect(const QGraphicsItem *item) const; |
|
112 |
|
113 void updateItems(); |
|
114 |
|
115 virtual void scrollTo(const QModelIndex &index, HbAbstractItemView::ScrollHint hint); |
|
116 void revealItem(const HbAbstractViewItem *item, HbAbstractItemView::ScrollHint hint); |
|
117 void checkBoundaries(QPointF &newPos); |
|
118 |
|
119 void updateScrollBarForUniformSizedItems(); |
|
120 void updateScrollBarForVariableSizedItems(); |
|
121 void setScrollBarMetrics(Qt::Orientation orientation); |
|
122 bool handleScrollBar(Qt::Orientation orientation); |
|
123 |
|
124 void rowsRemoved(const QModelIndex &parent, int start, int end); |
|
125 |
|
126 virtual QItemSelectionModel::SelectionFlags selectionFlags( |
|
127 const HbAbstractViewItem *item, |
|
128 const QEvent *event); |
|
129 void resetContainer(); |
|
130 void startAppearEffect(const QModelIndex &parent, int start, int end); |
|
131 virtual void ensureVisible(QPointF position, qreal xMargin, qreal yMargin); |
|
132 |
|
133 void _q_modelDestroyed(); |
|
134 void _q_layoutChanged(); |
|
135 void _q_animationEnabled(); |
|
136 void _q_animationFinished(const HbEffect::EffectStatus &status); |
|
137 |
|
138 public: |
|
139 QPersistentModelIndex mCurrentIndex; |
|
140 |
|
141 HbAbstractItemView::SelectionMode mSelectionMode; |
|
142 |
|
143 ItemViewOptions mOptions; |
|
144 |
|
145 SelectionSettings mSelectionSettings; |
|
146 |
|
147 QPointer<HbAbstractViewItem> mHitItem; |
|
148 |
|
149 // mContainer can always be assumed to be valid in the code |
|
150 HbAbstractItemContainer *mContainer; |
|
151 |
|
152 QModelIndex mVisibleIndex; |
|
153 |
|
154 QItemSelectionModel *mSelectionModel; |
|
155 QItemSelectionModel::SelectionFlag mContSelectionAction; |
|
156 |
|
157 bool mWasScrolling; |
|
158 QString mLayoutOptionName; |
|
159 bool mFilterRemoved; |
|
160 bool mClearingSelection; |
|
161 |
|
162 bool mAnimateItems; |
|
163 QList< QGraphicsItem * >mItemsAboutToBeDeleted; |
|
164 |
|
165 // introduced to solve scrollto problem when view is not visible |
|
166 QPersistentModelIndex mPostponedScrollIndex; |
|
167 HbAbstractItemView::ScrollHint mPostponedScrollHint; |
|
168 QModelIndex mPreviousSelectedIndex; |
|
169 QItemSelectionModel::SelectionFlags mPreviousSelectedCommand; |
|
170 Hb::InteractionModifiers mInstantClickedModifiers; |
|
171 |
|
172 QTimer *mAnimationTimer; |
|
173 QList< QPersistentModelIndex > mAppearAnimationIndexes; |
|
174 |
|
175 HbModelIterator *mModelIterator; |
|
176 HbAbstractItemView::ItemAnimations mEnabledAnimations; |
|
177 |
|
178 private: |
|
179 static HbAbstractItemViewPrivate *d_ptr(HbAbstractItemView *abstractItemView) { |
|
180 Q_ASSERT(abstractItemView); |
|
181 return abstractItemView->d_func(); |
|
182 } |
|
183 friend class HbGridItemContainer; |
|
184 friend class HbAbstractItemContainerPrivate; |
|
185 }; |
|
186 |
|
187 |
|
188 Q_DECLARE_OPERATORS_FOR_FLAGS( HbAbstractItemViewPrivate::ItemViewOptions ) |
|
189 Q_DECLARE_OPERATORS_FOR_FLAGS( HbAbstractItemViewPrivate::SelectionSettings ) |
|
190 |
|
191 #endif // HBABSTRACTITEMVIEW_P_H |