QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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 <memory>
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
23
24#include <QAbstractItemModel>
25#include <QSortFilterProxyModel>
26#include <QStringList>
27
30
43class CORE_EXPORT QgsDatabaseSchemaModel : public QAbstractItemModel
44{
45 Q_OBJECT
46
47 public:
48
49 // *INDENT-OFF*
50
58 {
59 Empty SIP_MONKEYPATCH_COMPAT_NAME(RoleEmpty) = Qt::UserRole,
60 };
61 Q_ENUM( CustomRole )
62 // *INDENT-ON*
63
64
70 explicit QgsDatabaseSchemaModel( const QString &provider, const QString &connection, QObject *parent SIP_TRANSFERTHIS = nullptr );
71
77 explicit QgsDatabaseSchemaModel( QgsAbstractDatabaseProviderConnection *connection SIP_TRANSFER, QObject *parent SIP_TRANSFERTHIS = nullptr );
78
79 // QAbstractItemModel interface
80 QModelIndex parent( const QModelIndex &child ) const override;
81 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
82 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
83 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
84 QModelIndex index( int row, int column, const QModelIndex &parent ) const override;
85
90 void setAllowEmptySchema( bool allowEmpty );
91
96 bool allowEmptySchema() const { return mAllowEmpty; }
97
98 public slots:
99
103 void refresh();
104
105 private:
106 void init();
107 std::unique_ptr< QgsAbstractDatabaseProviderConnection > mConnection;
108 QStringList mSchemas;
109 bool mAllowEmpty = false;
110};
111
112#endif // QGSDATABASESCHEMAMODEL_H
Provides common functionality for database based connections.
A model containing schemas from a database connection.
QgsDatabaseSchemaModel(const QString &provider, const QString &connection, QObject *parent=nullptr)
Constructor for QgsDatabaseSchemaModel, for the specified provider and connection name.
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_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:268
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)
Definition qgis_sip.h:270