[Qgis-developer] controlling visibility
Mauricio de Paulo
mauricio.dev at gmail.com
Wed Mar 11 01:38:47 EDT 2009
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.
I've put some thought about Join but with no good result. The only
useful thing I could think was that using ogr some providers are going
to be excluded from join features. I thought about inheriting
QgsVectorLayer as a QgsVectorLayerJoin where the data would be read
first from the second layer when rewind() and stored in a map so that we
could ask for each feature's joined record when nextFeature() was
called. But only works for 1*1 joins as we cannot change the number of
records on the first layer. Nevertheless, this would respect the usual
behavior of QgsVectorLayer and so would also work when a joined table
got inside plugins.
I'm really looking forward to this implementation.
Thanks, Carson
Maurício de Paulo
On Tue, 2009-03-10 at 15:40 +0000, Carson Farmer wrote:
> Hello devs,
>
> I am very close to having a QgsTableProvider for loading, accessing,
> editing, and visualising non-spatial tables in QGIS. It is really quite
> simple, and essentially is an ogr provider for non-spatial data (i.e.
> can read dbf, csv, and probably postgres eventually as well). Currently,
> I can create a QgsVectorLayer with the 'table' provider, which is
> essentially just a normal QgsVectorLayer that has no spatial information
> (i.e. extent, geometries). You can do most things, including access the
> provider, and 'select', 'nextFeature', 'featureAtId', etc from there.
> The only problems that I have noticed so far are:
>
> a) If Options > Rendering > 'By default new layers added to the map
> should be displayed' is checked, QGIS crashes when the table is loaded.
> b) When added to the layer list, a polygon icon is displayed (I would
> like to change this to a attribute table icon).
> c) Currently, when right clicking the table layer, all context menu
> items are visible (I would like to remove some of these options: remove
> everything except open attribute table, remove, toggle editing, and rename).
>
> To address a), I would like to figure out how to automatically set the
> visibility of these 'table' layers to False, and keep it this way. I
> haven't really looked too much into b) and c), but if someone has a
> quick suggestion that would greatly help me out.
>
> The reasons for attempting to implement a QgsTableProvider are several:
> 1) It allows people to view non-spatial tables, edit them, and all sorts
> of useful things all from one place, and more importantly: 2) It will
> make joining and relating tables possible/much easier: OGR has the
> ability to join tables using SQL like queries, by I think this would
> make it possible to create non-permanent table joins in QGIS (an often
> requested feature).
>
> My eventual goal would be to allow table joins, appending the additional
> tables to the Files list of a layer...
>
> Anyway, any input/help is greatly appreciated, especially regarding the
> above items ;-)
>
> Carson
>
More information about the Qgis-developer
mailing list