#ifndef EWEATHER_H
#define EWEATHER_H

#include "eobject.h"

class eWeather : public eObject
{
    Q_OBJECT
public:
    struct Data {
        int     country;
        int     region1;
        int     region2;
        bool    weather;
        bool    temp;
        bool    wind;
        bool    humidity;
        bool    curTemp;
        int     tempType;
        int     tempUnitType;
        QString labelWeather;
        QString labelTemp;
        QString labelWind;
        QString labelHumidity;
        QString labelCurTemp;
        int     lineStyle;
        QString fontFamily;
        int     fontSize;
        bool    fontBold;
        bool    fontItalics;
        bool    fontUnderline;
        QColor  textColor;
        int     playRefresh;
        int     playDuration;
    };

public:
    explicit eWeather(QRectF rectInit,InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);
    explicit eWeather(const QJsonObject &json, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);

private:
    void init();

public:
    static void setElement(const QJsonObject &json, Data &attr);

public:
    virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
    virtual int type() const override { return eObject::Weather; }
    virtual QWidget* wAttr() override;
    virtual QWidget* wAttrElement() override;
    virtual QJsonObject save(const QString &pRoot) override { Q_UNUSED(pRoot); return elementJson(); }
    virtual QJsonObject elementJson() const override;

signals:

public slots:
    void onAttrChanged(const eWeather::Data &data);

private:
    Data m_attr;
};

#endif // EWEATHER_H
