QGIS API Documentation 3.41.0-Master (3440c17df1d)
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_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
122class CORE_EXPORT QgsFieldItem : public QgsDataItem
123{
124 Q_OBJECT
125 public:
126
132 const QgsField &field );
133
134 ~QgsFieldItem() override;
135
136#ifdef SIP_RUN
137 SIP_PYOBJECT __repr__();
138 % MethodCode
139 QString str = QStringLiteral( "<QgsFieldItem: %1>" ).arg( sipCpp->name() );
140 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
141 % End
142#endif
143
144 QIcon icon() override;
145
151 QgsField field() const { return mField; }
152
153 bool equal( const QgsDataItem *other ) override;
154
155 private:
156
157 const QgsField mField;
158
159};
160
161#endif // QGSFIELDSITEM_H
162
163
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 collection of field items with some internal logic to retrieve the fields and a the vector layer in...
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:39
#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.