16 #ifndef QGSPROCESSINGAGGREGATEWIDGETS_H
17 #define QGSPROCESSINGAGGREGATEWIDGETS_H
19 #include <QAbstractTableModel>
20 #include <QStyledItemDelegate>
29 class QItemSelectionModel;
61 Q_ENUM( ColumnDataIndex );
87 QObject *parent =
nullptr );
93 QList<QgsAggregateMappingModel::Aggregate> mapping()
const;
98 void setMapping(
const QList<QgsAggregateMappingModel::Aggregate> &mapping );
101 void appendField(
const QgsField &field,
const QString &source = QString(),
const QString &aggregate = QString() );
104 bool removeField(
const QModelIndex &index );
107 bool moveUp(
const QModelIndex &index );
110 bool moveDown(
const QModelIndex &index );
113 void setSourceFields(
const QgsFields &sourceFields );
125 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
126 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
127 QVariant data(
const QModelIndex &index,
int role )
const override;
128 QVariant headerData(
int section, Qt::Orientation orientation,
int role )
const override;
129 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
130 bool setData(
const QModelIndex &index,
const QVariant &value,
int role )
override;
134 bool moveUpOrDown(
const QModelIndex &index,
bool up =
true );
136 QList<Aggregate> mMapping;
138 std::unique_ptr< QgsFieldMappingModel::ExpressionContextGenerator> mExpressionContextGenerator;
165 QList<QgsAggregateMappingModel::Aggregate> mapping()
const;
170 void setMapping(
const QList<QgsAggregateMappingModel::Aggregate> &mapping );
173 QItemSelectionModel *selectionModel();
176 void setSourceFields(
const QgsFields &sourceFields );
181 void scrollTo(
const QModelIndex &index )
const;
199 void appendField(
const QgsField &field,
const QString &source = QString(),
const QString &aggregate = QString() );
202 bool removeSelectedFields( );
205 bool moveSelectedFieldsUp( );
208 bool moveSelectedFieldsDown( );
212 QTableView *mTableView =
nullptr;
213 QAbstractTableModel *mModel =
nullptr;
214 void updateColumns();
216 std::list<int> selectedRows( );
219 class AggregateDelegate:
public QStyledItemDelegate
224 AggregateDelegate( QObject *parent =
nullptr );
227 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
228 void setEditorData( QWidget *editor,
const QModelIndex &index )
const override;
229 void setModelData( QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index )
const override;
233 static const QStringList aggregates();
239 #endif // QGSPROCESSINGAGGREGATEWIDGETS_H