/usr/include/qgis/qgsfieldmodel.h is in libqgis-dev 2.8.6+dfsg-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | /***************************************************************************
qgsfieldmodel.h
--------------------------------------
Date : 01.04.2014
Copyright : (C) 2014 Denis Rouzaud
Email : denis.rouzaud@gmail.com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSFIELDMODEL_H
#define QGSFIELDMODEL_H
#include <QAbstractItemModel>
#include <QItemSelectionModel>
#include <QComboBox>
#include "qgsvectorlayer.h"
/**
* @brief The QgsFieldModel class is a model to display the list of fields of a layer in widgets.
* If allowed, expressions might be added to the end of the model.
* It can be associated with a QgsMapLayerModel to dynamically display a layer and its fields.
* @note added in 2.3
*/
class GUI_EXPORT QgsFieldModel : public QAbstractItemModel
{
Q_OBJECT
public:
enum FieldRoles
{
FieldNameRole = Qt::UserRole + 1, /* return field name if index corresponds to a field */
FieldIndexRole = Qt::UserRole + 2, /* return field index if index corresponds to a field */
ExpressionRole = Qt::UserRole + 3, /* return field name or expression */
IsExpressionRole = Qt::UserRole + 4, /* return if index corresponds to an expression */
ExpressionValidityRole = Qt::UserRole + 5, /* return if expression is valid or not */
FieldTypeRole = Qt::UserRole + 6 /* return the field type (if a field, return QVariant if expression) */
};
/**
* @brief QgsFieldModel creates a model to display the fields of a given layer
*/
explicit QgsFieldModel( QObject *parent = 0 );
//! return the index corresponding to a given fieldName
QModelIndex indexFromName( const QString &fieldName );
//! returns the currently used layer
void setAllowExpression( bool allowExpression );
bool allowExpression() { return mAllowExpression; }
bool isField( const QString& expression );
/**
* @brief setExpression sets a single expression to be added after the fields at the end of the model
*/
void setExpression( const QString &expression );
//! remove expressions from the model
void removeExpression();
//! returns the currently used layer
QgsVectorLayer* layer() { return mLayer; }
public slots:
//! set the layer of whch fields are displayed
void setLayer( QgsVectorLayer *layer );
protected slots:
virtual void updateModel();
private slots:
void layerDeleted();
protected:
QgsFields mFields;
QList<QString> mExpression;
QgsVectorLayer* mLayer;
bool mAllowExpression;
private:
void fetchFeature();
// QAbstractItemModel interface
public:
QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override;
QModelIndex parent( const QModelIndex &child ) const override;
int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
int columnCount( const QModelIndex &parent ) const override;
QVariant data( const QModelIndex &index, int role ) const override;
};
#endif // QGSFIELDMODEL_H
|