#ifndef TYPES_H
#define TYPES_H

#include <QtGlobal>
#include <QRect>
#include <QString>
#include <QList>
#include <QDebug>
namespace UKUI {

enum class Categories {
    Android = 0,              // 0  安卓
    Network,                  // 1  网络
    Messaging,                // 2  社交
    Audio,                    // 3  影音
    Development,              // 4  开发
    Graphics,                 // 5  图像
    Game,                     // 6  游戏
    Office,                   // 7  办公
    Education,                // 8  教育
    System,                   // 9  系统
    Other                     // 10 其他
};

enum class Type {
    Icon = 1,
    Group,
    Container,
    Widget,
    Unknown
};

class BaseItem {
public:
    BaseItem(QString name, qint32 id, QList<int> categories = {-1}, Type type = Type::Unknown, QList<int> placeholder = {1,1}) :
        m_name(name), m_identify(id), m_type(type), m_placeholder(placeholder), m_categories(categories) {}
    virtual ~BaseItem() {}

    void setName(QString name) {
        m_name = name;
    }
    QString getName() {
        return m_name;
    }
    void setId(qint32 id) {
        m_identify = id;
    }
    quint32 getId() {
        return m_identify;
    }
    void setType(Type type) {
        m_type = type;
    }
    Type getType() {
        return m_type;
    }
    void setPlaceHolder(QList<int> place) {
        m_placeholder = place;
    }
    QList<int> getPlaceHolder() {
        return m_placeholder;
    }
    void setCategories(QList<int> categories) {
        m_categories = categories;
    }
    QList<int> getCategories() {
        return m_categories;
    }

private:
    QString m_name;
    quint32 m_identify;
    Type m_type;
    QList<int> m_placeholder;
    QList<int> m_categories;
};

class IconItem : public BaseItem
{
public:
    IconItem(QString desktopName, QString name, qint32 id, QString iconName, QList<int> categories, Type type = Type::Icon) :
        BaseItem(name, id, categories, type), m_desktopName(desktopName), m_icon(iconName) {}
    ~IconItem() {}
    QString getDesktopName() {
        return m_desktopName;
    }
    const QString getIconName() {
        return m_icon;
    }
    void setIconName(QString name) {
        m_icon = name;
    }
private:
    QString m_desktopName;
    QString m_icon;
};

class Widget : public BaseItem
{
public:
    Widget(QString qmlFilePath, QString name, qint32 id, QList<int> placeholder, Type type = Type::Widget) :
        BaseItem(name, id, {-1}, type, placeholder), m_qmlFilePath(qmlFilePath) {}
    ~Widget() {}
    QString getQmlFilePath() {
        return m_qmlFilePath;
    }

private:
    QString m_qmlFilePath;
};

class GroupItem : public BaseItem
{
public:
    GroupItem(QString name, qint32 id, Type type = Type::Group, bool isScrollable = false) :
        BaseItem(name, id, {-1}, type) {}
    bool isScrollLayout() {
        return isScrollable;
    }
    void setScrollLayout(bool scroll) {
        isScrollable = scroll;
    }
    ~GroupItem() {}
private:
    bool isScrollable;
};

class ContainerItem : public BaseItem
{
public:
    ContainerItem(QString name, qint32 id, QList<int> placeholder = {2,2}, Type type = Type::Container, bool isScrollable = false) :
        BaseItem(name, id, {-1}, type, placeholder) {}
    ~ContainerItem() {}
    bool isScrollLayout() {
        return isScrollable;
    }
    void setScrollLayout(bool scroll) {
        isScrollable = scroll;
    }
private:
    bool isScrollable;
};

}

#endif // TYPES_H
