QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsfieldsitem.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsfieldsitem.h
3 -------------------
4 begin : 2011-04-01
5 copyright : (C) 2011 Radim Blazek
6 email : radim dot blazek at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef QGSFIELDSITEM_H
18#define QGSFIELDSITEM_H
19
20#include "qgis_sip.h"
21#include "qgis_core.h"
22#include "qgsdataitem.h"
24#include "qgsfield.h"
25
33class CORE_EXPORT QgsFieldsItem : public QgsDataItem
34{
35 Q_OBJECT
36
37 public:
38
50 const QString &path,
51 const QString &connectionUri,
52 const QString &providerKey,
53 const QString &schema,
54 const QString &tableName );
55
56 ~QgsFieldsItem() override;
57
58#ifdef SIP_RUN
59 SIP_PYOBJECT __repr__();
60 % MethodCode
61 QString str = QStringLiteral( "<QgsFieldsItem: %1>" ).arg( sipCpp->path() );
62 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
63 % End
64#endif
65
66 QVector<QgsDataItem *> createChildren() override;
67
68 QIcon icon() override;
69
73 QString schema() const;
74
78 QString tableName() const;
79
83 QString connectionUri() const;
84
89
95
101 bool canRenameFields() const { return mCanRename; }
102
103 private:
104
105 QString mSchema;
106 QString mTableName;
107 QString mConnectionUri;
108 bool mCanRename = false;
109 std::unique_ptr<QgsAbstractDatabaseProviderConnection::TableProperty> mTableProperty;
110
111};
112
113
121class CORE_EXPORT QgsFieldItem : public QgsDataItem
122{
123 Q_OBJECT
124 public:
125
131 const QgsField &field );
132
133 ~QgsFieldItem() override;
134
135#ifdef SIP_RUN
136 SIP_PYOBJECT __repr__();
137 % MethodCode
138 QString str = QStringLiteral( "<QgsFieldItem: %1>" ).arg( sipCpp->name() );
139 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
140 % End
141#endif
142
143 QIcon icon() override;
144
150 QgsField field() const { return mField; }
151
152 bool equal( const QgsDataItem *other ) override;
153
154 private:
155
156 const QgsField mField;
157
158};
159
160#endif // QGSFIELDSITEM_H
161
162
Base class for all items in the model.
Definition: qgsdataitem.h:46
virtual QVector< QgsDataItem * > createChildren()
Create children.
virtual QIcon icon()
virtual bool equal(const QgsDataItem *other)
Returns true if this item is equal to another item (by testing item type and path).
A layer field item, information about the connection URI, the schema and the table as well as the lay...
QgsField field() const
Returns the field definition.
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:51
A collection of field items with some internal logic to retrieve the fields and a the vector layer in...
Definition: qgsfieldsitem.h:34
bool canRenameFields() const
Returns true if the connection supports renaming fields.
Represents a vector layer which manages a vector based data sets.
#define str(x)
Definition: qgis.cpp:37
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_FACTORY
Definition: qgis_sip.h:76
const QgsField & field
Definition: qgsfield.h:463
The TableProperty class represents a database table or view.