QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgsdatabaseschemamodel.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsdatabaseschemamodel.h
3 --------------------------------------
4 Date : March 2020
5 Copyright : (C) 2020 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7***************************************************************************
8* *
9* This program is free software; you can redistribute it and/or modify *
10* it under the terms of the GNU General Public License as published by *
11* the Free Software Foundation; either version 2 of the License, or *
12* (at your option) any later version. *
13* *
14***************************************************************************/
15
16#ifndef QGSDATABASESCHEMAMODEL_H
17#define QGSDATABASESCHEMAMODEL_H
18
19#include <QAbstractItemModel>
20#include <QSortFilterProxyModel>
21#include <QStringList>
22#include <memory>
23
24#include "qgis_core.h"
25#include "qgis_sip.h"
26
29
42class CORE_EXPORT QgsDatabaseSchemaModel : public QAbstractItemModel
43{
44 Q_OBJECT
45
46 public:
47
49 enum Role
50 {
51 RoleEmpty = Qt::UserRole,
52 };
53
60 explicit QgsDatabaseSchemaModel( const QString &provider, const QString &connection, QObject *parent SIP_TRANSFERTHIS = nullptr );
61
67 explicit QgsDatabaseSchemaModel( QgsAbstractDatabaseProviderConnection *connection SIP_TRANSFER, QObject *parent SIP_TRANSFERTHIS = nullptr );
68
69 // QAbstractItemModel interface
70 QModelIndex parent( const QModelIndex &child ) const override;
71 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
72 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
73 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
74 QModelIndex index( int row, int column, const QModelIndex &parent ) const override;
75
80 void setAllowEmptySchema( bool allowEmpty );
81
86 bool allowEmptySchema() const { return mAllowEmpty; }
87
88 public slots:
89
93 void refresh();
94
95 private:
96 void init();
97 std::unique_ptr< QgsAbstractDatabaseProviderConnection > mConnection;
98 QStringList mSchemas;
99 bool mAllowEmpty = false;
100};
101
102#endif // QGSDATABASESCHEMAMODEL_H
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connection...
A model containing schemas from a database connection.
bool allowEmptySchema() const
Returns true if the model allows the empty schema ("not set") choice.
Holds data provider key, description, and associated shared library file or function pointer informat...
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_TRANSFER
Definition: qgis_sip.h:36