Results 1 to 11 of 11

Thread: filterAcceptRows() is being called for all the top level items in the tree.

  1. #1
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default filterAcceptRows() is being called for all the top level items in the tree.

    I have taken editable tree model example for my application and try to implement proxyModel on top of it.
    I have re-implemented filterAcceptRows() function, when i apply filter this function is calling for all the top level items.
    Is it possible to call this function only for the items which are visible currently in a view & then when I scroll down Apply same filter for newly brought items into view ?

    Because i have lots of data from DB (more than 20 lak top level items and child inside them), its taking much time to filter.

    Or any suggestions while handling lots of data with filtering capability (I am doing lazy population too & I want my filter to be behave in this way http://www.qtcentre.org/threads/46471-QTreeView-Filter, so when I am actually iterating through all the parent and child items it is taking lots of time).

    Thanks in Advance :-)

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: filterAcceptRows() is being called for all the top level items in the tree.

    Only rows that pass the filter can be visible in the view. The view it has to determine the possibly visible rows from the whole set before it can know the actually visible rows. That determination is done by filterAcceptableRows().

    Every time you fetchMore() or otherwise manipulated the data the entire set of fetched rows will be refiltered because that is the only way to know if the changed data has altered what might be visible and therefore what is actually visible. This is is especially true if the view is sorting data but the source data is not sorted.

    I would be surprised if the proxy filtered more rows than were currently fetched in the source model. If your source model properly implements canFetchMore() and fetchMore() then i would expect this to just work.

    If you have 2 million top level items then you almost certainly should be considering filtering at the time of selection from the database rather than in the in-memory model and view.

  3. #3
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: filterAcceptRows() is being called for all the top level items in the tree.

    The kind of lazy loading I am doing is different here, I am not using a fetchMore concept at all. I have to build a tree based on a particular column data (there are > 50 columns in my Db).
    So instead of reading entire data in data base, I am reading single column which will be used to build my tree and when data() function is being called I am reading each cell(item in case of tree) data on demand.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: filterAcceptRows() is being called for all the top level items in the tree.

    Quote Originally Posted by DURGAPRASAD NEELAM View Post
    The kind of lazy loading I am doing is different here, I am not using a fetchMore concept at all.
    It doesn't really matter. What matters is what rowCount() returns. The filter proxy will go from 0 to rowCount()-1 rows.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: filterAcceptRows() is being called for all the top level items in the tree.

    Quote Originally Posted by wysota View Post
    It doesn't really matter. What matters is what rowCount() returns. The filter proxy will go from 0 to rowCount()-1 rows.
    yes, I got this point. but what I want is, is there any way to stop it and Apply filter on currently viewing items and then when I move my scroll bar down apply the same filter to this new items.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: filterAcceptRows() is being called for all the top level items in the tree.

    The kind of lazy loading I am doing is different here
    Yes, you are not lazy loading the top level items, only their children. So you have more than 2 million items loaded into an in-memory model... That it takes some time to filter 2 million records using a brute force approach on un-indexed data through a generic interface is not surprising.

    Filtering is the sort of thing that database engines do for a living and you should think about using that.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: filterAcceptRows() is being called for all the top level items in the tree.

    Quote Originally Posted by DURGAPRASAD NEELAM View Post
    yes, I got this point. but what I want is, is there any way to stop it and Apply filter on currently viewing items and then when I move my scroll bar down apply the same filter to this new items.
    How would you determine the size of the scrollbar then?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: filterAcceptRows() is being called for all the top level items in the tree.

    Quote Originally Posted by wysota View Post
    How would you determine the size of the scrollbar then?
    I am not sure exactly, but we can get a signal when we move a scroll bar, I thought of doing it by catching that signal.

    If it is not possible, You could suggest some other way as well :-)

    @ChrisW67 : we have tried by applying filter on data base this is also taking much time, so I am searching for the solution (like lazy loading I want lazy filtering )

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: filterAcceptRows() is being called for all the top level items in the tree.

    Quote Originally Posted by DURGAPRASAD NEELAM View Post
    I am not sure exactly, but we can get a signal when we move a scroll bar, I thought of doing it by catching that signal.
    Where would you move the scrollbar if you don't know how many entries the model has? If the model filtered only until the view was populated with visible items the scroll bar would think there were no more items available and the scroll bar would not be visible.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: filterAcceptRows() is being called for all the top level items in the tree.


    1. Is it possible to call this function only for the items which are visible currently in a view & then when I scroll down Apply same filter for newly brought items into view ?

    2. If it is not possible, You could suggest some other way as well :-)

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: filterAcceptRows() is being called for all the top level items in the tree.

    Quote Originally Posted by DURGAPRASAD NEELAM View Post
    [SIZE=4]
    [B] 1. Is it possible to call this function only for the items which are visible currently in a view & then when I scroll down Apply same filter for newly brought items into view ?
    Yes. Subclass QAbstractProxyModel and implement your own proxy.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Level of an item QStandardItemModel for tree
    By mqt in forum Qt Programming
    Replies: 1
    Last Post: 3rd October 2013, 09:21
  2. QTreeWidget::findItems only searches top level items ?
    By krisha in forum Qt Programming
    Replies: 3
    Last Post: 27th October 2011, 08:28
  3. Replies: 2
    Last Post: 9th June 2011, 11:20
  4. filterAcceptRows() is being called many times for same souceRow.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 19th February 2009, 03:49
  5. Crash while checking the index is of particular level of a tree
    By kapil sharma in forum Qt Programming
    Replies: 1
    Last Post: 27th November 2008, 07:21

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.