QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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 <QComboBox>
20
21#include "qgis_gui.h"
22#include "qgis_sip.h"
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 protected:
35 bool lessThan( const QModelIndex &source_left, const QModelIndex &source_right ) const override;
36
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
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