QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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 <QAbstractItemModel>
20#include <QSortFilterProxyModel>
21#include <QStringList>
22
23#include "qgis_core.h"
24#include "qgis_sip.h"
25
27
38class CORE_EXPORT QgsProviderConnectionModel : public QAbstractItemModel
39{
40 Q_OBJECT
41
42 public:
43
44 // *INDENT-OFF*
45
53 {
54 ConnectionName SIP_MONKEYPATCH_COMPAT_NAME(RoleConnectionName) = Qt::UserRole,
55 Uri SIP_MONKEYPATCH_COMPAT_NAME(RoleUri),
56 Configuration SIP_MONKEYPATCH_COMPAT_NAME(RoleConfiguration),
57 Empty SIP_MONKEYPATCH_COMPAT_NAME(RoleEmpty),
58 };
59 Q_ENUM( CustomRole )
60 // *INDENT-ON*
61
62
68 explicit QgsProviderConnectionModel( const QString &provider, QObject *parent SIP_TRANSFERTHIS = nullptr );
69
74 void setAllowEmptyConnection( bool allowEmpty );
75
80 bool allowEmptyConnection() const { return mAllowEmpty; }
81
82 // QAbstractItemModel interface
83 QModelIndex parent( const QModelIndex &child ) const override;
84 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
85 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
86 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
87 QModelIndex index( int row, int column, const QModelIndex &parent ) const override;
88 private slots:
89 void removeConnection( const QString &connection );
90 void addConnection( const QString &connection );
91
92 private:
93 QString mProvider;
94 QgsProviderMetadata *mMetadata = nullptr;
95 QStringList mConnections;
96 bool mAllowEmpty = false;
97};
98
99#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.
Holds data provider key, description, and associated shared library file or function pointer informat...
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:271
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)
Definition qgis_sip.h:273