/
qgssourcefieldsproperties.h
112 lines (90 loc) · 3.14 KB
/
qgssourcefieldsproperties.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/***************************************************************************
qgssourcefieldsproperties.h
---------------------
begin : July 2017
copyright : (C) 2017 by David Signer
email : david at opengis dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSSOURCEFIELDSPROPERTIES_H
#define QGSSOURCEFIELDSPROPERTIES_H
#include <QMimeData>
#include <QPushButton>
#include <QTableWidget>
#include <QTreeWidget>
#include <QWidget>
#include <QSpinBox>
#include <QTreeWidgetItem>
#include <QDropEvent>
#include <QPushButton>
#include <QTableWidgetItem>
#include <QMessageBox>
#include <QFileDialog>
#include <QHBoxLayout>
#include <QFormLayout>
#include "qgsvectorlayer.h"
#include "ui_qgssourcefieldsproperties.h"
#include "qgis_app.h"
#include "qgsaddattrdialog.h"
#include "qgslogger.h"
#include "qgsproject.h"
#include "qgsexpressionbuilderdialog.h"
#include "qgsfieldcalculator.h"
class APP_EXPORT QgsSourceFieldsProperties : public QWidget, private Ui_QgsSourceFieldsProperties
{
Q_OBJECT
public:
explicit QgsSourceFieldsProperties( QgsVectorLayer *layer, QWidget *parent = nullptr );
~QgsSourceFieldsProperties();
void init();
void apply();
void loadRows();
void setRow( int row, int idx, const QgsField &field );
/** Adds an attribute to the table (but does not commit it yet)
\param field the field to add
\returns false in case of a name conflict, true in case of success */
bool addAttribute( const QgsField &field );
protected:
void updateButtons();
QgsVectorLayer *mLayer = nullptr;
// Holds all the first column items (header: id) of the table.
// The index in the list is the fieldIdx, and therefore acts as a mapping
// between fieldIdx and QTableWidgetItem->row()
QList<QTableWidgetItem *> mIndexedWidgets;
enum AttrColumns
{
AttrIdCol = 0,
AttrNameCol,
AttrAliasCol,
AttrTypeCol,
AttrTypeNameCol,
AttrLengthCol,
AttrPrecCol,
AttrCommentCol,
AttrWMSCol,
AttrWFSCol,
AttrColCount,
};
private:
Ui::QgsSourceFieldsProperties *ui;
void updateFieldRenamingStatus();
signals:
void toggleEditing();
private slots:
void updateExpression();
//! Editing of layer was toggled
void editingToggled();
void addAttributeClicked();
void deleteAttributeClicked();
void calculateFieldClicked();
void attributeAdded( int idx );
void attributeDeleted( int idx );
void attributesListCellChanged( int row, int column );
};
#endif // QGSSOURCEFIELDSPROPERTIES_H