#ifndef PROPERTY_ITEMWIDGET_H
#define PROPERTY_ITEMWIDGET_H

#include <QWidget>
#include <QLabel>
#include <QTextEdit>
#include <QPushButton>
#include <QComboBox>
#include <QHBoxLayout>

#include "size_para.h"
#include "ukui_printer.h"

class CustomLabel;

class ProperytItemWidget : public QWidget
{
    Q_OBJECT
public:
    explicit ProperytItemWidget(QString propertyName,
                        PropertyBoxStyle style,
                        QWidget *parent = nullptr);

    explicit ProperytItemWidget(QString propertyName,
                        PropertyBoxStyle style,
                        AttrName propertyValue,
                        QWidget *parent = nullptr);

    explicit ProperytItemWidget(QString propertyName,
                        PropertyBoxStyle style,
                        AttrName propertyValue,
                        QList<AttrName> propertyList,
                        QWidget *parent = nullptr);

    //设置第一项标题的内容
    void setfirstTitleText(const QString &content);

    void setSecondProperty(const QString &content);

    void setSecondProperty(const AttrName &content, const QList<AttrName> &list);

    //设置第三项按钮文字
    void setThirdButtonText(const QString &content);
    void showWarning(bool flag);
    bool isPropertyChanged();
    QString getChangedProperty();
    QString getProperty();
    QString getSecondComboBoxContent();

signals:
    void thirdOperateButtonClicked();
    void showProperyChanged(QString, QString);

private:
    //布局
    void initLayout();
    void init();
    void initFirst();
    void initSecond();
    void initThird();

private:
    //设置第二项label需要显示的icon
    void setSecondLabelIcon(const QString &content);
    PropertyBoxStyle m_style = PropertyBoxStyle::TEXT_WITH_LINEEDIT_EDITABLE;
    QString m_name = QString();
    AttrName m_value;
    QList<AttrName> m_valueList;

    CustomLabel *m_firstTitle = nullptr;
    
    QPushButton *m_secondIcon = nullptr;
    QLabel *m_secondLabel = nullptr;
    QLineEdit *m_secondLineEdit = nullptr;
    QComboBox *m_secondComboBox = nullptr;

    QPushButton *m_warningIcon = nullptr;
    QPushButton *m_thirdOperateButton = nullptr;

    QHBoxLayout *m_mainLayout = nullptr;

signals:
    //第三项按钮点击信号
    void thirdButtonClicked();
};

#endif // PROPERTY_ITEMWIDGET_H
