#include "menu.h"

Menu::Menu()
{
    this->setHasIcons(true);
    customPositionModified = false;
}

void Menu::createIcons()
{
    icons = new QVector<Icon*>;
    for (int i = 0; i < numberOfElements; i++)
    {
        icons->append(new Icon());
    }
}

bool Menu::isAutomaticPosition()
{
    return automaticPosition;
}

void Menu::setAutomaticPosition(bool value)
{    
    automaticPosition = value;    
}

bool Menu::isTitleEnabled()
{
    return hasTitle;
}

void Menu::setHasTitle(bool value)
{
    hasTitle = value;
}


QVector<Icon*> *Menu::getIcons()
{
    return icons;
}

void Menu::setIcons(QVector<Icon*> *value)
{
    icons = value;
}

void Menu::setIconPath(int positionIcon,const QString path)
{
    icons->at(positionIcon)->setPath(path);
}

QString Menu::getIconPath(int positionIcon)
{
    return  icons->at(positionIcon)->getPath();
}

void Menu::setIconTitle(int positionIcon, QString title)
{    
     icons->at(positionIcon)->setTitle(title);
}

QString Menu::getIconTitle(int positionIcon)
{
    return  icons->at(positionIcon)->getTitle();
}

void Menu::setIconTopMargin(int positionIcon, int topMargin)
{
     icons->at(positionIcon)->setTopMargin(topMargin);
     customPositionModified = true;
}

int Menu::getIconTopMargin(int positionIcon)
{
    return  icons->at(positionIcon)->getTopMargin();
}

void Menu::setIconBottomMargin(int positionIcon, int bottomMargin)
{    
     icons->at(positionIcon)->setBottomMargin(bottomMargin);
     customPositionModified = true;
}

int Menu::getIconBottomMargin(int positionIcon)
{
    return  icons->at(positionIcon)->getBottomMargin();
}

void Menu::setIconLeftMargin(int positionIcon, int leftMargin)
{
     icons->at(positionIcon)->setLeftMargin(leftMargin);
     customPositionModified = true;
}

int Menu::getIconLeftMargin(int positionIcon)
{
    return  icons->at(positionIcon)->getLeftMargin();
}

void Menu::setIconRightMargin(int positionIcon, int rigthMargin)
{
     icons->at(positionIcon)->setRightMargin(rigthMargin);
     customPositionModified = true;
}

int Menu::getIconRightMargin(int positionIcon)
{
    return  icons->at(positionIcon)->getRightMargin();
}

void Menu::resizeNumberOfIcons()
{    
    int previousSize = icons->size();
    for(int i =0; i < abs(numberOfElements - previousSize); i++)
    {
        if(numberOfElements < previousSize)
        {
            icons->removeAt(icons->size() -1);
        }
        else
        {
            icons->append(new Icon());
        }
    }
}

bool Menu::getCustomPositionModified() const
{
    return customPositionModified;
}
