[Qgis-developer] Discussion on browser and file extensions

Etienne Tourigny etourigny.dev at gmail.com
Sun May 27 14:37:35 PDT 2012


Guiseppe,

I have implemented this and sent a new pull request, along with other
small fixes for .vrt and .gz files.

Can you look at this and if possible commit it before 1.8 is released?

https://github.com/qgis/Quantum-GIS/pull/151

Etienne

On Fri, May 25, 2012 at 1:09 PM, Etienne Tourigny
<etourigny.dev at gmail.com> wrote:
> On Fri, May 25, 2012 at 12:41 PM, Giuseppe Sucameli
> <brush.tyler at gmail.com> wrote:
>> 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().
>
> ah ok, so name() would return the filename, whereas layerName() would
> return the filename without extension, to be used in the drag&drop
> operations. Sounds reasonable.
> Would need to modify mime data stuff also, in QgsMimeDataUtils::Uri
>
> what about file-based datacollection items? I guess only the layers
> can get dropped to other targets, therefore no need to change
> anything?
>
>>
>> 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.
>
> ah ok, thanks
>
>>
>> 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