#include "xmenulist.h"

MenuList::MenuList()
    : XAsset()
    , mName(new XString())
    , mMenuCount(0)
    , mMenus(QVector<XMenuDef*>())
{
    
}

MenuList::~MenuList()
{
    for (int i = 0; i < mMenus.size(); i++)
    {
        delete mMenus[i];
    }

    delete mName;
}

void MenuList::SetName(XString *aName)
{
    mName = aName;
}

XString *MenuList::GetName() const
{
    return mName;
}

int MenuList::GetMenuCount() const
{
    return mMenuCount;
}

void MenuList::SetMenuEntry(int aIndex, XMenuDef *aMenuDef)
{
    mMenus[aIndex] = aMenuDef;
}

XMenuDef *MenuList::GetMenuEntry(int aIndex) const
{
    return mMenus[aIndex];
}

void MenuList::Clear()
{
    for (int i = 0; i < mMenus.size(); i++)
    {
        delete mMenus[i];
    }

    mName->Clear();
    mMenuCount = 0;
    mMenus.clear();
}

void MenuList::ParseData(QDataStream *aStream)
{
    mName->ParsePtr(aStream, false);

    *aStream
        >> mMenuCount;

    for (int i = 0; i < mMenuCount; i++)
    {
        XMenuDef* newMenu = new XMenuDef();
    }
}
