QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsdataprovider.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdataprovider.h - DataProvider Interface class
3  --------------------------------------
4  Date : 09-Sep-2003
5  Copyright : (C) 2003 by Gary E.Sherman
6  email : sherman at mrcc.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 QQGSDATAPROVIDER_H
17 #define QQGSDATAPROVIDER_H
18 
19 #include <QDateTime>
20 #include <QObject>
21 #include <QString>
22 #include <QStringList>
23 
24 //#include "qgsdataitem.h"
25 #include "qgserror.h"
26 
27 typedef int dataCapabilities_t();
28 
29 class QgsRectangle;
31 
32 
46 class CORE_EXPORT QgsDataProvider : public QObject
47 {
48  Q_OBJECT
49 
50  public:
51 
52  Q_ENUMS( DataCapability )
53 
55  {
56  NoDataCapabilities = 0,
57  File = 1,
58  Dir = 1 << 1,
59  Database = 1 << 2,
60  Net = 1 << 3 // Internet source
61  };
62 
63  QgsDataProvider( QString const & uri = "" )
64  : mDataSourceURI( uri )
65  {}
66 
70  virtual ~QgsDataProvider() {}
71 
72 
78  virtual QgsCoordinateReferenceSystem crs() = 0;
79 
80 
86  virtual void setDataSourceUri( const QString & uri )
87  {
88  mDataSourceURI = uri;
89  }
90 
96  virtual QString dataSourceUri() const
97  {
98  return mDataSourceURI;
99  }
100 
101 
106  virtual QgsRectangle extent() = 0;
107 
108 
113  virtual bool isValid() = 0;
114 
115 
119  virtual void updateExtents()
120  {
121  // NOP by default
122  }
123 
124 
131  virtual bool setSubsetString( QString subset, bool updateFeatureCount = true )
132  {
133  // NOP by default
134  Q_UNUSED( subset );
135  Q_UNUSED( updateFeatureCount );
136  return false;
137  }
138 
139 
141  virtual bool supportsSubsetString() { return false; }
142 
150  {
151  return QString::null;
152  }
153 
154 
161  virtual QStringList subLayers() const
162  {
163  return QStringList(); // Empty
164  }
165 
166 
174  virtual QStringList subLayerStyles() const
175  {
176  return QStringList(); // Empty
177  }
178 
179 
183  virtual uint subLayerCount() const
184  {
185  return 0;
186  }
187 
188 
194  virtual void setLayerOrder( const QStringList &layers )
195  {
196  //prevent unused var warnings
197  if ( layers.count() < 1 )
198  {
199  return;
200  }
201  // NOOP
202  }
203 
204 
208  virtual void setSubLayerVisibility( const QString &name, bool vis )
209  {
210  //prevent unused var warnings
211  if ( name.isEmpty() || !vis )
212  {
213  return;
214  }
215  // NOOP
216  }
217 
218 
233  virtual QString name() const = 0;
234 
235 
247  virtual QString description() const = 0;
248 
249 
261  virtual QString fileVectorFilters() const
262  {
263  return "";
264  }
265 
266 
278  virtual QString fileRasterFilters() const
279  {
280  return "";
281  }
282 
285  virtual void reloadData() {}
286 
288  virtual QDateTime timestamp() const { return mTimestamp; }
289 
291  virtual QDateTime dataTimestamp() const { return QDateTime(); }
292 
297  virtual QgsError error() const { return mError; }
298 
299  signals:
300 
306  void fullExtentCalculated();
307 
315  void dataChanged();
316 
321  void dataChanged( int changed );
322 
323  protected:
328 
331 
333  void appendError( const QgsErrorMessage & theMessage ) { mError.append( theMessage );}
334 
336  void setError( const QgsError & theError ) { mError = theError;}
337 
338  private:
339 
344  QString mDataSourceURI;
345 };
346 
347 
348 #endif
virtual uint subLayerCount() const
return the number of layers for the current data source
virtual void setSubLayerVisibility(const QString &name, bool vis)
Set the visibility of the given sublayer name.
virtual QString subsetString()
Returns the subset definition string (typically sql) currently in use by the layer and used by the pr...
A rectangle specified with double values.
Definition: qgsrectangle.h:35
virtual void updateExtents()
Update the extents of the layer.
virtual QString fileRasterFilters() const
return raster file filter string
virtual bool supportsSubsetString()
provider supports setting of subset strings
QDateTime mTimestamp
Timestamp of data in the moment when the data were loaded by provider.
Abstract base class for spatial data provider implementations.
void setError(const QgsError &theError)
Set error message.
virtual QString fileVectorFilters() const
return vector file filter string
virtual QDateTime dataTimestamp() const
Current time stamp of data source.
virtual QStringList subLayers() const
Sub-layers handled by this provider, in order from bottom to top.
const char * name() const
int count(const T &value) const
QgsDataProvider(QString const &uri="")
virtual bool setSubsetString(QString subset, bool updateFeatureCount=true)
Set the subset string used to create a subset of features in the layer.
virtual QDateTime timestamp() const
Time stamp of data source in the moment when data/metadata were loaded by provider.
bool isEmpty() const
virtual void setLayerOrder(const QStringList &layers)
Reorder the list of layer names to be rendered by this provider (in order from bottom to top) ...
QgsErrorMessage represents single error message.
Definition: qgserror.h:29
virtual void setDataSourceUri(const QString &uri)
Set the data source specification.
virtual QStringList subLayerStyles() const
Sub-layer styles for each sub-layer handled by this provider, in order from bottom to top...
QgsError is container for error messages (report).
Definition: qgserror.h:77
virtual void reloadData()
Reloads the data from the source.
Class for storing a coordinate reference system (CRS)
QgsError mError
Error.
void appendError(const QgsErrorMessage &theMessage)
Add error message.
virtual ~QgsDataProvider()
We need this so the subclass destructors get called.
int dataCapabilities_t()
virtual QgsError error() const
Get current status error.
virtual QString dataSourceUri() const
Get the data source specification.