41 #endif |
41 #endif |
42 |
42 |
43 /*! |
43 /*! |
44 @beta |
44 @beta |
45 @hbwidgets |
45 @hbwidgets |
46 \class HbDataFormViewItem represents an item/view in HbDataForm. Each HbDataFormModelItem |
46 \class HbDataFormViewItem |
47 added inside a model is represented using HbDataFormViewItem instance. |
47 \brief HbDataFormViewItem represents an item view in HbDataForm corresponding to model item. |
|
48 Each HbDataFormModelItem added inside model is represented using HbDataFormViewItem instance. |
48 |
49 |
49 HbDataFormViewItem have different visualization based upon the |
50 HbDataFormViewItem have different visualization based upon the |
50 HbDataFormModelItem::DataItemType: |
51 HbDataFormModelItem::DataItemType: |
51 |
52 |
52 - FormPageItem: This type does not have any visualization. Whatever QString is passed while |
53 - FormPageItem: This type does not have any visualization. Whatever QString is passed while |
58 HbDataFormModelItem for this type is set as a group heading. |
59 HbDataFormModelItem for this type is set as a group heading. |
59 - GroupPageItem: This type does not have any visualization. Whatever QString is passed while |
60 - GroupPageItem: This type does not have any visualization. Whatever QString is passed while |
60 creating HbDataFormModelItem, is added in a group combo box. User can switch between |
61 creating HbDataFormModelItem, is added in a group combo box. User can switch between |
61 different group page using this combo. |
62 different group page using this combo. |
62 - DataItems: Any type other then FormPageItem, GroupItem and GroupPageItem is treated as |
63 - DataItems: Any type other then FormPageItem, GroupItem and GroupPageItem is treated as |
63 a data item. Data item contains label and the content widget. Data item content |
64 a data item. Data item can contain label, description, icon and content widget. Data items |
64 widget can be set using HbDataFormModelItem::ItemTypeRole and label of data items |
65 can not have any children. They are always placed at the leaf. Data item content widget |
65 can be set using HbDataFormModelItem::LabelRole. Data items can not have any |
66 can be set using HbDataFormModelItem::ItemTypeRole, label of data items can be set using |
66 children. They are always placed at the leaf. |
67 HbDataFormModelItem::LabelRole, description of data item can be set using |
|
68 HbDataFormModelItem::DescriptionRole. |
67 |
69 |
68 If HbDataFormViewItem represents a GroupItem then it can be expanded and collapsed. |
70 If HbDataFormViewItem represents a GroupItem then it can be expanded and collapsed. |
69 If group is expanded then all the child items are shown. |
71 If group is expanded then all the child items are shown. |
70 |
72 |
71 If user wants to create a custom data item then he has to derive from this class and set that |
73 If user wants to create a custom data item then he has to derive from this class and set that |
157 { |
159 { |
158 } |
160 } |
159 |
161 |
160 /*! |
162 /*! |
161 \reimp |
163 \reimp |
162 Creates HbDataFormViewItem. This function is called form HbAbstractItemContainer |
164 Creates HbDataFormViewItem. This function is called from HbAbstractItemContainer |
163 when model is getting parsed for creating items. |
165 when model is getting parsed for creating items. |
164 |
166 |
165 */ |
167 */ |
166 HbAbstractViewItem* HbDataFormViewItem::createItem() |
168 HbAbstractViewItem* HbDataFormViewItem::createItem() |
167 { |
169 { |
168 return new HbDataFormViewItem(*this); |
170 return new HbDataFormViewItem(*this); |
169 } |
171 } |
170 /*! |
172 /*! |
171 \reimp |
173 \reimp |
172 Returns true if \a model index is supported by HbDataFormViewItem, otherwise returns false. |
174 Returns true if \a model index is supported by HbDataFormViewItem prototype, otherwise returns false. |
173 This function is called for every item on the prototype list (, if several prototypes exist) |
175 This function is called for every item on the prototype list (if several prototypes exist) |
174 until item is found, which can create item for \a index. The prototype list is gone |
176 until item is found, which can create view item for \a index. |
175 through from end to the beginning. |
177 |
176 \sa HbAbstractItemView::setItemPrototype(HbAbstractViewItem *prototype), HbAbstractItemView::setItemPrototype(const QList<HbAbstractViewItem *> &prototypes) |
178 \sa HbAbstractItemView::setItemPrototype(HbAbstractViewItem *prototype) |
177 |
179 \sa HbAbstractItemView::setItemPrototype(const QList<HbAbstractViewItem *> &prototypes) |
178 |
|
179 */ |
180 */ |
180 bool HbDataFormViewItem::canSetModelIndex(const QModelIndex &index) const |
181 bool HbDataFormViewItem::canSetModelIndex(const QModelIndex &index) const |
181 { |
182 { |
182 HbDataFormModelItem::DataItemType itemType = |
183 HbDataFormModelItem::DataItemType itemType = |
183 static_cast<HbDataFormModelItem::DataItemType>( |
184 static_cast<HbDataFormModelItem::DataItemType>( |
192 |
193 |
193 } |
194 } |
194 |
195 |
195 /*! |
196 /*! |
196 \reimp |
197 \reimp |
197 Updates child graphics items to represent current state and content. In case when |
198 Updates child graphics items to represent current state and content stored in model. In case when |
198 HbDataFormViewItem represents data item and DataItemType is set to custom item, then |
199 HbDataFormViewItem represents data item and DataItemType is set to custom item, then |
199 createCustomWidget is called. User can override createCustomWidget and can pass his own |
200 createCustomWidget is called. User can override createCustomWidget and can pass his own |
200 custom widget. |
201 custom widget. |
201 |
202 |
202 \sa createCustomWidget |
203 \sa createCustomWidget |
274 setProperty( "hasIcon", false ); |
275 setProperty( "hasIcon", false ); |
275 return *this; |
276 return *this; |
276 } |
277 } |
277 |
278 |
278 /*! |
279 /*! |
279 @alpha |
280 @beta |
|
281 |
280 Restores the data from the model and assign to the widget. |
282 Restores the data from the model and assign to the widget. |
281 The property for restoring and saving the data need to be initialized when the |
283 The content widget property for restoring and saving the data need to be initialized when the |
282 data item is created. |
284 data item is created. If model item type is custom, then application developer has to override |
|
285 this API in order to get notification when data is changed in model. |
283 |
286 |
284 \sa save |
287 \sa save |
285 */ |
288 */ |
286 void HbDataFormViewItem::restore() |
289 void HbDataFormViewItem::restore() |
287 { |
290 { |
328 } |
331 } |
329 } |
332 } |
330 } |
333 } |
331 |
334 |
332 /*! |
335 /*! |
333 @alpha |
336 @beta |
334 Saves the current data of the content widget in data item to the model . |
337 |
|
338 Saves the current data of the content widget in data item to the model. |
335 The property for restoring and saving the data need to be initialized when the |
339 The property for restoring and saving the data need to be initialized when the |
336 data item is created. |
340 data item is created. If model item type is custom, then application developer has to override |
|
341 this API in order to save the content widget value in model. |
337 |
342 |
338 \sa restore |
343 \sa restore |
339 */ |
344 */ |
340 void HbDataFormViewItem::save() |
345 void HbDataFormViewItem::save() |
341 { |
346 { |
354 } |
359 } |
355 } |
360 } |
356 } |
361 } |
357 |
362 |
358 /*! |
363 /*! |
359 @alpha |
364 @beta |
360 |
365 |
361 This is a virtual function which by default returns NULL. This function must be overridden |
366 This is a virtual function which by default returns NULL. This function must be overridden |
362 in case user wants to create a data item of type custom item. The user is supposed to pass |
367 in case user wants to create a data item of type custom item. The user is supposed to pass |
363 the widget which is wants to display in data item. |
368 the widget which he wants to display in data item. |
364 */ |
369 */ |
365 HbWidget* HbDataFormViewItem::createCustomWidget() |
370 HbWidget* HbDataFormViewItem::createCustomWidget() |
366 { |
371 { |
367 return 0; |
372 return 0; |
368 } |
373 } |
369 |
374 |
370 /*! |
375 /*! |
371 \reimp |
376 \reimp |
372 Sets the item to either collapse or expanded, depending on the value of \a expanded. |
377 Sets the item to either collapse or expanded state, depending on the value of \a expanded. |
373 The function calls setModelIndexes which inturn will make the child items visible/invisible |
378 The function calls setModelIndexes which inturn will make the child items visible/invisible |
374 accordingly. This API is valid if HbDataFormViewItem represents a GroupItem. |
379 accordingly. This API is valid only if HbDataFormViewItem represents a FormPageItem, GroupItem |
|
380 or GroupPageItem. |
375 |
381 |
376 \sa isExpanded |
382 \sa isExpanded |
377 */ |
383 */ |
378 void HbDataFormViewItem::setExpanded(bool expanded) |
384 void HbDataFormViewItem::setExpanded(bool expanded) |
379 { |
385 { |
404 } |
410 } |
405 return false; |
411 return false; |
406 } |
412 } |
407 |
413 |
408 /*! |
414 /*! |
409 This API is valid only if HbDataFormViewItem represents a data item. Returns the |
415 @beta |
410 content widget of data item. For example if data item is of type SliderItem then |
416 |
411 this API will return the instance of HbSlider. |
417 Returns the content widget of data item. For example if data item is of type SliderItem |
412 If user wants to connect to some signals of content widget in data item then this |
418 then this API will return the instance of HbSlider. If user wants to connect to some |
413 API can be used to fetch the instance of the widget. It will return the instance only |
419 signals of content widget in data item then this API can be used to fetch the instance |
414 if data item is visible. User can connect to HbDataForm::activated() signal |
420 of the widget. It will return the instance only if data item is visible. User can connect |
415 and when this item is visible then he can query the content widget using this API. |
421 to HbDataForm::itemShown() signal and when this item is visible then he can query the |
|
422 content widget using this API. |
416 */ |
423 */ |
417 HbWidget* HbDataFormViewItem::dataItemContentWidget()const |
424 HbWidget* HbDataFormViewItem::dataItemContentWidget()const |
418 { |
425 { |
419 Q_D(const HbDataFormViewItem); |
426 Q_D(const HbDataFormViewItem); |
420 HbWidget *widget = d->mContentWidget;; |
427 HbWidget *widget = d->mContentWidget;; |
451 //not called in HbAbstractViewItem::pressStateChanged. |
458 //not called in HbAbstractViewItem::pressStateChanged. |
452 Q_UNUSED(value); |
459 Q_UNUSED(value); |
453 Q_UNUSED(animate); |
460 Q_UNUSED(animate); |
454 } |
461 } |
455 |
462 |
|
463 /*! |
|
464 \reimp |
|
465 */ |
456 void HbDataFormViewItem::initStyleOption(HbStyleOptionDataFormViewItem *option) const |
466 void HbDataFormViewItem::initStyleOption(HbStyleOptionDataFormViewItem *option) const |
457 { |
467 { |
458 Q_D( const HbDataFormViewItem ); |
468 Q_D( const HbDataFormViewItem ); |
459 |
469 |
460 HbWidget::initStyleOption(option); |
470 HbWidget::initStyleOption(option); |
461 option->label = d->mLabel; |
471 option->label = d->mLabel; |
462 option->icon = d->mIcon; |
472 option->icon = d->mIcon; |
463 option->description = d->mDescription; |
473 option->description = d->mDescription; |
464 } |
474 } |
465 |
475 |
|
476 /*! |
|
477 \reimp |
|
478 */ |
466 void HbDataFormViewItem::showEvent(QShowEvent * event) |
479 void HbDataFormViewItem::showEvent(QShowEvent * event) |
467 { |
480 { |
468 Q_D( const HbDataFormViewItem ); |
481 Q_D( const HbDataFormViewItem ); |
469 |
482 |
470 HbWidget::showEvent( event ); |
483 HbWidget::showEvent( event ); |