[Qgis-developer] controlling visibility

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Mar 11 04:13:15 EDT 2009


2009/3/11 Mauricio de Paulo <mauricio.dev at gmail.com>:
> Hi Carson,
> After thinking a little about it I don't think it's a good idea to use
> it as QgsVectorLayer. I think it's better to redefine a new
> QgsTableLayer as done with QgsRasterLayer so to respect
> QgsMapLayer::LayerType(). This way we would avoid problems with plugins
> thinking it's a vector layer and geoprocessing empty geometries (now
> mapcomposer and it's legend also comes to mind). Maybe it's a good idea
> to create a tab in the layer legend to nonspatial tables.
>
> I've thought about it some time ago and I always thought the interface
> would be something like GvSIG and ArcGIS where the tables are all
> (spatial and non-spatial) in a place where you can join/relate them
> separate from the geometry representations.

+1 from me. Carson, your current implementation sounds like a huge
hack, and hacking stuff like this into qgis core this way is probably
a bad idea! In an object-oriented context a table doesn't have the
qualities of a QgsMapLayer - srs, transparency, extent, etc - and so
shouldn't be a subclass of that.

  I'm not sure in what way a table is even a 'Layer'! You can't layer
one table on another... There may not be much common behaviour between
a data table and a map layer, so perhaps they should inherit from some
other class, or not at all. Maybe have a QgsData class and then
QgsMapLayer and QgsDataTable inherit from that. Then the legend
displays QgsData objects - perhaps grouped as maps and data tables.

 I'd then implement QgsDataTable to have a "provider" so you could
plug in different table types - CSV file, spreadsheet, RDBMS - or
maybe subclass them - QgsCSVDataTable, QgsXLSDataTable etc.

 I suspect you are leveraging off QgsVectorLayer so you can just
simply use the current attribute data table editor with no further
ado. The right thing would be to make that table editor available to
vector layers and data tables.

 Or possibly vector layers are a mix-in of a data table class and a
vector geometry class. But that would need some serious rewriting. But
it might mean that you could use attribute data from a vector layer in
the same way as a data table from a database...

 Just some thoughts over breakfast!

Barry


More information about the Qgis-developer mailing list