QGIS API Documentation 3.99.0-Master (d270888f95f)
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
101
107 bool canRenameFields() const { return mCanRename; }
108
109 private:
110
111 QString mSchema;
112 QString mTableName;
113 QString mConnectionUri;
114 bool mCanRename = false;
115 std::unique_ptr<QgsAbstractDatabaseProviderConnection::TableProperty> mTableProperty;
116
117};
118
119
128class CORE_EXPORT QgsFieldItem : public QgsDataItem
129{
130 Q_OBJECT
131 public:
132
138 const QgsField &field );
139
140 ~QgsFieldItem() override;
141
142#ifdef SIP_RUN
143 SIP_PYOBJECT __repr__();
144 % MethodCode
145 QString str = u"<QgsFieldItem: %1>"_s.arg( sipCpp->name() );
146 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
147 % End
148#endif
149
150 QIcon icon() override;
151
157 QgsField field() const { return mField; }
158
159 bool equal( const QgsDataItem *other ) override;
160
161 private:
162
163 const QgsField mField;
164
165};
166
167#endif // QGSFIELDSITEM_H
168
169
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.
QString schema() const
Returns the schema name.
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:84
The TableProperty class represents a database table or view.