QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
33 class 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 
88  QgsVectorLayer *layer() SIP_FACTORY;
89 
95 
96  private:
97 
98  QString mSchema;
99  QString mTableName;
100  QString mConnectionUri;
101  std::unique_ptr<QgsAbstractDatabaseProviderConnection::TableProperty> mTableProperty;
102 
103 };
104 
105 
113 class CORE_EXPORT QgsFieldItem : public QgsDataItem
114 {
115  Q_OBJECT
116  public:
117 
123  const QgsField &field );
124 
125  ~QgsFieldItem() override;
126 
127 #ifdef SIP_RUN
128  SIP_PYOBJECT __repr__();
129  % MethodCode
130  QString str = QStringLiteral( "<QgsFieldItem: %1>" ).arg( sipCpp->name() );
131  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
132  % End
133 #endif
134 
135  QIcon icon() override;
136 
142  QgsField field() const { return mField; }
143 
144  bool equal( const QgsDataItem *other ) override;
145 
146  private:
147 
148  const QgsField mField;
149 
150 };
151 
152 #endif // QGSFIELDSITEM_H
153 
154 
QgsDataItem::icon
virtual QIcon icon()
Definition: qgsdataitem.cpp:162
qgsdataitem.h
QgsFieldItem
A layer field item, information about the connection URI, the schema and the table as well as the lay...
Definition: qgsfieldsitem.h:113
field
const QgsField & field
Definition: qgsfield.h:463
QgsFieldsItem
A collection of field items with some internal logic to retrieve the fields and a the vector layer in...
Definition: qgsfieldsitem.h:33
QgsDataItem::equal
virtual bool equal(const QgsDataItem *other)
Returns true if this item is equal to another item (by testing item type and path).
Definition: qgsdataitem.cpp:501
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsAbstractDatabaseProviderConnection::TableProperty
The TableProperty class represents a database table or view.
Definition: qgsabstractdatabaseproviderconnection.h:265
qgis_sip.h
str
#define str(x)
Definition: qgis.cpp:37
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
qgsfield.h
QgsDataItem
Base class for all items in the model.
Definition: qgsdataitem.h:45
qgsabstractdatabaseproviderconnection.h
QgsFieldItem::field
QgsField field() const
Returns the field definition.
Definition: qgsfieldsitem.h:142
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsDataItem::createChildren
virtual QVector< QgsDataItem * > createChildren()
Create children.
Definition: qgsdataitem.cpp:184
QgsField
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:50