QGIS API Documentation 3.41.0-Master (af5edcb665c)
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
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:
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 void rowsAboutToBeRemoved();
115 void rowsRemoved();
116
117 private:
118 QgsProviderConnectionModel *mModel = nullptr;
119 QSortFilterProxyModel *mSortModel = nullptr;
120 QString mPreviousConnection;
121};
122
123#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