131 consider using other view elements like ListView (which only creates delegate items |
132 consider using other view elements like ListView (which only creates delegate items |
132 when they are scrolled into view) or use the \l {Dynamic Object Creation} methods to |
133 when they are scrolled into view) or use the \l {Dynamic Object Creation} methods to |
133 create items as they are required. |
134 create items as they are required. |
134 |
135 |
135 Also, note that Repeater is \l {Item}-based, and can only repeat \l {Item}-derived objects. |
136 Also, note that Repeater is \l {Item}-based, and can only repeat \l {Item}-derived objects. |
136 For example, it cannot be used to repeat QtObjects: |
137 For example, it cannot be used to repeat QObjects: |
137 \badcode |
138 \badcode |
138 Item { |
139 Item { |
139 //XXX does not work! Can't repeat QtObject as it doesn't derive from Item. |
140 //XXX does not work! Can't repeat QObject as it doesn't derive from Item. |
140 Repeater { |
141 Repeater { |
141 model: 10 |
142 model: 10 |
142 QtObject {} |
143 QObject {} |
143 } |
144 } |
144 } |
145 } |
145 \endcode |
146 \endcode |
146 */ |
147 */ |
147 |
148 |
148 /*! |
|
149 \internal |
|
150 \class QDeclarativeRepeater |
|
151 */ |
|
152 |
|
153 /*! |
|
154 Create a new QDeclarativeRepeater instance. |
|
155 */ |
|
156 QDeclarativeRepeater::QDeclarativeRepeater(QDeclarativeItem *parent) |
149 QDeclarativeRepeater::QDeclarativeRepeater(QDeclarativeItem *parent) |
157 : QDeclarativeItem(*(new QDeclarativeRepeaterPrivate), parent) |
150 : QDeclarativeItem(*(new QDeclarativeRepeaterPrivate), parent) |
158 { |
151 { |
159 } |
152 } |
160 |
153 |
161 /*! |
|
162 Destroy the repeater instance. All items it instantiated are also |
|
163 destroyed. |
|
164 */ |
|
165 QDeclarativeRepeater::~QDeclarativeRepeater() |
154 QDeclarativeRepeater::~QDeclarativeRepeater() |
166 { |
155 { |
167 } |
156 } |
168 |
157 |
169 /*! |
158 /*! |
243 /* |
232 /* |
244 connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); |
233 connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); |
245 connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); |
234 connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); |
246 */ |
235 */ |
247 regenerate(); |
236 regenerate(); |
248 emit countChanged(); |
237 } |
249 } |
238 emit countChanged(); |
250 } |
239 } |
251 |
240 |
252 /*! |
241 /*! |
253 \qmlproperty Component Repeater::delegate |
242 \qmlproperty Component Repeater::delegate |
254 \default |
243 \default |
298 return d->model->count(); |
287 return d->model->count(); |
299 return 0; |
288 return 0; |
300 } |
289 } |
301 |
290 |
302 |
291 |
303 /*! |
|
304 \internal |
|
305 */ |
|
306 void QDeclarativeRepeater::componentComplete() |
292 void QDeclarativeRepeater::componentComplete() |
307 { |
293 { |
308 QDeclarativeItem::componentComplete(); |
294 QDeclarativeItem::componentComplete(); |
309 regenerate(); |
295 regenerate(); |
310 } |
296 } |
311 |
297 |
312 /*! |
|
313 \internal |
|
314 */ |
|
315 QVariant QDeclarativeRepeater::itemChange(GraphicsItemChange change, |
298 QVariant QDeclarativeRepeater::itemChange(GraphicsItemChange change, |
316 const QVariant &value) |
299 const QVariant &value) |
317 { |
300 { |
318 QVariant rv = QDeclarativeItem::itemChange(change, value); |
301 QVariant rv = QDeclarativeItem::itemChange(change, value); |
319 if (change == ItemParentHasChanged) { |
302 if (change == ItemParentHasChanged) { |