#ifndef COMPONENTMODEL_H
#define COMPONENTMODEL_H

#include <QObject>
#include <QMap>
#include <QDebug>
class ComponentModel : public QObject
{
    Q_OBJECT
    Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged FINAL)
    Q_PROPERTY(QString designator READ designator WRITE setDesignator NOTIFY designatorChanged FINAL)
    Q_PROPERTY(QString currentVariant READ currentVariant WRITE setCurrentVariant NOTIFY currentVariantChanged FINAL)
    Q_PROPERTY(QMap<QString, QString> properties READ properties WRITE setProperties NOTIFY propertiesChanged FINAL)

public:
    explicit ComponentModel(QObject *parent = nullptr);

    int id() const;
    void setId(int newId);

    QString designator() const;
    void setDesignator(const QString &newDesignator);

    QString currentVariant() const;
    void setCurrentVariant(const QString &newCurrentVariant);

    QMap<QString, QString> properties() const;
    void setProperties(const QMap<QString, QString> &newProperties);
    void setBaseProperties(const QMap<QString, QString> &newBaseProperties);
    void setVariantProperties(const QString &variantName, const QMap<QString, QString> &variantProps);

signals:
    void idChanged();
    void designatorChanged();

    void currentVariantChanged();

    void propertiesChanged();

private:
    int m_id;
    QString m_designator;
    QString m_currentVariant;
    QMap<QString, QString> m_currentProperties;
    QMap<QString, QString> m_baseProperties;
    QMap<QString, QMap<QString, QString>> m_variantProperties;
    void updateCurrentProperties();
};

#endif // COMPONENTMODEL_H
