QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgsproviderconnectionmodel.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsproviderconnectionmodel.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 QGSPROVIDERCONNECTIONMODEL_H
17#define QGSPROVIDERCONNECTIONMODEL_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21
22#include <QAbstractItemModel>
23#include <QSortFilterProxyModel>
24#include <QStringList>
25
27
38class CORE_EXPORT QgsProviderConnectionModel : public QAbstractItemModel
39{
40 Q_OBJECT
41
42 public:
43 // *INDENT-OFF*
44
52 {
53 ConnectionName SIP_MONKEYPATCH_COMPAT_NAME( RoleConnectionName ) = Qt::UserRole,
55 Configuration SIP_MONKEYPATCH_COMPAT_NAME( RoleConfiguration ),
56 Empty SIP_MONKEYPATCH_COMPAT_NAME( RoleEmpty ),
57 };
58 Q_ENUM( CustomRole )
59 // *INDENT-ON*
60
61
67 explicit QgsProviderConnectionModel( const QString &provider, QObject *parent SIP_TRANSFERTHIS = nullptr );
68
73 void setAllowEmptyConnection( bool allowEmpty );
74
79 bool allowEmptyConnection() const { return mAllowEmpty; }
80
81 // QAbstractItemModel interface
82 QModelIndex parent( const QModelIndex &child ) const override;
83 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
84 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
85 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
86 QModelIndex index( int row, int column, const QModelIndex &parent ) const override;
87 private slots:
88 void removeConnection( const QString &connection );
89 void addConnection( const QString &connection );
90
91 private:
92 QString mProvider;
93 QgsProviderMetadata *mMetadata = nullptr;
94 QStringList mConnections;
95 bool mAllowEmpty = false;
96};
97
98#endif // QGSPROVIDERCONNECTIONMODEL_H
A model containing registered connection names for a specific data provider.
bool allowEmptyConnection() const
Returns true if the model allows the empty connection ("not set") choice.
QgsProviderConnectionModel(const QString &provider, QObject *parent=nullptr)
Constructor for QgsProviderConnectionModel, for the specified provider.
Holds data provider key, description, and associated shared library file or function pointer informat...
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:267
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)
Definition qgis_sip.h:269