QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 class QgsRectangle;
29 
30 
44 class CORE_EXPORT QgsDataProvider : public QObject
45 {
46  Q_OBJECT
47 
48  public:
49 
50  Q_ENUMS( DataCapability )
51 
53  {
54  NoDataCapabilities = 0,
55  File = 1,
56  Dir = 1 << 1,
57  Database = 1 << 2,
58  Net = 1 << 3 // Internet source
59  };
60 
61  QgsDataProvider( QString const & uri = "" )
62  : mDataSourceURI( uri )
63  {}
64 
68  virtual ~QgsDataProvider() {};
69 
70 
76  virtual QgsCoordinateReferenceSystem crs() = 0;
77 
78 
84  virtual void setDataSourceUri( const QString & uri )
85  {
86  mDataSourceURI = uri;
87  }
88 
94  virtual QString dataSourceUri() const
95  {
96  return mDataSourceURI;
97  }
98 
99 
104  virtual QgsRectangle extent() = 0;
105 
106 
111  virtual bool isValid() = 0;
112 
113 
117  virtual void updateExtents()
118  {
119  // NOP by default
120  }
121 
122 
129  virtual bool setSubsetString( QString subset, bool updateFeatureCount = true )
130  {
131  // NOP by default
132  Q_UNUSED( subset );
133  Q_UNUSED( updateFeatureCount );
134  return false;
135  }
136 
137 
142  virtual bool supportsSubsetString() { return false; }
143 
150  virtual QString subsetString()
151  {
152  return QString::null;
153  }
154 
155 
162  virtual QStringList subLayers() const
163  {
164  return QStringList(); // Empty
165  }
166 
167 
175  virtual QStringList subLayerStyles() const
176  {
177  return QStringList(); // Empty
178  }
179 
180 
184  virtual uint subLayerCount() const
185  {
186  return 0;
187  }
188 
189 
195  virtual void setLayerOrder( const QStringList &layers )
196  {
197  //prevent unused var warnings
198  if ( layers.count() < 1 )
199  {
200  return;
201  }
202  // NOOP
203  }
204 
205 
209  virtual void setSubLayerVisibility( const QString &name, bool vis )
210  {
211  //prevent unused var warnings
212  if ( name.isEmpty() || !vis )
213  {
214  return;
215  }
216  // NOOP
217  }
218 
219 
234  virtual QString name() const = 0;
235 
236 
248  virtual QString description() const = 0;
249 
250 
262  virtual QString fileVectorFilters() const
263  {
264  return "";
265  }
266 
267 
279  virtual QString fileRasterFilters() const
280  {
281  return "";
282  }
283 
286  virtual void reloadData() {}
287 
289  virtual QDateTime timestamp() const { return mTimestamp; }
290 
292  virtual QDateTime dataTimestamp() const { return QDateTime(); }
293 
298  virtual QgsError error() const { return mError; }
299 
300  signals:
301 
307  void fullExtentCalculated();
308 
314  void dataChanged();
315 
321  void dataChanged( int changed );
322 
323  protected:
327  QDateTime mTimestamp;
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
Definition: qgsdataprovider.h:184
virtual void setSubLayerVisibility(const QString &name, bool vis)
Set the visibility of the given sublayer name.
Definition: qgsdataprovider.h:209
virtual QString subsetString()
Returns the subset definition string (typically sql) currently in use by the layer and used by the pr...
Definition: qgsdataprovider.h:150
A rectangle specified with double values.
Definition: qgsrectangle.h:35
virtual void updateExtents()
Update the extents of the layer.
Definition: qgsdataprovider.h:117
virtual QString fileRasterFilters() const
return raster file filter string
Definition: qgsdataprovider.h:279
virtual bool supportsSubsetString()
provider supports setting of subset strings
Definition: qgsdataprovider.h:142
QDateTime mTimestamp
Timestamp of data in the moment when the data were loaded by provider.
Definition: qgsdataprovider.h:327
Abstract base class for spatial data provider implementations.
Definition: qgsdataprovider.h:44
void setError(const QgsError &theError)
Set error message.
Definition: qgsdataprovider.h:336
DataCapability
Definition: qgsdataprovider.h:52
virtual QString fileVectorFilters() const
return vector file filter string
Definition: qgsdataprovider.h:262
virtual QDateTime dataTimestamp() const
Current time stamp of data source.
Definition: qgsdataprovider.h:292
virtual QStringList subLayers() const
Sub-layers handled by this provider, in order from bottom to top.
Definition: qgsdataprovider.h:162
QgsDataProvider(QString const &uri="")
Definition: qgsdataprovider.h:61
virtual bool setSubsetString(QString subset, bool updateFeatureCount=true)
Set the subset string used to create a subset of features in the layer.
Definition: qgsdataprovider.h:129
virtual QDateTime timestamp() const
Time stamp of data source in the moment when data/metadata were loaded by provider.
Definition: qgsdataprovider.h:289
virtual void setLayerOrder(const QStringList &layers)
Reorder the list of layer names to be rendered by this provider (in order from bottom to top) ...
Definition: qgsdataprovider.h:195
QgsErrorMessage represents single error message.
Definition: qgserror.h:29
virtual void setDataSourceUri(const QString &uri)
Set the data source specification.
Definition: qgsdataprovider.h:84
virtual QStringList subLayerStyles() const
Sub-layer styles for each sub-layer handled by this provider, in order from bottom to top...
Definition: qgsdataprovider.h:175
QgsError is container for error messages (report).
Definition: qgserror.h:77
void append(const QString &theMessage, const QString &theTag)
Append new error message.
Definition: qgserror.cpp:40
virtual void reloadData()
Reloads the data from the source.
Definition: qgsdataprovider.h:286
Class for storing a coordinate reference system (CRS)
Definition: qgscoordinatereferencesystem.h:50
QgsError mError
Error.
Definition: qgsdataprovider.h:330
void appendError(const QgsErrorMessage &theMessage)
Add error message.
Definition: qgsdataprovider.h:333
virtual ~QgsDataProvider()
We need this so the subclass destructors get called.
Definition: qgsdataprovider.h:68
virtual QgsError error() const
Get current status error.
Definition: qgsdataprovider.h:298
virtual QString dataSourceUri() const
Get the data source specification.
Definition: qgsdataprovider.h:94