QGIS API Documentation 3.99.0-Master (a8f284845db)
Loading...
Searching...
No Matches
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_core.h"
21#include "qgis_sip.h"
23#include "qgsdataitem.h"
24#include "qgsfield.h"
25
26#include <QString>
27
28using namespace Qt::StringLiterals;
29
39class CORE_EXPORT QgsFieldsItem : public QgsDataItem
40{
41 Q_OBJECT
42
43 public:
44
56 const QString &path,
57 const QString &connectionUri,
58 const QString &providerKey,
59 const QString &schema,
60 const QString &tableName );
61
62 ~QgsFieldsItem() override;
63
64#ifdef SIP_RUN
65 SIP_PYOBJECT __repr__();
66 % MethodCode
67 QString str = u"<QgsFieldsItem: %1>"_s.arg( sipCpp->path() );
68 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
69 % End
70#endif
71
72 QVector<QgsDataItem *> createChildren() override;
73
74 QIcon icon() override;
75
79 QString schema() const;
80
84 QString tableName() const;
85
89 QString connectionUri() const;
90
95
103 QgsFields fields() const;
104
110
116 bool canRenameFields() const { return mCanRename; }
117
118 private:
119
120 QString mSchema;
121 QString mTableName;
122 QString mConnectionUri;
123 bool mCanRename = false;
124 std::unique_ptr<QgsAbstractDatabaseProviderConnection::TableProperty> mTableProperty;
125 QgsFields mFields;
126};
127
128
137class CORE_EXPORT QgsFieldItem : public QgsDataItem
138{
139 Q_OBJECT
140 public:
141
147 const QgsField &field );
148
149 ~QgsFieldItem() override;
150
151#ifdef SIP_RUN
152 SIP_PYOBJECT __repr__();
153 % MethodCode
154 QString str = u"<QgsFieldItem: %1>"_s.arg( sipCpp->name() );
155 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
156 % End
157#endif
158
159 QIcon icon() override;
160
166 QgsField field() const { return mField; }
167
168 bool equal( const QgsDataItem *other ) override;
169
170 private:
171
172 const QgsField mField;
173
174};
175
176#endif // QGSFIELDSITEM_H
177
178
Base class for all items in the model.
Definition qgsdataitem.h:50
QgsDataItem(Qgis::BrowserItemType type, QgsDataItem *parent, const QString &name, const QString &path, const QString &providerKey=QString())
Constructor for QgsDataItem, with the specified parent item.
virtual QVector< QgsDataItem * > createChildren()
Create children.
QString path() const
virtual QIcon icon()
QgsDataItem * parent() const
Gets item parent.
QString providerKey() const
Returns the provider key that created this item (e.g.
virtual bool equal(const QgsDataItem *other)
Returns true if this item is equal to another item (by testing item type and path).
QgsFieldItem(QgsDataItem *parent, const QgsField &field)
Constructor for QgsFieldItem, with the specified parent item and field.
QgsField field() const
Returns the field definition.
Encapsulate a field in an attribute table or data source.
Definition qgsfield.h:56
QString tableName() const
Returns the table name.
QgsFieldsItem(QgsDataItem *parent, const QString &path, const QString &connectionUri, const QString &providerKey, const QString &schema, const QString &tableName)
Constructor for QgsFieldsItem, with the specified parent item.
QgsAbstractDatabaseProviderConnection::TableProperty * tableProperty() const
Returns the (possibly nullptr) properties of the table this fields belong to.
QString connectionUri() const
Returns the connection URI.
QgsVectorLayer * layer()
Creates and returns a (possibly nullptr) layer from the connection URI and schema/table information.
bool canRenameFields() const
Returns true if the connection supports renaming fields.
QgsFields fields() const
Returns the fields contained by the item.
QString schema() const
Returns the schema name.
Container of fields for a vector layer.
Definition qgsfields.h:46
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_FACTORY
Definition qgis_sip.h:83
The TableProperty class represents a database table or view.