QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgsdatabasetablecombobox.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsdatabasetablecombobox.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 QGSDATABASETABLECOMBOBOX_H
17#define QGSDATABASETABLECOMBOBOX_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 QgsDatabaseTableComboBoxSortModel: public QSortFilterProxyModel
31{
32 Q_OBJECT
33 public:
34 explicit QgsDatabaseTableComboBoxSortModel( 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 QgsDatabaseTableComboBox : public QWidget
52{
53 Q_OBJECT
54
55 public:
56
65 explicit QgsDatabaseTableComboBox( const QString &provider, const QString &connection, const QString &schema = QString(), QWidget *parent SIP_TRANSFERTHIS = nullptr );
66
74 explicit QgsDatabaseTableComboBox( QgsAbstractDatabaseProviderConnection *connection SIP_TRANSFER, const QString &schema = QString(), QWidget *parent SIP_TRANSFERTHIS = nullptr );
75
80 void setAllowEmptyTable( bool allowEmpty );
81
86 bool allowEmptyTable() const;
87
91 QString currentTable() const;
92
96 QString currentSchema() const;
97
101 QComboBox *comboBox() { return mComboBox; }
102
103 public slots:
104
110 void setTable( const QString &table, const QString &schema = QString() );
111
117 void setConnectionName( const QString &connection, const QString &provider = QString() );
118
122 void setSchema( const QString &schema );
123
127 void refreshTables();
128
129 signals:
131 void tableChanged( const QString &table, const QString &schema = QString() );
132
133 private slots:
134 void indexChanged( int i );
135 void rowsChanged();
136
137 private:
138 void init();
139
140 bool mAllowEmpty = false;
141 QString mProvider;
142 QString mConnection;
143 QString mSchema;
144 QgsDatabaseTableModel *mModel = nullptr;
145 QSortFilterProxyModel *mSortModel = nullptr;
146 QComboBox *mComboBox = nullptr;
147};
148
149#endif // QGSDATABASETABLECOMBOBOX_H
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connection...
The QgsDatabaseTableComboBox class is a combo box which displays the list of tables for a specific da...
void tableChanged(const QString &table, const QString &schema=QString())
Emitted whenever the currently selected table changes.
QComboBox * comboBox()
Returns the combobox portion of the widget.
A model containing tables from a database connection.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_TRANSFER
Definition qgis_sip.h:36