20   , mModel( subType, this )
    28   removeButton->setEnabled( 
false );
    29   mModel.setList( list );
    34 QgsListModel::QgsListModel( QVariant::Type subType, QObject *parent ) :
    35   QAbstractTableModel( parent ),
    40 void QgsListModel::setList( 
const QVariantList &
list )
    47 QVariantList QgsListModel::list()
 const    50   for ( QVariantList::const_iterator it = mLines.constBegin(); it != mLines.constEnd(); ++it )
    53     if ( cur.convert( mSubType ) )
    59 bool QgsListModel::valid()
 const    61   for ( QVariantList::const_iterator it = mLines.constBegin(); it != mLines.constEnd(); ++it )
    64     if ( !cur.convert( mSubType ) ) 
return false;
    69 int QgsListModel::rowCount( 
const QModelIndex &parent )
 const    72   return mLines.count();
    75 int QgsListModel::columnCount( 
const QModelIndex &parent )
 const    81 QVariant QgsListModel::headerData( 
int section, Qt::Orientation orientation, 
int role )
 const    83   if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section == 0 )
    85     return QObject::tr( 
"Value" );
    90 QVariant QgsListModel::data( 
const QModelIndex &index, 
int role )
 const    92   if ( index.row() < 0 ||
    93        index.row() >= mLines.count() ||
    94        ( role != Qt::DisplayRole && role != Qt::EditRole ) ||
    97     return QVariant( mSubType );
    99   return mLines.at( index.row() );
   102 bool QgsListModel::setData( 
const QModelIndex &index, 
const QVariant &value, 
int role )
   104   if ( index.row() < 0 || index.row() >= mLines.count() ||
   105        index.column() != 0 || role != Qt::EditRole )
   109   mLines[index.row()] = value.toString();
   110   emit dataChanged( index, index );
   114 Qt::ItemFlags QgsListModel::flags( 
const QModelIndex &index )
 const   116   return QAbstractTableModel::flags( index ) | Qt::ItemIsEditable;
   119 bool QgsListModel::insertRows( 
int position, 
int rows, 
const QModelIndex &parent )
   122   beginInsertRows( QModelIndex(), position, position + rows - 1 );
   123   for ( 
int i = 0; i < rows; ++i )
   125     mLines.insert( position, QVariant( mSubType ) );
   131 bool QgsListModel::removeRows( 
int position, 
int rows, 
const QModelIndex &parent )
   134   beginRemoveRows( QModelIndex(), position, position + rows - 1 );
   135   for ( 
int i = 0; i < rows; ++i )
   136     mLines.removeAt( position );