[Qgis-developer] Discussion on browser and file extensions

Etienne Tourigny etourigny.dev at gmail.com
Fri May 25 08:08:20 PDT 2012

On Fri, May 25, 2012 at 11:55 AM, Giuseppe Sucameli
<sucameli at faunalia.it> wrote:
> Hi Radim,
> On Wed, May 23, 2012 at 6:45 PM, Radim Blazek <radim.blazek at gmail.com> wrote:
>>> and adding a QgsDataItem::fileName() member which the browser would
>>> use for layer items. It very simple to fix now.
>> It should be possible to get the file name from QgsDataItem::uri().
> if the layer is file-based get the name from the uri, otherwise get
> it from name(). Is that what you meant?
> 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).

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

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)


>> 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

More information about the Qgis-developer mailing list