16#ifndef QGSPROCESSINGAGGREGATEWIDGETS_H
17#define QGSPROCESSINGAGGREGATEWIDGETS_H
24#include <QAbstractTableModel>
26#include <QStyledItemDelegate>
30class QItemSelectionModel;
90 QList<QgsAggregateMappingModel::Aggregate>
mapping()
const;
98 void appendField(
const QgsField &field,
const QString &source = QString(),
const QString &aggregate = QString() );
104 bool moveUp(
const QModelIndex &index );
107 bool moveDown(
const QModelIndex &index );
122 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
123 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
124 QVariant
data(
const QModelIndex &index,
int role )
const override;
125 QVariant
headerData(
int section, Qt::Orientation orientation,
int role )
const override;
126 Qt::ItemFlags
flags(
const QModelIndex &index )
const override;
127 bool setData(
const QModelIndex &index,
const QVariant &value,
int role )
override;
130 bool moveUpOrDown(
const QModelIndex &index,
bool up =
true );
131 static QString qgsFieldToTypeName(
const QgsField &field );
132 static void setFieldTypeFromName(
QgsField &field,
const QString &name );
134 QList<Aggregate> mMapping;
136 std::unique_ptr<QgsFieldMappingModel::ExpressionContextGenerator> mExpressionContextGenerator;
160 QList<QgsAggregateMappingModel::Aggregate>
mapping()
const;
192 void scrollTo(
const QModelIndex &index )
const;
210 void appendField(
const QgsField &field,
const QString &source = QString(),
const QString &aggregate = QString() );
222 QTableView *mTableView =
nullptr;
223 QAbstractTableModel *mModel =
nullptr;
224 QPointer<QgsVectorLayer> mSourceLayer;
225 void updateColumns();
227 std::list<int> selectedRows();
234class QgsAggregateMappingDelegate :
public QStyledItemDelegate
239 QgsAggregateMappingDelegate( QObject *parent =
nullptr );
242 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
243 void setEditorData( QWidget *editor,
const QModelIndex &index )
const override;
244 void setModelData( QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index )
const override;
248 static const QStringList aggregates();
Holds mapping information for defining sets of aggregates of fields from a QgsFields object.
QgsFields sourceFields() const
Returns a list of source fields.
void appendField(const QgsField &field, const QString &source=QString(), const QString &aggregate=QString())
Appends a new field to the model, with an optional source and aggregate.
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
ColumnDataIndex
The ColumnDataIndex enum represents the column index for the view.
Qt::ItemFlags flags(const QModelIndex &index) const override
bool removeField(const QModelIndex &index)
Removes the field at index from the model, returns true on success.
bool moveUp(const QModelIndex &index)
Moves down the field at index.
QVariant data(const QModelIndex &index, int role) const override
QList< QgsAggregateMappingModel::Aggregate > mapping() const
Returns a list of Aggregate objects representing the current status of the model.
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QgsExpressionContextGenerator * contextGenerator() const
Returns the context generator with the source fields.
bool moveDown(const QModelIndex &index)
Moves up the field at index.
void setSourceFields(const QgsFields &sourceFields)
Set source fields to sourceFields.
void setMapping(const QList< QgsAggregateMappingModel::Aggregate > &mapping)
Sets the mapping to show in the model.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void setBaseExpressionContextGenerator(const QgsExpressionContextGenerator *generator)
Sets the base expression context generator, which will generate the expression contexts for expressio...
QgsAggregateMappingModel(const QgsFields &sourceFields=QgsFields(), QObject *parent=nullptr)
Constructs a QgsAggregateMappingModel from a set of sourceFields.
Abstract interface for generating an expression context.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
Represents a vector layer which manages a vector based dataset.
The Aggregate struct holds information about an aggregate column.
QString source
The source expression used as the input for the aggregate calculation.
QString delimiter
Delimiter string.
QString aggregate
Aggregate name.
QgsField field
The field in its current status (it might have been renamed).