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