QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
28 const QString &connectionUri,
29 const QString &providerKey,
30 const QString &schema,
31 const QString &tableName )
32 :
QgsDataItem(
Qgis::BrowserItemType::Fields, parent, tr(
"Fields" ), path, providerKey )
34 , mTableName( tableName )
35 , mConnectionUri( connectionUri )
44 mTableProperty = std::make_unique<QgsAbstractDatabaseProviderConnection::TableProperty>( conn->table(
schema,
tableName ) );
48 QgsDebugMsg( QStringLiteral(
"Error creating fields item: %1" ).arg( ex.
what() ) );
70 const QgsFields constFields { conn->fields( mSchema, mTableName ) };
71 for (
const auto &f : constFields )
94 return mConnectionUri;
99 std::unique_ptr<QgsVectorLayer> vl;
118 QgsDebugMsg( QStringLiteral(
"Error getting connection from %1" ).arg( mConnectionUri ) );
131 return mTableProperty.get();
145 :
QgsDataItem(
Qgis::BrowserItemType::Field, parent,
field.name(), parent->path() +
'/' +
field.name(), parent->providerKey() )
152 QStringList constraintsText;
153 if ( constraints.testFlag( QgsFieldConstraints::Constraint::ConstraintNotNull ) )
155 constraintsText.push_back( tr(
"NOT NULL" ) );
157 if ( constraints.testFlag( QgsFieldConstraints::Constraint::ConstraintUnique ) )
159 constraintsText.push_back( tr(
"UNIQUE" ) );
161 if ( ! constraintsText.isEmpty() )
163 setToolTip( QStringLiteral(
"<ul><li>%1</li></ul>" ).arg( constraintsText.join( QLatin1String(
"</li><li>" ) ) ) );
175 if ( parentFields && parentFields->tableProperty() &&
176 parentFields->tableProperty()->geometryColumn() ==
mName &&
177 !parentFields->tableProperty()->geometryColumnTypes().isEmpty() )
179 if ( mField.
typeName() == QLatin1String(
"raster" ) )
186 case QgsWkbTypes::GeometryType::LineGeometry:
188 case QgsWkbTypes::GeometryType::PointGeometry:
190 case QgsWkbTypes::GeometryType::PolygonGeometry:
192 case QgsWkbTypes::GeometryType::UnknownGeometry:
194 case QgsWkbTypes::GeometryType::NullGeometry:
214 const QgsFieldItem *o = qobject_cast<const QgsFieldItem *>( other );
static QIcon iconRaster()
Returns an icon representing raster layers.
QgsFieldItem(QgsDataItem *parent, const QgsField &field)
Constructor for QgsFieldItem, with the specified parent item and field.
QgsVectorLayer * layer()
Creates and returns a (possibly NULL) layer from the connection URI and schema/table information.
static QIcon iconPolygon()
Returns an icon representing polygon geometries.
Container of fields for a vector layer.
static QIcon iconLine()
Returns an icon representing line geometries.
void setToolTip(const QString &msg)
QString typeName() const
Gets the field type.
A layer field item, information about the connection URI, the schema and the table as well as the lay...
QString tableName() const
Returns the table name.
static QIcon iconDefaultLayer()
Returns a default icon for layers, which aren't the standard raster/vector/...
A collection of field items with some internal logic to retrieve the fields and a the vector layer in...
Qgis::BrowserItemCapabilities mCapabilities
The TableProperty class represents a database table or view.
QgsAbstractDatabaseProviderConnection::TableProperty * tableProperty() const
Returns the (possibly NULL) properties of the table this fields belong to.
@ Collapse
The collapse/expand status for this items children should be ignored in order to avoid undesired netw...
bool equal(const QgsDataItem *other) override
Returns true if this item is equal to another item (by testing item type and path).
QgsDataItem * parent() const
Gets item parent.
@ RefreshChildrenWhenItemIsRefreshed
When the item is refreshed, all its populated children will also be refreshed in turn (since QGIS 3....
@ Populated
Children created.
virtual void setState(Qgis::BrowserItemState state)
Set item state.
static QIcon iconPoint()
Returns an icon representing point geometries.
QgsProviderMetadata * providerMetadata(const QString &providerKey) const
Returns metadata of the provider or nullptr if not found.
~QgsFieldsItem() override
static QIcon iconGeometryCollection()
Returns an icon representing geometry collections.
Custom exception class for provider connection related exceptions.
Data item that can be used to report problems (e.g. network error)
static QIcon iconForFieldType(QVariant::Type type, QVariant::Type subType=QVariant::Type::Invalid)
Returns an icon corresponding to a field type.
QVariant::Type subType() const
If the field is a collection, gets its element's type.
QString schema() const
Returns the schema name.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Represents a vector layer which manages a vector based data sets.
QgsFieldConstraints constraints
static GeometryType geometryType(Type type) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
QVector< QgsDataItem * > children() const
The Qgis class provides global constants for use throughout the application.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
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.
QString providerKey() const
Returns the provider key that created this item (e.g.
Base class for all items in the model.
QgsField field() const
Returns the field definition.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
void setSortKey(const QVariant &key)
Sets a custom sorting key for the item.
QVector< QgsDataItem * > createChildren() override
Create children.
Qgis::BrowserItemType type() const
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connection...
@ Fertile
Can create children. Even items without this capability may have children, but cannot create them,...
QString connectionUri() const
Returns the connection URI.
Encapsulate a field in an attribute table or data source.