QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
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 <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
48 // *INDENT-OFF*
49
57 {
58 Empty SIP_MONKEYPATCH_COMPAT_NAME(RoleEmpty) = Qt::UserRole,
59 };
60 Q_ENUM( CustomRole )
61 // *INDENT-ON*
62
63
69 explicit QgsDatabaseSchemaModel( const QString &provider, const QString &connection, QObject *parent SIP_TRANSFERTHIS = nullptr );
70
76 explicit QgsDatabaseSchemaModel( QgsAbstractDatabaseProviderConnection *connection SIP_TRANSFER, QObject *parent SIP_TRANSFERTHIS = nullptr );
77
78 // QAbstractItemModel interface
79 QModelIndex parent( const QModelIndex &child ) const override;
80 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
81 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
82 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
83 QModelIndex index( int row, int column, const QModelIndex &parent ) const override;
84
89 void setAllowEmptySchema( bool allowEmpty );
90
95 bool allowEmptySchema() const { return mAllowEmpty; }
96
97 public slots:
98
102 void refresh();
103
104 private:
105 void init();
106 std::unique_ptr< QgsAbstractDatabaseProviderConnection > mConnection;
107 QStringList mSchemas;
108 bool mAllowEmpty = false;
109};
110
111#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_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:271
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)
Definition qgis_sip.h:273