author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:33:45 +0100 | |
branch | GCC_SURGE |
changeset 37 | 451b2e1545b2 |
parent 19 | afea38384506 |
parent 33 | 11b6825f0862 |
permissions | -rw-r--r-- |
24 | 1 |
/* |
2 |
* Copyright (c) 2009 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 RADIOSTRIPBASE_H_ |
|
19 |
#define RADIOSTRIPBASE_H_ |
|
20 |
||
21 |
// System includes |
|
22 |
#include <HbScrollArea> |
|
23 |
||
24 |
// Forward declarations |
|
25 |
class HbWidget; |
|
26 |
class QAbstractItemModel; |
|
27 |
||
28 |
// Class declaration |
|
29 |
class RadioStripBase : public HbScrollArea |
|
30 |
{ |
|
31 |
Q_OBJECT |
|
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
32 |
Q_PROPERTY(int autoScrollTime READ autoScrollTime WRITE setAutoScrollTime) |
24 | 33 |
|
34 |
public: |
|
35 |
||
36 |
virtual ~RadioStripBase(); |
|
37 |
||
38 |
void setAutoScrollTime( const int time ); |
|
39 |
int autoScrollTime() const; |
|
40 |
||
41 |
void setModel( QAbstractItemModel* model ); |
|
42 |
QAbstractItemModel* model() const; |
|
43 |
||
44 |
void setCyclic( bool isCyclic ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
45 |
void setOverlap( qreal overlap ); |
24 | 46 |
void setAutoCenter( bool autoCenter ); |
47 |
void setItemSize( const QSizeF& size ); |
|
48 |
void setIndex( int index, bool animateToCenter ); |
|
49 |
||
50 |
protected: |
|
51 |
||
52 |
RadioStripBase( QGraphicsItem* parent = 0 ); |
|
53 |
||
54 |
// from base class QGraphicsWidget |
|
55 |
||
56 |
void resizeEvent( QGraphicsSceneResizeEvent* event ); |
|
57 |
||
58 |
// from base class QGraphicsItem |
|
59 |
||
60 |
void mousePressEvent( QGraphicsSceneMouseEvent* event ); |
|
61 |
void mouseReleaseEvent( QGraphicsSceneMouseEvent* event ); |
|
62 |
||
63 |
private: |
|
64 |
||
65 |
Q_DISABLE_COPY( RadioStripBase ) |
|
66 |
||
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
67 |
// from base class HbScrollArea |
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
68 |
|
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
69 |
bool scrollByAmount( const QPointF& delta ); |
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
70 |
|
24 | 71 |
virtual void updateItemPrimitive( QGraphicsItem* itemToUpdate, int itemIndex ) = 0; |
72 |
virtual QGraphicsItem* createItemPrimitive( QGraphicsItem *parent ) = 0; |
|
73 |
||
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
74 |
virtual void scrollPosChanged() = 0; |
24 | 75 |
|
76 |
void moveAllItemsToPool(); |
|
77 |
||
78 |
void populateAndLayout(); |
|
79 |
||
80 |
QGraphicsItem* constructItem( int index, bool append ); |
|
81 |
||
82 |
QGraphicsItem* getFromPool(); |
|
83 |
||
84 |
void returnToPool( QGraphicsItem* item ); |
|
85 |
||
86 |
qreal indexToOffset( int index ); |
|
87 |
||
88 |
int offsetToIndex( qreal offset ); |
|
89 |
||
90 |
void updateItemWithIndex( int index ); |
|
91 |
||
92 |
void adjustItems(); |
|
93 |
||
94 |
protected: // data |
|
95 |
||
96 |
int mAutoScrollTime; |
|
97 |
||
98 |
private: //data |
|
99 |
||
100 |
HbWidget* mStripContainer; |
|
101 |
||
102 |
QAbstractItemModel* mModel; |
|
103 |
||
104 |
bool mIsCyclic; |
|
105 |
bool mAutoCenter; |
|
106 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
107 |
qreal mOverlap; |
24 | 108 |
|
109 |
QSizeF mItemSize; |
|
110 |
||
111 |
QList<QGraphicsItem*> mItemPool; |
|
112 |
QGraphicsWidget* mItemPoolParent; |
|
113 |
||
114 |
int mCurrentIndex; |
|
115 |
int mPressedIndex; |
|
116 |
||
117 |
qreal mStripLength; |
|
118 |
qreal mContentsLength; |
|
119 |
||
120 |
QList<QGraphicsItem*> mItemAtSlot; |
|
121 |
QList<int> mIndexAtSlot; // Can be bigger than rowcount if cyclic is used |
|
122 |
||
123 |
}; |
|
124 |
||
125 |
||
126 |
#endif // RADIOSTRIPBASE_H_ |