emailuis/nmsettingui/src/nmsettingsformcustomitems.cpp
changeset 68 83cc6bae1de8
parent 43 99bcbff212ad
equal deleted inserted replaced
67:459da34cdb45 68:83cc6bae1de8
    56     From HbDataFormViewItem.
    56     From HbDataFormViewItem.
    57 */
    57 */
    58 HbAbstractViewItem *NmSettingsFormCustomItems::createItem()
    58 HbAbstractViewItem *NmSettingsFormCustomItems::createItem()
    59 {
    59 {
    60     NM_FUNCTION;
    60     NM_FUNCTION;
    61     
    61 
    62     return new NmSettingsFormCustomItems(*this);
    62     return new NmSettingsFormCustomItems(*this);
    63 }
    63 }
    64 
    64 
    65 bool NmSettingsFormCustomItems::canSetModelIndex(const QModelIndex &index) const
    65 bool NmSettingsFormCustomItems::canSetModelIndex(const QModelIndex &index) const
    66 {
    66 {
    67     NM_FUNCTION;
    67     NM_FUNCTION;
    68     
    68 
    69     int type(index.data(HbDataFormModelItem::ItemTypeRole).toInt());
    69     int type(index.data(HbDataFormModelItem::ItemTypeRole).toInt());
    70     return type==NmButtonItem;
    70     return type==NmButtonItem;
    71 }
    71 }
    72 
    72 
    73 /*!
    73 /*!
    74     Sets the custom widget's properties from the model item.
    74     Sets the custom widget's properties from the model item.
    75 */
    75 */
    76 void NmSettingsFormCustomItems::restore()
    76 void NmSettingsFormCustomItems::restore()
    77 {
    77 {
    78     NM_FUNCTION;
    78     NM_FUNCTION;
    79     
    79 
    80     HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType>(
    80     HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType>(
    81         modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
    81         modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
    82      if (itemType==NmButtonItem) {
    82      if (itemType==NmButtonItem) {
    83 
    83 
    84          HbDataFormModel* model = static_cast<HbDataFormModel*>
    84          HbDataFormModel* model = static_cast<HbDataFormModel*>
   100     From HbDataFormViewItem.
   100     From HbDataFormViewItem.
   101 */
   101 */
   102 HbWidget *NmSettingsFormCustomItems::createCustomWidget()
   102 HbWidget *NmSettingsFormCustomItems::createCustomWidget()
   103 {
   103 {
   104     NM_FUNCTION;
   104     NM_FUNCTION;
   105     
   105 
   106     HbDataFormModelItem::DataItemType itemType =
   106     HbDataFormModelItem::DataItemType itemType =
   107         static_cast<HbDataFormModelItem::DataItemType>(
   107         static_cast<HbDataFormModelItem::DataItemType>(
   108             modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
   108             modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
   109 
   109 
   110     HbWidget *widget = 0;
   110     HbWidget *widget = NULL;
   111 
   111 
   112     switch (itemType) {
   112     switch (itemType) {
   113       case NmButtonItem: {
   113       case NmButtonItem: {
   114             // Push button.
   114             // Push button.
   115             widget = new HbPushButton();
   115             widget = new HbPushButton();