QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
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#include "ui_qgsfieldcalculatorbase.h"
20
21#include "qgis_gui.h"
22#include "qgsfields.h"
23#include "qgshelp.h"
24
25class QgsVectorLayer;
26class QgsMessageBar;
27
44class GUI_EXPORT QgsFieldCalculator : public QDialog, private Ui::QgsFieldCalculatorBase
45{
46 Q_OBJECT
47 public:
48 QgsFieldCalculator( QgsVectorLayer *vl, QWidget *parent = nullptr );
49
55 int changedAttributeId() const { return mAttributeId; }
56
57 public slots:
58 void accept() override;
59
60 private slots:
61 void mNewFieldGroupBox_toggled( bool on );
62 void mUpdateExistingGroupBox_toggled( bool on );
63 void mCreateVirtualFieldCheckbox_stateChanged( int state );
64 void mOutputFieldNameLineEdit_textChanged( const QString &text );
65 void mOutputFieldTypeComboBox_activated( int index );
66 void mExistingFieldComboBox_currentIndexChanged( const int index );
67
69 void setDialogButtonState();
70 void setPrecisionMinMax();
71 void showHelp();
72 void calculate();
74 void pushMessage( const QString &text, Qgis::MessageLevel level = Qgis::MessageLevel::Info, int duration = -1 );
75
76 private:
80 void populateFields();
82 void populateOutputFieldTypes();
83
84 QgsVectorLayer *mVectorLayer = nullptr;
85
86 bool mCanAddAttribute = false;
87 bool mCanChangeAttributeValue = false;
88
90 QgsField fieldDefinition();
91
93 int mAttributeId;
94
95 QgsMessageBar *mMsgBar = nullptr;
96
98};
99
100#endif // QGSFIELDCALCULATOR_H
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition qgis.h:156
@ Info
Information message.
Definition qgis.h:157
A dialog that provides calculation of new fields using existing fields, values and a set of operators...
int changedAttributeId() const
Returns the field index of the field for which new attribute values were calculated.
QgsFieldCalculator(QgsVectorLayer *vl, QWidget *parent=nullptr)
friend class TestQgsFieldCalculator
Encapsulate a field in an attribute table or data source.
Definition qgsfield.h:54
A bar for displaying non-blocking messages to the user.
Represents a vector layer which manages a vector based dataset.