Skip to content

Introduce new API for list item contents

Arjen Hiemstra requested to merge work/ahiemstra/listcontents into master

So far, BasicListItem has been the thing to use for lists. However, it has grown rather complex due to this, which is a problem since list items should be as lightweight as possible. Additionally, all the styling is custom, which makes using a plain ItemDelegate and its subclasses rather awkward as its styling doesn't match.

To address this, a while ago we discussed replacing BasicListItem with simpler items that can be used as the contentItem of an ItemDelegate. This allows us to add different content items for different kinds of layouts, without affecting users of the simpler layouts. Moreover, it allows reusing the different ItemDelegate subclasses.

This MR adds a new submodule, "Delegates", that contains two items, TitleSubtitle and IconTitleSubtitle that implement a basic Title + Subtitle and Icon + Title + Subtitle layout. It also contains four wrappers around the Controls delegate types that extend those with a subtitle property. There is nothing that replicates BasicListItem's leading and trailing properties since those can now be fairly easily replicated uising a RowLayout containing one of the basic layout items.

There is a new testcase included that replicates "BasicListItemTest" using these items. This is what this looks like using Qt6's Fusion style:

Screenshot_20230904_132916

Edited by Arjen Hiemstra

Merge request reports