QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
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 "qgis_gui.h"
20
#include "
qgis_sip.h
"
21
22
#include <QComboBox>
23
#include <QSortFilterProxyModel>
24
25
class
QgsDatabaseTableModel
;
26
class
QgsAbstractDatabaseProviderConnection
;
27
29
#ifndef SIP_RUN
30
class
GUI_EXPORT QgsDatabaseTableComboBoxSortModel :
public
QSortFilterProxyModel
31
{
32
Q_OBJECT
33
public
:
34
explicit
QgsDatabaseTableComboBoxSortModel( QObject *parent =
nullptr
);
35
36
protected
:
37
bool
lessThan(
const
QModelIndex &source_left,
const
QModelIndex &source_right )
const override
;
38
};
39
#endif
41
51
class
GUI_EXPORT
QgsDatabaseTableComboBox
:
public
QWidget
52
{
53
Q_OBJECT
54
55
public
:
64
explicit
QgsDatabaseTableComboBox
(
const
QString &provider,
const
QString &connection,
const
QString &schema = QString(), QWidget *parent
SIP_TRANSFERTHIS
=
nullptr
);
65
73
explicit
QgsDatabaseTableComboBox
(
QgsAbstractDatabaseProviderConnection
*connection
SIP_TRANSFER
,
const
QString &schema = QString(), QWidget *parent
SIP_TRANSFERTHIS
=
nullptr
);
74
79
void
setAllowEmptyTable
(
bool
allowEmpty );
80
85
bool
allowEmptyTable
()
const
;
86
90
QString
currentTable
()
const
;
91
95
QString
currentSchema
()
const
;
96
100
QComboBox *
comboBox
() {
return
mComboBox; }
101
102
public
slots:
103
109
void
setTable(
const
QString &table,
const
QString &schema = QString() );
110
116
void
setConnectionName(
const
QString &connection,
const
QString &provider = QString() );
117
121
void
setSchema(
const
QString &schema );
122
126
void
refreshTables();
127
128
signals:
130
void
tableChanged
(
const
QString &table,
const
QString &schema = QString() );
131
132
private
slots:
133
void
indexChanged(
int
i );
134
void
rowsChanged();
135
136
private
:
137
void
init();
138
139
bool
mAllowEmpty =
false
;
140
QString mProvider;
141
QString mConnection;
142
QString mSchema;
143
QgsDatabaseTableModel
*mModel =
nullptr
;
144
QSortFilterProxyModel *mSortModel =
nullptr
;
145
QComboBox *mComboBox =
nullptr
;
146
};
147
148
#endif
// QGSDATABASETABLECOMBOBOX_H
QgsAbstractDatabaseProviderConnection
Provides common functionality for database based connections.
Definition
qgsabstractdatabaseproviderconnection.h:50
QgsDatabaseTableComboBox::tableChanged
void tableChanged(const QString &table, const QString &schema=QString())
Emitted whenever the currently selected table changes.
QgsDatabaseTableComboBox::currentSchema
QString currentSchema() const
Returns the schema of the current table selected in the combo box.
Definition
qgsdatabasetablecombobox.cpp:181
QgsDatabaseTableComboBox::comboBox
QComboBox * comboBox()
Returns the combobox portion of the widget.
Definition
qgsdatabasetablecombobox.h:100
QgsDatabaseTableComboBox::allowEmptyTable
bool allowEmptyTable() const
Returns true if the combobox allows the empty table ("not set") choice.
Definition
qgsdatabasetablecombobox.cpp:56
QgsDatabaseTableComboBox::setAllowEmptyTable
void setAllowEmptyTable(bool allowEmpty)
Sets whether an optional empty table ("not set") option is present in the combobox.
Definition
qgsdatabasetablecombobox.cpp:49
QgsDatabaseTableComboBox::QgsDatabaseTableComboBox
QgsDatabaseTableComboBox(const QString &provider, const QString &connection, const QString &schema=QString(), QWidget *parent=nullptr)
Constructor for QgsDatabaseTableComboBox, for the specified provider and connection.
Definition
qgsdatabasetablecombobox.cpp:30
QgsDatabaseTableComboBox::currentTable
QString currentTable() const
Returns the name of the current table selected in the combo box.
Definition
qgsdatabasetablecombobox.cpp:192
QgsDatabaseTableModel
A model containing tables from a database connection.
Definition
qgsdatabasetablemodel.h:41
qgis_sip.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
SIP_TRANSFER
#define SIP_TRANSFER
Definition
qgis_sip.h:35
Generated on
for QGIS API Documentation by
1.17.0