QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
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 "qgis_gui.h"
20#include "qgis_sip.h"
21
22#include <QComboBox>
23#include <QSortFilterProxyModel>
24
26
28#ifndef SIP_RUN
29class GUI_EXPORT QgsProviderConnectionComboBoxSortModel : public QSortFilterProxyModel
30{
31 Q_OBJECT
32 public:
33 explicit QgsProviderConnectionComboBoxSortModel( QObject *parent = nullptr );
34
35 protected:
36 bool lessThan( const QModelIndex &source_left, const QModelIndex &source_right ) const override;
37};
38#endif
40
50class GUI_EXPORT QgsProviderConnectionComboBox : public QComboBox
51{
52 Q_OBJECT
53
54 public:
55
62 explicit QgsProviderConnectionComboBox( const QString &provider, QWidget *parent SIP_TRANSFERTHIS = nullptr );
63
69 explicit QgsProviderConnectionComboBox( QWidget *parent = nullptr ) SIP_SKIP;
70
77 void setProvider( const QString &provider );
78
83 void setAllowEmptyConnection( bool allowEmpty );
84
89 bool allowEmptyConnection() const;
90
94 QString currentConnection() const;
95
99 QString currentConnectionUri() const;
100
101 public slots:
102
106 void setConnection( const QString &connection );
107
108 signals:
110 void connectionChanged( const QString &connection );
111
112 private slots:
113 void indexChanged( int i );
114 void rowsChanged();
115 void rowsAboutToBeRemoved();
116 void rowsRemoved();
117
118 private:
119 QgsProviderConnectionModel *mModel = nullptr;
120 QSortFilterProxyModel *mSortModel = nullptr;
121 QString mPreviousConnection;
122};
123
124#endif // QGSPROVIDERCONNECTIONCOMBOBOX_H
QgsProviderConnectionComboBox(const QString &provider, QWidget *parent=nullptr)
Constructor for QgsProviderConnectionComboBox, for the specified provider.
QString currentConnectionUri() const
Returns the uri of the current connection selected in the combo box.
void setProvider(const QString &provider)
Sets the provider to be used.
void setConnection(const QString &connection)
Sets the current connection selected in the combo box.
bool allowEmptyConnection() const
Returns true if the combobox allows the empty connection ("not set") choice.
void setAllowEmptyConnection(bool allowEmpty)
Sets whether an optional empty connection ("not set") option is present in the combobox.
QString currentConnection() const
Returns the name of the current connection selected in the combo box.
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:134