QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
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 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 42 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 56 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 21 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 32 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 95 of file qgsdatabaseschemamodel.h.

◆ columnCount()

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

Definition at line 61 of file qgsdatabaseschemamodel.cpp.

◆ data()

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

Definition at line 68 of file qgsdatabaseschemamodel.cpp.

◆ index()

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

Definition at line 98 of file qgsdatabaseschemamodel.cpp.

◆ parent()

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

Definition at line 46 of file qgsdatabaseschemamodel.cpp.

◆ refresh

void QgsDatabaseSchemaModel::refresh ( )
slot

Refreshes the schema list by querying the underlying connection.

Definition at line 127 of file qgsdatabaseschemamodel.cpp.

◆ rowCount()

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

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


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