[Interest] Model-view solution

Max Paperno max-l at wdg.us
Mon Jun 7 02:21:45 CEST 2021


Hi Lars,

> Qt5 has a concept of Proxy Model - would it be possible to implement
> a list model and then use proxy model to "transforms" the data into a
> tree structure?

Short answer would be "yes."  Which approach is preferable for you 
really depends on your needs (current and possibly future).  A table 
model isn't really harder to implement than, say, jumping through hoops 
to manipulate the data later.  OTOH any database table is "flat" and 
provides no actual limitations since tables can be joined/etc.

Anyway, by way of example you may be interested in checking out my 
GroupedItemsProxyModel[1] which in fact takes a table model source and 
can group it into a tree of N levels based on existing (and virtual) 
columns in the data.

It's not documented very well I'm afraid. I thought I had a demo of it 
somewhere but can't find it... but LMK if that would help.

> How memory and CPU demanding would such a solution be for the system?

> It is difficult to estimate data load but anywhere between 100 and 100'000 items. 

I think you answered your own question. :-) Also 100K items in a view 
may not be practical anyway... I would imagine you'd want to load them 
incrementally ("lazily") if you get to those numbers.  If you mean just 
filtering through 100K records to only show some of them... yea it 
really depends on how well the data is indexed or what kind of 
searches/filtering is being done.  For example if you have frequently 
searched columns (or combinations) then it may make sense to keep a 
separate reference table (index) to those records keyed by the criteria 
value, and keep those index tables updated whenever relevant table data 
changes (just like a "real" database can do).


HTH,
-Max


[1] 
https://github.com/mpaperno/maxLibQt/blob/master/src/itemmodels/GroupedItemsProxyModel.h
Formatted docs (such as they are): 
https://mpaperno.github.io/maxLibQt/class_grouped_items_proxy_model.html



On 6/6/2021 2:54 PM, Lars Sunde wrote:
> Hello folks,
> 
> We are looking for some feedback on using Qt5 model view framework.
> 
> Our model contains two building blocks (item and list) that has the same 
> metadata attributes (id, title, type, author, publish year, revision, 
> data etc). List is basically just references to items.
> 
> A conceptual example of our model:
> Item A (rev 1)
> Item B
> Item C
> Item A (rev 3)
> List 1 (contains reference to Item A[rev 2], Item B, Item E)
> Item D
> Item A (rev 2)
> Item E
> List 2 (contains reference to Item D, Item E)
> 
> Our primary concern is whether to use a list or tree model to represent 
> the data.
> 
> Using a list model appear easier to implement but does this model 
> introduce limitation or increased complexities in view logic?
> 
> The following views is needed:
> # In list view
>     - show all items
>     - show all items with metadata attribute type equal "foo"
>     - show all items with metadata attribute type equal "foo" and only 
> latest revision
> # In tree view
>     - show all items structured by revision. This means Item A (rev 3) 
> will be on level 1, with a child node on level 2(Item A rev 2) and with 
> a child node on level 3 (Item A rev 1).
>     - show all items structured by categories. This means adding a node 
> "foo" (this is not an item or list, but will be shown in UI) and adding 
> all items with metadata attribute type equal "foo" as children. Same for 
> "bar" and others.
>     - show all lists with content of list a children.
> It is difficult to estimate data load but anywhere between 100 and 
> 100'000 items.
> 
> Qt5 has a concept of Proxy Model - would it be possible to implement a 
> list model and then use proxy model to "transforms" the data into a tree 
> structure? How memory and CPU demanding would such a solution be for the 
> system?
> 
> Appreciate any input.
> 
> kind regards, Lars




More information about the Interest mailing list