QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
Public Types | Public Slots | Public Member Functions | List of all members
QgsDatabaseSchemaModel Class Reference

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

#include <qgsdatabaseschemamodel.h>

Inheritance diagram for QgsDatabaseSchemaModel:
Inheritance graph
[legend]

Public Types

enum  Role { RoleEmpty = Qt::UserRole }
 Model roles. More...
 

Public Slots

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

Public Member Functions

 QgsDatabaseSchemaModel (const QString &provider, const QString &connection, QObject *parent=nullptr)
 Constructor for QgsDatabaseSchemaModel, for the specified provider and connection name. More...
 
 QgsDatabaseSchemaModel (QgsAbstractDatabaseProviderConnection *connection, QObject *parent=nullptr)
 Constructor for QgsDatabaseSchemaModel, for the specified connection. More...
 
bool allowEmptySchema () const
 Returns true if the model allows the empty schema ("not set") choice. More...
 
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. More...
 

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 42 of file qgsdatabaseschemamodel.h.

Member Enumeration Documentation

◆ Role

Model roles.

Enumerator
RoleEmpty 

Entry is an empty entry.

Definition at line 49 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 20 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 31 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 86 of file qgsdatabaseschemamodel.h.

◆ columnCount()

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

Definition at line 60 of file qgsdatabaseschemamodel.cpp.

◆ data()

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

Definition at line 67 of file qgsdatabaseschemamodel.cpp.

◆ index()

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

Definition at line 97 of file qgsdatabaseschemamodel.cpp.

◆ parent()

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

Definition at line 45 of file qgsdatabaseschemamodel.cpp.

◆ refresh

void QgsDatabaseSchemaModel::refresh ( )
slot

Refreshes the schema list by querying the underlying connection.

Definition at line 126 of file qgsdatabaseschemamodel.cpp.

◆ rowCount()

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

Definition at line 52 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 107 of file qgsdatabaseschemamodel.cpp.


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