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 );
132 QList<Aggregate> mMapping;
134 std::unique_ptr<QgsFieldMappingModel::ExpressionContextGenerator> mExpressionContextGenerator;
158 QList<QgsAggregateMappingModel::Aggregate> mapping()
const;
163 void setMapping(
const QList<QgsAggregateMappingModel::Aggregate> &mapping );
166 QItemSelectionModel *selectionModel();
169 void setSourceFields(
const QgsFields &sourceFields );
190 void scrollTo(
const QModelIndex &index )
const;
208 void appendField(
const QgsField &field,
const QString &source = QString(),
const QString &aggregate = QString() );
211 bool removeSelectedFields();
214 bool moveSelectedFieldsUp();
217 bool moveSelectedFieldsDown();
220 QTableView *mTableView =
nullptr;
221 QAbstractTableModel *mModel =
nullptr;
222 QPointer<QgsVectorLayer> mSourceLayer;
223 void updateColumns();
225 std::list<int> selectedRows();
232class QgsAggregateMappingDelegate :
public QStyledItemDelegate
237 QgsAggregateMappingDelegate( QObject *parent =
nullptr );
240 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
241 void setEditorData( QWidget *editor,
const QModelIndex &index )
const override;
242 void setModelData( QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index )
const override;
246 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)