1 /***************************************************************************
2     qgsowsconnection.h  -  OWS connection
3                              -------------------
4     begin                : 3 April 2005
5     original             : (C) 2005 by Brendan Morley email  : morb at ozemail dot com dot au
6     wms search           : (C) 2009 Mathias Walker <mwa at sourcepole.ch>, Sourcepole AG
7 
8     generalized          : (C) 2012 Radim Blazek, based on qgswmsconnection.h
9 
10 
11  ***************************************************************************/
12 
13 /***************************************************************************
14  *                                                                         *
15  *   This program is free software; you can redistribute it and/or modify  *
16  *   it under the terms of the GNU General Public License as published by  *
17  *   the Free Software Foundation; either version 2 of the License, or     *
18  *   (at your option) any later version.                                   *
19  *                                                                         *
20  ***************************************************************************/
21 
22 #ifndef QGSOWSCONNECTION_H
23 #define QGSOWSCONNECTION_H
24 
25 #include "qgis_core.h"
26 #include "qgsdatasourceuri.h"
27 
28 #include <QStringList>
29 #include <QPushButton>
30 
31 /**
32  * \ingroup core
33  * \brief Connections management
34  */
35 class CORE_EXPORT QgsOwsConnection : public QObject
36 {
37     Q_OBJECT
38 
39   public:
40 
41     /**
42      * Constructor
43      * \param service service name: WMS,WFS,WCS
44      * \param connName connection name
45      */
46     QgsOwsConnection( const QString &service, const QString &connName );
47 
48     /**
49      * Returns the connection name.
50      * \since QGIS 3.0
51      */
52     QString connectionName() const;
53 
54     /**
55      * Returns connection info string.
56      * \since QGIS 3.0
57      */
58     QString connectionInfo() const;
59 
60     /**
61      * Returns a string representing the service type, e.g. "WMS".
62      * \since QGIS 3.0
63      */
64     QString service() const;
65 
66     /**
67      * Returns the connection uri.
68      */
69     QgsDataSourceUri uri() const;
70 
71     /**
72      * Adds uri parameters relating to the settings for a WMS or WCS connection to a QgsDataSourceUri \a uri.
73      * Connection settings are taken from the specified QSettings \a settingsKey.
74      * \since QGIS 3.0
75      */
76     static QgsDataSourceUri &addWmsWcsConnectionSettings( QgsDataSourceUri &uri, const QString &settingsKey );
77 
78     /**
79      * Adds uri parameters relating to the settings for a WFS connection to a QgsDataSourceUri \a uri.
80      * Connection settings are taken from the specified QSettings \a settingsKey.
81      * \since QGIS 3.0
82      */
83     static QgsDataSourceUri &addWfsConnectionSettings( QgsDataSourceUri &uri, const QString &settingsKey );
84 
85     //! Returns the list of connections for the specified service
86     static QStringList connectionList( const QString &service );
87 
88     //! Deletes the connection for the specified service with the specified name
89     static void deleteConnection( const QString &service, const QString &name );
90 
91     //! Retrieves the selected connection for the specified service
92     static QString selectedConnection( const QString &service );
93     //! Marks the specified connection for the specified service as selected
94     static void setSelectedConnection( const QString &service, const QString &name );
95 
96   protected:
97     QgsDataSourceUri mUri;
98 
99   private:
100 
101     QString mConnName;
102     QString mService;
103     QString mConnectionInfo;
104 
105     static void addCommonConnectionSettings( QgsDataSourceUri &uri, const QString &settingsKey );
106 
107 };
108 
109 
110 #endif // QGSOWSCONNECTION_H
111