TaskTree: Introduce List element

The List element of GroupItem type is a helper for
constructing Group content with an initializer lists.
Since there is no easy way of mixing items and lists of items
inside the initializer list, the List element encloses
the list of children in a single GroupItem element making it
possible to mix the lists of GroupItems with individual
GroupItem elements on a single initializer list.

This addresses the 25th point in the master task below.

Task-number: QTCREATORBUG-28741
Change-Id: I5fa4b76677f5aa7dcf875b9e9a16d86a26d380a7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2023-11-03 23:07:26 +01:00
parent af63dcaf96
commit 1da7f18fb7
3 changed files with 32 additions and 22 deletions

View File

@@ -188,6 +188,7 @@ public:
protected:
enum class Type {
List,
Group,
GroupData,
Storage,
@@ -195,6 +196,7 @@ protected:
};
GroupItem() = default;
GroupItem(Type type) : m_type(type) { }
GroupItem(const GroupData &data)
: m_type(Type::GroupData)
, m_groupData(data) {}
@@ -220,6 +222,14 @@ private:
TaskHandler m_taskHandler;
};
// TODO: Add tests.
class TASKING_EXPORT List final : public GroupItem
{
public:
List(const QList<GroupItem> &children) : GroupItem(Type::List) { addChildren(children); }
List(std::initializer_list<GroupItem> children) : GroupItem(Type::List) { addChildren(children); }
};
class TASKING_EXPORT Group final : public GroupItem
{
public: