21 ** If you have questions regarding the use of this file, please contact |
21 ** If you have questions regarding the use of this file, please contact |
22 ** Nokia at developer.feedback@nokia.com. |
22 ** Nokia at developer.feedback@nokia.com. |
23 ** |
23 ** |
24 ****************************************************************************/ |
24 ****************************************************************************/ |
25 |
25 |
26 #ifndef HBABSTRACTITEMCONTAINERPRIVATE_H |
26 #ifndef HBABSTRACTITEMCONTAINER_P_H |
27 #define HBABSTRACTITEMCONTAINERPRIVATE_H |
27 #define HBABSTRACTITEMCONTAINER_P_H |
28 |
28 |
29 #include "hbwidget_p.h" |
29 #include <hbwidget.h> |
30 #include "hbabstractitemcontainer.h" |
|
31 #include "hbabstractviewitem.h" |
|
32 |
30 |
33 #include <QPersistentModelIndex> |
31 class HbAbstractItemContainerPrivate; |
34 |
32 class QModelIndex; |
35 class HbAbstractViewItem; |
33 class HbAbstractViewItem; |
36 class HbAbstractItemView; |
34 class HbAbstractItemView; |
37 |
35 |
38 #include <QHash> |
36 class HB_AUTOTEST_EXPORT HbAbstractItemContainer : public HbWidget |
39 |
|
40 class HbAbstractItemContainerPrivate : public HbWidgetPrivate |
|
41 { |
37 { |
42 Q_DECLARE_PUBLIC(HbAbstractItemContainer) |
38 Q_OBJECT |
43 |
39 |
44 public: |
40 public: |
|
41 explicit HbAbstractItemContainer(QGraphicsItem *parent = 0); |
|
42 virtual ~HbAbstractItemContainer(); |
45 |
43 |
46 struct StateItem |
44 virtual void addItem(const QModelIndex &index, bool animate = false); |
47 { |
45 virtual void removeItem(const QModelIndex &index, bool animate = false); |
48 QPersistentModelIndex index; |
46 virtual void removeItem(int pos, bool animate = false); |
49 QMap<int,QVariant> state; |
47 void removeItems(); |
50 }; |
|
51 |
48 |
52 HbAbstractItemContainerPrivate(); |
49 HbAbstractViewItem* itemByIndex(const QModelIndex &index) const; |
53 virtual ~HbAbstractItemContainerPrivate(); |
50 QList<HbAbstractViewItem *> items() const; |
54 |
51 |
55 QRectF itemBoundingRect(const QGraphicsItem *item) const; |
52 virtual void reset(); |
56 |
53 |
57 void firstAndLastVisibleBufferIndex(int& firstVisibleBufferIndex, |
54 HbAbstractItemView *itemView() const; |
58 int& lastVisibleBufferIndex, |
55 void setItemView(HbAbstractItemView *view); |
59 const QRectF &viewRect, |
56 |
|
57 virtual void setModelIndexes(const QModelIndex &startIndex = QModelIndex()); |
|
58 |
|
59 void firstAndLastVisibleModelIndex( |
|
60 QModelIndex& firstVisibleModelIndex, |
|
61 QModelIndex& lastVisibleModelIndex, |
60 bool fullyVisible = true) const; |
62 bool fullyVisible = true) const; |
61 |
63 |
62 bool visible(HbAbstractViewItem* item, const QRectF &viewRect, bool fullyVisible = true) const; |
64 QList<HbAbstractViewItem *> itemPrototypes() const; |
|
65 bool setItemPrototype(HbAbstractViewItem *prototype); |
|
66 bool setItemPrototypes(const QList<HbAbstractViewItem *> &prototypes); |
63 |
67 |
64 void deletePrototypes(); |
68 void setItemTransientState(const QModelIndex &index, QHash<QString,QVariant> state); |
|
69 void setItemTransientStateValue(const QModelIndex &index, const QString &key, const QVariant &value); |
65 |
70 |
66 int findStateItem(const QModelIndex &index) const; |
71 QMap<int,QVariant> itemState(const QModelIndex &index) const; |
|
72 QHash<QString, QVariant> itemTransientState(const QModelIndex &index) const; |
67 |
73 |
68 void initPrototype(HbAbstractViewItem *prototype) const; |
74 void removeItemTransientStates(); |
69 |
75 |
70 HbAbstractViewItem *createItem(const QModelIndex &index); |
76 void setItemRecycling(bool enabled); |
71 HbAbstractViewItem *itemPrototype(const QModelIndex& index) const; |
77 bool itemRecycling() const; |
72 |
78 |
73 virtual void updateItemBuffer(); |
79 virtual void setUniformItemSizes(bool enable); |
74 void increaseBufferSize(int amount); |
80 bool uniformItemSizes() const; |
75 void decreaseBufferSize(int amount); |
|
76 |
81 |
77 HbAbstractViewItem* item(const QModelIndex &index) const; |
82 virtual bool eventFilter(QObject *obj, QEvent *event); |
78 |
83 |
79 void doRemoveItem(HbAbstractViewItem *item, const QModelIndex &index, bool animate = false); |
84 virtual void resizeContainer(); |
80 |
85 |
81 void deleteItem(HbAbstractViewItem *item, bool animate = false); |
86 signals: |
82 |
87 |
83 virtual bool intoContainerBuffer(const QModelIndex &index) const; |
88 void itemCreated(HbAbstractViewItem *item); |
84 virtual int containerBufferIndexForModelIndex(const QModelIndex &index) const; |
|
85 |
89 |
86 virtual qreal getDiffWithoutScrollareaCompensation(const QPointF &delta) const; |
90 protected: |
87 |
91 |
88 void restoreItemPosition(HbAbstractViewItem *item, const QPointF &position); |
92 HbAbstractItemContainer(HbAbstractItemContainerPrivate &dd, QGraphicsItem *parent); |
89 |
93 |
90 void insertItem(HbAbstractViewItem *item, int pos, const QModelIndex &index, bool animate); |
94 virtual void itemAdded(int index, HbAbstractViewItem *item, bool animate) = 0; |
|
95 virtual void itemRemoved(HbAbstractViewItem *item, bool animate) = 0; |
91 |
96 |
92 mutable QList<HbAbstractViewItem*> mPrototypes; |
97 virtual void viewResized(const QSizeF &size) = 0; |
93 QList<StateItem> mItemStateList; |
|
94 QHash<QPersistentModelIndex, QHash<QString, QVariant> > mItemStates; |
|
95 |
98 |
96 QList<HbAbstractViewItem*> mItems; |
99 virtual void setItemModelIndex(HbAbstractViewItem *item, const QModelIndex &index); |
97 HbAbstractItemView *mItemView; |
|
98 |
100 |
99 int mBufferSize; |
101 QVariant itemChange(GraphicsItemChange change, const QVariant & value) ; |
100 bool mItemRecycling; |
|
101 |
102 |
102 bool mUniformItemSizes; |
103 virtual QPointF recycleItems(const QPointF &delta); |
103 QPersistentModelIndex mFirstItemIndex; |
104 |
104 static const int UpdateItemBufferEvent; |
105 void insertItem(int pos, const QModelIndex &index, bool animate = false); |
|
106 |
|
107 virtual int maxItemCount() const; |
|
108 |
|
109 virtual bool event(QEvent *e); |
|
110 |
|
111 virtual HbAbstractViewItem *createDefaultPrototype() const = 0; |
|
112 |
|
113 private: |
|
114 |
|
115 Q_DECLARE_PRIVATE_D(d_ptr, HbAbstractItemContainer) |
|
116 Q_DISABLE_COPY(HbAbstractItemContainer) |
|
117 |
|
118 friend class HbAbstractItemView; |
105 }; |
119 }; |
106 |
120 |
107 Q_DECLARE_METATYPE(HbAbstractItemContainerPrivate::StateItem) |
121 #endif |
108 |
|
109 #endif /* HBABSTRACTITEMCONTAINERPRIVATE_H */ |
|