QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsproviderconnectioncombobox.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsproviderconnectioncombobox.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 QGSPROVIDERCONNECTIONCOMBOBOX_H
17 #define QGSPROVIDERCONNECTIONCOMBOBOX_H
18 
19 #include <QComboBox>
20 
21 #include "qgis_gui.h"
22 #include "qgis_sip.h"
23 #include <QSortFilterProxyModel>
24 
26 
28 #ifndef SIP_RUN
29 class GUI_EXPORT QgsProviderConnectionComboBoxSortModel: public QSortFilterProxyModel
30 {
31  public:
32  explicit QgsProviderConnectionComboBoxSortModel( QObject *parent = nullptr );
33  protected:
34  bool lessThan( const QModelIndex &source_left, const QModelIndex &source_right ) const override;
35 
36 };
37 #endif
39 
49 class GUI_EXPORT QgsProviderConnectionComboBox : public QComboBox
50 {
51  Q_OBJECT
52 
53  public:
54 
61  explicit QgsProviderConnectionComboBox( const QString &provider, QWidget *parent SIP_TRANSFERTHIS = nullptr );
62 
68  explicit QgsProviderConnectionComboBox( QWidget *parent = nullptr ) SIP_SKIP;
69 
76  void setProvider( const QString &provider );
77 
82  void setAllowEmptyConnection( bool allowEmpty );
83 
88  bool allowEmptyConnection() const;
89 
93  QString currentConnection() const;
94 
98  QString currentConnectionUri() const;
99 
100  public slots:
101 
105  void setConnection( const QString &connection );
106 
107  signals:
109  void connectionChanged( const QString &connection );
110 
111  private slots:
112  void indexChanged( int i );
113  void rowsChanged();
114 
115  private:
116  QgsProviderConnectionModel *mModel = nullptr;
117  QSortFilterProxyModel *mSortModel = nullptr;
118 };
119 
120 #endif // QGSPROVIDERCONNECTIONCOMBOBOX_H
The QgsProviderConnectionComboBox class is a combo box which displays the list of connections registe...
void connectionChanged(const QString &connection)
Emitted whenever the currently selected connection changes.
A model containing registered connection names for a specific data provider.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_SKIP
Definition: qgis_sip.h:126