QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsdatabaseschemacombobox.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsdatabaseschemacombobox.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 QGSDATABASESCHEMACOMBOBOX_H
17#define QGSDATABASESCHEMACOMBOBOX_H
18
19#include <QComboBox>
20
21#include "qgis_gui.h"
22#include "qgis_sip.h"
23#include <QSortFilterProxyModel>
24
27
29#ifndef SIP_RUN
30class GUI_EXPORT QgsDatabaseSchemaComboBoxSortModel: public QSortFilterProxyModel
31{
32 Q_OBJECT
33 public:
34 explicit QgsDatabaseSchemaComboBoxSortModel( QObject *parent = nullptr );
35 protected:
36 bool lessThan( const QModelIndex &source_left, const QModelIndex &source_right ) const override;
37
38};
39#endif
41
51class GUI_EXPORT QgsDatabaseSchemaComboBox : public QWidget
52{
53 Q_OBJECT
54
55 public:
56
63 explicit QgsDatabaseSchemaComboBox( const QString &provider, const QString &connection, QWidget *parent SIP_TRANSFERTHIS = nullptr );
64
71
76 void setAllowEmptySchema( bool allowEmpty );
77
82 bool allowEmptySchema() const;
83
87 QString currentSchema() const;
88
92 QComboBox *comboBox() { return mComboBox; }
93
94 public slots:
95
99 void setSchema( const QString &schema );
100
106 void setConnectionName( const QString &connection, const QString &provider = QString() );
107
111 void refreshSchemas();
112
113 signals:
115 void schemaChanged( const QString &schema );
116
117 private slots:
118 void indexChanged( int i );
119 void rowsChanged();
120
121 private:
122 void init();
123
124 bool mAllowEmpty = false;
125 QString mProvider;
126 QgsDatabaseSchemaModel *mModel = nullptr;
127 QSortFilterProxyModel *mSortModel = nullptr;
128 QComboBox *mComboBox = nullptr;
129};
130
131#endif // QGSDATABASESCHEMACOMBOBOX_H
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connection...
The QgsDatabaseSchemaComboBox class is a combo box which displays the list of schemas for a specific ...
void schemaChanged(const QString &schema)
Emitted whenever the currently selected schema changes.
QComboBox * comboBox()
Returns the combobox portion of the widget.
A model containing schemas from a database connection.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_TRANSFER
Definition: qgis_sip.h:36