16 #ifndef QGSPROCESSINGAGGREGATEWIDGETS_H
17 #define QGSPROCESSINGAGGREGATEWIDGETS_H
19 #include <QAbstractTableModel>
20 #include <QStyledItemDelegate>
30 class QItemSelectionModel;
88 QObject *parent =
nullptr );
94 QList<QgsAggregateMappingModel::Aggregate> mapping()
const;
99 void setMapping(
const QList<QgsAggregateMappingModel::Aggregate> &mapping );
102 void appendField(
const QgsField &
field,
const QString &source = QString(),
const QString &aggregate = QString() );
105 bool removeField(
const QModelIndex &index );
108 bool moveUp(
const QModelIndex &index );
111 bool moveDown(
const QModelIndex &index );
114 void setSourceFields(
const QgsFields &sourceFields );
126 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
127 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
128 QVariant data(
const QModelIndex &index,
int role )
const override;
129 QVariant headerData(
int section, Qt::Orientation orientation,
int role )
const override;
130 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
131 bool setData(
const QModelIndex &index,
const QVariant &value,
int role )
override;
135 bool moveUpOrDown(
const QModelIndex &index,
bool up =
true );
137 QList<Aggregate> mMapping;
139 std::unique_ptr< QgsFieldMappingModel::ExpressionContextGenerator> mExpressionContextGenerator;
166 QList<QgsAggregateMappingModel::Aggregate> mapping()
const;
171 void setMapping(
const QList<QgsAggregateMappingModel::Aggregate> &mapping );
174 QItemSelectionModel *selectionModel();
177 void setSourceFields(
const QgsFields &sourceFields );
198 void scrollTo(
const QModelIndex &index )
const;
216 void appendField(
const QgsField &
field,
const QString &source = QString(),
const QString &aggregate = QString() );
219 bool removeSelectedFields( );
222 bool moveSelectedFieldsUp( );
225 bool moveSelectedFieldsDown( );
229 QTableView *mTableView =
nullptr;
230 QAbstractTableModel *mModel =
nullptr;
231 QPointer< QgsVectorLayer > mSourceLayer;
232 void updateColumns();
234 std::list<int> selectedRows( );
237 class AggregateDelegate:
public QStyledItemDelegate
242 AggregateDelegate( QObject *parent =
nullptr );
245 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
246 void setEditorData( QWidget *editor,
const QModelIndex &index )
const override;
247 void setModelData( QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index )
const override;
251 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)