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 
144  virtual bool supportsSubsetString() { return false; }
145 
152  virtual QString subsetString()
153  {
154  return QString::null;
155  }
156 
157 
164  virtual QStringList subLayers() const
165  {
166  return QStringList(); // Empty
167  }
168 
169 
177  virtual QStringList subLayerStyles() const
178  {
179  return QStringList(); // Empty
180  }
181 
182 
186  virtual uint subLayerCount() const
187  {
188  return 0;
189  }
190 
191 
197  virtual void setLayerOrder( const QStringList &layers )
198  {
199  //prevent unused var warnings
200  if ( layers.count() < 1 )
201  {
202  return;
203  }
204  // NOOP
205  }
206 
207 
211  virtual void setSubLayerVisibility( const QString &name, bool vis )
212  {
213  //prevent unused var warnings
214  if ( name.isEmpty() || !vis )
215  {
216  return;
217  }
218  // NOOP
219  }
220 
221 
236  virtual QString name() const = 0;
237 
238 
250  virtual QString description() const = 0;
251 
252 
264  virtual QString fileVectorFilters() const
265  {
266  return "";
267  }
268 
269 
281  virtual QString fileRasterFilters() const
282  {
283  return "";
284  }
285 
288  virtual void reloadData() {}
289 
291  virtual QDateTime timestamp() const { return mTimestamp; }
292 
294  virtual QDateTime dataTimestamp() const { return QDateTime(); }
295 
300  virtual QgsError error() const { return mError; }
301 
302  signals:
303 
309  void fullExtentCalculated();
310 
316  void dataChanged();
317 
323  void dataChanged( int changed );
324 
325  protected:
329  QDateTime mTimestamp;
330 
333 
335  void appendError( const QgsErrorMessage & theMessage ) { mError.append( theMessage );}
336 
338  void setError( const QgsError & theError ) { mError = theError;}
339 
340  private:
341 
346  QString mDataSourceURI;
347 };
348 
349 
350 #endif
virtual uint subLayerCount() const
return the number of layers for the current data source
Definition: qgsdataprovider.h:186
virtual void setSubLayerVisibility(const QString &name, bool vis)
Set the visibility of the given sublayer name.
Definition: qgsdataprovider.h:211
virtual QString subsetString()
Returns the subset definition string (typically sql) currently in use by the layer and used by the pr...
Definition: qgsdataprovider.h:152
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:281
virtual bool supportsSubsetString()
provider supports setting of subset strings
Definition: qgsdataprovider.h:144
QDateTime mTimestamp
Timestamp of data in the moment when the data were loaded by provider.
Definition: qgsdataprovider.h:329
Abstract base class for spatial data provider implementations.
Definition: qgsdataprovider.h:46
void setError(const QgsError &theError)
Set error message.
Definition: qgsdataprovider.h:338
DataCapability
Definition: qgsdataprovider.h:54
virtual QString fileVectorFilters() const
return vector file filter string
Definition: qgsdataprovider.h:264
virtual QDateTime dataTimestamp() const
Current time stamp of data source.
Definition: qgsdataprovider.h:294
virtual QStringList subLayers() const
Sub-layers handled by this provider, in order from bottom to top.
Definition: qgsdataprovider.h:164
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:291
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:197
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:177
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:288
Class for storing a coordinate reference system (CRS)
Definition: qgscoordinatereferencesystem.h:50
QgsError mError
Error.
Definition: qgsdataprovider.h:332
void appendError(const QgsErrorMessage &theMessage)
Add error message.
Definition: qgsdataprovider.h:335
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:300
virtual QString dataSourceUri() const
Get the data source specification.
Definition: qgsdataprovider.h:96