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 HBABSTRACTITEMCONTAINER_H |
|
27 #define HBABSTRACTITEMCONTAINER_H |
|
28 |
|
29 #include <hbwidget.h> |
|
30 |
|
31 class HbAbstractItemContainerPrivate; |
|
32 class QModelIndex; |
|
33 class HbAbstractViewItem; |
|
34 class HbAbstractItemView; |
|
35 |
|
36 class HB_WIDGETS_EXPORT HbAbstractItemContainer : public HbWidget |
|
37 { |
|
38 Q_OBJECT |
|
39 |
|
40 public: |
|
41 explicit HbAbstractItemContainer(QGraphicsItem *parent = 0); |
|
42 virtual ~HbAbstractItemContainer(); |
|
43 |
|
44 virtual void addItem(const QModelIndex &index, bool animate = false); |
|
45 virtual void removeItem(const QModelIndex &index, bool animate = false); |
|
46 virtual void removeItem(int pos, bool animate = false); |
|
47 void removeItems(); |
|
48 |
|
49 HbAbstractViewItem* itemByIndex(const QModelIndex &index) const; |
|
50 QList<HbAbstractViewItem *> items() const; |
|
51 |
|
52 virtual void reset(); |
|
53 |
|
54 HbAbstractItemView *itemView() const; |
|
55 void setItemView(HbAbstractItemView *view); |
|
56 |
|
57 virtual void setModelIndexes(const QModelIndex &startIndex = QModelIndex()); |
|
58 |
|
59 QModelIndex firstItemIndex() const; |
|
60 QModelIndex lastItemIndex() const; |
|
61 |
|
62 void firstAndLastVisibleModelIndex( |
|
63 QModelIndex& firstVisibleModelIndex, |
|
64 QModelIndex& lastVisibleModelIndex, |
|
65 bool fullyVisible = true) const; |
|
66 |
|
67 QList<HbAbstractViewItem *> itemPrototypes() const; |
|
68 bool setItemPrototype(HbAbstractViewItem *prototype); |
|
69 bool setItemPrototypes(const QList<HbAbstractViewItem *> &prototypes); |
|
70 |
|
71 void setItemTransientState(const QModelIndex &index, QHash<QString,QVariant> state); |
|
72 void setItemTransientStateValue(const QModelIndex &index, const QString &key, const QVariant &value); |
|
73 |
|
74 void setItemState(const QModelIndex &index, QMap<int,QVariant> state); |
|
75 void setItemStateValue(const QModelIndex &index, int key, QVariant value); |
|
76 |
|
77 QMap<int,QVariant> itemState(const QModelIndex &index) const; |
|
78 QHash<QString, QVariant> itemTransientState(const QModelIndex &index) const; |
|
79 |
|
80 void removeItemStates(); |
|
81 void removeItemTransientStates(); |
|
82 |
|
83 void setItemRecycling(bool enabled); |
|
84 bool itemRecycling() const; |
|
85 |
|
86 virtual void setUniformItemSizes(bool enable); |
|
87 bool uniformItemSizes() const; |
|
88 |
|
89 virtual bool eventFilter(QObject *obj, QEvent *event); |
|
90 |
|
91 enum { Type = Hb::ItemType_AbstractItemContainer }; |
|
92 int type() const; |
|
93 |
|
94 signals: |
|
95 |
|
96 void itemCreated(HbAbstractViewItem *item); |
|
97 |
|
98 protected: |
|
99 |
|
100 HbAbstractItemContainer(HbAbstractItemContainerPrivate &dd, QGraphicsItem *parent); |
|
101 |
|
102 virtual void itemAdded(int index, HbAbstractViewItem *item, bool animate) = 0; |
|
103 virtual void itemRemoved(HbAbstractViewItem *item, bool animate) = 0; |
|
104 |
|
105 virtual void viewResized(const QSizeF &size) = 0; |
|
106 |
|
107 virtual void setItemModelIndex(HbAbstractViewItem *item, const QModelIndex &index); |
|
108 |
|
109 QVariant itemChange(GraphicsItemChange change, const QVariant & value) ; |
|
110 |
|
111 virtual QPointF recycleItems(const QPointF &delta); |
|
112 |
|
113 void insertItem(int pos, const QModelIndex &index, bool animate = false); |
|
114 |
|
115 virtual int maxItemCount() const; |
|
116 |
|
117 virtual bool event(QEvent *e); |
|
118 |
|
119 virtual HbAbstractViewItem *createDefaultPrototype() const = 0; |
|
120 |
|
121 private: |
|
122 |
|
123 Q_DECLARE_PRIVATE_D(d_ptr, HbAbstractItemContainer) |
|
124 Q_DISABLE_COPY(HbAbstractItemContainer) |
|
125 |
|
126 friend class HbAbstractItemView; |
|
127 }; |
|
128 |
|
129 #endif |
|