[Qt-interest] QFIleSystemModel custom files and dirs loads

Bruno Seabra Lima bslima at telemidia.puc-rio.br
Tue Jan 25 22:01:34 CET 2011


Just to be in the records :
Just Extends the QSortFilterProxyModel
then implements: bool filterAcceptsRow(int sourceRow, const QModelIndex &
sourceParent) const;

QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);

    if(sourceParent.isValid())

    {

        if (sourceParent == topIndex)

        {

            return !(sourceModel()->data(index0).toString().contains("blah"));

        }

    }

    return true;

This code only filters the directories that are direct connected to rootIndex

PS:

Remember to map the index FromSource before setRootIndex in the view:


fileSystemView->setRootIndex(workspace_model->mapFromSource

                                 (index));


Bruno Seabra Mendonça Lima

--------------
Bacharel em Ciência da Computação - UFMA
Mestrando da PUC-Rio
Pesquisador Laboratório Telemidia (PUC-Rio)
Pesquisador Colaborador LAWS (UFMA)
Pesquisador/Desenvolvedor Intacto Software
-------------
www.bslima.com


On Tue, Jan 25, 2011 at 6:33 PM, Bruno Seabra Lima <
bslima at telemidia.puc-rio.br> wrote:

> Thanks man :D
> I think is going to work ...just need some adjustments
>
> Bruno Seabra Mendonça Lima
> --------------
> Bacharel em Ciência da Computação - UFMA
> Mestrando da PUC-Rio
> Pesquisador Laboratório Telemidia (PUC-Rio)
> Pesquisador Colaborador LAWS (UFMA)
> Pesquisador/Desenvolvedor Intacto Software
> -------------
> www.bslima.com
>
>
> On Tue, Jan 25, 2011 at 3:47 PM, sarvesh saran <aquarian.thunder at gmail.com
> > wrote:
>
>> Hi Bruno,
>>
>> Try to use a QSortFilterProxyModel subclass with redefined
>> filterAcceptsRow() :
>>
>> http://doc.qt.nokia.com/latest/qsortfilterproxymodel.html#filterAcceptsRow
>>
>> <http://doc.qt.nokia.com/latest/qsortfilterproxymodel.html#filterAcceptsRow>
>> thanks,
>> Sarvesh
>>
>> On Tue, Jan 25, 2011 at 10:22 PM, Bruno Seabra Lima <
>> bslima at telemidia.puc-rio.br> wrote:
>>
>>> Sorry,
>>> Didnt did the trick for me the NameFilter doesnt apply to Folders.
>>> Am i right ?
>>>
>>> I have to prevent some folders to be present in the QFileSystemModel.
>>>
>>> Any ideas ?
>>>
>>> Cheers mate
>>>
>>> Bruno Seabra Mendonça Lima
>>> --------------
>>> Bacharel em Ciência da Computação - UFMA
>>> Mestrando da PUC-Rio
>>> Pesquisador Laboratório Telemidia (PUC-Rio)
>>> Pesquisador Colaborador LAWS (UFMA)
>>> Pesquisador/Desenvolvedor Intacto Software
>>> -------------
>>> www.bslima.com
>>>
>>>
>>> On Tue, Jan 25, 2011 at 2:39 PM, Bruno Seabra Lima <
>>> bslima at telemidia.puc-rio.br> wrote:
>>>
>>>> I manage to modify my config file and works with the nameFIlter ...
>>>> thanks
>>>> :D
>>>>
>>>>
>>>> Bruno Seabra Mendonça Lima
>>>> --------------
>>>> Bacharel em Ciência da Computação - UFMA
>>>> Mestrando da PUC-Rio
>>>> Pesquisador Laboratório Telemidia (PUC-Rio)
>>>> Pesquisador Colaborador LAWS (UFMA)
>>>> Pesquisador/Desenvolvedor Intacto Software
>>>> -------------
>>>> www.bslima.com
>>>>
>>>>
>>>> On Tue, Jan 25, 2011 at 12:17 PM, Andre Somers <andre at familiesomers.nl>wrote:
>>>>
>>>>> Op Di, 25 januari, 2011 2:10 pm, schreef Bruno Seabra Lima:
>>>>> > Hey everyone,
>>>>> >
>>>>> > I need to use a FileSystemModel, but i need to load just certain
>>>>> files
>>>>> > and directories.
>>>>> > I look at the NameFilters, but the filter i wanna create does not
>>>>> depends
>>>>> > of
>>>>> > the name,
>>>>> > depends on a external configuration file.
>>>>> >
>>>>> > Is there a way to create such thing ?
>>>>>
>>>>> What do you expect to be in the configuration file? What kind of
>>>>> filters
>>>>> do you need to be able to specify?
>>>>>
>>>>> André
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Qt-interest mailing list
>>>>> Qt-interest at qt.nokia.com
>>>>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>>>>
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Qt-interest mailing list
>>> Qt-interest at qt.nokia.com
>>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110125/a88e688b/attachment.html 


More information about the Qt-interest-old mailing list