src/hbwidgets/dataform/hbdataformmodel.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 3 11d3954df52a
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    25 
    25 
    26 #include <hbdataformmodelitem.h>
    26 #include <hbdataformmodelitem.h>
    27 #include <hbdataformmodel.h>
    27 #include <hbdataformmodel.h>
    28 
    28 
    29 #include "hbdataformmodel_p.h"
    29 #include "hbdataformmodel_p.h"
       
    30 #include "hbdataformmodelitem_p.h"
    30 
    31 
    31 /*
    32 /*
    32     \internal
    33     \internal
    33 
    34 
    34     adds the dataformviewitem or page or group depending upon /a itemType
    35     adds the dataformviewitem or page or group depending upon /a itemType
   136 HbDataFormModel::HbDataFormModel(QObject *parent)
   137 HbDataFormModel::HbDataFormModel(QObject *parent)
   137     :QAbstractItemModel(parent),d_ptr(new HbDataFormModelPrivate )
   138     :QAbstractItemModel(parent),d_ptr(new HbDataFormModelPrivate )
   138 {
   139 {
   139     Q_D(HbDataFormModel);
   140     Q_D(HbDataFormModel);
   140     d->q_ptr = this; 
   141     d->q_ptr = this; 
   141     d->mRoot->setModel(this);
   142     HbDataFormModelItemPrivate::d_ptr(d->mRoot)->setModel(this);   
   142 }
   143 }
   143 
   144 
   144 HbDataFormModel::~HbDataFormModel()
   145 HbDataFormModel::~HbDataFormModel()
   145 {
   146 {
   146     Q_D(HbDataFormModel);
   147     Q_D(HbDataFormModel);
   367     parent->insertChild(index,data);    
   368     parent->insertChild(index,data);    
   368 }
   369 }
   369 
   370 
   370 
   371 
   371 /*!
   372 /*!
   372    \deprecated  HbDataFormModel::insertRows(int, int, const QModelIndex&)
       
   373         is deprecated. Please use other insert and additem API's in HbDataFormModel instead.
       
   374 */
       
   375 bool HbDataFormModel::insertRows(int row, int count, const QModelIndex &index)
       
   376 {
       
   377     Q_D(HbDataFormModel);
       
   378     HbDataFormModelItem *item = index.isValid() ? itemFromIndex(index) : d->mRoot;
       
   379     if (item == 0) {
       
   380         return false;
       
   381     }
       
   382 
       
   383     QList<HbDataFormModelItem*> items;
       
   384     for(int i =0 ; i < count ; i ++) {
       
   385         items.append(new HbDataFormModelItem());
       
   386     }
       
   387     item->insertChildren(row,count,items);
       
   388     return true;
       
   389 }
       
   390 
       
   391 
       
   392 /*!
       
   393     @beta
   373     @beta
   394 
   374 
   395     Removes and deletes the model item from the model at the given \a index. The visualization
   375     Removes and deletes the model item from the model at the given \a index. The visualization
   396     corresponding to this \a index is also deleted. Returns true if \a index is removed otherwise
   376     corresponding to this \a index is also deleted. Returns true if \a index is removed otherwise
   397     returns false.
   377     returns false.
   417 {
   397 {
   418     if( !item ) {
   398     if( !item ) {
   419         return false;
   399         return false;
   420     }
   400     }
   421     HbDataFormModelItem* parent = const_cast<HbDataFormModelItem*>(item->parent());
   401     HbDataFormModelItem* parent = const_cast<HbDataFormModelItem*>(item->parent());
   422     if ( item->model() != this ) {
   402     if ( HbDataFormModelItemPrivate::d_ptr(item)->model() != this ) {
   423                return false;
   403                return false;
   424     }
   404     }
   425     
   405     
   426     if( parent ) {
   406     if( parent ) {
   427         int index = parent->indexOf(item);
   407         int index = parent->indexOf(item);
   589 void HbDataFormModel::clear()
   569 void HbDataFormModel::clear()
   590 {
   570 {
   591     Q_D(HbDataFormModel);
   571     Q_D(HbDataFormModel);
   592     removeItem(invisibleRootItem());
   572     removeItem(invisibleRootItem());
   593     d->mRoot = new HbDataFormModelItem();
   573     d->mRoot = new HbDataFormModelItem();
   594     d->mRoot->setModel(this);
   574     HbDataFormModelItemPrivate::d_ptr(d->mRoot)->setModel(this);
       
   575     
   595     reset();
   576     reset();
   596 }
   577 }
   597 
   578 
   598 /*!
   579 /*!
   599     \reimp
   580     \reimp