macgitver / MacGitverModules

DEPRECATED: Modules for MacGitver
5 stars 1 forks source link

Widgets: Add a "Flat" Tree Model, Delegate and ComboBox … #27

Closed scunz closed 11 years ago

scunz commented 11 years ago

Well, long time ago somebody told me, inventing wheels from scratch was useless spent time. So, I'm always trying to invent something new; and here we go again: Let me proudly introduce "flat trees" to the world... :-)

This is a QAbstractItemModel that takes a list of strings and separates each of them by a char. Segments are taken as nodes in a tree. Just like a filesystem does. Items are than flatly stored inside a list (internally keeping a tree, of course). The non-leaves are declared "headers" and not selectable; the leaves are selectable.

The delegate draws this structure as a edge-less tree, forming a flat looking hierarchy. A CombBox is provided that will set up a QListView as drop down view.