QGIS API Documentation 3.43.0-Master (c4a2e9c6d2f)
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
35class CORE_EXPORT QgsFieldsItem : public QgsDataItem
36{
37 Q_OBJECT
38
39 public:
40
52 const QString &path,
53 const QString &connectionUri,
54 const QString &providerKey,
55 const QString &schema,
56 const QString &tableName );
57
58 ~QgsFieldsItem() override;
59
60#ifdef SIP_RUN
61 SIP_PYOBJECT __repr__();
62 % MethodCode
63 QString str = QStringLiteral( "<QgsFieldsItem: %1>" ).arg( sipCpp->path() );
64 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
65 % End
66#endif
67
68 QVector<QgsDataItem *> createChildren() override;
69
70 QIcon icon() override;
71
75 QString schema() const;
76
80 QString tableName() const;
81
85 QString connectionUri() const;
86
91
97
103 bool canRenameFields() const { return mCanRename; }
104
105 private:
106
107 QString mSchema;
108 QString mTableName;
109 QString mConnectionUri;
110 bool mCanRename = false;
111 std::unique_ptr<QgsAbstractDatabaseProviderConnection::TableProperty> mTableProperty;
112
113};
114
115
124class CORE_EXPORT QgsFieldItem : public QgsDataItem
125{
126 Q_OBJECT
127 public:
128
134 const QgsField &field );
135
136 ~QgsFieldItem() override;
137
138#ifdef SIP_RUN
139 SIP_PYOBJECT __repr__();
140 % MethodCode
141 QString str = QStringLiteral( "<QgsFieldItem: %1>" ).arg( sipCpp->name() );
142 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
143 % End
144#endif
145
146 QIcon icon() override;
147
153 QgsField field() const { return mField; }
154
155 bool equal( const QgsDataItem *other ) override;
156
157 private:
158
159 const QgsField mField;
160
161};
162
163#endif // QGSFIELDSITEM_H
164
165
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 data item representing a single field from a layer.
QgsField field() const
Returns the field definition.
Encapsulate a field in an attribute table or data source.
Definition qgsfield.h:53
A browser item which contains a collection of field items.
bool canRenameFields() const
Returns true if the connection supports renaming fields.
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_FACTORY
Definition qgis_sip.h:76
The TableProperty class represents a database table or view.