[Qgis-developer] Discussion on browser and file extensions

Etienne Tourigny etourigny.dev at gmail.com
Fri May 25 07:58:51 PDT 2012


On Wed, May 23, 2012 at 1:45 PM, Radim Blazek <radim.blazek at gmail.com> wrote:
> On Wed, May 23, 2012 at 1:35 PM, Etienne Tourigny
> <etourigny.dev at gmail.com> wrote:
>> This can be solved in code by removing the extension in the
>> QgsDataItem name() member, this way it does not have to be stripped in
>> drop operations,
>> 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().
> QgsDataItem is base for various data sources, most of them are not
> file based.

I understand your point.

Getting the filename from QgsDataItem::uri() has some issues with .zip
files (because of the special /vsizip/file.zip/file_in_zip.ext
syntax).  It is possible to strip the first part and get just the
filename.

Unfortunately, it seems that QgsBrowserModel::data() gets called
*very* often, even though the contents of the browser have not changed
-  when hiding or showing the window, or scrolling the browser for
example.

This can be taxing if there are many files and the filename stripping
logic has to be done on all visible files many many times.

So the 2 solutions I see are
1) have a new member fileName() that returns this effectively (say
with an internal member when creating the item) and deals with
provider-related issues such as /vsizip/ issues
2) cache the values of the data() function

Etienne

>
> Radim


More information about the Qgis-developer mailing list