16#ifndef QGSPROCESSINGAGGREGATEWIDGETS_H
17#define QGSPROCESSINGAGGREGATEWIDGETS_H
19#include <QAbstractTableModel>
20#include <QStyledItemDelegate>
30class QItemSelectionModel;
90 QList<QgsAggregateMappingModel::Aggregate> mapping()
const;
95 void setMapping(
const QList<QgsAggregateMappingModel::Aggregate> &mapping );
98 void appendField(
const QgsField &field,
const QString &source = QString(),
const QString &aggregate = QString() );
101 bool removeField(
const QModelIndex &index );
104 bool moveUp(
const QModelIndex &index );
107 bool moveDown(
const QModelIndex &index );
110 void setSourceFields(
const QgsFields &sourceFields );
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;
165 void setMapping(
const QList<QgsAggregateMappingModel::Aggregate> &mapping );
168 QItemSelectionModel *selectionModel();
171 void setSourceFields(
const QgsFields &sourceFields );
192 void scrollTo(
const QModelIndex &index )
const;
210 void appendField(
const QgsField &field,
const QString &source = QString(),
const QString &aggregate = QString() );
213 bool removeSelectedFields();
216 bool moveSelectedFieldsUp();
219 bool moveSelectedFieldsDown();
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();
The QgsAggregateMappingModel holds mapping information for defining sets of aggregates of fields from...
ColumnDataIndex
The ColumnDataIndex enum represents the column index for the view.
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 data sets.
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)