Skip to content

File OverlayChildren.hpp

File List > inspection > internal > OverlayChildren.hpp

Go to the documentation of this file

//
// SPDX-FileCopyrightText: 2026 Michal Grabarczyk
// SPDX-License-Identifier: GPL-3.0-only WITH Universal-FOSS-exception-1.0
//
// This file is also available under a separate commercial license.
// See COMMERCIAL-LICENSING.md for contact information.
//
#pragma once

#include <QList>
#include <QPointer>
#include <QQmlListProperty>
#include <QQuickItem>
#include <QVariant>

namespace QAccelPlot::Internal {

class OverlayChildren {
public:
    OverlayChildren(QObject& owner, QVariant tool, const char* toolProperty);

    [[nodiscard]] QQmlListProperty<QObject> list();
    void setOverlay(QQuickItem* overlay);

private:
    static void append(QQmlListProperty<QObject>* list, QObject* object);
    static qsizetype count(QQmlListProperty<QObject>* list);
    static QObject* at(QQmlListProperty<QObject>* list, qsizetype index);
    void restack();

    QObject& owner_;
    QVariant tool_;
    const char* toolProperty_;
    QPointer<QQuickItem> overlay_;
    QList<QPointer<QObject>> objects_;
};

} // namespace QAccelPlot::Internal