#include "categoryitem.h"
#include <QMetaEnum>

class CategoryItemPrivate {
public:
    int category;
    QString name;
    QString icon;
    QString normalIcon;
    QString clickIcon;
    int pageCount;
};

CategoryItem::CategoryItem(QObject *parent)
    : QObject(parent)
    , p(new CategoryItemPrivate)
{

}

CategoryItem::~CategoryItem()
{
    delete p;
}

int CategoryItem::category() const
{
    return p->category;
}

void CategoryItem::setCategory(const int &category)
{
    if (p->category != category) {
        p->category = category;
        Q_EMIT categoryChanged();
    }
}

QString CategoryItem::name() const
{
    return p->name;
}

void CategoryItem::setName(const QString &name)
{
    if (p->name != name) {
        p->name = name;
        Q_EMIT nameChanged();
    }
}

QString CategoryItem::normalIcon() const
{
    return p->normalIcon;
}

void CategoryItem::setNormalIcon(const QString &icon)
{
    if (p->normalIcon != icon) {
        p->normalIcon = icon;
        Q_EMIT normalIconChanged();
    }
}

QString CategoryItem::clickIcon() const
{
    return p->clickIcon;
}

void CategoryItem::setClickIcon(const QString &icon)
{
    if (p->clickIcon != icon) {
        p->clickIcon = icon;
        Q_EMIT clickIconChanged();
    }
}

int CategoryItem::pageCount() const
{
    return p->pageCount;
}

void CategoryItem::setPageCount(const int &pageCount)
{
    if (p->pageCount != pageCount) {
        p->pageCount = pageCount;
        Q_EMIT pageCountChanged();
    }
}

QString CategoryItem::categoryToString(Category category)
{
    QMetaEnum categoryEnum = QMetaEnum::fromType<CategoryItem::Category>();
    return categoryEnum.valueToKey(category);
}
