QGIS API Documentation 4.1.0-Master (009143bf4b4)
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:
56 QgsFieldCalculator( QgsVectorLayer *vl, QWidget *parent = nullptr, int fieldIndex = -1 );
57
63 int changedAttributeId() const { return mAttributeId; }
64
65 public slots:
66 void accept() override;
67
68 private slots:
69 void mNewFieldGroupBox_toggled( bool on );
70 void mUpdateExistingGroupBox_toggled( bool on );
71 void mCreateVirtualFieldCheckbox_stateChanged( int state );
72 void mOutputFieldNameLineEdit_textChanged( const QString &text );
73 void mOutputFieldTypeComboBox_activated( int index );
74 void mExistingFieldComboBox_currentIndexChanged( const int index );
75
77 void setDialogButtonState();
78 void setPrecisionMinMax();
79 void showHelp();
80 void calculate();
82 void pushMessage( const QString &text, Qgis::MessageLevel level = Qgis::MessageLevel::Info, int duration = -1 );
83
84 private:
88 void populateFields( int fieldIndex );
90 void populateOutputFieldTypes();
91
92 QgsVectorLayer *mVectorLayer = nullptr;
93
94 bool mCanAddAttribute = false;
95 bool mCanChangeAttributeValue = false;
96
98 QgsField fieldDefinition();
99
101 int mAttributeId;
102
103 QgsMessageBar *mMsgBar = nullptr;
104
106};
107
108#endif // QGSFIELDCALCULATOR_H
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition qgis.h:160
@ Info
Information message.
Definition qgis.h:161
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.
friend class TestQgsFieldCalculator
QgsFieldCalculator(QgsVectorLayer *vl, QWidget *parent=nullptr, int fieldIndex=-1)
Constructor for QgsFieldCalculator, with the specified parent widget.
Encapsulate a field in an attribute table or data source.
Definition qgsfield.h:56
A bar for displaying non-blocking messages to the user.
Represents a vector layer which manages a vector based dataset.