QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
QgsDatabaseSchemaModel Class Reference

A model containing schemas from a database connection. More...

#include <qgsdatabaseschemamodel.h>

Inheritance diagram for QgsDatabaseSchemaModel:

Public Types

enum class  CustomRole : int { Empty = Qt::UserRole }
 Custom model roles. More...

Public Slots

void refresh ()
 Refreshes the schema list by querying the underlying connection.

Public Member Functions

 QgsDatabaseSchemaModel (const QString &provider, const QString &connection, QObject *parent=nullptr)
 Constructor for QgsDatabaseSchemaModel, for the specified provider and connection name.
 QgsDatabaseSchemaModel (QgsAbstractDatabaseProviderConnection *connection, QObject *parent=nullptr)
 Constructor for QgsDatabaseSchemaModel, for the specified connection.
bool allowEmptySchema () const
 Returns true if the model allows the empty schema ("not set") choice.
int columnCount (const QModelIndex &parent=QModelIndex()) const override
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
QModelIndex index (int row, int column, const QModelIndex &parent) const override
QModelIndex parent (const QModelIndex &child) const override
int rowCount (const QModelIndex &parent=QModelIndex()) const override
void setAllowEmptySchema (bool allowEmpty)
 Sets whether an optional empty schema ("not set") option is present in the model.

Detailed Description

A model containing schemas from a database connection.

This class does not automatically subscribe to database updates. Schemas are queried from the database initially upon model construction. In order to update the listed schemas, QgsDatabaseSchemaModel::refresh() must be manually called.

Since
QGIS 3.14

Definition at line 43 of file qgsdatabaseschemamodel.h.

Member Enumeration Documentation

◆ CustomRole

enum class QgsDatabaseSchemaModel::CustomRole : int
strong

Custom model roles.

Note
Prior to QGIS 3.36 this was available as QgsDatabaseSchemaModel::Role
Since
QGIS 3.36
Enumerator
Empty 

Entry is an empty entry.

Definition at line 57 of file qgsdatabaseschemamodel.h.

Constructor & Destructor Documentation

◆ QgsDatabaseSchemaModel() [1/2]

QgsDatabaseSchemaModel::QgsDatabaseSchemaModel ( const QString & provider,
const QString & connection,
QObject * parent = nullptr )
explicit

Constructor for QgsDatabaseSchemaModel, for the specified provider and connection name.

Warning
The provider must support the connection API methods in its QgsProviderMetadata implementation in order for the model to work correctly.

Definition at line 23 of file qgsdatabaseschemamodel.cpp.

◆ QgsDatabaseSchemaModel() [2/2]

QgsDatabaseSchemaModel::QgsDatabaseSchemaModel ( QgsAbstractDatabaseProviderConnection * connection,
QObject * parent = nullptr )
explicit

Constructor for QgsDatabaseSchemaModel, for the specified connection.

Ownership of connection is transferred to the model.

Definition at line 34 of file qgsdatabaseschemamodel.cpp.

Member Function Documentation

◆ allowEmptySchema()

bool QgsDatabaseSchemaModel::allowEmptySchema ( ) const
inline

Returns true if the model allows the empty schema ("not set") choice.

See also
setAllowEmptySchema()

Definition at line 96 of file qgsdatabaseschemamodel.h.

◆ columnCount()

int QgsDatabaseSchemaModel::columnCount ( const QModelIndex & parent = QModelIndex()) const
override

Definition at line 63 of file qgsdatabaseschemamodel.cpp.

◆ data()

QVariant QgsDatabaseSchemaModel::data ( const QModelIndex & index,
int role = Qt::DisplayRole ) const
override

Definition at line 70 of file qgsdatabaseschemamodel.cpp.

◆ index()

QModelIndex QgsDatabaseSchemaModel::index ( int row,
int column,
const QModelIndex & parent ) const
override

Definition at line 100 of file qgsdatabaseschemamodel.cpp.

◆ parent()

QModelIndex QgsDatabaseSchemaModel::parent ( const QModelIndex & child) const
override

Definition at line 48 of file qgsdatabaseschemamodel.cpp.

◆ refresh

void QgsDatabaseSchemaModel::refresh ( )
slot

Refreshes the schema list by querying the underlying connection.

Definition at line 129 of file qgsdatabaseschemamodel.cpp.

◆ rowCount()

int QgsDatabaseSchemaModel::rowCount ( const QModelIndex & parent = QModelIndex()) const
override

Definition at line 55 of file qgsdatabaseschemamodel.cpp.

◆ setAllowEmptySchema()

void QgsDatabaseSchemaModel::setAllowEmptySchema ( bool allowEmpty)

Sets whether an optional empty schema ("not set") option is present in the model.

See also
allowEmptySchema()

Definition at line 110 of file qgsdatabaseschemamodel.cpp.


The documentation for this class was generated from the following files: