QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgssourcefieldsproperties.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssourcefieldsproperties.h
3  ---------------------
4  begin : July 2017
5  copyright : (C) 2017 by David Signer
6  email : david at opengis dot ch
7 
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef QGSSOURCEFIELDSPROPERTIES_H
18 #define QGSSOURCEFIELDSPROPERTIES_H
19 
20 // We don't want to expose this in the public API
21 #define SIP_NO_FILE
22 
23 #include <QMimeData>
24 #include <QPushButton>
25 #include <QTableWidget>
26 #include <QTreeWidget>
27 #include <QWidget>
28 #include <QSpinBox>
29 #include <QTreeWidgetItem>
30 #include <QDropEvent>
31 #include <QTableWidgetItem>
32 #include <QMessageBox>
33 #include <QFileDialog>
34 #include <QHBoxLayout>
35 #include <QFormLayout>
36 
37 #include "ui_qgssourcefieldsproperties.h"
38 #include "qgis_gui.h"
39 #include "qgslogger.h"
41 #include "qgsfieldcalculator.h"
42 
47 class GUI_EXPORT QgsSourceFieldsProperties : public QWidget, private Ui_QgsSourceFieldsProperties
48 {
49  Q_OBJECT
50 
51  public:
52  explicit QgsSourceFieldsProperties( QgsVectorLayer *layer, QWidget *parent = nullptr );
53 
54  void init();
55  void apply();
56 
57  void loadRows();
58  void setRow( int row, int idx, const QgsField &field );
59 
65  bool addAttribute( const QgsField &field );
66 
67  protected:
68  void updateButtons();
69 
70  QgsVectorLayer *mLayer = nullptr;
71 
72  // Holds all the first column items (header: id) of the table.
73  // The index in the list is the fieldIdx, and therefore acts as a mapping
74  // between fieldIdx and QTableWidgetItem->row()
75  QList<QTableWidgetItem *> mIndexedWidgets;
76 
78  {
79  AttrIdCol = 0,
89  };
90 
91  private:
92  Ui::QgsSourceFieldsProperties *ui = nullptr;
93  void updateFieldRenamingStatus();
94 
95  signals:
96  void toggleEditing();
97 
98  private slots:
99 
100  void updateExpression();
101 
103  void editingToggled();
104  void addAttributeClicked();
105  void deleteAttributeClicked();
106  void calculateFieldClicked();
107 
108  void attributeAdded( int idx );
109  void attributeDeleted( int idx );
110 
111  void attributesListCellChanged( int row, int column );
112  void attributesListCellPressed( int row, int column );
113 
114 };
115 
116 #endif // QGSSOURCEFIELDSPROPERTIES_H
qgsfieldcalculator.h
QgsSourceFieldsProperties::AttrCommentCol
@ AttrCommentCol
Definition: qgssourcefieldsproperties.h:86
QgsSourceFieldsProperties::AttrTypeCol
@ AttrTypeCol
Definition: qgssourcefieldsproperties.h:82
QgsSourceFieldsProperties::AttrConfigurationFlagsCol
@ AttrConfigurationFlagsCol
Definition: qgssourcefieldsproperties.h:87
field
const QgsField & field
Definition: qgsfield.h:463
QgsSourceFieldsProperties::mIndexedWidgets
QList< QTableWidgetItem * > mIndexedWidgets
Definition: qgssourcefieldsproperties.h:75
QgsSourceFieldsProperties::AttrAliasCol
@ AttrAliasCol
Definition: qgssourcefieldsproperties.h:81
QgsSourceFieldsProperties::AttrLengthCol
@ AttrLengthCol
Definition: qgssourcefieldsproperties.h:84
QgsSourceFieldsProperties::AttrColumns
AttrColumns
Definition: qgssourcefieldsproperties.h:77
QgsSourceFieldsProperties::AttrNameCol
@ AttrNameCol
Definition: qgssourcefieldsproperties.h:80
QgsSourceFieldsProperties::AttrColCount
@ AttrColCount
Definition: qgssourcefieldsproperties.h:88
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsSourceFieldsProperties
Definition: qgssourcefieldsproperties.h:47
QgsSourceFieldsProperties::AttrTypeNameCol
@ AttrTypeNameCol
Definition: qgssourcefieldsproperties.h:83
QgsSourceFieldsProperties::AttrPrecCol
@ AttrPrecCol
Definition: qgssourcefieldsproperties.h:85
qgslogger.h
qgsexpressionbuilderdialog.h
QgsField
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:50