25027444a9
Use std::unique_ptr to manage items tree memory allocations. This also use the new string literals operator. Change-Id: Iab002b5dc612b75cef0be10862e263c6c6c013c1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
33 lines
692 B
C++
33 lines
692 B
C++
// Copyright (C) 2016 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
#ifndef TREEITEM_H
|
|
#define TREEITEM_H
|
|
|
|
#include <QVariant>
|
|
#include <QList>
|
|
|
|
//! [0]
|
|
class TreeItem
|
|
{
|
|
public:
|
|
explicit TreeItem(const QVariantList &data, TreeItem *parentItem = nullptr);
|
|
|
|
void appendChild(std::unique_ptr<TreeItem> &&child);
|
|
|
|
TreeItem *child(int row);
|
|
int childCount() const;
|
|
int columnCount() const;
|
|
QVariant data(int column) const;
|
|
int row() const;
|
|
TreeItem *parentItem();
|
|
|
|
private:
|
|
std::vector<std::unique_ptr<TreeItem>> m_childItems;
|
|
QVariantList m_itemData;
|
|
TreeItem *m_parentItem;
|
|
};
|
|
//! [0]
|
|
|
|
#endif // TREEITEM_H
|