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();
257 #endif // QGSPROCESSINGAGGREGATEWIDGETS_H