Skip to content

File Category.hpp

File List > QAccelPlot > src > QAccelPlot > series > Category.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 <QColor>
#include <QObject>
#include <QString>

#if __has_include(<QtQmlIntegration/qqmlintegration.h>)
#include <QtQmlIntegration/qqmlintegration.h>
#else
#include <QtQml/qqmlregistration.h>
#endif

namespace QAccelPlot {

class Category : public QObject {
    Q_OBJECT
    QML_NAMED_ELEMENT(Category)


    Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
    Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
    Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)

public:
    explicit Category(QObject* parent = nullptr);
    Category(int value, QString name, const QColor& color, QObject* parent = nullptr);

    int value() const;
    void setValue(int value);

    QString name() const;
    void setName(const QString& name);

    QColor color() const;
    void setColor(const QColor& color);

signals:
    void valueChanged();
    void nameChanged();
    void colorChanged();

private:
    int value_{0};
    QString name_;
    QColor color_;
};

} // namespace QAccelPlot