25 : QAbstractItemModel( parent )
27 , mAllowExpression( false )
34 QModelIndex idx =
index( r, 0 );
123 for (
int i = 0; i < newFields.
count(); ++i )
133 beginRemoveRows( QModelIndex(), i, i );
168 beginRemoveRows( QModelIndex(), start, end );
185 if ( !expression.isEmpty() )
199 if ( hasIndex( row, column, parent ) )
201 return createIndex( row, column, row );
204 return QModelIndex();
210 return QModelIndex();
215 if ( parent.isValid() )
231 if ( !index.isValid() )
267 return index.internalId();
291 return (
int )field.
type();
296 case Qt::DisplayRole:
303 else if ( role == Qt::EditRole )
305 return mFields[index.internalId()].name();
315 case Qt::ForegroundRole:
324 return QBrush( QColor( Qt::red ) );
335 QFont font = QFont();
336 font.setItalic(
true );
QList< QgsField > toList() const
Utility function to return a list of QgsField instances.
Class for parsing and evaluation of expressions (formerly called "search strings").
const QString & name() const
Gets the name of the field.
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
bool prepare(const QgsFields &fields)
Get the expression ready for evaluation - find out column indexes.
QModelIndex parent(const QModelIndex &child) const
void setExpression(const QString &expression)
setExpression sets a single expression to be added after the fields at the end of the model ...
Container of fields for a vector layer.
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
QgsVectorLayer * layer()
returns the currently used layer
bool isField(const QString &expression)
void removeExpression()
remove expressions from the model
QString attributeDisplayName(int attributeIndex) const
Convenience function that returns the attribute alias if defined or the field name else...
void setLayer(QgsVectorLayer *layer)
set the layer of whch fields are displayed
QVariant data(const QModelIndex &index, int role) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
void setAllowExpression(bool allowExpression)
returns the currently used layer
int count() const
Return number of items.
Encapsulate a field in an attribute table or data source.
void remove(int fieldIdx)
Remove a field with the given index.
int indexFromName(const QString &name) const
Look up field's index from name. Returns -1 on error.
int columnCount(const QModelIndex &parent) const
virtual void updateModel()
QgsFieldModel(QObject *parent=0)
QgsFieldModel creates a model to display the fields of a given layer.
QList< QString > mExpression
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
int rowCount(const QModelIndex &parent=QModelIndex()) const
QModelIndex indexFromName(const QString &fieldName)
return the index corresponding to a given fieldName
Represents a vector layer which manages a vector based data sets.
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.