31 #include <hbeffect.h> |
31 #include <hbeffect.h> |
32 #include <hbframebackground.h> |
32 #include <hbframebackground.h> |
33 #include <hbnamespace.h> |
33 #include <hbnamespace.h> |
34 #include <hboogmwatcher_p.h> |
34 #include <hboogmwatcher_p.h> |
35 #include <hbabstractitemview.h> |
35 #include <hbabstractitemview.h> |
36 #include <hbstyleoptionabstractviewitem_p.h> |
36 #include <hbstyle.h> |
37 |
37 |
38 #include <QObject> |
38 #include <QObject> |
|
39 #include <QGraphicsItem> |
39 #include <QPersistentModelIndex> |
40 #include <QPersistentModelIndex> |
40 #include <QPointer> |
41 #include <QPointer> |
41 #include <QExplicitlySharedDataPointer> |
42 #include <QExplicitlySharedDataPointer> |
42 #include <QSharedData> |
43 #include <QSharedData> |
43 #include <QPainter> |
44 #include <QPainter> |
44 |
45 |
45 class QGraphicsItem; |
46 class QGraphicsObject; |
46 class QTimer; |
47 class QTimer; |
47 class QGestureEvent; |
48 class QGestureEvent; |
48 |
49 |
49 #define HB_SD(Class) Class##Shared * sd = (Class##Shared *)(d->mSharedData.data()) |
50 #define HB_SD(Class) Class##Shared * sd = (Class##Shared *)(d->mSharedData.data()) |
50 #define HB_SDD(Class) Q_D(Class); Class##Shared * sd = (Class##Shared *)(d->mSharedData.data()) |
51 #define HB_SDD(Class) Q_D(Class); Class##Shared * sd = (Class##Shared *)(d->mSharedData.data()) |
141 mItemView(0), |
142 mItemView(0), |
142 mDefaultFrame(), |
143 mDefaultFrame(), |
143 mItemType("viewitem"), |
144 mItemType("viewitem"), |
144 mPressStateChangeTimer(0), |
145 mPressStateChangeTimer(0), |
145 mPressedItem(0), |
146 mPressedItem(0), |
146 mLowGraphicsMemory(false), |
147 mLowGraphicsMemory(false) |
147 mStyleOption(0) |
|
148 { |
148 { |
149 HbOogmWatcher *watcher = HbOogmWatcher::instance(); |
149 HbOogmWatcher *watcher = HbOogmWatcher::instance(); |
150 |
150 |
151 connect(watcher, SIGNAL(graphicsMemoryLow()), this, SLOT(disablePixmapCaches())); |
151 connect(watcher, SIGNAL(graphicsMemoryLow()), this, SLOT(disablePixmapCaches())); |
152 connect(watcher, SIGNAL(graphicsMemoryGood()), this, SLOT(enablePixmapCaches())); |
152 connect(watcher, SIGNAL(graphicsMemoryGood()), this, SLOT(enablePixmapCaches())); |
153 |
|
154 mStyleOption = new HbStyleOptionAbstractViewItem; |
|
155 } |
153 } |
156 |
154 |
157 virtual ~HbAbstractViewItemShared() |
155 virtual ~HbAbstractViewItemShared() |
158 { |
156 { |
159 delete mStyleOption; |
157 } |
160 } |
158 |
|
159 void updateIconItemsAsyncMode(); |
|
160 |
|
161 void setItemView(HbAbstractItemView *view); |
161 |
162 |
162 public slots: |
163 public slots: |
163 |
164 |
164 void pressStateChangeTimerTriggered(); |
165 void pressStateChangeTimerTriggered(); |
165 void disablePixmapCaches(); |
166 void disablePixmapCaches(); |
166 void enablePixmapCaches(); |
167 void enablePixmapCaches(); |
167 |
168 |
|
169 void scrollingStarted(); |
|
170 |
168 public: |
171 public: |
169 |
172 |
170 HbAbstractViewItem *mPrototype; |
173 HbAbstractViewItem *mPrototype; |
171 HbAbstractItemView *mItemView; |
174 HbAbstractItemView *mItemView; |
172 |
175 |
179 QTimer *mPressStateChangeTimer; |
182 QTimer *mPressStateChangeTimer; |
180 HbAbstractViewItem *mPressedItem; |
183 HbAbstractViewItem *mPressedItem; |
181 bool mAnimatePress; |
184 bool mAnimatePress; |
182 |
185 |
183 bool mLowGraphicsMemory; |
186 bool mLowGraphicsMemory; |
184 |
|
185 HbStyleOptionAbstractViewItem *mStyleOption; |
|
186 }; |
187 }; |
187 |
188 |
188 class HbAbstractViewItemPrivate : public HbWidgetPrivate |
189 class HbAbstractViewItemPrivate : public HbWidgetPrivate |
189 { |
190 { |
190 Q_DECLARE_PUBLIC( HbAbstractViewItem ) |
191 Q_DECLARE_PUBLIC( HbAbstractViewItem ) |
265 return *this; |
266 return *this; |
266 } |
267 } |
267 |
268 |
268 void init(); |
269 void init(); |
269 |
270 |
|
271 static HbAbstractViewItemPrivate *d_ptr(HbAbstractViewItem *item) { |
|
272 Q_ASSERT(item); |
|
273 return item->d_func(); |
|
274 } |
|
275 |
270 inline bool isPrototype() const |
276 inline bool isPrototype() const |
271 { |
277 { |
272 Q_Q(const HbAbstractViewItem); |
278 Q_Q(const HbAbstractViewItem); |
273 return q == mSharedData->mPrototype; |
279 return q == mSharedData->mPrototype; |
274 } |
280 } |
275 |
281 |
276 |
282 |
277 virtual int modelItemType() const; |
283 virtual int modelItemType() const; |
278 |
284 |
279 void _q_animationFinished(const HbEffect::EffectStatus &status); |
285 void _q_animationFinished(const HbEffect::EffectStatus &status); |
|
286 void _q_childrenChanged(); |
280 |
287 |
281 void repolishCloneItems(); |
288 void repolishCloneItems(); |
282 void updateCloneItems(bool updateChildItems); |
289 void updateCloneItems(bool updateChildItems); |
283 |
290 |
284 virtual void setInsidePopup(bool insidePopup); |
291 virtual void setInsidePopup(bool insidePopup); |
288 void revealItem(); |
295 void revealItem(); |
289 |
296 |
290 void setPressed(bool pressed, bool animate); |
297 void setPressed(bool pressed, bool animate); |
291 |
298 |
292 void paintItems(QPainter *painter, QStyleOptionGraphicsItem *option, QGraphicsItem *startItem, QGraphicsItem *endItem); |
299 void paintItems(QPainter *painter, QStyleOptionGraphicsItem *option, QGraphicsItem *startItem, QGraphicsItem *endItem); |
293 void paintChildItemsRecursively(QGraphicsItem *child, QPainter *painter,QStyleOptionGraphicsItem *option); |
300 void paintChildItemsRecursively(QGraphicsItem *child, QPainter *painter,QStyleOptionGraphicsItem *option, const QPointF &translatePosition); |
294 |
301 void drawSubPixmap(QPixmap *pixmap, |
|
302 QPainter *painter, |
|
303 const QTransform &itemToPixmapTransform, |
|
304 const QStyleOptionGraphicsItem *option); |
295 void setChildFlags(QGraphicsItem *child, bool pixmapCacheEnabled); |
305 void setChildFlags(QGraphicsItem *child, bool pixmapCacheEnabled); |
296 void setChildFlagRecursively(bool pixmapCacheEnabled); |
306 void setChildFlagRecursively(bool pixmapCacheEnabled); |
297 |
307 |
298 inline bool usePixmapCache() const; |
308 inline bool usePixmapCache() const; |
299 |
309 |
304 QGraphicsItem *startItem, |
314 QGraphicsItem *startItem, |
305 QGraphicsItem *endItem); |
315 QGraphicsItem *endItem); |
306 |
316 |
307 void releasePixmaps(); |
317 void releasePixmaps(); |
308 |
318 |
|
319 static bool iconLoadedCallback(HbIconItem *target, void *param); |
|
320 |
|
321 bool iconLoaded(HbIconItem *target); |
|
322 |
|
323 void updateIconItemsAsyncMode(QGraphicsItem *item); |
|
324 |
|
325 inline void repolishItem(); |
309 public: |
326 public: |
310 QPersistentModelIndex mIndex; |
327 QPersistentModelIndex mIndex; |
311 |
328 |
312 QGraphicsItem *mBackgroundItem; |
329 QGraphicsObject *mBackgroundItem; |
313 QVariant mBackground; |
330 QVariant mBackground; |
314 |
331 |
315 QGraphicsItem *mFrame; |
332 QGraphicsObject *mFrame; |
316 |
333 |
317 Qt::CheckState mCheckState; |
334 Qt::CheckState mCheckState; |
318 QGraphicsItem *mSelectionItem; |
335 QGraphicsObject *mSelectionItem; |
319 |
336 |
320 int mModelItemType; |
337 int mModelItemType; |
321 bool mRepolishRequested; |
338 bool mRepolishRequested; |
322 |
339 |
323 // whether mContentChanged flag is supported |
340 // whether mContentChanged flag is supported |
324 bool mContentChangedSupported; |
341 bool mContentChangedSupported; |
325 // Status of child item existence changed. |
342 // Status of child item existence changed. |
326 bool mItemsChanged; |
343 bool mItemsChanged; |
327 bool mPressed; |
344 bool mPressed; |
328 |
345 |
329 QGraphicsItem *mFocusItem; |
346 QGraphicsObject *mFocusItem; |
330 |
347 |
331 QGraphicsItem *mMultiSelectionTouchArea; |
348 QGraphicsObject *mMultiSelectionTouchArea; |
332 |
349 |
333 QExplicitlySharedDataPointer<HbAbstractViewItemShared> mSharedData; |
350 QExplicitlySharedDataPointer<HbAbstractViewItemShared> mSharedData; |
334 |
351 |
335 HbViewItemPixmapPainter *mBackPixmapPainter; |
352 HbViewItemPixmapPainter *mBackPixmapPainter; |
336 HbViewItemPixmapPainter *mFrontPixmapPainter; |
353 HbViewItemPixmapPainter *mFrontPixmapPainter; |
337 |
354 |
|
355 QVector<QGraphicsItem*> mUpdateItems; |
|
356 |
338 bool mInPaintItems; |
357 bool mInPaintItems; |
339 |
358 |
340 QGraphicsItem *mNonCachableItem; |
359 QGraphicsItem *mNonCachableItem; |
341 bool mResetPixmapCache; |
360 bool mResetPixmapCache; |
342 |
361 |
|
362 QList<QGraphicsItem *> mChildren; |
|
363 |
343 friend class HbAbstractViewItemShared; |
364 friend class HbAbstractViewItemShared; |
344 }; |
365 }; |
345 |
366 |
346 bool HbAbstractViewItemPrivate::usePixmapCache() const |
367 bool HbAbstractViewItemPrivate::usePixmapCache() const |
347 { |
368 { |