src/hbwidgets/dataform/hbdataformmodel.cpp
changeset 3 11d3954df52a
parent 2 06ff229162e9
child 6 c3690ec91ef8
equal deleted inserted replaced
2:06ff229162e9 3:11d3954df52a
   121    \ingroup model-view
   121    \ingroup model-view
   122 
   122 
   123     HbDataFormModel is derived from QAbstractItemModel. So applications can use,
   123     HbDataFormModel is derived from QAbstractItemModel. So applications can use,
   124     QAbstractItemModel API's to create their datamodel. HbDataFormModel also provides
   124     QAbstractItemModel API's to create their datamodel. HbDataFormModel also provides
   125     convenience API's specific to HbDataForm. These convinience API's are useful in creating 
   125     convenience API's specific to HbDataForm. These convinience API's are useful in creating 
   126     form page, group, group page and data item.
   126     FormPageItem, GroupItem, GroupPageItem and data item.
   127 
   127 
   128     A HbDataForm can be used to display the contents of the model.
   128     A HbDataForm can be used to display the contents of the model.
   129     HbDataFormModel also has Apis to return modelindex of the items and vice-versa.
   129     HbDataFormModel also has APIs to return modelindex of the items and vice-versa.
   130     So applications can individually modify the items data and set it to the HbDataForm.
   130     So applications can individually modify the items data and set it to the HbDataForm.
       
   131 
       
   132     The signals emitted by HbDataFormModel
       
   133     \li dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) emitted when the 
       
   134     HbDataFormModel is updated \atopLeft and \abottomRight will be same since every node has only one column.
       
   135     User can connect to this signal and can fetch the instance of HbDataFormViewItem from HbDataForm 
       
   136     using the API dataFormViewItem(const QModelIndex &index) or user can fetch HbDataFormModelItem using API 
       
   137     itemFromIndex(const QModelIndex &index) in HbDataFormModel .When user updates model using 
       
   138     setContentWidgetData API provided in HbDataFormModelItem class, then DataForm takes care of updating the 
       
   139     corresponding item's visualization.
   131  */
   140  */
   132 
   141 
   133 /*!
   142 /*!
   134     Constructs a new data form model with the given \a parent.
   143     Constructs a new data form model with the given \a parent.
   135     
   144     
   140     Q_D(HbDataFormModel);
   149     Q_D(HbDataFormModel);
   141     d->q_ptr = this; 
   150     d->q_ptr = this; 
   142     HbDataFormModelItemPrivate::d_ptr(d->mRoot)->setModel(this);   
   151     HbDataFormModelItemPrivate::d_ptr(d->mRoot)->setModel(this);   
   143 }
   152 }
   144 
   153 
       
   154 /*!
       
   155     Destructor.    
       
   156 */
   145 HbDataFormModel::~HbDataFormModel()
   157 HbDataFormModel::~HbDataFormModel()
   146 {
   158 {
   147     Q_D(HbDataFormModel);
   159     Q_D(HbDataFormModel);
   148     removeItem(d->mRoot);
   160     removeItem(d->mRoot);
   149     delete d_ptr;
   161     delete d_ptr;
   150 }
   162 }
   151 
   163 
   152 /*!
   164 /*!
   153     @beta
   165     @beta
   154 
   166 
   155     Appends FormPageItem and return pointer to newly created HbDataFormModelItem.
   167     Appends FormPageItem and returns pointer to newly created HbDataFormModelItem.
   156     The parent of FormPageItem is always model's root item. The DataItemType is set
   168     The parent of FormPageItem is always model's root item. The DataItemType is set
   157     as FormPageItem.
   169     as FormPageItem.
   158 
   170 
   159     \a label Label for data page. This label will be added in the top level combo box.
   171     \a label Label for data page. This label will be added in the top level combo box.
   160 
   172 
   237     @beta
   249     @beta
   238 
   250 
   239     This is a convenience API. If user wants then he can create HbDataFormModelItem 
   251     This is a convenience API. If user wants then he can create HbDataFormModelItem 
   240     individually and then add that item in model using this API.
   252     individually and then add that item in model using this API.
   241     If the \a data is of FormpageItemtype then parent is not considered. FormPage Items are always added
   253     If the \a data is of FormpageItemtype then parent is not considered. FormPage Items are always added
   242     to rootItem. Also GroupPage Item has to be inserted in GroupItem.
   254     to rootItem. Also GroupPageItem has to be inserted only in GroupItem.
   243 
   255 
   244     \a data Child item to be inserted.
   256     \a data Child item to be inserted.
   245     \a parent Parent of DataFormViewItem
   257     \a parent Parent of DataFormViewItem
   246 
   258 
   247     \sa insertDataFormItem
   259     \sa insertDataFormItem
   416     return false;
   428     return false;
   417 
   429 
   418 }
   430 }
   419 
   431 
   420 /*!
   432 /*!
   421   \reimp
   433     \reimp
   422 */
   434 */
   423 bool HbDataFormModel::removeRows(int row, int count, const QModelIndex &index)
   435 bool HbDataFormModel::removeRows(int row, int count, const QModelIndex &index)
   424 {   
   436 {   
   425     HbDataFormModelItem *item = itemFromIndex(index);
   437     HbDataFormModelItem *item = itemFromIndex(index);
   426     if ((item == 0) || (count < 1) || (row < 0) || ((row + count) > item->childCount())) {
   438     if ((item == 0) || (count < 1) || (row < 0) || ((row + count) > item->childCount())) {
   430     item->removeChildren(row, count);
   442     item->removeChildren(row, count);
   431     return true;
   443     return true;
   432 }
   444 }
   433 
   445 
   434 /*!
   446 /*!
   435   \reimp
   447     \reimp
   436     Column value should be 0 as DataForm has only one column.If the value is not 0
   448     Column value should be 0 as DataForm has only one column.If the value is not 0
   437     function returns invalid index.
   449     function returns invalid index.
   438     If index is not valid then rootItem's index is considered.
   450     If index is not valid then rootItem's index is considered.
   439 */
   451 */
   440 QModelIndex HbDataFormModel::index(int row, int column,
   452 QModelIndex HbDataFormModel::index(int row, int column,
   624         }
   636         }
   625     }
   637     }
   626     return QModelIndex();
   638     return QModelIndex();
   627 }
   639 }
   628 
   640 
   629 /*! @beta
   641 /*!
       
   642     @beta
   630 
   643 
   631     Returns the HbDataFormModelItem at given \a row and with given parent /a index.
   644     Returns the HbDataFormModelItem at given \a row and with given parent /a index.
   632 */
   645 */
   633 HbDataFormModelItem* HbDataFormModel::item(int row, const QModelIndex &index) const
   646 HbDataFormModelItem* HbDataFormModel::item(int row, const QModelIndex &index) const
   634 {
   647 {