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 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 
149  virtual QString subsetString()
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 
312  void dataChanged();
313 
318  void dataChanged( int changed );
319 
320  protected:
324  QDateTime mTimestamp;
325 
328 
330  void appendError( const QgsErrorMessage & theMessage ) { mError.append( theMessage );}
331 
333  void setError( const QgsError & theError ) { mError = theError;}
334 
335  private:
336 
341  QString mDataSourceURI;
342 };
343 
344 
345 #endif
virtual uint subLayerCount() const
return the number of layers for the current data source
Definition: qgsdataprovider.h:183
virtual void setSubLayerVisibility(const QString &name, bool vis)
Set the visibility of the given sublayer name.
Definition: qgsdataprovider.h:208
virtual QString subsetString()
Returns the subset definition string (typically sql) currently in use by the layer and used by the pr...
Definition: qgsdataprovider.h:149
A rectangle specified with double values.
Definition: qgsrectangle.h:35
virtual void updateExtents()
Update the extents of the layer.
Definition: qgsdataprovider.h:119
virtual QString fileRasterFilters() const
return raster file filter string
Definition: qgsdataprovider.h:278
virtual bool supportsSubsetString()
provider supports setting of subset strings
Definition: qgsdataprovider.h:141
QDateTime mTimestamp
Timestamp of data in the moment when the data were loaded by provider.
Definition: qgsdataprovider.h:324
Abstract base class for spatial data provider implementations.
Definition: qgsdataprovider.h:46
void setError(const QgsError &theError)
Set error message.
Definition: qgsdataprovider.h:333
DataCapability
Definition: qgsdataprovider.h:54
virtual QString fileVectorFilters() const
return vector file filter string
Definition: qgsdataprovider.h:261
virtual QDateTime dataTimestamp() const
Current time stamp of data source.
Definition: qgsdataprovider.h:291
virtual QStringList subLayers() const
Sub-layers handled by this provider, in order from bottom to top.
Definition: qgsdataprovider.h:161
QgsDataProvider(QString const &uri="")
Definition: qgsdataprovider.h:63
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:131
virtual QDateTime timestamp() const
Time stamp of data source in the moment when data/metadata were loaded by provider.
Definition: qgsdataprovider.h:288
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:194
QgsErrorMessage represents single error message.
Definition: qgserror.h:29
virtual void setDataSourceUri(const QString &uri)
Set the data source specification.
Definition: qgsdataprovider.h:86
virtual QStringList subLayerStyles() const
Sub-layer styles for each sub-layer handled by this provider, in order from bottom to top...
Definition: qgsdataprovider.h:174
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:285
Class for storing a coordinate reference system (CRS)
Definition: qgscoordinatereferencesystem.h:50
QgsError mError
Error.
Definition: qgsdataprovider.h:327
void appendError(const QgsErrorMessage &theMessage)
Add error message.
Definition: qgsdataprovider.h:330
virtual ~QgsDataProvider()
We need this so the subclass destructors get called.
Definition: qgsdataprovider.h:70
int dataCapabilities_t()
Definition: qgsdataprovider.h:27
virtual QgsError error() const
Get current status error.
Definition: qgsdataprovider.h:297
virtual QString dataSourceUri() const
Get the data source specification.
Definition: qgsdataprovider.h:96