16#ifndef QGSPROCESSINGAGGREGATEWIDGETS_H
17#define QGSPROCESSINGAGGREGATEWIDGETS_H
24#include <QAbstractTableModel>
26#include <QStyledItemDelegate>
30class QItemSelectionModel;
91 QList<QgsAggregateMappingModel::Aggregate>
mapping()
const;
99 void appendField(
const QgsField &field,
const QString &source = QString(),
const QString &aggregate = QString() );
105 bool moveUp(
const QModelIndex &index );
108 bool moveDown(
const QModelIndex &index );
123 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
124 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
125 QVariant
data(
const QModelIndex &index,
int role )
const override;
126 QVariant
headerData(
int section, Qt::Orientation orientation,
int role )
const override;
127 Qt::ItemFlags
flags(
const QModelIndex &index )
const override;
128 bool setData(
const QModelIndex &index,
const QVariant &value,
int role )
override;
131 bool moveUpOrDown(
const QModelIndex &index,
bool up =
true );
132 static QString qgsFieldToTypeName(
const QgsField &field );
133 static void setFieldTypeFromName(
QgsField &field,
const QString &name );
135 QList<Aggregate> mMapping;
137 std::unique_ptr<QgsFieldMappingModel::ExpressionContextGenerator> mExpressionContextGenerator;
162 QList<QgsAggregateMappingModel::Aggregate>
mapping()
const;
194 void scrollTo(
const QModelIndex &index )
const;
212 void appendField(
const QgsField &field,
const QString &source = QString(),
const QString &aggregate = QString() );
224 QTableView *mTableView =
nullptr;
225 QAbstractTableModel *mModel =
nullptr;
226 QPointer<QgsVectorLayer> mSourceLayer;
227 void updateColumns();
229 std::list<int> selectedRows();
236class QgsAggregateMappingDelegate :
public QStyledItemDelegate
241 QgsAggregateMappingDelegate( QObject *parent =
nullptr );
244 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
245 void setEditorData( QWidget *editor,
const QModelIndex &index )
const override;
246 void setModelData( QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index )
const override;
250 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).