QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
qgsfieldcalculator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfieldcalculator.h
3  ---------------------
4  begin : September 2009
5  copyright : (C) 2009 by Marco Hugentobler
6  email : marco at hugis dot net
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSFIELDCALCULATOR_H
17 #define QGSFIELDCALCULATOR_H
18 
19 // We don't want to expose this in the public API
20 #define SIP_NO_FILE
21 
22 #include "ui_qgsfieldcalculatorbase.h"
23 #include "qgshelp.h"
24 #include "qgsfields.h"
25 #include "qgis_gui.h"
26 
27 class QgsVectorLayer;
28 
35 class GUI_EXPORT QgsFieldCalculator: public QDialog, private Ui::QgsFieldCalculatorBase
36 {
37  Q_OBJECT
38  public:
39  QgsFieldCalculator( QgsVectorLayer *vl, QWidget *parent = nullptr );
40 
41  int changedAttributeId() const { return mAttributeId; }
42 
43  public slots:
44  void accept() override;
45 
46  void mNewFieldGroupBox_toggled( bool on );
47  void mUpdateExistingGroupBox_toggled( bool on );
48  void mCreateVirtualFieldCheckbox_stateChanged( int state );
49  void mOutputFieldNameLineEdit_textChanged( const QString &text );
50  void mOutputFieldTypeComboBox_activated( int index );
51 
52  private slots:
54  void setOkButtonState();
55  void setPrecisionMinMax();
56  void showHelp();
57 
58  private:
62  void populateFields();
64  void populateOutputFieldTypes();
65 
66  QgsVectorLayer *mVectorLayer = nullptr;
67 
68  bool mCanAddAttribute = false;
69  bool mCanChangeAttributeValue = false;
70 
72  QgsField fieldDefinition();
73 
75  int mAttributeId;
76 
77  friend class TestQgsFieldCalculator;
78 };
79 
80 #endif // QGSFIELDCALCULATOR_H
A dialog class that provides calculation of new fields using existing fields, values and a set of ope...
int changedAttributeId() const
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:51
Represents a vector layer which manages a vector based data sets.