[Qgis-developer] Discussion on browser and file extensions

Giuseppe Sucameli brush.tyler at gmail.com
Fri May 25 08:41:23 PDT 2012


Hi Etienne,

On Fri, May 25, 2012 at 5:08 PM, Etienne Tourigny
<etourigny.dev at gmail.com> wrote:
>> BTW we need another method, right? Something like
>> QgsLayerItem::layerName()
>
> This is the approach in my patches, only it is also supported in
> QgsDataItem (see below why).

IMHO it isn't.

In your patch the fileName method is used to get the name
displayed in the browser (see QgsBrowserModel::data() line 153),

instead in my proposal the QgsLayerItem::layerName() would be used to get
the name of the layer to load (not the filename).

You should keep the QgsDataItem::name() for filename (data shown
in the browser) and add a new method for QgsLayerItem::layerName().

BTW, I'm wondering if Radim meant the same.

> Also, this could use uri() like you suggested instead of path(), not
> sure I understand the distinction

URI is the string used to load a layer, path is a way to identify a
qgsdataitem in the browser tree.

Cheers.

> QString QgsDataItem::fileName() const
> {
>  QFileInfo fileInfo( path() );
>  return fileInfo.isFile() ? fileInfo.fileName() : name();
> }
>
> Again, this works in the default case, but the function should be
> overloaded for efficiency in the case of gdal ang ogr /vsizip files
> (like I did in my patches)
>
> Regards,
> Etienne
>
>>
>>> QgsDataItem is base for various data sources, most of them are not
>>> file based.
>>
>> I agree, having a fileName() method in the QgsDataItem class
>> is non-sense.
>
> Well unless mistaken, you could have a QgsDataCollectionItem which is
> file-based, such as multi-layer shape or qml?
>
>>
>> Cheers.
>>
>> --
>> Giuseppe Sucameli - Faunalia
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer



-- 
Giuseppe Sucameli


More information about the Qgis-developer mailing list