|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef HGWIDGET_P_H |
|
19 #define HGWIDGET_P_H |
|
20 |
|
21 #include <hgwidgets/hgwidgets.h> |
|
22 #include <hbwidget_p.h> |
|
23 #include <QTimer> |
|
24 #include <QTime> |
|
25 |
|
26 class QAbstractItemModel; |
|
27 class HgContainer; |
|
28 class HgScrollBufferManager; |
|
29 class QGraphicsLinearLayout; |
|
30 class HgIndexFeedback; |
|
31 |
|
32 class HgWidgetPrivate : public HbWidgetPrivate |
|
33 { |
|
34 Q_DECLARE_PUBLIC(HgWidget) |
|
35 |
|
36 public: |
|
37 |
|
38 HgWidgetPrivate(); |
|
39 virtual ~HgWidgetPrivate(); |
|
40 |
|
41 void init(HgContainer *container); |
|
42 |
|
43 void setModel(QAbstractItemModel *model); |
|
44 |
|
45 void setSelectionModel(QItemSelectionModel *selectionModel); |
|
46 QItemSelectionModel *selectionModel() const; |
|
47 |
|
48 void setSelectionMode(HgWidget::SelectionMode mode, bool resetSelection); |
|
49 HgWidget::SelectionMode selectionMode() const; |
|
50 void selectAll(); |
|
51 void clearSelection(); |
|
52 |
|
53 QModelIndex currentIndex() const; |
|
54 void setCurrentIndex(const QModelIndex &index, |
|
55 QItemSelectionModel::SelectionFlags selectionFlag=QItemSelectionModel::NoUpdate); |
|
56 |
|
57 void scrollTo(const QModelIndex &index); |
|
58 |
|
59 bool getItemOutline(const QModelIndex& index, QPolygonF& points); |
|
60 void aboutToChangeOrientation(); |
|
61 void orientationChanged(Qt::Orientation orientation); |
|
62 |
|
63 QList<QModelIndex> getVisibleItemIndices() const; |
|
64 Qt::Orientation scrollDirection() const; |
|
65 |
|
66 void setIndexFeedbackPolicy( HgWidget::IndexFeedbackPolicy policy); |
|
67 HgWidget::IndexFeedbackPolicy indexFeedbackPolicy() const; |
|
68 |
|
69 private: |
|
70 |
|
71 void clearCurrentModel(); |
|
72 void initializeNewModel(); |
|
73 |
|
74 void adjustGeometry(); |
|
75 |
|
76 void createScrollBar(Qt::Orientation orientation); |
|
77 |
|
78 void setScrollBarPolicy(HgWidget::ScrollBarPolicy policy); |
|
79 void replaceScrollBar(HbScrollBar *scrollBar); |
|
80 |
|
81 virtual void updateScrollMetrics( qreal pos = 0 ); |
|
82 void prepareScrollBars( qreal pos = 0); |
|
83 |
|
84 virtual void updateScrollBar(qreal pos = 0); |
|
85 void displayScrollBar(qreal pos = 0); |
|
86 void setScrollBarMetrics(qreal pos = 0); |
|
87 |
|
88 void lostForeground(); |
|
89 void gainedForeground(); |
|
90 |
|
91 // private slot functions |
|
92 void _q_scrollPositionChanged(qreal index, bool scrollBarAnimation); |
|
93 void _q_releaseItems( int releaseStart, int releaseEnd ); |
|
94 void _q_requestItems( int requestStart, int requestEnd ); |
|
95 void _q_hideScrollBars(); |
|
96 void _q_thumbPositionChanged(qreal value, Qt::Orientation orientation); |
|
97 void _q_insertRows(const QModelIndex &parent, int start, int end); |
|
98 void _q_removeRows(const QModelIndex &parent, int start, int end); |
|
99 void _q_moveRows(const QModelIndex &sourceParent, int sourceStart, |
|
100 int sourceEnd, const QModelIndex &destinationParent, |
|
101 int destinationRow); |
|
102 void _q_groovePressed(qreal value, Qt::Orientation orientation); |
|
103 |
|
104 protected: |
|
105 |
|
106 QGraphicsLinearLayout *mLayout; |
|
107 |
|
108 HgContainer *mContainer; |
|
109 HgScrollBufferManager *mBufferManager; |
|
110 |
|
111 QAbstractItemModel *mModel; |
|
112 QItemSelectionModel *mSelectionModel; |
|
113 QItemSelectionModel *mDefaultSelectionModel; |
|
114 |
|
115 HbScrollBar *mScrollBar; |
|
116 HgWidget::ScrollBarPolicy mScrollBarPolicy; |
|
117 bool mAbleToScroll; |
|
118 QTimer mScrollBarHideTimer; |
|
119 |
|
120 bool mHandleLongPress; |
|
121 bool mForeground; |
|
122 int mBufferSize; |
|
123 HgIndexFeedback *mIndexFeedback; |
|
124 }; |
|
125 |
|
126 #endif //HGWIDGET_p_H |
|
127 |